teos.carrier¶
-
class
Carrier(btc_connect_params)[source]¶ Bases:
objectThe
Carrieris in charge of interacting withbitcoindto send/get transactions. It usesReceiptobjects to report about the sending outcome.- Parameters
btc_connect_params (
dict) – a dictionary with the parameters to connect to bitcoind (rpc user, rpc password, host and port).
-
logger¶ The logger for this component.
- Type
Logger
-
issued_receipts¶ A dictionary of issued receipts to prevent resending the same transaction over and over. It should periodically be reset to prevent it from growing unbounded.
- Type
dict
-
get_transaction(txid)[source]¶ Queries transaction data to
bitcoindgiven a transaction id.- Parameters
txid (
str) – a 32-byte hex-formatted string representing the transaction id.- Returns
A dictionary with the transaction data if the transaction can be found on the chain.
Noneotherwise.- Return type
dictorNone
-
send_transaction(rawtx, txid)[source]¶ Tries to send a given raw transaction to the Bitcoin network using
bitcoind.- Parameters
rawtx (
str) – a (potentially) signed raw transaction ready to be broadcast.txid (
str) – the transaction id corresponding torawtx.
- Returns
A receipt reporting whether the transaction was successfully delivered or not and why.
- Return type
-
class
Receipt(delivered, confirmations=0, reason=None)[source]¶ Bases:
objectThe
Receiptclass represent the interaction between theCarrierandbitcoindwhen broadcasting transactions. It is used to signal whether or not a transaction has been successfully broadcast and why.- Parameters
delivered (
bool) – whether or not the transaction has been successfully broadcast.confirmations (
int) – the number of confirmations of the transaction to broadcast. In certain situations theCarriermay fail to broadcast a transaction because it was already in the blockchain. This attribute signals those situations.reason (
int) – an error code describing why the transaction broadcast failed.
- Returns
A receipt describing whether or not the transaction was delivered. Notice that transactions that are already on chain are flagged as delivered with a
confirmations > 0whereas new transactions are so withconfirmations = 0.- Return type