Node¶
Node¶
- class Node(**kwargs)¶
Implements the node api endpoints.
- status(publish: bool = False, **kwargs) StatusModel ¶
Gets the node status.
- Parameters:
publish (bool) – If true, publish a full node event with the status.
**kwargs – Extra keyword arguments.
- Returns:
Information about the node status.
- Return type:
- Raises:
APIError – Error thrown by node API. See message for details.
- get_blockheader(block_hash: str | uint256, is_json_format: bool = True, **kwargs) BlockHeaderModel ¶
Gets the specified block header.
- Parameters:
block_hash (str, uint256) – The specified block hash.
is_json_format (bool, optional) – If block header should be returned as json. Default=True.
**kwargs – Extra keyword arguments.
- Returns:
The block headers.
- Return type:
- Raises:
APIError – Error thrown by node API. See message for details.
- get_raw_transaction(trxid: uint256 | str, verbose: bool = False, **kwargs) hexstr | TransactionModel ¶
Gets a raw transaction from a transaction id.
Requires txindex=1 in node configuration.
- Parameters:
trxid (uint256, str) – The transaction hash.
verbose (bool, optional) – If output should include verbose transaction data. Default=False.
**kwargs – Extra keyword arguments.
- Returns:
A raw transaction.
- Return type:
Union[hexstr, TransactionModel]
- Raises:
APIError – Error thrown by node API. See message for details.
- decode_raw_transaction(raw_hex: str | hexstr, **kwargs) TransactionModel ¶
Decodes raw transaction hex into a transaction model.
- validate_address(address: str, **kwargs) ValidateAddressModel ¶
Validate an address
- Parameters:
address (str) – The address to validate.
**kwargs – Extra keyword arguments.
- Returns:
Information on the validity of the provided address, and if valid, if it is a witness or script address.
- Return type:
- Raises:
APIError – Error thrown by node API. See message for details.
- get_txout(trxid: uint256 | str, vout: int, include_mempool: bool = True, **kwargs) GetTxOutModel ¶
Gets a specified txout from a given transaction.
- Parameters:
trxid (uint256, str) – The trxid to check.
vout (int) – The vout.
include_mempool (bool, optional) – Include mempool in check. Default=True.
**kwargs – Extra keyword arguments.
- Returns:
The specified txout.
- Return type:
- Raises:
APIError – Error thrown by node API. See message for details.
- get_txout_proof(txids: List[str | uint256], block_hash: uint256 | str, **kwargs) hexstr ¶
The merkle proof that the specified transaction exist in a given block.
Should have txindex enabled if not specifying blockhash.
- shutdown(**kwargs) None ¶
Triggers node shutdown.
- Parameters:
**kwargs – Extra keyword arguments.
- Returns:
None
- Raises:
APIError – Error thrown by node API. See message for details.
- stop(**kwargs) None ¶
Triggers node shutdown.
- Parameters:
**kwargs – Extra keyword arguments.
- Returns:
None
- Raises:
APIError – Error thrown by node API. See message for details.
- async_loops(**kwargs) List[AsyncLoopsModel] ¶
Gets the currently running async loops.
- Parameters:
**kwargs – Extra keyword arguments.
- Returns:
A list of active asynchronous loops.
- Return type:
List[AsyncLoopsModel]
- Raises:
APIError – Error thrown by node API. See message for details.
- delete_datafolder_chain(**kwargs) None ¶
Schedules data folder storing chain state in the datafolder for deletion on the next graceful shutdown.
- Parameters:
**kwargs – Extra keyword arguments.
- Returns:
None
- Raises:
APIError – Error thrown by node API. See message for details.
- rewind(height: int, **kwargs) str ¶
Signals the node to rewind to the specified height. This will be done via writing a flag to the .conf file so that on startup it be executed.
- Parameters:
height (int) – The specified height to rewind to on restart.
**kwargs – Extra keyword arguments.
- Returns:
str
- Raises:
APIError – Error thrown by node API. See message for details.
AsyncLoopsModel¶
BlockHeaderModel¶
- class BlockHeaderModel(*, version: int, merkleroot: hexstr, nonce: int, bits: str, previousblockhash: uint256 = None, time: datetime)¶
A pydantic model representing the block header.
- version: int¶
The version of the block.
- nonce: int¶
The nonce.
- bits: str¶
The block’s bits.
- time: datetime¶
The time of the block.
ConnectedPeerModel¶
- class ConnectedPeerModel(*, version: str, remoteSocketEndpoint: str, tipHeight: int)¶
A pydantic model representing a connected peer.
- version: str¶
The connectedpeer’s version.
- remote_socket_endpoint: str¶
The connected peer’s remote socket endpoint.
- tip_height: int¶
The connected peer’s tip height.
FeaturesDataModel¶
- class FeaturesDataModel(*, namespace: str, state: FeatureInitializationState)¶
A pydantic model for features data.
- namespace: str¶
The feature namespace.
- state: FeatureInitializationState¶
The feature initialization state.
GetTxOutModel¶
- class GetTxOutModel(*, bestblock: uint256, confirmations: int, value: Money, scriptPubKey: ScriptPubKey, coinbase: bool)¶
A pydantic model for get tx out response.
- confirmations: int¶
The numberof confirmations.
- script_pubkey: ScriptPubKey¶
The utxo scriptpubkey.
- coinbase: bool¶
If true, the utxo originated as a coinbase transaction.
StatusModel¶
- class StatusModel(*, agent: str, version: str, externalAddress: str, network: str, coinTicker: str, processId: str, consensusHeight: int = None, blockStoreHeight: int, bestPeerHeight: int = None, inboundPeers: List[ConnectedPeerModel], outboundPeers: List[ConnectedPeerModel], featuresData: List[FeaturesDataModel], dataDirectoryPath: str, runningTime: str, difficulty: float = None, protocolVersion: int, testnet: bool, relayFee: Money, state: FullNodeState, inIbd: bool, headerHeight: int)¶
A pydantic model for node status information.
- agent: str¶
The node’s agent string.
- version: str¶
The node version.
- external_address: str¶
The node external address.
- network: str¶
The network.
- coin_ticker: str¶
The ticker string of the current network’s coin.
- process_id: str¶
The process id of the node.
- consensus_height: int | None¶
The current consensus height.
- blockstore_height: int¶
The current blockstore height.
- best_peer_height: int | None¶
The highest block height among connected peers.
- inbound_peers: List[ConnectedPeerModel]¶
A list of inbound connected peers.
- outbound_peers: List[ConnectedPeerModel]¶
A list of outbound connected peers.
- features_data: List[FeaturesDataModel]¶
A list of features active on the node.
- data_directory_path: str¶
The path to the node’s data directory.
- running_time: str¶
The node’s current running time.
- difficulty: float | None¶
The current difficulty, if applicable.
- protocol_version: int¶
The current protocol version.
- testnet: bool¶
If true, node is on testnet.
- state: FullNodeState¶
The node state model.
- in_ibd: bool¶
If true, the node is in IBD state.
- header_height: int¶
The header height.
TransactionModel¶
- class TransactionModel(*, hex: hexstr, txid: uint256, hash: uint256, version: int, size: int, vsize: int, weight: int, locktime: int, vin: List[VIn], vout: List[VOut], blockhash: uint256 = None, confirmations: int = None, time: datetime = None, blocktime: datetime = None)
A pydantic model for a transaction.
- hex: hexstr
The transaction hex.
- txid: uint256
The transaction hash.
- hash: uint256
The transaction hash.
- version: int
The transaction version.
- size: int
The transaction size.
- vsize: int
The transaction vsize.
- weight: int
The transaction weight.
- locktime: int
The transaction locktime.
- vin: List[VIn]
A list of VIn.
- vout: List[VOut]
A list of VOut.
- blockhash: uint256 | None
The hash of the block containing the transaction.
- confirmations: int | None
The number of confirmations of the transaction.
- time: datetime | None
The transaction time.
- blocktime: datetime | None
The blocktime.
ValidateAddressModel¶
- class ValidateAddressModel(*, isvalid: bool, address: Address, scriptPubKey: str, isscript: bool, iswitness: bool)¶
A pydantic model for address validation.
- isvalid: bool¶
True if the address is valid.
- scriptPubKey: str¶
The scriptPubKey.
- isscript: bool¶
True if is a script address.
- iswitness: bool¶
True if is a witness address.