xpring
The Xpring SDK for Python.
Install
pip install xpring[py]
API
Wallet
Construct
You can construct a Wallet from its seed. If you do not have your own wallet yet, you can generate one with some free XRP on the testnet.
import xpring
seed = 'sEdSKaCy2JT7JaM7v95H9SxkhP9wS2r'
wallet = xpring.Wallet.from_seed(seed)
print(wallet.private_key.hex())
# b4c4e046826bd26190d09715fc31f4e6a728204eadd112905b08b14b7f15c4f3
print(wallet.public_key.hex())
# ed01fa53fa5a7e77798f882ece20b1abc00bb358a9e55a202d0d0676bd0ce37a63
print(wallet.account_id.hex())
# d28b177e48d9a8d057e70f7e464b498367281b98
print(wallet.address)
# rLUEXYuLiQptky37CqLcm9USQpPiz5rkpD
Sign / Verify
A Wallet can sign and verify arbitrary bytes, but you’ll generally want to leave these low-level responsibilities to the Client.
message = bytes.fromhex('DEADBEEF')
signature = wallet.sign(message)
wallet.verify(message, signature)
# True
Client
Client is the gateway to the XRP Ledger. It is constructed with the URL of the gRPC service of a rippled server. If you are running the server yourself, you need to configure the [port_grpc] stanza in your configuration file. In the example configuration file, it is commented out.
url = 'localhost:50051'
client = xpring.Client.from_url(url)
Account
>>> client.get_account(wallet.address)
account_data {
account {
address: "rDuKotkyx18D5WqWCA4mVhRWK2YLqDFKaY"
}
balance {
drops: 999999820
}
sequence: 10
previous_transaction_id: b"..."
previous_transaction_ledger_sequence: 4845872
}
ledger_index: 4869818
Fee
>>> client.get_fee()
current_ledger_size: 6
drops {
base_fee {
drops: 10
}
median_fee {
drops: 5000
}
minimum_fee {
drops: 10
}
open_ledger_fee {
drops: 10
}
}
expected_ledger_size: 25
ledger_current_index: 4869844
levels {
median_level: 128000
minimum_level: 256
open_ledger_level: 256
reference_level: 256
}
max_queue_size: 2000
Submit
>>> unsigned_transaction = {
... 'Account': 'rDuKotkyx18D5WqWCA4mVhRWK2YLqDFKaY',
... 'Amount': '10',
... 'Destination': 'rNJDvXkaBRwJYdeEcx9pchE2SecMkH3FLz',
... 'Fee': '10',
... 'Flags': 0x80000000,
... 'Sequence': 9,
... 'TransactionType': 'Payment'
... }
>>> signed_transaction = wallet.sign_transaction(unsigned_transaction)
>>> client.submit(signed_transaction)
engine_result {
result_type: RESULT_TYPE_TES
result: "tesSUCCESS"
}
engine_result_message: "The transaction was applied. Only final in a validated ledger."
hash: b"..."
Develop
Dependencies
The protocol buffers and definitions file are in submodules:
git submodule update --init
Use Poetry to install dependencies, build the protocol buffers, and copy the definitions file:
poetry install
poetry run invoke prebuild
Tasks
There are several Invoke tasks:
poetry run invoke ${task}
test: Pytest with coverage and doctests.
lint: Mypy, Pylint, and Pydocstyle.
serve: Serve the docs locally and rebuild them on file changes.
Metadata
Release files for xpring 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xpring-0.3.0.tar.gz | 21.3 kB | Without provenance | Details for xpring-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xpring-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for xpring-0.3.0-py3-none-any.whl |
Total release size: 43.2 kB
Release files / xpring-0.3.0.tar.gz
| Download URL | xpring-0.3.0.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc50dc66bfca6e136576c523acf6bc6e2c3684c99558b08332515b64dc37ed62
|
|
BLAKE2b-256 checksum How to use checksums |
842128d125f4689cab2a23264372051dd2e156787f918589ea9f0a1b0701f873
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.7.1 Linux/5.3.0-40-generic
|
Release files / xpring-0.3.0-py3-none-any.whl
| Download URL | xpring-0.3.0-py3-none-any.whl |
|---|---|
| Size | 21.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87a581a157abca28b7db43e222175fd2120b6eaf5fe9026242bf60155e8d7237
|
|
BLAKE2b-256 checksum How to use checksums |
a07213db6b3a1da9ccf9f56d34d68b3ad79c2136660160874a2b0b127bedf340
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.3 CPython/3.7.1 Linux/5.3.0-40-generic
|
Security for xpring 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.