Skip to main content

Client

Struct Client 

Source
pub struct Client<B, W, S, K> {
    pub server_info: Info,
    /* private fields */
}
Expand description

A client to interact with Ark server

See OfflineClient docs for details.

Fields§

§server_info: Info

Implementations§

Source§

impl<B, W, S, K> Client<B, W, S, K>
where B: Blockchain + Send + Sync + 'static, W: BoardingWallet + OnchainWallet + Send + Sync + 'static, S: SwapStorage + 'static, K: KeyProvider + Send + Sync + 'static,

Source

pub fn start_vtxo_watcher( self: &Arc<Self>, delegator: Arc<DelegatorClient>, ) -> VtxoWatcherHandle

Start a background task that watches for new VTXOs and:

  1. Delegates them to the configured delegator service for future auto-renewal
  2. Self-renews VTXOs that are close to expiry (safety net)

Reconnects automatically with exponential backoff (1s → 2s → … → 30s) on stream errors.

Requires the client to be wrapped in an Arc for shared ownership with the background task.

Returns a VtxoWatcherHandle that stops the watcher when dropped.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn issue_asset( &self, amount: u64, control_asset_config: Option<ControlAssetConfig>, metadata: Option<Vec<(String, String)>>, ) -> Result<IssueAssetResult, Error>

Issue a new asset.

Creates a fresh asset with the given amount. The asset is sent to the caller’s own address. If control_asset is provided, the asset can be reissued in the future.

Source

pub async fn reissue_asset( &self, asset_id: AssetId, amount: u64, ) -> Result<Txid, Error>

Reissue additional units of an existing asset.

The asset must have been created with a control asset. The control asset is spent as input and sent back to the caller, while the new asset units are minted.

Source

pub async fn burn_asset( &self, asset_id: AssetId, amount: u64, ) -> Result<Txid, Error>

Burn a specific amount of an asset.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn settle<R>(&self, rng: &mut R) -> Result<Option<Txid>, Error>
where R: Rng + CryptoRng + Clone,

Settle all prior VTXOs and boarding outputs into the next batch, generating new confirmed VTXOs.

Source

pub async fn settle_with_notes<R>( &self, rng: &mut R, notes: Vec<ArkNote>, ) -> Result<Option<Txid>, Error>
where R: Rng + CryptoRng + Clone,

Settle all prior VTXOs, boarding outputs, and the provided ArkNotes into the next batch.

ArkNotes are bearer tokens that can be redeemed by revealing their preimage. This method combines them with regular VTXOs and boarding outputs into a single settlement transaction.

Source

pub async fn settle_vtxos<R>( &self, rng: &mut R, vtxo_outpoints: &[OutPoint], boarding_outpoints: &[OutPoint], ) -> Result<Option<Txid>, Error>
where R: Rng + CryptoRng + Clone,

Settle specific VTXOs and boarding outputs by outpoint into the next batch, generating new confirmed VTXOs.

Unlike Self::settle, this method allows the caller to specify exactly which VTXOs and boarding outputs to settle by providing their outpoints.

Source

pub async fn collaborative_redeem<R>( &self, rng: &mut R, to_address: Address, to_amount: Amount, ) -> Result<Txid, Error>
where R: Rng + CryptoRng + Clone,

Settle some prior VTXOs and boarding outputs into the next batch, generating UTXOs as outputs to a new commitment transaction.

Source

pub async fn collaborative_redeem_vtxo_selection<R>( &self, rng: &mut R, input_vtxos: impl Iterator<Item = OutPoint> + Clone, to_address: Address, to_amount: Amount, ) -> Result<Txid, Error>
where R: Rng + CryptoRng + Clone,

Settle a selection of VTXOs into the next batch, generating UTXOs as outputs to a new commitment transaction.

Source

pub async fn generate_delegate( &self, delegate_cosigner_pk: PublicKey, ) -> Result<Delegate, Error>

Generate a delegate for settling VTXOs on behalf of the owner.

The owner pre-signs the intent and forfeit transactions, allowing another party to complete the settlement at a later time using the provided delegate_cosigner_pk.

