Skip to main content

BitcoinAnchorLayer

Struct BitcoinAnchorLayer 

Source
pub struct BitcoinAnchorLayer { /* private fields */ }
Expand description

Bitcoin implementation of the AnchorLayer trait with HD wallet support

Implementations§

Source§

impl BitcoinAnchorLayer

Source

pub fn with_wallet( config: BitcoinConfig, wallet: SealWallet, ) -> BitcoinResult<Self>

Create with an existing HD wallet.

Source

pub fn from_xpub(config: BitcoinConfig, xpub: &str) -> BitcoinResult<Self>

Create a new adapter with an HD wallet from an xpub key

Source

pub fn signet() -> BitcoinResult<Self>

Create with default config for signet (random wallet)

Source

pub fn with_rpc(self, rpc: Box<dyn BitcoinRpc + Send + Sync>) -> Self

Attach a real RPC client for broadcasting transactions

Source

pub fn wallet(&self) -> &SealWallet

Get a reference to the wallet

Source

pub fn tx_builder_mut(&mut self) -> &mut CommitmentTxBuilder

Get a mutable reference to the tx_builder

Source

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

Source

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

Source

pub fn build_commitment_data( &self, commitment: Hash, protocol_id: [u8; 32], ) -> Result<CommitmentData, AdapterError>

Build commitment data for a commitment transaction

Source

pub fn get_current_height_for_test(&self) -> u64

Get current block height (public, for testing)

Source

pub fn get_funding_address( &self, account: u32, index: u32, ) -> Result<Address, AdapterError>

Get the funding address for a specific account and index

Source

pub fn add_utxo( &self, outpoint: OutPoint, amount_sat: u64, account: u32, index: u32, )

Add a UTXO to the wallet from a known outpoint

Trait Implementations§

Source§

impl AnchorLayer for BitcoinAnchorLayer

Source§

type SealRef = BitcoinSealRef

Chain-specific seal reference type
Source§

type AnchorRef = BitcoinAnchorRef

Chain-specific anchor reference type
Source§

type InclusionProof = BitcoinInclusionProof

Chain-specific inclusion proof type
Source§

type FinalityProof = BitcoinFinalityProof

Chain-specific finality proof type
Source§

fn publish( &self, commitment: Hash, seal: Self::SealRef, ) -> CoreResult<Self::AnchorRef>

Publish a commitment under a single-use seal. Read more
Source§

fn verify_inclusion( &self, anchor: Self::AnchorRef, ) -> CoreResult<Self::InclusionProof>

Extract inclusion proof from the base layer. Read more
Source§

fn verify_finality( &self, anchor: Self::AnchorRef, ) -> CoreResult<Self::FinalityProof>

Verify finality according to base-layer rules. Read more
Source§

fn enforce_seal(&self, seal: Self::SealRef) -> CoreResult<()>

Enforce that the seal is single-use and non-replayable. Read more
Source§

fn create_seal(&self, value: Option<u64>) -> CoreResult<Self::SealRef>

Create a new seal for authorizing state transitions. Read more
Source§

fn hash_commitment( &self, contract_id: Hash, previous_commitment: Hash, transition_payload_hash: Hash, seal_ref: &Self::SealRef, ) -> Hash

Compute a commitment hash from components. Read more
Source§

fn build_proof_bundle( &self, anchor: Self::AnchorRef, transition_dag: DAGSegment, ) -> CoreResult<ProofBundle>

Build a complete proof bundle for peer-to-peer verification. Read more
Source§

fn rollback(&self, anchor: Self::AnchorRef) -> CoreResult<()>

Handle rollback of an anchor due to chain reorg. Read more
Source§

fn domain_separator(&self) -> [u8; 32]

Get the domain separator for this adapter.
Source§

fn signature_scheme(&self) -> SignatureScheme

Get the signature scheme used by this chain. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more