Skip to content

Commit c84b3c4

Browse files
committed
Update docs on HTLC and DelayedPayment keys for clarity
This also adds required linebreaks to keep the docs to a reasonable width.
1 parent f725d06 commit c84b3c4

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

lightning/src/ln/channel_keys.rs

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,26 @@ macro_rules! key_read_write {
9292

9393

9494

95-
/// Master key used in conjunction with per_commitment_point to generate [`local_delayedpubkey`](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
96-
/// A watcher can be given a [DelayedPaymentBasepoint] to generate per commitment [DelayedPaymentKey] to create justice transactions.
95+
/// Base key used in conjunction with a `per_commitment_point` to generate a [`DelayedPaymentKey`].
96+
///
97+
/// The delayed payment key is used to pay the commitment state broadcaster their
98+
/// non-HTLC-encumbered funds after a delay to give their counterparty a chance to punish if the
99+
/// state broadcasted was previously revoked.
97100
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
98101
pub struct DelayedPaymentBasepoint(pub PublicKey);
99102
basepoint_impl!(DelayedPaymentBasepoint);
100103
key_read_write!(DelayedPaymentBasepoint);
101104

102-
/// [delayedpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
103-
/// To allow a counterparty to contest a channel state published by a node, Lightning protocol sets delays for some of the outputs, before can be spend.
104-
/// For example a commitment transaction has to_local output encumbered by a delay, negotiated at the channel establishment flow.
105-
/// To spend from such output a node has to generate a script using, among others, a local delayed payment key.
105+
106+
/// A derived key built from a [`DelayedPaymentBasepoint`] and `per_commitment_point`.
107+
///
108+
/// The delayed payment key is used to pay the commitment state broadcaster their
109+
/// non-HTLC-encumbered funds after a delay. This delay gives their counterparty a chance to
110+
/// punish and claim all the channel funds if the state broadcasted was previously revoked.
111+
///
112+
/// [See the BOLT specs]
113+
/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
114+
/// for more information on key derivation details.
106115
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
107116
pub struct DelayedPaymentKey(pub PublicKey);
108117

@@ -111,15 +120,25 @@ impl DelayedPaymentKey {
111120
}
112121
key_read_write!(DelayedPaymentKey);
113122

114-
/// Master key used in conjunction with per_commitment_point to generate [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
123+
/// Base key used in conjunction with a `per_commitment_point` to generate an [`HtlcKey`].
124+
///
125+
/// HTLC keys are used to ensure only the recipient of an HTLC can claim it on-chain with the HTLC
126+
/// preimage and that only the sender of an HTLC can claim it on-chain after it has timed out.
127+
/// Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script.
115128
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
116129
pub struct HtlcBasepoint(pub PublicKey);
117130
basepoint_impl!(HtlcBasepoint);
118131
key_read_write!(HtlcBasepoint);
119132

120-
121-
/// [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) is a child key of an htlc basepoint,
122-
/// that enables secure routing of payments in onion scheme without a risk of them getting stuck or diverted. It is used to claim the funds in successful or timed out htlc outputs.
133+
/// A derived key built from a [`HtlcBasepoint`] and `per_commitment_point`.
134+
///
135+
/// HTLC keys are used to ensure only the recipient of an HTLC can claim it on-chain with the HTLC
136+
/// preimage and that only the sender of an HTLC can claim it on-chain after it has timed out.
137+
/// Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script.
138+
///
139+
/// [See the BOLT specs]
140+
/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
141+
/// for more information on key derivation details.
123142
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
124143
pub struct HtlcKey(pub PublicKey);
125144

0 commit comments

Comments
 (0)