Skip to content

Commit a8038a8

Browse files
authored
Merge pull request #940 from TheBlueMatt/2021-06-fix-docs
Clean up docs on public chan_utils methods to be more useful
2 parents 1d4f9c8 + 8cdc855 commit a8038a8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,18 @@ pub fn make_funding_redeemscript(broadcaster: &PublicKey, countersignatory: &Pub
525525
}.push_opcode(opcodes::all::OP_PUSHNUM_2).push_opcode(opcodes::all::OP_CHECKMULTISIG).into_script()
526526
}
527527

528-
/// panics if htlc.transaction_output_index.is_none()!
529-
pub fn build_htlc_transaction(prev_hash: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment, broadcaster_delayed_payment_key: &PublicKey, revocation_key: &PublicKey) -> Transaction {
528+
/// Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC
529+
/// parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the
530+
/// transaction which needs signing, and can be used to construct an HTLC transaction which is
531+
/// broadcastable given a counterparty HTLC signature.
532+
///
533+
/// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the
534+
/// commitment transaction).
535+
pub fn build_htlc_transaction(commitment_txid: &Txid, feerate_per_kw: u32, contest_delay: u16, htlc: &HTLCOutputInCommitment, broadcaster_delayed_payment_key: &PublicKey, revocation_key: &PublicKey) -> Transaction {
530536
let mut txins: Vec<TxIn> = Vec::new();
531537
txins.push(TxIn {
532538
previous_output: OutPoint {
533-
txid: prev_hash.clone(),
539+
txid: commitment_txid.clone(),
534540
vout: htlc.transaction_output_index.expect("Can't build an HTLC transaction for a dust output"),
535541
},
536542
script_sig: Script::new(),
@@ -1177,7 +1183,12 @@ impl<'a> TrustedCommitmentTransaction<'a> {
11771183
}
11781184
}
11791185

1180-
/// Get the transaction number obscure factor
1186+
/// Commitment transaction numbers which appear in the transactions themselves are XOR'd with a
1187+
/// shared secret first. This prevents on-chain observers from discovering how many commitment
1188+
/// transactions occurred in a channel before it was closed.
1189+
///
1190+
/// This function gets the shared secret from relevant channel public keys and can be used to
1191+
/// "decrypt" the commitment transaction number given a commitment transaction on-chain.
11811192
pub fn get_commitment_transaction_number_obscure_factor(
11821193
broadcaster_payment_basepoint: &PublicKey,
11831194
countersignatory_payment_basepoint: &PublicKey,

0 commit comments

Comments
 (0)