Repository: bitcoindevkit/bdk-ffi (language: python)

Issue:
Add change descriptor to Wallet



Discussion / hints:

Fix patch:
diff --git a/bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt b/bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt
index ef6d335a..941b6eab 100644
--- a/bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt
+++ b/bindings/bdk-kotlin/demo/src/main/kotlin/Main.kt
@@ -62,7 +62,7 @@ fun main(args: Array<String>) {
             BlockchainConfig.Electrum(
                     ElectrumConfig("ssl://electrum.blockstream.info:60002", null, 5u, null, 10u)
             )
-    val wallet = OnlineWallet(descriptor, network, db, client)
+    val wallet = OnlineWallet(descriptor, null, network, db, client)
     wallet.sync(LogProgress(), null)
     println("Initial wallet balance: ${wallet.getBalance()}")
     println("Please send $amount satoshis to address: ${wallet.getNewAddress()}")
diff --git a/src/bdk.udl b/src/bdk.udl
index e830577a..23148c16 100644
--- a/src/bdk.udl
+++ b/src/bdk.udl
@@ -126,7 +126,7 @@ callback interface BdkProgress {
 
 interface OnlineWallet {
   [Throws=BdkError]
-  constructor(string descriptor, Network network, DatabaseConfig database_config, BlockchainConfig blockchain_config);
+  constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config, BlockchainConfig blockchain_config);
 
   // OfflineWalletOperations
   string get_new_address();
diff --git a/src/lib.rs b/src/lib.rs
index 8364ecff..e19ab219 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -193,6 +193,7 @@ impl PartiallySignedBitcoinTransaction {
 impl OnlineWallet {
     fn new(
         descriptor: String,
+        change_descriptor: Option<String>,
         network: Network,
         database_config: DatabaseConfig,
         blockchain_config: BlockchainConfig,
@@ -225,7 +226,7 @@ impl OnlineWallet {
         let blockchain = AnyBlockchain::from_config(&any_blockchain_config)?;
         let wallet = Mutex::new(Wallet::new(
             &descriptor,
-            None,
+            change_descriptor.to_owned().as_ref(),
             network,
             database,
             blockchain,


Test patch:
diff --git a/bindings/bdk-kotlin/jvm/src/testFixtures/kotlin/org/bitcoindevkit/bdk/LibTest.kt b/bindings/bdk-kotlin/jvm/src/testFixtures/kotlin/org/bitcoindevkit/bdk/LibTest.kt
index 8b946b42..0811c8a2 100644
--- a/bindings/bdk-kotlin/jvm/src/testFixtures/kotlin/org/bitcoindevkit/bdk/LibTest.kt
+++ b/bindings/bdk-kotlin/jvm/src/testFixtures/kotlin/org/bitcoindevkit/bdk/LibTest.kt
@@ -61,7 +61,7 @@ abstract class LibTest {
                 100u
             )
         )
-        val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
+        val wallet = OnlineWallet(desc, null, Network.TESTNET, db, client)
         assertNotNull(wallet)
         val network = wallet.getNetwork()
         assertEquals(network, Network.TESTNET)
@@ -87,7 +87,7 @@ abstract class LibTest {
                 100u
             )
         )
-        val wallet = OnlineWallet(desc, Network.TESTNET, db, client)
+        val wallet = OnlineWallet(desc, null, Network.TESTNET, db, client)
         wallet.sync(LogProgress(), null)
         val balance = wallet.getBalance()
         assertTrue(balance > 0u)