Trait Broadcaster

Source
pub trait Broadcaster {
    // Required methods
    fn send_raw_transaction(
        &self,
        tx: &Transaction,
    ) -> impl Future<Output = ClientResult<Txid>> + Send;
    fn test_mempool_accept(
        &self,
        tx: &Transaction,
    ) -> impl Future<Output = ClientResult<Vec<TestMempoolAccept>>> + Send;
    fn submit_package(
        &self,
        txs: &[Transaction],
    ) -> impl Future<Output = ClientResult<SubmitPackage>> + Send;
}
Expand description

Broadcasting functionality that any Bitcoin client that interacts with the Bitcoin network should provide.

§Note

This is a fully async trait. The user should be responsible for handling the async nature of the trait methods. And if implementing this trait for a specific type that is not async, the user should consider wrapping with tokio’s spawn_blocking or any other method.

Required Methods§

Source

fn send_raw_transaction( &self, tx: &Transaction, ) -> impl Future<Output = ClientResult<Txid>> + Send

Sends a raw transaction to the network.

§Parameters
  • tx: The raw transaction to send. This should be a byte array containing the serialized raw transaction data.
Source

fn test_mempool_accept( &self, tx: &Transaction, ) -> impl Future<Output = ClientResult<Vec<TestMempoolAccept>>> + Send

Tests if a raw transaction is valid.

Source

fn submit_package( &self, txs: &[Transaction], ) -> impl Future<Output = ClientResult<SubmitPackage>> + Send

Submit a package of raw transactions (serialized, hex-encoded) to local node.

The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool. This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.

§Warning

Successful submission does not mean the transactions will propagate throughout the network.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§