@@ -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.
11811192pub fn get_commitment_transaction_number_obscure_factor (
11821193 broadcaster_payment_basepoint : & PublicKey ,
11831194 countersignatory_payment_basepoint : & PublicKey ,
0 commit comments