1use crate::error::Error;
2use ark_core::UtxoCoinSelection;
3use bitcoin::Address;
4use bitcoin::Amount;
5use bitcoin::FeeRate;
6use bitcoin::Psbt;
7use std::future::Future;
8
9pub trait OnchainWallet {
13 fn get_onchain_address(&self) -> Result<Address, Error>;
14
15 fn sync(&self) -> impl Future<Output = Result<(), Error>>;
16
17 fn balance(&self) -> Result<Balance, Error>;
18
19 fn prepare_send_to_address(
20 &self,
21 address: Address,
22 amount: Amount,
23 fee_rate: FeeRate,
24 ) -> Result<Psbt, Error>;
25
26 fn sign(&self, psbt: &mut Psbt) -> Result<bool, Error>;
27
28 fn select_coins(&self, target_amount: Amount) -> Result<UtxoCoinSelection, Error>;
29}
30
31#[derive(Debug, Clone, Copy)]
32pub struct Balance {
33 pub immature: Amount,
35 pub trusted_pending: Amount,
37 pub untrusted_pending: Amount,
39 pub confirmed: Amount,
41}