Skip to content

Commit a2d8b2b

Browse files
authored
Fixes issue with page rendering locally (#218)
1 parent cbfbd6e commit a2d8b2b

File tree

2 files changed

+2931
-3347
lines changed

2 files changed

+2931
-3347
lines changed

docs/key_management.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ LDK provides a simple default `KeysManager` implementation that takes a 32-byte
44

55
However, LDK also allows to customize the way key material and entropy are sourced through custom implementations of the `NodeSigner`, `SignerProvider`, and `EntropySource` traits located in `chain::keysinterface`. These traits include basic methods to provide public and private key material, as well as pseudorandom numbers.
66

7-
87
A `KeysManager` can be constructed simply with only a 32-byte seed and some random integers which ensure uniqueness across restarts (defined as `starting_time_secs` and `starting_time_nanos`):
98

109
<CodeSwitcher :languages="{rust:'Rust', java:'Java', kotlin:'Kotlin'}">
@@ -47,14 +46,15 @@ val keys_manager = KeysManager.of(
4746
</CodeSwitcher>
4847

4948
# Creating a Unified Wallet
49+
5050
LDK makes it simple to combine an on-chain and off-chain wallet in the same app. This means users don’t need to worry about storing two different recovery phrases. For apps containing a hierarchical deterministic wallet (or "HD Wallet") we recommend using the entropy from a [hardened child key derivation](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc#hardened-child-key-derivation) path for your LDK seed.
5151

5252
Using a [BDK](https://bitcoindevkit.org/)-based wallet the steps would be as follows:
5353

54-
1) Generate a mnemonic/entropy source.
55-
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.
56-
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.
57-
4) Optional: use a custom `SignerProvider` implementation to have the BDK wallet provide the destination and shutdown scripts (see [Spending On-Chain Funds](#spending-on-chain-funds)).
54+
1. Generate a mnemonic/entropy source.
55+
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.
56+
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.
57+
4. Optional: use a custom `SignerProvider` implementation to have the BDK wallet provide the destination and shutdown scripts (see [Spending On-Chain Funds](#spending-on-chain-funds)).
5858

5959
<CodeSwitcher :languages="{rust:'Rust', java:'Java', kotlin:'Kotlin'}">
6060
<template v-slot:rust>
@@ -134,12 +134,12 @@ val keysManager = KeysManager.of(
134134

135135
::: tip Protection for on-chain wallet
136136

137-
An advantage to this approach is that the LDK entropy is contained within your initial mnemonic and a user only has one master private key to backup and secure. Another added benefit is that if your lightning keys were to be leaked we reduce the exposure to those funds and not the rest of the on-chain wallet.
137+
An advantage to this approach is that the LDK entropy is contained within your initial mnemonic and a user only has one master private key to backup and secure. Another added benefit is that if your lightning keys were to be leaked we reduce the exposure to those funds and not the rest of the on-chain wallet.
138138

139139
:::
140140

141-
Spending On-Chain Funds
142-
=======================
141+
# Spending On-Chain Funds
142+
143143
When a channel has been closed and some outputs on chain are spendable only by us, LDK provides a `util::events::Event::SpendableOutputs` event in return from `ChannelMonitor::get_and_clear_pending_events()`. It contains a list of `chain::keysinterface::SpendableOutputDescriptor` objects which describe the output and provide all necessary information to spend it.
144144

145145
If you're using `KeysManager` directly, a utility method is provided which can generate a signed transaction given a list of `
@@ -150,8 +150,9 @@ If you are not using `KeysManager` for keys generation, you must re-derive the p
150150
In order to make the outputs from channel closing spendable by a third-party wallet, a middleground between using the default `KeysManager` and an entirely custom implementation of `SignerProvider`/`NodeSigner`/`EntropySource` could be to implement a wrapper around `KeysManager`. Such a wrapper would need to override the respective methods returning the destination and shutdown scripts while simply dropping any instances of `SpendableOutputDescriptor::StaticOutput`, as these then could be spent by the third-party wallet from which the scripts had been derived.
151151

152152
For example, a wrapper based on BDK's [`Wallet`](https://docs.rs/bdk/*/bdk/wallet/struct.Wallet.html) could look like this:
153+
153154
<CodeSwitcher :languages="{rust:'Rust'}">
154-
<template v-slot:rust>
155+
<template v-slot:rust>
155156

156157
```rust
157158
pub struct BDKKeysManager<D>

0 commit comments

Comments
 (0)