Expose set_recipients API from TxBuiler (#186)
This commit is contained in:
@@ -168,6 +168,11 @@ dictionary LocalUtxo {
|
||||
boolean is_spent;
|
||||
};
|
||||
|
||||
dictionary AddressAmount {
|
||||
string address;
|
||||
u64 amount;
|
||||
};
|
||||
|
||||
interface Wallet {
|
||||
[Throws=BdkError]
|
||||
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
|
||||
@@ -235,6 +240,8 @@ interface TxBuilder {
|
||||
|
||||
TxBuilder add_data(sequence<u8> data);
|
||||
|
||||
TxBuilder set_recipients(sequence<AddressAmount> recipients);
|
||||
|
||||
[Throws=BdkError]
|
||||
PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet);
|
||||
};
|
||||
|
||||
16
src/lib.rs
16
src/lib.rs
@@ -37,6 +37,11 @@ uniffi_macros::include_scaffolding!("bdk");
|
||||
|
||||
type BdkError = Error;
|
||||
|
||||
pub struct AddressAmount {
|
||||
pub address: String,
|
||||
pub amount: u64,
|
||||
}
|
||||
|
||||
pub struct AddressInfo {
|
||||
pub index: u32,
|
||||
pub address: String,
|
||||
@@ -421,6 +426,17 @@ impl TxBuilder {
|
||||
})
|
||||
}
|
||||
|
||||
fn set_recipients(&self, recipients: Vec<AddressAmount>) -> Arc<Self> {
|
||||
let recipients = recipients
|
||||
.iter()
|
||||
.map(|address_amount| (address_amount.address.clone(), address_amount.amount))
|
||||
.collect();
|
||||
Arc::new(TxBuilder {
|
||||
recipients,
|
||||
..self.clone()
|
||||
})
|
||||
}
|
||||
|
||||
fn add_unspendable(&self, unspendable: OutPoint) -> Arc<Self> {
|
||||
let mut unspendable_hash_set = self.unspendable.clone();
|
||||
unspendable_hash_set.insert(unspendable);
|
||||
|
||||
Reference in New Issue
Block a user