Skip to content

Commit

Permalink
feat: expose list_unspent and list_output methods on wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Apr 10, 2024
1 parent 5f458e4 commit 07337cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ interface Wallet {

[Throws=CalculateFeeError]
FeeRate calculate_fee_rate([ByRef] Transaction tx);

sequence<LocalOutput> list_unspent();

sequence<LocalOutput> list_output();
};

interface Update {};
Expand Down
16 changes: 15 additions & 1 deletion bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::descriptor::Descriptor;
use crate::error::{
Alpha3Error, CalculateFeeError, PersistenceError, TxidParseError, WalletCreationError,
};
use crate::types::{AddressIndex, AddressInfo, Balance, CanonicalTx, FeeRate, ScriptAmount};
use crate::types::{AddressIndex, AddressInfo, Balance, CanonicalTx, FeeRate, LocalOutput, ScriptAmount};

use bdk::bitcoin::blockdata::script::ScriptBuf as BdkScriptBuf;
use bdk::bitcoin::psbt::PartiallySignedTransaction as BdkPartiallySignedTransaction;
Expand Down Expand Up @@ -128,6 +128,20 @@ impl Wallet {
.map(|bdk_fee_rate| Arc::new(FeeRate(bdk_fee_rate)))
.map_err(|e| e.into())
}

pub fn list_unspent(&self) -> Vec<LocalOutput> {
self.get_wallet()
.list_unspent()
.map(|o| o.into())
.collect()
}

pub fn list_output(&self) -> Vec<LocalOutput> {
self.get_wallet()
.list_output()
.map(|o| o.into())
.collect()
}
}

pub struct SentAndReceivedValues {
Expand Down

0 comments on commit 07337cd

Please sign in to comment.