use bitcoin::{Amount, Txid};
#[cfg(feature = "utoipa")]
use utoipa::ToSchema;
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(ToSchema))]
pub struct Send {
#[cfg_attr(feature = "utoipa", schema(value_type = String))]
pub txid: Txid,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(ToSchema))]
pub struct Address {
#[cfg_attr(feature = "utoipa", schema(value_type = String))]
pub address: bitcoin::Address<bitcoin::address::NetworkUnchecked>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "utoipa", derive(ToSchema))]
pub struct OnchainBalance {
#[serde(rename="total_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub total: Amount,
#[serde(rename="trusted_spendable_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub trusted_spendable: Amount,
#[serde(rename="immature_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub immature: Amount,
#[serde(rename="trusted_pending_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub trusted_pending: Amount,
#[serde(rename="untrusted_pending_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub untrusted_pending: Amount,
#[serde(rename="confirmed_sat", with="bitcoin::amount::serde::as_sat")]
#[cfg_attr(feature = "utoipa", schema(value_type = u64))]
pub confirmed: Amount,
}
impl From<bark::onchain::bdk_wallet::Balance> for OnchainBalance {
fn from(b: bark::onchain::bdk_wallet::Balance) -> Self {
OnchainBalance {
total: b.total(),
trusted_spendable: b.trusted_pending,
immature: b.immature,
trusted_pending: b.trusted_pending,
untrusted_pending: b.untrusted_pending,
confirmed: b.confirmed,
}
}
}