§Arguments
  • delegate_cosigner_pk - The cosigner public key that the delegate will use
  • select_recoverable_vtxos - Whether to include recoverable VTXOs
§Returns

A Delegate struct containing all the pre-signed data needed for settlement.

Source

pub fn sign_delegate_psbts( &self, intent_psbt: &mut Psbt, forfeit_psbts: &mut [Psbt], ) -> Result<(), Error>

Sign a set of delegate PSBTs, including the intent PSBT and the forfeit PSBTs.

Source

pub async fn settle_delegate<R>( &self, rng: &mut R, delegate: Delegate, own_cosigner_kp: Keypair, ) -> Result<Txid, Error>
where R: Rng + CryptoRng,

Settle a delegate by completing the batch protocol using pre-signed data.

This method allows Bob to settle Alice’s VTXOs using the pre-signed intent and forfeit transactions from the Delegate struct.

§Arguments
  • rng - Random number generator for nonce generation
  • delegate - The delegate struct containing pre-signed data
  • own_cosigner_kp - Bob’s cosigner keypair (must match the delegate_cosigner_pk)
§Returns

The commitment transaction ID if successful.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn prepare_ln_invoice_payment( &self, invoice: Bolt11Invoice, ) -> Result<SubmarineSwapData, Error>

Prepare the payment of a BOLT11 invoice by setting up a submarine swap via Boltz.

This function does not execute the payment itself. Once you are ready for payment you will have to send the required amount to the vhtlc_address.

If you are looking for a function which pays the invoice immediately, consider using Client::pay_ln_invoice instead.

§Arguments
§Returns
Source

pub async fn pay_ln_invoice( &self, invoice: Bolt11Invoice, ) -> Result<SubmarineSwapResult, Error>

Pay a BOLT11 invoice by performing a submarine swap via Boltz. This allows to make Lightning payments with an Ark wallet.

§Arguments
§Returns
  • A [SubmarineSwapResult], including an identifier for the swap and the TXID of the Ark transaction that funds the VHTLC.
Source

pub async fn wait_for_invoice_paid( &self, swap_id: &str, ) -> Result<[u8; 32], Error>

Wait for the Lightning invoice associated with a submarine swap to be paid by Boltz.

Boltz will first need to claim our VHTLC before paying the invoice. When Boltz claims the VHTLC, the preimage is revealed in the claim transaction’s witness. This method extracts and persists the preimage to swap storage.

§Returns

The 32-byte preimage that was revealed when Boltz claimed the VHTLC.

Source

pub async fn extract_submarine_swap_preimage( &self, swap_id: &str, ) -> Result<[u8; 32], Error>

Extract the preimage from a claimed submarine swap VHTLC.

After Boltz claims the VHTLC, the preimage is embedded in the claim transaction’s PSBT via the VTXO_CONDITION_KEY unknown field. This method fetches that transaction and extracts the preimage.

The extracted preimage is validated against the stored preimage hash and persisted to swap storage.

Source

pub async fn refund_expired_vhtlc(&self, swap_id: &str) -> Result<Txid, Error>

Refund a VHTLC after the timelock has expired.

This path does not require a signature from Boltz.

Source

pub async fn refund_expired_vhtlc_via_settlement<R>( &self, rng: &mut R, swap_id: &str, ) -> Result<Txid, Error>
where R: Rng + CryptoRng,

Refund a VHTLC after the timelock has expired via settlement.

This path does not require a signature from Boltz.

Source

pub async fn refund_vhtlc(&self, swap_id: &str) -> Result<Txid, Error>

Refund a VHTLC with collaboration from Boltz.

This path requires Boltz’s cooperation to sign the refund transaction. It allows refunding a submarine swap before the timelock expires. For refunds after timelock expiry without Boltz cooperation, use Client::refund_expired_vhtlc instead.

Source

pub async fn get_ln_invoice( &self, amount: SwapAmount, expiry_secs: Option<u64>, description: Option<String>, ) -> Result<ReverseSwapResult, Error>

Generate a BOLT11 invoice to perform a reverse submarine swap via Boltz. This allows to receive Lightning payments into an Ark wallet.

