cashscript_py.network.electrum_network_provider module
Electrum/Fulcrum-based network provider for BCH.
- class ElectrumNetworkProvider(network: Network = Network.MAINNET)[source]
Bases:
NetworkProviderNetworkProvider backed by bitcash FulcrumProtocolAPI.
Connects to specific servers per network and provides UTXO queries, block height, raw transaction fetching, and broadcasting.
- async get_block_height() int[source]
Return the current block height.
- Raises:
RequestFailed – If the provider returns an error.
UnexpectedResponse – If the provider returns a malformed response.
- async get_raw_transaction(txid: str) str[source]
Retrieve the raw transaction hex for a txid.
- Parameters:
txid – Transaction ID (hex).
- Returns:
Raw transaction hex.
- Raises:
RequestFailed – If the provider returns an error.
UnexpectedResponse – If the provider returns a malformed response.
- async get_utxos(address: str) list[Utxo][source]
Fetch UTXOs for a CashAddress.
- Parameters:
address – CashAddress string.
- Returns:
List of Utxo objects.
- Raises:
RequestFailed – If the provider returns an error.
UnexpectedResponse – If the provider returns a malformed response.
- async send_raw_transaction(tx_hex: str) str[source]
Broadcast a raw transaction to the network.
- Parameters:
tx_hex – Hex-encoded transaction.
- Returns:
Transaction ID computed for the broadcast transaction.
- Raises:
BroadcastFailed – If the transaction was not accepted by the network.