diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index a94b250e..721f53ae 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -1,3 +1,10 @@ namespace bdk { string hello_world(); }; + +enum Network { + "Bitcoin", + "Testnet", + "Signet", + "Regtest", +}; diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 8be20ac2..0a8ff364 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -45,13 +45,49 @@ mod wallet; // use std::io::Cursor; // use std::str::FromStr; // use std::sync::Arc; -// + +use bdk::bitcoin::Network as BdkNetwork; + uniffi::include_scaffolding!("bdk"); pub fn hello_world() -> String { String::from("Hello World") } +pub enum Network { + /// Mainnet Bitcoin. + Bitcoin, + /// Bitcoin's testnet network. + Testnet, + /// Bitcoin's signet network. + Signet, + /// Bitcoin's regtest network. + Regtest, +} + +impl From for BdkNetwork { + fn from(network: Network) -> Self { + match network { + Network::Bitcoin => BdkNetwork::Bitcoin, + Network::Testnet => BdkNetwork::Testnet, + Network::Signet => BdkNetwork::Signet, + Network::Regtest => BdkNetwork::Regtest, + } + } +} + +impl From for Network { + fn from(network: BdkNetwork) -> Self { + match network { + BdkNetwork::Bitcoin => Network::Bitcoin, + BdkNetwork::Testnet => Network::Testnet, + BdkNetwork::Signet => Network::Signet, + BdkNetwork::Regtest => Network::Regtest, + _ => panic!("Network {} not supported", network), + } + } +} + // /// A output script and an amount of satoshis. // pub struct ScriptAmount { // pub script: Arc