pub struct BitcoinAnchorLayer { /* private fields */ }Expand description
Bitcoin implementation of the AnchorLayer trait with HD wallet support
Implementations§
Source§impl BitcoinAnchorLayer
impl BitcoinAnchorLayer
Sourcepub fn with_wallet(
config: BitcoinConfig,
wallet: SealWallet,
) -> BitcoinResult<Self>
pub fn with_wallet( config: BitcoinConfig, wallet: SealWallet, ) -> BitcoinResult<Self>
Create with an existing HD wallet.
Sourcepub fn from_xpub(config: BitcoinConfig, xpub: &str) -> BitcoinResult<Self>
pub fn from_xpub(config: BitcoinConfig, xpub: &str) -> BitcoinResult<Self>
Create a new adapter with an HD wallet from an xpub key
Sourcepub fn signet() -> BitcoinResult<Self>
pub fn signet() -> BitcoinResult<Self>
Create with default config for signet (random wallet)
Sourcepub fn with_rpc(self, rpc: Box<dyn BitcoinRpc + Send + Sync>) -> Self
pub fn with_rpc(self, rpc: Box<dyn BitcoinRpc + Send + Sync>) -> Self
Attach a real RPC client for broadcasting transactions
Sourcepub fn wallet(&self) -> &SealWallet
pub fn wallet(&self) -> &SealWallet
Get a reference to the wallet
Sourcepub fn tx_builder_mut(&mut self) -> &mut CommitmentTxBuilder
pub fn tx_builder_mut(&mut self) -> &mut CommitmentTxBuilder
Get a mutable reference to the tx_builder
Sourcepub fn fund_seal(
&self,
outpoint: OutPoint,
) -> Result<(BitcoinSealRef, Bip86Path), AdapterError>
pub fn fund_seal( &self, outpoint: OutPoint, ) -> Result<(BitcoinSealRef, Bip86Path), AdapterError>
Create a seal backed by a real on-chain UTXO
This method creates a seal from an existing UTXO in the wallet.
The UTXO must have been previously added to the wallet via add_utxo()
or discovered via scan_wallet_for_utxos().
§Arguments
outpoint- The outpoint of the UTXO to use as the seal
§Returns
A seal reference and the derivation path, or an error if the UTXO is not found
Sourcepub fn scan_wallet_for_utxos(
&self,
account: u32,
gap_limit: usize,
) -> Result<usize, AdapterError>
pub fn scan_wallet_for_utxos( &self, account: u32, gap_limit: usize, ) -> Result<usize, AdapterError>
Scan the wallet’s addresses for on-chain UTXOs
This method requires an RPC client to be attached. It will scan addresses and populate the wallet with any discovered UTXOs.
§Arguments
account- The account number to scan (typically 0)gap_limit- Number of consecutive empty addresses before stopping (typically 20)
§Returns
The number of UTXOs discovered
Sourcepub fn build_commitment_data(
&self,
commitment: Hash,
protocol_id: [u8; 32],
) -> Result<CommitmentData, AdapterError>
pub fn build_commitment_data( &self, commitment: Hash, protocol_id: [u8; 32], ) -> Result<CommitmentData, AdapterError>
Build commitment data for a commitment transaction
Sourcepub fn get_current_height_for_test(&self) -> u64
pub fn get_current_height_for_test(&self) -> u64
Get current block height (public, for testing)
Sourcepub fn get_funding_address(
&self,
account: u32,
index: u32,
) -> Result<Address, AdapterError>
pub fn get_funding_address( &self, account: u32, index: u32, ) -> Result<Address, AdapterError>
Get the funding address for a specific account and index