§Arguments
  • amount: the expected Amount to be received.
  • expiry_secs: optional invoice expiry, in seconds from now. If None, Boltz’s default is used.
  • description: optional memo embedded in the BOLT11 invoice’s d field (visible to the payer).
§Returns
  • A ReverseSwapResult, including an identifier for the reverse swap and the Bolt11Invoice to be paid.
Source

pub async fn get_ln_invoice_from_hash( &self, amount: SwapAmount, expiry_secs: Option<u64>, preimage_hash_sha256: Hash, description: Option<String>, ) -> Result<ReverseSwapResult, Error>

Generate a BOLT11 invoice using a provided SHA256 preimage hash for a reverse submarine swap via Boltz. This allows receiving Lightning payments when the preimage is managed externally.

§Arguments
  • amount: the expected Amount to be received.
  • expiry_secs: optional invoice expiry, in seconds from now. If None, Boltz’s default is used.
  • preimage_hash_sha256: the SHA256 hash of the preimage. The preimage itself is not stored and must be provided later when claiming via Self::claim_vhtlc.
  • description: optional memo embedded in the BOLT11 invoice’s d field (visible to the payer).
§Returns
  • A [ReverseSwapResult], including an identifier for the reverse swap and the Bolt11Invoice to be paid.
§Note

After calling this method, use Self::wait_for_vhtlc_funding to wait for the VHTLC to be funded, then Self::claim_vhtlc with the preimage to claim the funds.

Source

pub async fn wait_for_vhtlc_funding(&self, swap_id: &str) -> Result<(), Error>

Wait for the VHTLC associated with a reverse submarine swap to be funded.

This method only waits for the funding transaction to be detected (in mempool or confirmed). It does not claim the VHTLC. Use Self::claim_vhtlc to claim after the preimage is known.

§Arguments
  • swap_id: The unique identifier for the reverse swap.
§Returns

Returns Ok(()) when the VHTLC funding transaction is detected.

Source

pub async fn claim_vhtlc( &self, swap_id: &str, preimage: [u8; 32], ) -> Result<ClaimVhtlcResult, Error>

Claim a funded VHTLC for a reverse submarine swap using the preimage.

This method should be called after the VHTLC has been funded (after Self::wait_for_vhtlc_funding returns) and the preimage is known.

§Arguments
  • swap_id: The unique identifier for the reverse swap.
  • preimage: The 32-byte preimage that unlocks the VHTLC.
§Returns

Returns a [ClaimVhtlcResult] with details about the claim transaction.

Source

pub async fn wait_for_vhtlc( &self, swap_id: &str, ) -> Result<ClaimVhtlcResult, Error>

Wait for the VHTLC associated with a reverse submarine swap to be funded, then claim it.

§Note

This method requires that the preimage was stored when creating the reverse swap (i.e., via Self::get_ln_invoice). If the swap was created with Self::get_ln_invoice_from_hash, use Self::wait_for_vhtlc_funding followed by Self::claim_vhtlc instead.

Source

pub async fn create_chain_swap( &self, direction: ChainSwapDirection, amount: ChainSwapAmount, ) -> Result<ChainSwapResult, Error>

Create a chain swap via Boltz for swapping between ARK and on-chain BTC.

Returns a ChainSwapResult containing the swap ID and the address the user must fund to initiate the swap. For ChainSwapDirection::ArkToBtc, the user should send Ark VTXOs to the user_lockup_address using [Client::send_vtxo]. For ChainSwapDirection::BtcToArk, the user should send BTC to the user_lockup_address.

After funding, use Self::wait_for_chain_swap_server_lockup to wait for Boltz to lock their side, then Self::claim_chain_swap to claim.

Source

pub async fn wait_for_chain_swap_server_lockup( &self, swap_id: &str, ) -> Result<Option<String>, Error>

Wait for Boltz to lock funds on their side of the chain swap.

Returns when the server’s lockup transaction is detected in the mempool or confirmed. After this returns, use Self::claim_chain_swap to claim the funds.

Returns the server’s lockup transaction ID if available.

Source

pub async fn claim_chain_swap(&self, swap_id: &str) -> Result<Txid, Error>

