Skip to content

Commit aa5768b

Browse files
committed
Slightly expand documentation on KeysInterface
Specifically, this notes when methods can or can not return the same value on each call.
1 parent 5173113 commit aa5768b

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,31 @@ pub trait KeysInterface: Send + Sync {
337337
/// A type which implements ChannelKeys which will be returned by get_channel_keys.
338338
type ChanKeySigner : ChannelKeys;
339339

340-
/// Get node secret key (aka node_id or network_key)
340+
/// Get node secret key (aka node_id or network_key).
341+
///
342+
/// This method must return the same value each time it is called.
341343
fn get_node_secret(&self) -> SecretKey;
342-
/// Get destination redeemScript to encumber static protocol exit points.
344+
/// Get a script pubkey which we send funds to when claiming on-chain contestable outputs.
345+
///
346+
/// This method should return a different value each time it is called, to avoid linking
347+
/// on-chain funds across channels as controlled to the same user.
343348
fn get_destination_script(&self) -> Script;
344-
/// Get shutdown_pubkey to use as PublicKey at channel closure
349+
/// Get a public key which we will send funds to (in the form of a P2WPKH output) when closing
350+
/// a channel.
351+
///
352+
/// This method should return a different value each time it is called, to avoid linking
353+
/// on-chain funds across channels as controlled to the same user.
345354
fn get_shutdown_pubkey(&self) -> PublicKey;
346355
/// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
347356
/// restarted with some stale data!
357+
///
358+
/// This method must return a different value each time it is called.
348359
fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner;
349360
/// Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
350361
/// onion packets and for temporary channel IDs. There is no requirement that these be
351362
/// persisted anywhere, though they must be unique across restarts.
363+
///
364+
/// This method must return a different value each time it is called.
352365
fn get_secure_random_bytes(&self) -> [u8; 32];
353366

354367
/// Reads a `ChanKeySigner` for this `KeysInterface` from the given input stream.

0 commit comments

Comments
 (0)