Skip to content

Commit 14a3c53

Browse files
committed
feat: apply_unconfirmed_txs on wallet
1 parent 2c9d903 commit 14a3c53

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

bdk-ffi/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bdk-ffi/src/bdk.udl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,14 @@ interface Wallet {
737737

738738
[Throws=SqliteError]
739739
boolean persist(Connection connection);
740+
741+
/// Apply relevant unconfirmed transactions to the wallet.
742+
/// Transactions that are not relevant are filtered out.
743+
void apply_unconfirmed_txs(sequence<UnconfirmedTx> unconfirmed_txs);
740744
};
741745

746+
typedef dictionary UnconfirmedTx;
747+
742748
interface Update {};
743749

744750
interface Policy {

bdk-ffi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ use crate::types::SyncRequestBuilder;
8787
use crate::types::SyncScriptInspector;
8888
use crate::types::Tx;
8989
use crate::types::TxStatus;
90+
use crate::types::UnconfirmedTx;
9091
use crate::types::Update;
9192
use crate::wallet::Wallet;
9293

bdk-ffi/src/types.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,3 +592,9 @@ impl From<BdkTx> for Tx {
592592
}
593593
}
594594
}
595+
596+
#[derive(uniffi::Record)]
597+
pub struct UnconfirmedTx {
598+
pub tx: Arc<Transaction>,
599+
pub last_seen: u64,
600+
}

bdk-ffi/src/wallet.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::error::{
77
use crate::store::Connection;
88
use crate::types::{
99
AddressInfo, Balance, CanonicalTx, FullScanRequestBuilder, KeychainAndIndex, LocalOutput,
10-
Policy, SentAndReceivedValues, SignOptions, SyncRequestBuilder, Update,
10+
Policy, SentAndReceivedValues, SignOptions, SyncRequestBuilder, UnconfirmedTx, Update,
1111
};
1212

1313
use bdk_wallet::bitcoin::{Network, Txid};
@@ -130,6 +130,14 @@ impl Wallet {
130130
.map_err(CannotConnectError::from)
131131
}
132132

133+
pub fn apply_unconfirmed_txs(&self, unconfirmed_txs: Vec<UnconfirmedTx>) {
134+
self.get_wallet().apply_unconfirmed_txs(
135+
unconfirmed_txs
136+
.into_iter()
137+
.map(|utx| (Arc::new(utx.tx.as_ref().into()), utx.last_seen)),
138+
)
139+
}
140+
133141
pub(crate) fn derivation_index(&self, keychain: KeychainKind) -> Option<u32> {
134142
self.get_wallet().derivation_index(keychain)
135143
}

0 commit comments

Comments
 (0)