Skip to content

Commit 8d6cd12

Browse files
author
Conor Okus
committed
Update comment
1 parent ad082e1 commit 8d6cd12

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

docs/key_management.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ LDK makes it simple to combine an on-chain and off-chain wallet in the same app.
5555
Using a [BDK](https://bitcoindevkit.org/)-based wallet the steps would be as follows:
5656
1) Generate a mnemonic/entropy
5757
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.
5959

60-
<CodeSwitcher :languages="{rust:'Rust', kotlin:'Kotlin'}">
60+
<CodeSwitcher :languages="{rust:'Rust', java:'Java', kotlin:'Kotlin'}">
6161
<template v-slot:rust>
6262

6363
```rust
@@ -79,6 +79,37 @@ let keys_manager = KeysManager::new(&ldk_seed, cur.as_secs(), cur.subsec_nanos()
7979
```
8080

8181
</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+
82113
<template v-slot:kotlin>
83114

84115
```kotlin

0 commit comments

Comments
 (0)