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 c7f9f86
Show file tree
Hide file tree
Showing 2 changed files with 15 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
12 changes: 11 additions & 1 deletion bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ 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 +130,14 @@ 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 c7f9f86

Please sign in to comment.