BitcoinCanister

Struct BitcoinCanister 

Source
pub struct BitcoinCanister<'agent> { /* private fields */ }
Expand description

The canister interface for the IC Bitcoin canister.

Implementations§

Source§

impl<'agent> BitcoinCanister<'agent>

Source

pub fn from_canister( canister: Canister<'agent>, network: BitcoinNetwork, ) -> Self

Create a BitcoinCanister interface from an existing canister object.

Source

pub fn create( agent: &'agent Agent, canister_id: Principal, network: BitcoinNetwork, ) -> Self

Create a BitcoinCanister interface pointing to the specified canister ID.

Source

pub fn mainnet(agent: &'agent Agent) -> Self

Create a BitcoinCanister interface for the Bitcoin mainnet canister on the IC mainnet.

Source

pub fn testnet(agent: &'agent Agent) -> Self

Create a BitcoinCanister interface for the Bitcoin testnet canister on the IC mainnet.

Source

pub fn for_network( agent: &'agent Agent, network: BitcoinNetwork, ) -> Result<Self, AgentError>

Create a BitcoinCanister interface for the specified Bitcoin network on the IC mainnet. Errors if Regtest is specified.

Source

pub fn get_balance( &self, address: &str, min_confirmations: Option<u32>, ) -> impl 'agent + AsyncCall<Value = (u64,)>

Gets the BTC balance (in satoshis) of a particular Bitcoin address, filtering by number of confirmations. Most applications should require 6 confirmations.

Source

pub fn get_balance_query( &self, address: &str, min_confirmations: Option<u32>, ) -> impl 'agent + SyncCall<Value = (u64,)>

Gets the BTC balance (in satoshis) of a particular Bitcoin address, filtering by number of confirmations. Most applications should require 6 confirmations.

Source

pub fn get_utxos( &self, address: &str, filter: Option<UtxosFilter>, ) -> impl 'agent + AsyncCall<Value = (GetUtxosResponse,)>

Fetch the list of UTXOs for a Bitcoin address, filtering by number of confirmations. Most applications should require 6 confirmations.

This method is paginated. If not all the results can be returned, then next_page will be set to Some, and its value can be passed to this method to get the next page.

Source

pub fn get_utxos_query( &self, address: &str, filter: Option<UtxosFilter>, ) -> impl 'agent + SyncCall<Value = (GetUtxosResponse,)>

Fetch the list of UTXOs for a Bitcoin address, filtering by number of confirmations. Most applications should require 6 confirmations.

This method is paginated. If not all the results can be returned, then next_page will be set to Some, and its value can be passed to this method to get the next page.

Source

pub fn get_current_fee_percentiles( &self, ) -> impl 'agent + AsyncCall<Value = (Vec<u64>,)>

Gets the transaction fee percentiles for the last 10,000 transactions. In the returned vector, v[i] is the ith percentile fee, measured in millisatoshis/vbyte, and v[0] is the smallest fee.

Source

pub fn get_block_headers( &self, start_height: u32, end_height: Option<u32>, ) -> impl 'agent + AsyncCall<Value = (GetBlockHeadersResponse,)>

Gets the block headers for the specified range of blocks. If end_height is None, the returned tip_height provides the tip at the moment the chain was queried.

Source

pub fn send_transaction( &self, transaction: Vec<u8>, ) -> impl 'agent + AsyncCall<Value = ()>

Submits a new Bitcoin transaction. No guarantees are made about the outcome.

Methods from Deref<Target = Canister<'agent>>§

Source

pub fn canister_id_(&self) -> &Principal

Get the canister ID of this canister. Prefer using canister_id instead.

Source

pub fn canister_id(&self) -> &Principal

Get the canister ID of this canister.

Source

pub fn update_<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call. Prefer using update instead.

Source

pub fn update<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>

Create an AsyncCallBuilder to do an update call.

Source

pub fn query_<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call. Prefer using query instead.

Source

pub fn query<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>

Create a SyncCallBuilder to do a query call.

Source

pub async fn wait<'canister>( &'canister self, request_id: &RequestId, ) -> Result<Vec<u8>, AgentError>

Call request_status on the RequestId in a loop and return the response as a byte vector.

Source

pub fn clone_with_(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal. Prefer using clone_with instead.

Source

pub fn clone_with(&self, id: Principal) -> Self

Creates a copy of this canister, changing the canister ID to the provided principal.

Trait Implementations§

Source§

impl<'agent> Debug for BitcoinCanister<'agent>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'agent> Deref for BitcoinCanister<'agent>

Source§

type Target = Canister<'agent>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'agent> Freeze for BitcoinCanister<'agent>

§

impl<'agent> !RefUnwindSafe for BitcoinCanister<'agent>

§

impl<'agent> Send for BitcoinCanister<'agent>

§

impl<'agent> Sync for BitcoinCanister<'agent>

§

impl<'agent> Unpin for BitcoinCanister<'agent>

§

impl<'agent> !UnwindSafe for BitcoinCanister<'agent>

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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T