Claim the Ark VHTLC from a chain swap after Boltz has locked funds.

This claims the server’s Ark VHTLC lockup using the stored preimage. It is intended for ChainSwapDirection::BtcToArk swaps where the server locks an Ark VHTLC.

Call this after Self::wait_for_chain_swap_server_lockup returns.

Source

pub async fn claim_chain_swap_btc( &self, swap_id: &str, destination_address: Address, fee_rate_sat_vb: f64, ) -> Result<Txid, Error>

Claim on-chain BTC from a chain swap after Boltz has locked funds.

This claims the server’s on-chain BTC HTLC using the stored preimage. It is intended for ChainSwapDirection::ArkToBtc swaps where the server locks on-chain BTC.

Call this after Self::wait_for_chain_swap_server_lockup returns.

Source

pub async fn refund_chain_swap(&self, swap_id: &str) -> Result<Txid, Error>

Refund the Ark VHTLC from a chain swap after the timelock has expired.

This is for ChainSwapDirection::ArkToBtc swaps where the user locked an Ark VHTLC and needs to reclaim it (e.g. if Boltz never locked BTC or the swap expired).

This path does not require a signature from Boltz.

Source

pub async fn refund_chain_swap_btc( &self, swap_id: &str, destination_address: Address, fee_rate_sat_vb: f64, ) -> Result<Txid, Error>

Refund on-chain BTC from a chain swap after the timelock has expired.

This is for ChainSwapDirection::BtcToArk swaps where the user locked on-chain BTC and needs to reclaim it (e.g. if Boltz never locked the Ark VHTLC or the swap expired).

Source

pub async fn get_swap_status( &self, swap_id: &str, ) -> Result<SwapStatusInfo, Error>

Query the current status of any Boltz swap by ID.

Checks local swap storage to determine the swap type, then queries the Boltz API for the live status.

Source

pub async fn get_fees(&self) -> Result<BoltzFees, Error>

Fetch fee information from Boltz for both submarine and reverse swaps.

§Returns
  • A [BoltzFees] struct containing fee information for both swap types.
Source

pub async fn get_limits(&self) -> Result<SwapLimits, Error>

Fetch swap amount limits from Boltz for submarine swaps.

§Returns
  • A [SwapLimits] struct containing minimum and maximum swap amounts in satoshis.
Source

pub fn subscribe_to_swap_updates( &self, swap_id: String, ) -> impl Stream<Item = Result<SwapStatus, Error>> + '_

Use Boltz’s API to learn about updates for a particular swap.

Source

pub async fn list_pending_vhtlc_spend_txs( &self, ) -> Result<Vec<PendingVhtlcSpendTx>, Error>

List pending (submitted but not finalized) VHTLC spend transactions.

This checks all non-terminal swaps in storage, queries the server for pending VTXOs on their VHTLC addresses, and determines the spend type from the PSBT data.

Source

pub async fn continue_pending_vhtlc_spend_tx( &self, pending: &PendingVhtlcSpendTx, ) -> Result<Txid, Error>

Continue (finalize) a pending VHTLC spend transaction.

Handles the different spend types appropriately:

  • Claim: signs the checkpoint with the claim key and injects the preimage.
  • CollaborativeRefund: re-requests Boltz’s signature, then signs with the refund key.
  • ExpiredRefund: signs the checkpoint with the refund key (no Boltz needed).
Source

pub async fn continue_pending_vhtlc_spend_txs(&self) -> Result<Vec<Txid>, Error>

Sign and finalize all pending VHTLC spend transactions.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn estimate_onchain_fees<R>( &self, rng: &mut R, to_address: Address, to_amount: Amount, ) -> Result<SignedAmount, Error>
where R: Rng + CryptoRng + Clone,

Estimates the fee to collaboratively redeem VTXOs to an on-chain Bitcoin address.

This function calculates the expected fee for moving funds from the Ark protocol back to a standard on-chain Bitcoin address through a collaborative redemption process. The fee is estimated by creating a simulated intent and querying the Ark server.

