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

StatusModel

Raises

APIError – Error thrown by node API. See message for details.

get_blockheader(block_hash: Union[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

BlockHeaderModel

Raises

APIError – Error thrown by node API. See message for details.

get_raw_transaction(trxid: Union[uint256, str], verbose: bool = False, **kwargs) Union[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: Union[str, hexstr], **kwargs) TransactionModel

Decodes raw transaction hex into a transaction model.

Parameters
  • raw_hex (hexstr, str) – The transaction hexstring.

  • **kwargs – Extra keyword arguments.

Returns

A transaction model.

Return type

TransactionModel

Raises

APIError – Error thrown by node API. See message for details.

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

ValidateAddressModel

Raises

APIError – Error thrown by node API. See message for details.

get_txout(trxid: Union[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

GetTxOutModel

Raises

APIError – Error thrown by node API. See message for details.

get_txout_proof(txids: List[Union[str, uint256]], block_hash: Union[uint256, str], **kwargs) hexstr

The merkle proof that the specified transaction exist in a given block.

Should have txindex enabled if not specifying blockhash.

Parameters
  • txids (List[uint256]) – A list of transaction hashes.

  • block_hash (uint256, optional) – The block hash to check.

  • **kwargs – Extra keyword arguments.

Returns

The merkle proof.

Return type

hexstr

Raises

APIError – Error thrown by node API. See message for details.

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.

log_levels(log_rules: List[LogRule], **kwargs) None

Changes log level for the specified loggers.

Parameters
  • log_rules (List[LogRule]) – A list of log rules to change.

  • **kwargs – Extra keyword arguments.

Returns

None

Raises

APIError – Error thrown by node API. See message for details.

log_rules(**kwargs) List[LogRule]

Returns the enabled log rules.

Parameters

**kwargs – Extra keyword arguments.

Returns

A list of active log rules.

Return type

List[LogRule]

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

class AsyncLoopsModel(*, loopName: str, status: str)

A pydantic model for async loops.

loop_name: str

The loop name.

status: str

The loop status.

BlockHeaderModel

class BlockHeaderModel(*, version: int, merkleroot: hexstr, nonce: int, bits: str, previousblockhash: uint256 = None, time: datetime.datetime)

A pydantic model representing the block header.

version: int

The version of the block.

merkleroot: hexstr

The merkle root of the block.

nonce: int

The nonce.

bits: str

The block’s bits.

previous_blockhash: Optional[uint256]

The previous blockhash.

time: datetime.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.

best_block: uint256

The highest block where utxo was present.

confirmations: int

The numberof confirmations.

value: Money

The value of the utxo.

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: Optional[int]

The current consensus height.

blockstore_height: int

The current blockstore height.

best_peer_height: Optional[int]

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: Optional[float]

The current difficulty, if applicable.

protocol_version: int

The current protocol version.

testnet: bool

If true, node is on testnet.

relay_fee: Money

The network transaction relay fee.

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.datetime = None, blocktime: datetime.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: Optional[uint256]

The hash of the block containing the transaction.

confirmations: Optional[int]

The number of confirmations of the transaction.

time: Optional[datetime.datetime]

The transaction time.

blocktime: Optional[datetime.datetime]

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.

address: Address

The address.

scriptPubKey: str

The scriptPubKey.

isscript: bool

True if is a script address.

iswitness: bool

True if is a witness address.