@@ -55,9 +55,9 @@ LDK makes it simple to combine an on-chain and off-chain wallet in the same app.
55
55
Using a [ BDK] ( https://bitcoindevkit.org/ ) -based wallet the steps would be as follows:
56
56
1 ) Generate a mnemonic/entropy
57
57
2 ) Build an HD wallet from that. That's now your on-chain wallet, and you can derive any BIP-compliant on-chain wallet/path for it from there.
58
- 3 ) Derive the private key at ` m/535'/535'/535' ` (or some other custom path). That's 32 bytes and is your starting entropy for your LDK wallet.
58
+ 3 ) Derive the private key at ` m/535h ` (or some other custom path). That's 32 bytes and is your starting entropy for your LDK wallet.
59
59
60
- <CodeSwitcher :languages =" {rust:'Rust', kotlin:'Kotlin'} " >
60
+ <CodeSwitcher :languages =" {rust:'Rust', java:'Java', kotlin:'Kotlin'} " >
61
61
<template v-slot:rust >
62
62
63
63
``` rust
@@ -79,6 +79,37 @@ let keys_manager = KeysManager::new(&ldk_seed, cur.as_secs(), cur.subsec_nanos()
79
79
```
80
80
81
81
</template >
82
+
83
+ <template v-slot:java >
84
+
85
+ ``` java
86
+ // Use BDK to create and build the HD wallet
87
+ Mnemonic mnemonic = Mnemonic . Companion . fromString(" sock lyrics " +
88
+ " village put galaxy " +
89
+ " famous pass act ship second diagram pull" );
90
+
91
+ // Other supported networks include mainnet (Bitcoin), Regtest, Signet
92
+ DescriptorSecretKey bip32RootKey = new DescriptorSecretKey (Network . TESTNET , mnemonic, null );
93
+
94
+ DerivationPath ldkDerivationPath = new DerivationPath (" m/535h" );
95
+ DescriptorSecretKey ldkChild = bip32RootKey. derive(ldkDerivationPath);
96
+
97
+ ByteArrayOutputStream bos = new ByteArrayOutputStream ();
98
+ ObjectOutputStream oos = new ObjectOutputStream (bos);
99
+ oos. writeObject(ldkChild. secretBytes());
100
+ byte [] entropy = bos. toByteArray();
101
+
102
+ // Seed the LDK KeysManager with the private key at m/535h
103
+ var startupTime = System . currentTimeMillis();
104
+ KeysManager keysManager = KeysManager . of(
105
+ entropy,
106
+ startupTime / 1000 ,
107
+ (int ) (startupTime * 1000 )
108
+ );
109
+ ```
110
+
111
+ </template >
112
+
82
113
<template v-slot:kotlin >
83
114
84
115
``` kotlin
0 commit comments