§Arguments
  • rng - A random number generator for creating the intent
  • to_address - The on-chain Bitcoin address to send funds to
  • to_amount - The amount to send to the destination address
§Returns

Returns the estimated fee as a SignedAmount. The fee will be deducted from the total available balance when performing the actual redemption.

§Errors

Returns an error if:

  • The available balance is insufficient for the requested amount
  • Failed to fetch VTXOs or boarding inputs
  • Failed to communicate with the Ark server
Source

pub async fn estimate_batch_fees<R>( &self, rng: &mut R, to_address: ArkAddress, ) -> Result<SignedAmount, Error>
where R: Rng + CryptoRng + Clone,

Estimates the fee to join the next batch and settle funds to an Ark address.

This function calculates the expected fee for consolidating all available VTXOs and boarding outputs into fresh VTXOs through the Ark batch process. The full available balance will be used, with fees deducted from the resulting VTXO.

Use this to estimate fees before calling settle or similar batch operations.

§Arguments
  • rng - A random number generator for creating the intent
  • to_address - The Ark address to receive the settled funds
§Returns

Returns the estimated fee as a SignedAmount. This fee will be deducted from the total available balance when joining the actual batch.

§Errors

Returns an error if:

  • Failed to fetch VTXOs or boarding inputs
  • Failed to communicate with the Ark server
Source

pub async fn estimate_onchain_fees_vtxo_selection<R>( &self, rng: &mut R, input_vtxos: impl Iterator<Item = OutPoint> + Clone, to_address: Address, to_amount: Amount, ) -> Result<SignedAmount, Error>
where R: Rng + CryptoRng + Clone,

Estimates the fee to collaboratively redeem specific VTXOs to an on-chain Bitcoin address.

This function is similar to estimate_onchain_fees, but allows you to specify exactly which VTXOs to use as inputs instead of using automatic coin selection. This is useful when you want to estimate fees for redeeming specific UTXOs.

§Arguments
  • rng - A random number generator for creating the intent
  • input_vtxos - An iterator of OutPoints specifying which VTXOs to use as inputs
  • to_address - The on-chain Bitcoin address to send funds to
  • to_amount - The amount to send to the destination address
§Returns

Returns the estimated fee as a SignedAmount. The fee will be deducted from the total input amount, with any remainder going to change.

§Errors

Returns an error if:

  • No matching VTXO outpoints are found
  • The total input amount is insufficient for the requested amount plus fees
  • Failed to fetch VTXOs
  • Failed to communicate with the Ark server
Source

pub async fn estimate_batch_fees_vtxo_selection<R>( &self, rng: &mut R, input_vtxos: impl Iterator<Item = OutPoint> + Clone, to_address: ArkAddress, ) -> Result<SignedAmount, Error>
where R: Rng + CryptoRng + Clone,

Estimates the fee to join the next batch with specific VTXOs and settle to an Ark address.

This function is similar to estimate_batch_fees, but allows you to specify exactly which VTXOs to use as inputs instead of using all available VTXOs. This is useful when you want to estimate fees for settling specific UTXOs into fresh VTXOs.

§Arguments
  • rng - A random number generator for creating the intent
  • input_vtxos - An iterator of OutPoints specifying which VTXOs to use as inputs
  • to_address - The Ark address to receive the settled funds
§Returns

Returns the estimated fee as a SignedAmount. The fee will be deducted from the total input amount when joining the actual batch.

§Errors

Returns an error if:

  • No matching VTXO outpoints are found
  • Failed to fetch VTXOs
  • Failed to communicate with the Ark server
Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn send(&self, receivers: Vec<SendReceiver>) -> Result<Txid, Error>

Send bitcoin and/or Arkade assets offchain to one or more receivers.

Coin selection handles both bitcoin-only and asset-bearing VTXOs. An asset packet is attached only when the transfer actually involves carried or requested assets.

§Arguments
  • receivers - a list of SendReceivers, specifying a target address, a bitcoin amount and an optional list of assets.
§Returns

The Txid of the resulting Ark transaction.

Source

pub async fn send_selection( &self, vtxo_outpoints: &[OutPoint], receivers: Vec<SendReceiver>, ) -> Result<Txid, Error>

