1use bitcoin::{Amount, Txid};
2#[cfg(feature = "utoipa")]
3use utoipa::ToSchema;
4
5#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
6#[cfg_attr(feature = "utoipa", derive(ToSchema))]
7pub struct Send {
8 #[cfg_attr(feature = "utoipa", schema(value_type = String))]
9 pub txid: Txid,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
13#[cfg_attr(feature = "utoipa", derive(ToSchema))]
14pub struct Address {
15 #[cfg_attr(feature = "utoipa", schema(value_type = String))]
16 pub address: bitcoin::Address<bitcoin::address::NetworkUnchecked>,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20#[cfg_attr(feature = "utoipa", derive(ToSchema))]
21pub struct OnchainBalance {
22 #[serde(rename="total_sat", with="bitcoin::amount::serde::as_sat")]
24 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
25 pub total: Amount,
26 #[serde(rename="trusted_spendable_sat", with="bitcoin::amount::serde::as_sat")]
31 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
32 pub trusted_spendable: Amount,
33 #[serde(rename="immature_sat", with="bitcoin::amount::serde::as_sat")]
35 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
36 pub immature: Amount,
37 #[serde(rename="trusted_pending_sat", with="bitcoin::amount::serde::as_sat")]
39 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
40 pub trusted_pending: Amount,
41 #[serde(rename="untrusted_pending_sat", with="bitcoin::amount::serde::as_sat")]
43 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
44 pub untrusted_pending: Amount,
45 #[serde(rename="confirmed_sat", with="bitcoin::amount::serde::as_sat")]
47 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
48 pub confirmed: Amount,
49}
50
51impl From<bark::onchain::bdk_wallet::Balance> for OnchainBalance {
52 fn from(b: bark::onchain::bdk_wallet::Balance) -> Self {
53 OnchainBalance {
54 total: b.total(),
55 trusted_spendable: b.trusted_pending,
56 immature: b.immature,
57 trusted_pending: b.trusted_pending,
58 untrusted_pending: b.untrusted_pending,
59 confirmed: b.confirmed,
60 }
61 }
62}