Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion bdk-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum KeychainKind {
}

/// Represents the observed position of some chain data.
#[derive(Debug, uniffi::Enum)]
#[derive(Debug, uniffi::Enum, Clone)]
pub enum ChainPosition {
/// The chain data is confirmed as it is anchored in the best chain by `A`.
Confirmed {
Expand Down Expand Up @@ -1094,3 +1094,30 @@ impl From<bdk_wallet::ChangeSet> for ChangeSet {
}
}
}

#[derive(uniffi::Record, Debug, Clone)]
pub struct TxDetails {
pub txid: Arc<Txid>,
pub sent: Arc<Amount>,
pub received: Arc<Amount>,
pub fee: Option<Arc<Amount>>,
pub fee_rate: Option<f32>,
pub balance_delta: i64,
pub chain_position: ChainPosition,
pub tx: Arc<Transaction>,
}

impl From<bdk_wallet::TxDetails> for TxDetails {
fn from(details: bdk_wallet::TxDetails) -> Self {
TxDetails {
txid: Arc::new(Txid(details.txid)),
sent: Arc::new(details.sent.into()),
received: Arc::new(details.received.into()),
fee: details.fee.map(|f| Arc::new(f.into())),
fee_rate: details.fee_rate.map(|fr| fr.to_sat_per_vb_ceil() as f32),
balance_delta: details.balance_delta.to_sat(),
chain_position: details.chain_position.into(),
tx: Arc::new(Transaction::from(details.tx.as_ref().clone())),
}
}
}
7 changes: 7 additions & 0 deletions bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ impl Wallet {
pub fn latest_checkpoint(&self) -> BlockId {
self.get_wallet().latest_checkpoint().block_id().into()
}

/// Get the [`TxDetails`] of a wallet transaction.
pub fn tx_details(&self, txid: Arc<Txid>) -> Option<crate::types::TxDetails> {
self.get_wallet()
.tx_details(txid.0)
.map(|details| details.into())
}
}

impl Wallet {
Expand Down
Loading