Skip to content

Commit

Permalink
feat: transactions_sort_by
Browse files Browse the repository at this point in the history
  • Loading branch information
reez committed Sep 19, 2024
1 parent bdb5174 commit ae7bb91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ interface Wallet {

sequence<CanonicalTx> transactions();

sequence<CanonicalTx> transactions_sort_by();

[Throws=TxidParseError]
CanonicalTx? get_tx(string txid);

Expand Down
8 changes: 8 additions & 0 deletions bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ impl Wallet {
.collect()
}

pub fn transactions_sort_by(&self) -> Vec<CanonicalTx> {
self.get_wallet()
.transactions_sort_by(|tx1, tx2| tx2.chain_position.cmp(&tx1.chain_position))
.into_iter()
.map(|tx| tx.into())
.collect()
}

pub fn get_tx(&self, txid: String) -> Result<Option<CanonicalTx>, TxidParseError> {
let txid =
Txid::from_str(txid.as_str()).map_err(|_| TxidParseError::InvalidTxid { txid })?;
Expand Down

0 comments on commit ae7bb91

Please sign in to comment.