terra_sdk.key.key
Key Objects
_1class Key()
Abstract Key interface, representing an agent with transaction-signing capabilities.
Arguments:
public_keyOptional[bytes] - compressed public key bytes,
public_key
Compressed public key bytes, used to derive :data:raw_address and :data:raw_pubkey.
raw_address
Raw Bech32 words of address, used to derive associated account and validator operator addresses.
raw_pubkey
Raw Bech32 words of pubkey, used to derive associated account and validator pubkeys.
sign
_2@abc.abstractmethod_2def sign(payload: bytes) -> bytes
Signs the data payload. An implementation of Key is expected to override this method.
Arguments:
payloadbytes - arbitrary data payload
Raises:
NotImplementedError- if not implemented
Returns:
bytes- signed payload
acc_address
_2@property_2def acc_address() -> AccAddress
Fluid Bech32 account address. Default derivation via :data:public_key is provided.
Raises:
ValueError- if Key was not initialized with proper public key
Returns:
AccAddress- account address
val_address
_2@property_2def val_address() -> ValAddress
Fluid Bech32 validator operator address. Default derivation via :data:public_key is provided.
Raises:
ValueError- if Key was not initialized with proper public key
Returns:
ValAddress- validator operator address
acc_pubkey
_2@property_2def acc_pubkey() -> AccPubKey
Fluid Bech32 account pubkey. Default derivation via :data:public_key is provided.
Raises:
ValueError- if Key was not initialized with proper public key
Returns:
AccPubKey- account pubkey
val_pubkey
_2@property_2def val_pubkey() -> ValPubKey
Fluid Bech32 validator pubkey. Default derivation via public_key is provided.
Raises:
ValueError- if Key was not initialized with proper public key
Returns:
ValPubKey- validator pubkey
create_signature
_1def create_signature(sign_doc: SignDoc) -> SignatureV2
Signs the transaction with the signing algorithm provided by this Key implementation,
and outputs the signature. The signature is only returned, and must be manually added to
the signatures field of an :class:Tx.
Arguments:
sign_docSignDoc - unsigned transaction
Raises:
ValueError- if missingpublic_key
Returns:
SignatureV2- signature object
sign_tx
_1def sign_tx(tx: Tx, options: SignOptions) -> Tx
Signs the transaction with the signing algorithm provided by this Key implementation,
and creates a ready-to-broadcast :class:Tx object with the signature applied.
Arguments:
txTx - unsigned transactionoptionsSignOptions - options for signing
Returns:
Tx- ready-to-broadcast transaction object