From 4977cb6d68830accf036b192dba3c524253e53f2 Mon Sep 17 00:00:00 2001 From: dhruvbaliyan Date: Tue, 9 Aug 2022 14:27:19 +0530 Subject: [PATCH] Added interface DerivationPath --- src/bdk.udl | 5 +++++ src/lib.rs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/bdk.udl b/src/bdk.udl index 15ef4b0..0583962 100644 --- a/src/bdk.udl +++ b/src/bdk.udl @@ -245,3 +245,8 @@ interface BumpFeeTxBuilder { [Throws=BdkError] PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet); }; + +interface DerivationPath { + [Throws=BdkError] + constructor(string path); +}; \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 06212e0..cc00eec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ use bdk::bitcoin::hashes::hex::ToHex; use bdk::bitcoin::secp256k1::Secp256k1; use bdk::bitcoin::util::psbt::PartiallySignedTransaction; +use bdk::bitcoin::util::bip32::DerivationPath as BdkDerivationPath; use bdk::bitcoin::{Address, Network, OutPoint as BdkOutPoint, Script, Txid}; use bdk::blockchain::any::{AnyBlockchain, AnyBlockchainConfig}; use bdk::blockchain::{ @@ -633,6 +634,20 @@ fn generate_mnemonic(word_count: WordCount) -> Result { Ok(mnemonic.to_string()) } +struct DerivationPath { + derivation_path_mutex: Mutex, +} + +impl DerivationPath { + fn new(path: String) -> Result { + BdkDerivationPath::from_str(&path) + .map(|x| DerivationPath { + derivation_path_mutex: Mutex::new(x), + }) + .map_err(|e| BdkError::Generic(e.to_string())) + } +} + uniffi::deps::static_assertions::assert_impl_all!(Wallet: Sync, Send); // The goal of these tests to to ensure `bdk-ffi` intermediate code correctly calls `bdk` APIs.