ark-client 0.10.0

Main client library for interacting with Ark servers
Documentation
use crate::error::Error;
use ark_core::UtxoCoinSelection;
use bitcoin::Address;
use bitcoin::Amount;
use bitcoin::FeeRate;
use bitcoin::Psbt;
use std::future::Future;

// TODO: I think we should get rid of `OnchainWallet` and just use `KeyProvider` plus explicit
// on-chain coin selection/signing dependencies.

pub trait OnchainWallet {
    fn get_onchain_address(&self) -> Result<Address, Error>;

    fn sync(&self) -> impl Future<Output = Result<(), Error>>;

    fn balance(&self) -> Result<Balance, Error>;

    fn prepare_send_to_address(
        &self,
        address: Address,
        amount: Amount,
        fee_rate: FeeRate,
    ) -> Result<Psbt, Error>;

    fn sign(&self, psbt: &mut Psbt) -> Result<bool, Error>;

    fn select_coins(&self, target_amount: Amount) -> Result<UtxoCoinSelection, Error>;
}

#[derive(Debug, Clone, Copy)]
pub struct Balance {
    /// All coinbase outputs not yet matured
    pub immature: Amount,
    /// Unconfirmed UTXOs generated by a wallet tx
    pub trusted_pending: Amount,
    /// Unconfirmed UTXOs received from an external wallet
    pub untrusted_pending: Amount,
    /// Confirmed and immediately spendable balance
    pub confirmed: Amount,
}