Spend specific VTXOs in an Ark transaction sending bitcoin and/or Arkade assets to one or more receivers.

Unlike Self::send, this method allows the caller to specify exactly which VTXOs to spend by providing their outpoints. This is useful for applications that want to have full control over VTXO selection.

§Arguments
  • vtxo_outpoints - a list of all the outpoints to be used as inputs to the transaction.
  • receivers - a list of SendReceivers, specifying a target address, a bitcoin amount and an optional list of assets.
§Returns

The Txid of the generated Ark transaction.

§Errors

Returns an error if the selected VTXOs don’t have enough BTC value or assets to cover the requested receiver amounts.

Source

pub async fn continue_pending_offchain_txs(&self) -> Result<Vec<Txid>, Error>

Resume and finalize any pending (submitted but not finalized) offchain transactions.

This handles the case where send_vtxo successfully submitted the transaction to the server but failed before finalizing (e.g. due to a crash or network error). The server holds the submitted-but-not-finalized transaction in a pending state. This method retrieves it, signs the checkpoint transactions, and finalizes.

§Returns

The Txids of the finalized Ark transactions, or an empty vec if there were no pending transactions.

Source

pub async fn list_pending_offchain_txs(&self) -> Result<Vec<PendingTx>, Error>

List pending (submitted but not finalized) offchain transactions.

This retrieves any transactions that were submitted to the server but not yet finalized (e.g. due to a crash or network error between submit and finalize).

§Returns

The pending transactions, or an empty vec if there are none.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub async fn build_unilateral_exit_trees( &self, ) -> Result<Vec<Vec<Transaction>>, Error>

Build the unilateral exit transaction tree for all spendable VTXOs.

§Returns

The tree as a Vec<Vec<Transaction>>, where each branch represents a path from a commitment transaction output to a spendable VTXO. Every transaction is finalized, but requires fee bumping through a P2A output.

Source

pub async fn broadcast_next_unilateral_exit_node( &self, branch: &[Transaction], ) -> Result<Option<Txid>, Error>

Broadcast the next unconfirmed transaction in a branch, skipping transactions that are already on the blockchain.

§Returns

Ok(Some(txid)) if a transaction was broadcast, Ok(None) if all are confirmed.

Source

pub async fn send_on_chain( &self, to_address: Address, to_amount: Amount, ) -> Result<Txid, Error>

Spend boarding outputs and VTXOs to an on-chain address.

All these outputs are spent unilaterally.

To be able to spend a boarding output, we must wait for the exit delay to pass.

To be able to spend a VTXO, the VTXO itself must be published on-chain (via something like unilateral_off_board), and then we must wait for the exit delay to pass.

Source§

impl<B, W, S, K> Client<B, W, S, K>

Source

pub fn delegator_pk(&self) -> Option<XOnlyPublicKey>

Returns the currently configured delegator pubkey, if any.

Source

pub fn boltz_referral_id(&self) -> Option<&str>

Returns the Boltz referral ID sent with all swap creation requests, if any.

Source

pub fn get_offchain_address(&self) -> Result<(ArkAddress, Vtxo), Error>

Get a new offchain receiving address.

When a delegator is configured (via delegator_pk passed to OfflineClient::new), returns a 3-leaf delegate address. Otherwise returns a standard 2-leaf address.

For HD wallets, this will derive a new address each time it’s called. For static key providers, this will always return the same address.

Source

pub fn get_offchain_addresses(&self) -> Result<Vec<(ArkAddress, Vtxo)>, Error>

Get all known offchain addresses for this wallet.

When a delegator is configured, this returns both the default (2-leaf) and delegate (3-leaf) addresses for each key, so that VTXOs at either address are visible. If historical delegator keys are set via historical_delegator_pks passed to OfflineClient::new, addresses for those are included too.

Source

pub async fn discover_keys(&self, gap_limit: u32) -> Result<u32, Error>

Discover and cache used keys using BIP44-style gap limit

This method derives keys in batches, checks all at once via list_vtxos, caches used ones, and stops when a full batch has no used keys.

Returns the number of discovered keys. No-op for StaticKeyProvider.

