diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 1fe1ed98..b90f059d 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -100,7 +100,7 @@ interface Wallet { Balance get_balance(); - boolean is_mine(Script script); + boolean is_mine([ByRef] Script script); [Throws=BdkError] void apply_update(Update update); @@ -118,7 +118,7 @@ interface Update {}; interface TxBuilder { constructor(); - TxBuilder add_recipient(Script script, u64 amount); + TxBuilder add_recipient([ByRef] Script script, u64 amount); TxBuilder set_recipients(sequence recipients); @@ -142,7 +142,7 @@ interface TxBuilder { TxBuilder drain_wallet(); - TxBuilder drain_to(Script script); + TxBuilder drain_to([ByRef] Script script); TxBuilder enable_rbf(); @@ -187,16 +187,16 @@ interface DerivationPath { }; interface DescriptorSecretKey { - constructor(Network network, Mnemonic mnemonic, string? password); + constructor(Network network, [ByRef] Mnemonic mnemonic, string? password); [Name=from_string, Throws=BdkError] constructor(string secret_key); [Throws=BdkError] - DescriptorSecretKey derive(DerivationPath path); + DescriptorSecretKey derive([ByRef] DerivationPath path); [Throws=BdkError] - DescriptorSecretKey extend(DerivationPath path); + DescriptorSecretKey extend([ByRef] DerivationPath path); DescriptorPublicKey as_public(); @@ -210,10 +210,10 @@ interface DescriptorPublicKey { constructor(string public_key); [Throws=BdkError] - DescriptorPublicKey derive(DerivationPath path); + DescriptorPublicKey derive([ByRef] DerivationPath path); [Throws=BdkError] - DescriptorPublicKey extend(DerivationPath path); + DescriptorPublicKey extend([ByRef] DerivationPath path); string as_string(); }; @@ -223,28 +223,28 @@ interface Descriptor { constructor(string descriptor, Network network); [Name=new_bip44] - constructor(DescriptorSecretKey secret_key, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorSecretKey secret_key, KeychainKind keychain, Network network); [Name=new_bip44_public] - constructor(DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); [Name=new_bip49] - constructor(DescriptorSecretKey secret_key, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorSecretKey secret_key, KeychainKind keychain, Network network); [Name=new_bip49_public] - constructor(DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); [Name=new_bip84] - constructor(DescriptorSecretKey secret_key, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorSecretKey secret_key, KeychainKind keychain, Network network); [Name=new_bip84_public] - constructor(DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); [Name=new_bip86] - constructor(DescriptorSecretKey secret_key, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorSecretKey secret_key, KeychainKind keychain, Network network); [Name=new_bip86_public] - constructor(DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); + constructor([ByRef] DescriptorPublicKey public_key, string fingerprint, KeychainKind keychain, Network network); string as_string(); @@ -262,7 +262,7 @@ interface EsploraClient { Update scan(Wallet wallet, u64 stop_gap, u64 parallel_requests); [Throws=BdkError] - void broadcast(Transaction transaction); + void broadcast([ByRef] Transaction transaction); }; // ------------------------------------------------------------------------ diff --git a/bdk-ffi/src/bitcoin.rs b/bdk-ffi/src/bitcoin.rs index c5e521a0..effa01a9 100644 --- a/bdk-ffi/src/bitcoin.rs +++ b/bdk-ffi/src/bitcoin.rs @@ -14,7 +14,6 @@ use std::io::Cursor; use std::str::FromStr; use std::sync::{Arc, Mutex}; -/// A Bitcoin script. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Script(pub(crate) BdkScriptBuf); @@ -36,13 +35,9 @@ impl From for Script { } pub enum Network { - /// Mainnet Bitcoin. Bitcoin, - /// Bitcoin's testnet network. Testnet, - /// Bitcoin's signet network. Signet, - /// Bitcoin's regtest network. Regtest, } @@ -69,7 +64,6 @@ impl From for Network { } } -/// A Bitcoin address. #[derive(Debug, PartialEq, Eq)] pub struct Address { inner: BdkAddress, @@ -141,7 +135,6 @@ impl From for Address { } } -/// A Bitcoin transaction. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Transaction { inner: BdkTransaction, @@ -242,7 +235,6 @@ impl PartiallySignedTransaction { // txid.to_hex() // } - /// Return the transaction. pub(crate) fn extract_tx(&self) -> Arc { let tx = self.inner.lock().unwrap().clone().extract_tx(); Arc::new(tx.into()) @@ -293,12 +285,9 @@ impl From for PartiallySignedTransaction { } } -/// A reference to a transaction output. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct OutPoint { - /// The referenced transaction's txid. pub txid: String, - /// The index of the referenced output in its transaction's vout. pub vout: u32, } @@ -311,12 +300,9 @@ impl From<&OutPoint> for BdkOutPoint { } } -/// A transaction output, which defines new coins to be created from old ones. #[derive(Debug, Clone)] pub struct TxOut { - /// The value of the output, in satoshis. pub value: u64, - /// The address of the output. pub script_pubkey: Arc