Skip to content

Commit 7fcb1d7

Browse files
refactor: migrate Network type to proc macros
1 parent 8496e53 commit 7fcb1d7

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

bdk-ffi/build.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

bdk-ffi/src/bdk.udl

Lines changed: 0 additions & 10 deletions
This file was deleted.

bdk-ffi/src/bitcoin.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use bdk_wallet::bitcoin::secp256k1::Secp256k1;
1919
use bdk_wallet::bitcoin::Amount as BdkAmount;
2020
use bdk_wallet::bitcoin::BlockHash as BitcoinBlockHash;
2121
use bdk_wallet::bitcoin::FeeRate as BdkFeeRate;
22-
use bdk_wallet::bitcoin::Network;
2322
use bdk_wallet::bitcoin::OutPoint as BdkOutPoint;
2423
use bdk_wallet::bitcoin::Psbt as BdkPsbt;
2524
use bdk_wallet::bitcoin::ScriptBuf as BdkScriptBuf;
@@ -39,6 +38,7 @@ use std::str::FromStr;
3938
use std::sync::{Arc, Mutex};
4039

4140
pub(crate) type DescriptorType = bdk_wallet::miniscript::descriptor::DescriptorType;
41+
pub type Network = bdk_wallet::bitcoin::Network;
4242

4343
/// A reference to an unspent output by TXID and output index.
4444
#[derive(Debug, Clone, Eq, PartialEq, std::hash::Hash, uniffi:: Record)]
@@ -76,6 +76,24 @@ impl From<OutPoint> for BdkOutPoint {
7676
}
7777
}
7878

79+
/// The cryptocurrency network to act on.
80+
///
81+
/// This is an exhaustive enum, meaning that we cannot add any future networks without defining a
82+
/// new, incompatible version of this type. If you are using this type directly and wish to support
83+
/// the new network, this will be a breaking change to your APIs and likely require changes in your
84+
/// code.
85+
///
86+
/// If you are concerned about forward compatibility, consider using T: Into<Params> instead of this
87+
/// type as a parameter to functions in your public API, or directly using the Params type.
88+
#[uniffi::remote(Enum)]
89+
pub enum Network {
90+
Bitcoin,
91+
Testnet,
92+
Testnet4,
93+
Signet,
94+
Regtest,
95+
}
96+
7997
/// An [`OutPoint`] used as a key in a hash map.
8098
///
8199
/// Due to limitations in generating the foreign language bindings, we cannot use [`OutPoint`] as a

bdk-ffi/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ mod wallet;
1414
use crate::bitcoin::FeeRate;
1515
use crate::bitcoin::OutPoint;
1616

17-
use bdk_wallet::bitcoin::Network;
18-
19-
uniffi::include_scaffolding!("bdk");
17+
uniffi::setup_scaffolding!("bdk");

0 commit comments

Comments
 (0)