§Arguments
  • gap_limit - Number of consecutive unused addresses before stopping
Source

pub fn get_boarding_address(&self) -> Result<Address, Error>

Source

pub fn get_onchain_address(&self) -> Result<Address, Error>

Source

pub fn get_boarding_addresses(&self) -> Result<Vec<Address>, Error>

Source

pub async fn get_virtual_tx_outpoints( &self, addresses: impl Iterator<Item = ArkAddress>, ) -> Result<Vec<VirtualTxOutPoint>, Error>

Source

pub async fn list_vtxos( &self, ) -> Result<(VtxoList, HashMap<ScriptBuf, Vtxo>), Error>

Source

pub async fn list_vtxos_for_addresses( &self, addresses: impl Iterator<Item = ArkAddress>, ) -> Result<VtxoList, Error>

Source

pub async fn list_vtxos_for_outpoints( &self, outpoints: Vec<OutPoint>, ) -> Result<(VtxoList, HashMap<ScriptBuf, Vtxo>), Error>

Source

pub async fn get_vtxo_chain( &self, out_point: OutPoint, size: i32, index: i32, ) -> Result<Option<VtxoChainResponse>, Error>

Source

pub async fn offchain_balance(&self) -> Result<OffChainBalance, Error>

Source

pub async fn get_asset(&self, asset_id: AssetId) -> Result<AssetInfo, Error>

Get information about an asset by its ID.

Source

pub async fn transaction_history(&self) -> Result<Vec<Transaction>, Error>

Source

pub fn dust(&self) -> Amount

The server’s dust threshold amount.

Source

pub fn network_client(&self) -> Client

Source

pub async fn bump_tx(&self, parent: &Transaction) -> Result<Transaction, Error>

Use the P2A output of a transaction to bump its transaction fee with a child transaction.

Source

pub async fn subscribe_to_scripts( &self, scripts: Vec<ArkAddress>, subscription_id: Option<String>, ) -> Result<String, Error>

Subscribe to receive transaction notifications for specific VTXO scripts

This method allows you to subscribe to get notified about transactions affecting the provided VTXO addresses. It can also be used to update an existing subscription by adding new scripts to it.

§Arguments
  • scripts - Vector of ArkAddress to subscribe to
  • subscription_id - Unique identifier for the subscription. Use the same ID to update an existing subscription. Use None for new subscriptions
§Returns

Returns the subscription ID if successful

Source

pub async fn unsubscribe_from_scripts( &self, scripts: Vec<ArkAddress>, subscription_id: String, ) -> Result<(), Error>

Remove scripts from an existing subscription

This method allows you to unsubscribe from receiving notifications for specific VTXO scripts while keeping the subscription active for other scripts.

§Arguments
  • scripts - Vector of ArkAddress to unsubscribe from
  • subscription_id - The subscription ID to update
Source

pub async fn get_subscription( &self, subscription_id: String, ) -> Result<impl Stream<Item = Result<SubscriptionResponse, Error>> + Unpin, Error>

Get a subscription stream that returns subscription responses

This method returns a stream that yields SubscriptionResponse messages containing information about new and spent VTXOs for the subscribed scripts.

§Arguments
  • subscription_id - The subscription ID to get the stream for
§Returns

Returns a Stream of SubscriptionResponse messages

Auto Trait Implementations§

§

impl<B, W, S, K> !Freeze for Client<B, W, S, K>

§

impl<B, W, S, K> !RefUnwindSafe for Client<B, W, S, K>

§

impl<B, W, S, K> Send for Client<B, W, S, K>
where K: Sync + Send, B: Sync + Send, W: Sync + Send, S: Sync + Send,

§

impl<B, W, S, K> Sync for Client<B, W, S, K>
where K: Sync + Send, B: Sync + Send, W: Sync + Send, S: Sync + Send,

§

impl<B, W, S, K> Unpin for Client<B, W, S, K>

§

impl<B, W, S, K> UnsafeUnpin for Client<B, W, S, K>

§

impl<B, W, S, K> !UnwindSafe for Client<B, W, S, K>

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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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, 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
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,