beem.transactionbuilder¶
-
class
beem.transactionbuilder.
TransactionBuilder
(tx={}, blockchain_instance=None, **kwargs)¶ Bases:
dict
This class simplifies the creation of transactions by adding operations and signers. To build your own transactions and sign them
Parameters: - tx (dict) – transaction (Optional). If not set, the new transaction is created.
- expiration (int) – Delay in seconds until transactions are supposed to expire (optional) (default is 30)
- blockchain_instance (Hive/Steem) – If not set, shared_blockchain_instance() is used
from beem.transactionbuilder import TransactionBuilder from beembase.operations import Transfer from beem import Hive wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" hive = Hive(nobroadcast=True, keys={'active': wif}) tx = TransactionBuilder(blockchain_instance=hive) transfer = {"from": "test", "to": "test1", "amount": "1 HIVE", "memo": ""} tx.appendOps(Transfer(transfer)) tx.appendSigner("test", "active") # or tx.appendWif(wif) signed_tx = tx.sign() broadcast_tx = tx.broadcast()
-
addSigningInformation
(account, permission, reconstruct_tx=False)¶ This is a private method that adds side information to a unsigned/partial transaction in order to simplify later signing (e.g. for multisig or coldstorage)
Not needed when “appendWif” was already or is going to be used
FIXME: Does not work with owner keys!
Parameters: reconstruct_tx (bool) – when set to False and tx is already contructed, it will not reconstructed and already added signatures remain
-
appendMissingSignatures
()¶ Store which accounts/keys are supposed to sign the transaction
This method is used for an offline-signer!
-
appendOps
(ops, append_to=None)¶ Append op(s) to the transaction builder
Parameters: ops (list) – One or a list of operations
-
appendSigner
(account, permission)¶ Try to obtain the wif key from the wallet by telling which account and permission is supposed to sign the transaction It is possible to add more than one signer.
Parameters: - account (str) – account to sign transaction with
- permission (str) – type of permission, e.g. “active”, “owner” etc
-
appendWif
(wif)¶ Add a wif that should be used for signing of the transaction.
Parameters: wif (string) – One wif key to use for signing a transaction.
-
broadcast
(max_block_age=-1, trx_id=True)¶ Broadcast a transaction to the steem network Returns the signed transaction and clears itself after broadast
Clears itself when broadcast was not successfully.
Parameters: - max_block_age (int) – parameter only used for appbase ready nodes
- trx_id (bool) – When True, trx_id is return
-
clear
()¶ Clear the transaction builder and start from scratch
-
clearWifs
()¶ Clear all stored wifs
-
constructTx
(ref_block_num=None, ref_block_prefix=None)¶ Construct the actual transaction and store it in the class’s dict store
-
get_block_params
(use_head_block=False)¶ Auxiliary method to obtain
ref_block_num
andref_block_prefix
. Requires a connection to a node!
-
get_parent
()¶ TransactionBuilders don’t have parents, they are their own parent
-
get_potential_signatures
()¶ Returns public key from signature
-
get_required_signatures
(available_keys=[])¶ Returns public key from signature
-
get_transaction_hex
()¶ Returns a hex value of the transaction
-
is_empty
()¶ Check if ops is empty
-
json
(with_prefix=False)¶ Show the transaction as plain json
-
list_operations
()¶ List all ops
-
searchPath
(account, perm)¶
-
setPath
(path)¶
-
set_expiration
(p)¶ Set expiration date
-
sign
(reconstruct_tx=True)¶ Sign a provided transaction with the provided key(s) One or many wif keys to use for signing a transaction. The wif keys can be provided by “appendWif” or the signer can be defined “appendSigner”. The wif keys from all signer that are defined by “appendSigner will be loaded from the wallet.
Parameters: reconstruct_tx (bool) – when set to False and tx is already contructed, it will not reconstructed and already added signatures remain
Verify the authority of the signed transaction