feat: add sent_and_received method on wallet
This commit is contained in:
parent
6b177f0893
commit
46e0324f28
@ -107,6 +107,8 @@ interface Wallet {
|
||||
|
||||
[Throws=BdkError]
|
||||
boolean sign(PartiallySignedTransaction psbt);
|
||||
|
||||
SentAndReceivedValues sent_and_received([ByRef] Transaction tx);
|
||||
};
|
||||
|
||||
interface Update {};
|
||||
@ -247,6 +249,11 @@ dictionary ScriptAmount {
|
||||
u64 amount;
|
||||
};
|
||||
|
||||
dictionary SentAndReceivedValues {
|
||||
u64 sent;
|
||||
u64 received;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// bdk crate - bitcoin re-exports
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -23,6 +23,7 @@ use crate::types::AddressInfo;
|
||||
use crate::types::Balance;
|
||||
use crate::types::LocalUtxo;
|
||||
use crate::types::ScriptAmount;
|
||||
use crate::wallet::SentAndReceivedValues;
|
||||
use crate::wallet::TxBuilder;
|
||||
use crate::wallet::Update;
|
||||
use crate::wallet::Wallet;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::bitcoin::{OutPoint, PartiallySignedTransaction};
|
||||
use crate::bitcoin::{OutPoint, PartiallySignedTransaction, Transaction};
|
||||
use crate::descriptor::Descriptor;
|
||||
use crate::types::Balance;
|
||||
use crate::types::ScriptAmount;
|
||||
@ -93,6 +93,16 @@ impl Wallet {
|
||||
.sign(&mut psbt, SignOptions::default())
|
||||
.map_err(|e| BdkError::Generic(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn sent_and_received(&self, tx: &Transaction) -> SentAndReceivedValues {
|
||||
let (sent, received): (u64, u64) = self.get_wallet().sent_and_received(&tx.clone().into());
|
||||
SentAndReceivedValues { sent, received }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SentAndReceivedValues {
|
||||
pub sent: u64,
|
||||
pub received: u64,
|
||||
}
|
||||
|
||||
pub struct Update(pub(crate) BdkUpdate);
|
||||
|
Loading…
x
Reference in New Issue
Block a user