Skip to content
Open
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
87 changes: 64 additions & 23 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
Expand Up @@ -20,14 +20,14 @@ bdk_esplora = { version = "0.22.1", default-features = false, features = ["std",
bdk_electrum = { version = "0.23.2", default-features = false, features = ["use-rustls-ring"] }
bdk_kyoto = { version = "0.15.0" }

uniffi = { version = "=0.29.4", features = ["cli"]}
uniffi = { version = "=0.30.0", features = ["cli"]}
thiserror = "2.0.17"

[build-dependencies]
uniffi = { version = "=0.29.4", features = ["build"] }
uniffi = { version = "=0.30.0", features = ["build"] }

[dev-dependencies]
uniffi = { version = "=0.29.4", features = ["bindgen-tests"] }
uniffi = { version = "=0.30.0", features = ["bindgen-tests"] }
assert_matches = "1.5.0"

[profile.release-smaller]
Expand Down
32 changes: 17 additions & 15 deletions bdk-ffi/src/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,23 @@ pub enum Network {
///
/// Due to limitations in generating the foreign language bindings, we cannot use [`OutPoint`] as a
/// key for hash maps.
#[derive(Debug, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Debug, Eq, Hash)]
pub struct HashableOutPoint(pub(crate) OutPoint);
#[derive(Debug, Clone, PartialEq, Eq, std::hash::Hash, uniffi::Record)]
pub struct HashableOutPoint {
/// The wrapped [`OutPoint`] that acts as a hashmap key.
pub outpoint: OutPoint,
}

#[uniffi::export]
impl HashableOutPoint {
/// Create a key for a key-value store from an [`OutPoint`]
#[uniffi::constructor]
pub fn new(outpoint: OutPoint) -> Self {
Self(outpoint)
Self { outpoint }
}

/// Get the internal [`OutPoint`]
pub fn outpoint(&self) -> OutPoint {
self.0.clone()
self.outpoint.clone()
}
}

Expand Down Expand Up @@ -710,37 +712,37 @@ impl From<TxOut> for BdkTxOut {
}

/// A bitcoin Block hash
#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash, Ord)]
pub struct BlockHash(pub(crate) BitcoinBlockHash);

impl_hash_like!(BlockHash, BitcoinBlockHash);

/// A bitcoin transaction identifier
#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash, Ord)]
pub struct Txid(pub(crate) BitcoinTxid);

impl_hash_like!(Txid, BitcoinTxid);

/// A bitcoin transaction identifier, including witness data.
/// For transactions with no SegWit inputs, the `txid` will be equivalent to `wtxid`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash, Ord)]
pub struct Wtxid(pub(crate) BitcoinWtxid);

impl_hash_like!(Wtxid, BitcoinWtxid);

/// A collision-proof unique identifier for a descriptor.
#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash, Ord)]
pub struct DescriptorId(pub(crate) BitcoinSha256Hash);

impl_hash_like!(DescriptorId, BitcoinSha256Hash);

/// The merkle root of the merkle tree corresponding to a block's transactions.
#[derive(Debug, Clone, Copy, PartialEq, Eq, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, std::hash::Hash, uniffi::Object)]
#[uniffi::export(Display, Eq, Hash, Ord)]
pub struct TxMerkleNode(pub(crate) BitcoinDoubleSha256Hash);

impl_hash_like!(TxMerkleNode, BitcoinDoubleSha256Hash);
Expand Down
8 changes: 4 additions & 4 deletions bdk-ffi/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ pub struct Anchor {
#[derive(Debug, Clone, uniffi::Record)]
pub struct TxGraphChangeSet {
pub txs: Vec<Arc<Transaction>>,
pub txouts: HashMap<Arc<HashableOutPoint>, TxOut>,
pub txouts: HashMap<HashableOutPoint, TxOut>,
pub anchors: Vec<Anchor>,
pub last_seen: HashMap<Arc<Txid>, u64>,
pub first_seen: HashMap<Arc<Txid>, u64>,
Expand All @@ -897,7 +897,7 @@ impl From<bdk_wallet::chain::tx_graph::ChangeSet<BdkConfirmationBlockTime>> for
.collect::<Vec<Arc<Transaction>>>();
let mut txouts = HashMap::new();
for (outpoint, txout) in core::mem::take(&mut value.txouts) {
txouts.insert(Arc::new(HashableOutPoint(outpoint.into())), txout.into());
txouts.insert(HashableOutPoint::new(outpoint.into()), txout.into());
}
let mut anchors = Vec::new();
for anchor in core::mem::take(&mut value.anchors) {
Expand Down Expand Up @@ -949,8 +949,8 @@ impl From<TxGraphChangeSet> for bdk_wallet::chain::tx_graph::ChangeSet<BdkConfir
txs.insert(tx);
}
let mut txouts = BTreeMap::new();
for txout in core::mem::take(&mut value.txouts) {
txouts.insert(txout.0.outpoint().into(), txout.1.into());
for (outpoint, txout) in core::mem::take(&mut value.txouts) {
txouts.insert(outpoint.outpoint().into(), txout.into());
}
let mut anchors = BTreeSet::new();
for anchor in core::mem::take(&mut value.anchors) {
Expand Down
Loading