Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions bdk-ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bdk-ffi"
version = "2.4.0-alpha.0"
version = "3.0.0-rc.1"
homepage = "https://bitcoindevkit.org"
repository = "https://github.com/bitcoindevkit/bdk"
edition = "2018"
Expand All @@ -15,10 +15,10 @@ name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"

[dependencies]
bdk_wallet = { version = "2.3.0", features = ["all-keys", "keys-bip39", "rusqlite"] }
bdk_wallet = { version = "=3.0.0-rc.1", features = ["all-keys", "keys-bip39", "rusqlite"] }
bdk_esplora = { version = "0.22.1", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
bdk_electrum = { version = "0.23.2", default-features = false, features = ["use-rustls-ring"] }
bdk_kyoto = { version = "0.15.4" }
bdk_kyoto = { git = "https://github.com/reez/bdk-kyoto", branch = "rc1" }

uniffi = { version = "=0.30.0", features = ["cli"]}
thiserror = "2.0.17"
Expand Down
31 changes: 18 additions & 13 deletions bdk-ffi/src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl Descriptor {
#[uniffi::constructor]
pub fn new(descriptor: String, network: Network) -> Result<Self, DescriptorError> {
let secp = Secp256k1::new();
let (extended_descriptor, key_map) = descriptor.into_wallet_descriptor(&secp, network)?;
let (extended_descriptor, key_map) =
descriptor.into_wallet_descriptor(&secp, network.into())?;
Ok(Self {
extended_descriptor,
key_map,
Expand All @@ -60,8 +61,9 @@ impl Descriptor {
}
BdkDescriptorSecretKey::XPrv(descriptor_x_key) => {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip44(derivable_key, keychain_kind).build(network).unwrap();
let (extended_descriptor, key_map, _) = Bip44(derivable_key, keychain_kind)
.build(network.into())
.unwrap();
Self {
extended_descriptor,
key_map,
Expand Down Expand Up @@ -96,7 +98,7 @@ impl Descriptor {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip44Public(derivable_key, fingerprint, keychain_kind)
.build(network)
.build(network.into())
.map_err(DescriptorError::from)?;

Ok(Self {
Expand Down Expand Up @@ -125,8 +127,9 @@ impl Descriptor {
}
BdkDescriptorSecretKey::XPrv(descriptor_x_key) => {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip49(derivable_key, keychain_kind).build(network).unwrap();
let (extended_descriptor, key_map, _) = Bip49(derivable_key, keychain_kind)
.build(network.into())
.unwrap();
Self {
extended_descriptor,
key_map,
Expand Down Expand Up @@ -161,7 +164,7 @@ impl Descriptor {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip49Public(derivable_key, fingerprint, keychain_kind)
.build(network)
.build(network.into())
.map_err(DescriptorError::from)?;

Ok(Self {
Expand Down Expand Up @@ -190,8 +193,9 @@ impl Descriptor {
}
BdkDescriptorSecretKey::XPrv(descriptor_x_key) => {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip84(derivable_key, keychain_kind).build(network).unwrap();
let (extended_descriptor, key_map, _) = Bip84(derivable_key, keychain_kind)
.build(network.into())
.unwrap();
Self {
extended_descriptor,
key_map,
Expand Down Expand Up @@ -226,7 +230,7 @@ impl Descriptor {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip84Public(derivable_key, fingerprint, keychain_kind)
.build(network)
.build(network.into())
.map_err(DescriptorError::from)?;

Ok(Self {
Expand Down Expand Up @@ -255,8 +259,9 @@ impl Descriptor {
}
BdkDescriptorSecretKey::XPrv(descriptor_x_key) => {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip86(derivable_key, keychain_kind).build(network).unwrap();
let (extended_descriptor, key_map, _) = Bip86(derivable_key, keychain_kind)
.build(network.into())
.unwrap();
Self {
extended_descriptor,
key_map,
Expand Down Expand Up @@ -291,7 +296,7 @@ impl Descriptor {
let derivable_key = descriptor_x_key.xkey;
let (extended_descriptor, key_map, _) =
Bip86Public(derivable_key, fingerprint, keychain_kind)
.build(network)
.build(network.into())
.map_err(DescriptorError::from)?;

Ok(Self {
Expand Down
2 changes: 1 addition & 1 deletion bdk-ffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ impl From<BdkSignerError> for SignerError {
BdkSignerError::MissingKey => SignerError::MissingKey,
BdkSignerError::InvalidKey => SignerError::InvalidKey,
BdkSignerError::UserCanceled => SignerError::UserCanceled,
BdkSignerError::InputIndexOutOfRange => SignerError::InputIndexOutOfRange,
BdkSignerError::InputIndexOutOfRange(_) => SignerError::InputIndexOutOfRange,
BdkSignerError::MissingNonWitnessUtxo => SignerError::MissingNonWitnessUtxo,
BdkSignerError::InvalidNonWitnessUtxo => SignerError::InvalidNonWitnessUtxo,
BdkSignerError::MissingWitnessUtxo => SignerError::MissingWitnessUtxo,
Expand Down
2 changes: 1 addition & 1 deletion bdk-ffi/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl DescriptorSecretKey {
let xkey: ExtendedKey = (mnemonic, password).into_extended_key().unwrap();
let descriptor_secret_key = BdkDescriptorSecretKey::XPrv(DescriptorXKey {
origin: None,
xkey: xkey.into_xprv(network).unwrap(),
xkey: xkey.into_xprv(network.into()).unwrap(),
derivation_path: BdkDerivationPath::master(),
wildcard: Wildcard::Unhardened,
});
Expand Down
24 changes: 10 additions & 14 deletions bdk-ffi/src/kyoto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use bdk_kyoto::bip157::ServiceFlags;
use bdk_kyoto::builder::Builder as BDKCbfBuilder;
use bdk_kyoto::builder::BuilderExt;
use bdk_kyoto::HeaderCheckpoint;
use bdk_kyoto::LightClient as BDKLightClient;
use bdk_kyoto::Receiver;
use bdk_kyoto::RejectReason;
use bdk_kyoto::Requester;
Expand All @@ -16,7 +15,7 @@ use bdk_kyoto::UnboundedReceiver;
use bdk_kyoto::UpdateSubscriber;
use bdk_kyoto::Warning as Warn;

use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -238,27 +237,24 @@ impl CbfBuilder {
if let Some(proxy) = &self.socks5_proxy {
let port = proxy.port;
let addr = proxy.address.inner;
builder = builder.socks5_proxy((addr, port));
builder = builder.socks5_proxy(SocketAddr::new(addr, port));
}

let BDKLightClient {
requester,
info_subscriber,
warning_subscriber,
update_subscriber,
node,
} = builder
let (client, logging, update_subscriber) = builder
.build_with_wallet(&wallet, scan_type)
.expect("networks match by definition");
.expect("networks match by definition")
.subscribe();
let (client, node) = client.managed_start();
let requester = client.requester();

let node = CbfNode {
node: std::sync::Mutex::new(Some(node)),
};

let client = CbfClient {
sender: Arc::new(requester),
info_rx: Mutex::new(info_subscriber),
warning_rx: Mutex::new(warning_subscriber),
info_rx: Mutex::new(logging.info_subscriber),
warning_rx: Mutex::new(logging.warning_subscriber),
update_rx: Mutex::new(update_subscriber),
};

Expand Down Expand Up @@ -308,7 +304,7 @@ impl CbfClient {
pub async fn broadcast(&self, transaction: &Transaction) -> Result<Arc<Wtxid>, CbfError> {
let tx = transaction.into();
self.sender
.broadcast_random(tx)
.broadcast_tx(tx)
.await
.map_err(From::from)
.map(|wtxid| Arc::new(Wtxid(wtxid)))
Expand Down
3 changes: 2 additions & 1 deletion bdk-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ use bdk_wallet::descriptor::policy::{
Condition as BdkCondition, PkOrF as BdkPkOrF, Policy as BdkPolicy,
Satisfaction as BdkSatisfaction, SatisfiableItem as BdkSatisfiableItem,
};
use bdk_wallet::event::WalletEvent as BdkWalletEvent;
#[allow(deprecated)]
use bdk_wallet::signer::{SignOptions as BdkSignOptions, TapLeavesOptions};
use bdk_wallet::AddressInfo as BdkAddressInfo;
use bdk_wallet::Balance as BdkBalance;
use bdk_wallet::LocalOutput as BdkLocalOutput;
use bdk_wallet::Update as BdkUpdate;
use bdk_wallet::WalletEvent as BdkWalletEvent;

use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::convert::TryFrom;
Expand Down Expand Up @@ -1314,6 +1314,7 @@ impl From<ChangeSet> for bdk_wallet::ChangeSet {
local_chain,
tx_graph,
indexer,
locked_outpoints: Default::default(),
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions bdk-ffi/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@ impl Wallet {
})
}

/// Informs the wallet that you no longer intend to broadcast a tx that was built from it.
///
/// This frees up the change address used when creating the tx for use in future transactions.
pub fn cancel_tx(&self, tx: &Transaction) {
self.get_wallet().cancel_tx(&tx.into())
}

/// Returns the utxo owned by this wallet corresponding to `outpoint` if it exists in the
/// wallet's database.
pub fn get_utxo(&self, op: OutPoint) -> Option<LocalOutput> {
Expand Down
Loading