BitcoinInterface

Trait BitcoinInterface 

Source
pub trait BitcoinInterface: Send + Sync {
    // Required methods
    fn get_transaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        txid: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<Transaction>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_block<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<Block>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_block_height<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<u32>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn generate_address<'life0, 'async_trait>(
        &'life0 self,
        address_type: AddressType,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<Address>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn create_transaction<'life0, 'async_trait>(
        &'life0 self,
        outputs: Vec<(String, u64)>,
        fee_rate: u64,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<Transaction>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn broadcast_transaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        transaction: &'life1 Transaction,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_balance<'life0, 'life1, 'async_trait>(
        &'life0 self,
        address: &'life1 Address,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn estimate_fee<'life0, 'async_trait>(
        &'life0 self,
        target_blocks: u8,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_block_header<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<BlockHeader>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn verify_merkle_proof<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tx_hash: &'life1 str,
        block_header: &'life2 BlockHeader,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn send_transaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tx: &'life1 Transaction,
    ) -> Pin<Box<dyn Future<Output = BitcoinResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn implementation_type(&self) -> BitcoinImplementationType;
}
Expand description

Common interface for Bitcoin operations

This trait defines the contract that all Bitcoin implementations must fulfill. It follows the “port” concept from hexagonal architecture, allowing different adapters (implementations) to be plugged in while maintaining a consistent API.

[AIR-3][AIS-3][BPC-3][RES-3] Complete implementation as per official Bitcoin Improvement Proposals (BIPs) standards

Required Methods§

Source

fn get_transaction<'life0, 'life1, 'async_trait>( &'life0 self, txid: &'life1 str, ) -> Pin<Box<dyn Future<Output = BitcoinResult<Transaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get transaction by txid

Retrieves detailed information about a transaction given its ID.

Source

fn get_block<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = BitcoinResult<Block>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get block by hash

Retrieves all transactions in a block given the block hash.

Source

fn get_block_height<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = BitcoinResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get current blockchain height

Returns the current height of the blockchain (number of blocks).

Source

fn generate_address<'life0, 'async_trait>( &'life0 self, address_type: AddressType, ) -> Pin<Box<dyn Future<Output = BitcoinResult<Address>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate a new address

Creates a new Bitcoin address of the specified type.

Source

fn create_transaction<'life0, 'async_trait>( &'life0 self, outputs: Vec<(String, u64)>, fee_rate: u64, ) -> Pin<Box<dyn Future<Output = BitcoinResult<Transaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create and sign a transaction

Creates a transaction sending to specified outputs with the given fee rate. The implementation handles input selection, change addresses, and signing.

Source

fn broadcast_transaction<'life0, 'life1, 'async_trait>( &'life0 self, transaction: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = BitcoinResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcast a transaction to the network

Sends a signed transaction to the Bitcoin network.

Source

fn get_balance<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 Address, ) -> Pin<Box<dyn Future<Output = BitcoinResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get balance for wallet/address

Returns the current balance of the wallet in satoshis.

Source

fn estimate_fee<'life0, 'async_trait>( &'life0 self, target_blocks: u8, ) -> Pin<Box<dyn Future<Output = BitcoinResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Estimate fee for a transaction

Estimates the fee rate (in sat/vB) needed for confirmation within target_blocks.

Source

fn get_block_header<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = BitcoinResult<BlockHeader>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get block header by hash

Retrieves block header information for a given block hash.

Source

fn verify_merkle_proof<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tx_hash: &'life1 str, block_header: &'life2 BlockHeader, ) -> Pin<Box<dyn Future<Output = BitcoinResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Verify a merkle proof

Verifies a merkle proof for a given transaction hash and block header.

Source

fn send_transaction<'life0, 'life1, 'async_trait>( &'life0 self, tx: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = BitcoinResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a transaction

Sends a transaction to the network.

Source

fn implementation_type(&self) -> BitcoinImplementationType

Implementation type

Returns which implementation type is being used.

Implementors§

Source§

impl BitcoinInterface for BitcoinAdapter

Implementation of BitcoinInterface following hexagonal architecture pattern [AIR-3][AIS-3][BPC-3][RES-3] Using async_trait for async interface implementation

Source§

impl BitcoinInterface for RustBitcoinImplementation