pub struct BitcoinCanister<'agent> { /* private fields */ }Expand description
The canister interface for the IC Bitcoin canister.
Implementations§
Source§impl<'agent> BitcoinCanister<'agent>
impl<'agent> BitcoinCanister<'agent>
Sourcepub fn from_canister(
canister: Canister<'agent>,
network: BitcoinNetwork,
) -> Self
pub fn from_canister( canister: Canister<'agent>, network: BitcoinNetwork, ) -> Self
Create a BitcoinCanister interface from an existing canister object.
Sourcepub fn create(
agent: &'agent Agent,
canister_id: Principal,
network: BitcoinNetwork,
) -> Self
pub fn create( agent: &'agent Agent, canister_id: Principal, network: BitcoinNetwork, ) -> Self
Create a BitcoinCanister interface pointing to the specified canister ID.
Sourcepub fn mainnet(agent: &'agent Agent) -> Self
pub fn mainnet(agent: &'agent Agent) -> Self
Create a BitcoinCanister interface for the Bitcoin mainnet canister on the IC mainnet.
Sourcepub fn testnet(agent: &'agent Agent) -> Self
pub fn testnet(agent: &'agent Agent) -> Self
Create a BitcoinCanister interface for the Bitcoin testnet canister on the IC mainnet.
Sourcepub fn for_network(
agent: &'agent Agent,
network: BitcoinNetwork,
) -> Result<Self, AgentError>
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.
Sourcepub fn get_balance(
&self,
address: &str,
min_confirmations: Option<u32>,
) -> impl 'agent + AsyncCall<Value = (u64,)>
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.
Sourcepub fn get_balance_query(
&self,
address: &str,
min_confirmations: Option<u32>,
) -> impl 'agent + SyncCall<Value = (u64,)>
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.
Sourcepub fn get_utxos(
&self,
address: &str,
filter: Option<UtxosFilter>,
) -> impl 'agent + AsyncCall<Value = (GetUtxosResponse,)>
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.
Sourcepub fn get_utxos_query(
&self,
address: &str,
filter: Option<UtxosFilter>,
) -> impl 'agent + SyncCall<Value = (GetUtxosResponse,)>
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.
Sourcepub fn get_current_fee_percentiles(
&self,
) -> impl 'agent + AsyncCall<Value = (Vec<u64>,)>
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.
Sourcepub fn get_block_headers(
&self,
start_height: u32,
end_height: Option<u32>,
) -> impl 'agent + AsyncCall<Value = (GetBlockHeadersResponse,)>
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.
Methods from Deref<Target = Canister<'agent>>§
Sourcepub fn canister_id_(&self) -> &Principal
pub fn canister_id_(&self) -> &Principal
Get the canister ID of this canister.
Prefer using canister_id instead.
Sourcepub fn canister_id(&self) -> &Principal
pub fn canister_id(&self) -> &Principal
Get the canister ID of this canister.
Sourcepub fn update_<'canister>(
&'canister self,
method_name: &str,
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update_<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
Prefer using update instead.
Sourcepub fn update<'canister>(
&'canister self,
method_name: &str,
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update<'canister>( &'canister self, method_name: &str, ) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
Sourcepub fn query_<'canister>(
&'canister self,
method_name: &str,
) -> SyncCallBuilder<'agent, 'canister>
pub fn query_<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
Prefer using query instead.
Sourcepub fn query<'canister>(
&'canister self,
method_name: &str,
) -> SyncCallBuilder<'agent, 'canister>
pub fn query<'canister>( &'canister self, method_name: &str, ) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
Sourcepub async fn wait<'canister>(
&'canister self,
request_id: &RequestId,
) -> Result<Vec<u8>, AgentError>
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.
Sourcepub fn clone_with_(&self, id: Principal) -> Self
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.
Sourcepub fn clone_with(&self, id: Principal) -> Self
pub fn clone_with(&self, id: Principal) -> Self
Creates a copy of this canister, changing the canister ID to the provided principal.