aea.crypto.ledger_
apis
Module wrapping all the public and private keys cryptography.
LedgerApis Objects
Store all the ledger apis we initialise.
has_
ledger
Check if it has the api.
get_
api
Get the ledger API.
get_
balance
Get the token balance.
Arguments:
identifier
: the identifier of the ledgeraddress
: the address to check for
Returns:
the token balance
get_
transfer_
transaction
| @classmethod
| get_transfer_transaction(cls, identifier: str, sender_address: str, destination_address: str, amount: int, tx_fee: int, tx_nonce: str, **kwargs: Any, ,) -> Optional[Any]
Get a transaction to transfer from self to destination.
Arguments:
identifier
: the identifier of the ledgersender_address
: the address of the senderdestination_address
: the address of the receiveramount
: the amounttx_nonce
: verifies the authenticity of the txtx_fee
: the tx feekwargs
: the keyword arguments.
Returns:
tx
send_
signed_
transaction
Send a signed transaction and wait for confirmation.
Arguments:
identifier
: the identifier of the ledgertx_signed
: the signed transaction
Returns:
the tx_digest, if present
get_
transaction_
receipt
Get the transaction receipt for a transaction digest.
Arguments:
identifier
: the identifier of the ledgertx_digest
: the digest associated to the transaction.
Returns:
the tx receipt, if present
get_
transaction
Get the transaction for a transaction digest.
Arguments:
identifier
: the identifier of the ledgertx_digest
: the digest associated to the transaction.
Returns:
the tx, if present
get_
contract_
address
Get the contract address from a transaction receipt.
Arguments:
identifier
: the identifier of the ledgertx_receipt
: the transaction receipt
Returns:
the contract address if successful
is_
transaction_
settled
Check whether the transaction is settled and correct.
Arguments:
identifier
: the identifier of the ledgertx_receipt
: the transaction digest
Returns:
True if correctly settled, False otherwise
is_
transaction_
valid
| @staticmethod
| is_transaction_valid(identifier: str, tx: Any, seller: Address, client: Address, tx_nonce: str, amount: int) -> bool
Check whether the transaction is valid.
Arguments:
identifier
: Ledger identifiertx
: the transactionseller
: the address of the seller.client
: the address of the client.tx_nonce
: the transaction nonce.amount
: the amount we expect to get from the transaction.
Returns:
True if is valid , False otherwise
generate_
tx_
nonce
Generate a random str message.
Arguments:
identifier
: ledger identifier.seller
: the address of the seller.client
: the address of the client.
Returns:
return the hash in hex.
recover_
message
| @staticmethod
| recover_message(identifier: str, message: bytes, signature: str, is_deprecated_mode: bool = False) -> Tuple[Address, ...]
Recover the addresses from the hash.
Arguments:
identifier
: ledger identifier.message
: the message we expectsignature
: the transaction signatureis_deprecated_mode
: if the deprecated signing was used
Returns:
the recovered addresses
get_
hash
Get the hash of a message.
Arguments:
identifier
: ledger identifier.message
: the message to be hashed.
Returns:
the hash of the message.
is_
valid_
address
Check if the address is valid.
Arguments:
identifier
: ledger identifier.address
: the address to validate.
Returns:
whether it is a valid address or not.