Skip to content

Commit 7dbced3

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 36cc581 commit 7dbced3

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
@@ -335,18 +335,31 @@ pub trait KeysInterface: Send + Sync {
335335
/// A type which implements ChannelKeys which will be returned by get_channel_keys.
336336
type ChanKeySigner : ChannelKeys;
337337

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

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

0 commit comments

Comments
 (0)