Skip to content

Commit 0c16e50

Browse files
committed
internal_build_outputs does not need TxCreationKeys
1 parent f83fb70 commit 0c16e50

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lightning/src/ln/chan_utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ impl CommitmentTransaction {
14511451
let to_countersignatory_value_sat = Amount::from_sat(to_countersignatory_value_sat);
14521452

14531453
// Sort outputs and populate output indices while keeping track of the auxiliary data
1454-
let (outputs, htlcs) = Self::internal_build_outputs(&keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters, &broadcaster_funding_key, &countersignatory_funding_key, signer, secp_ctx, is_holder_tx, commitment_number).unwrap();
1454+
let (outputs, htlcs) = Self::internal_build_outputs(&keys.per_commitment_point, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters, &broadcaster_funding_key, &countersignatory_funding_key, signer, secp_ctx, is_holder_tx, commitment_number).unwrap();
14551455

14561456
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(commitment_number, channel_parameters);
14571457
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
@@ -1480,11 +1480,11 @@ impl CommitmentTransaction {
14801480
self
14811481
}
14821482

1483-
fn internal_rebuild_transaction<Signer: ChannelSigner>(&self, keys: &TxCreationKeys, channel_parameters: &DirectedChannelTransactionParameters, broadcaster_funding_key: &PublicKey, countersignatory_funding_key: &PublicKey, signer: &Signer, secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool) -> Result<BuiltCommitmentTransaction, ()> {
1483+
fn internal_rebuild_transaction<Signer: ChannelSigner>(&self, per_commitment_point: &PublicKey, channel_parameters: &DirectedChannelTransactionParameters, broadcaster_funding_key: &PublicKey, countersignatory_funding_key: &PublicKey, signer: &Signer, secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool) -> Result<BuiltCommitmentTransaction, ()> {
14841484
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(self.commitment_number, channel_parameters);
14851485

14861486
let mut htlcs_with_aux = self.htlcs.iter().map(|h| (h.clone(), ())).collect();
1487-
let (outputs, _) = Self::internal_build_outputs(keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &mut htlcs_with_aux, channel_parameters, broadcaster_funding_key, countersignatory_funding_key, signer, secp_ctx, is_holder_tx, self.commitment_number)?;
1487+
let (outputs, _) = Self::internal_build_outputs(per_commitment_point, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &mut htlcs_with_aux, channel_parameters, broadcaster_funding_key, countersignatory_funding_key, signer, secp_ctx, is_holder_tx, self.commitment_number)?;
14881488

14891489
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
14901490
let txid = transaction.compute_txid();
@@ -1508,7 +1508,7 @@ impl CommitmentTransaction {
15081508
// - initial sorting of outputs / HTLCs in the constructor, in which case T is auxiliary data the
15091509
// caller needs to have sorted together with the HTLCs so it can keep track of the output index
15101510
// - building of a bitcoin transaction during a verify() call, in which case T is just ()
1511-
fn internal_build_outputs<T, Signer: ChannelSigner>(keys: &TxCreationKeys, to_broadcaster_value_sat: Amount, to_countersignatory_value_sat: Amount, htlcs_with_aux: &mut Vec<(HTLCOutputInCommitment, T)>, channel_parameters: &DirectedChannelTransactionParameters, broadcaster_funding_key: &PublicKey, countersignatory_funding_key: &PublicKey, signer: &Signer, secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool, commitment_number: u64) -> Result<(Vec<TxOut>, Vec<HTLCOutputInCommitment>), ()> {
1511+
fn internal_build_outputs<T, Signer: ChannelSigner>(per_commitment_point: &PublicKey, to_broadcaster_value_sat: Amount, to_countersignatory_value_sat: Amount, htlcs_with_aux: &mut Vec<(HTLCOutputInCommitment, T)>, channel_parameters: &DirectedChannelTransactionParameters, broadcaster_funding_key: &PublicKey, countersignatory_funding_key: &PublicKey, signer: &Signer, secp_ctx: &Secp256k1<secp256k1::All>, is_holder_tx: bool, commitment_number: u64) -> Result<(Vec<TxOut>, Vec<HTLCOutputInCommitment>), ()> {
15121512
let mut txouts: Vec<(TxOut, Option<&mut HTLCOutputInCommitment>)> = Vec::new();
15131513

15141514
if to_countersignatory_value_sat > Amount::ZERO {
@@ -1524,7 +1524,7 @@ impl CommitmentTransaction {
15241524
if to_broadcaster_value_sat > Amount::ZERO {
15251525
txouts.push((
15261526
TxOut {
1527-
script_pubkey: signer.get_revokeable_spk(is_holder_tx, commitment_number, &keys.per_commitment_point, secp_ctx),
1527+
script_pubkey: signer.get_revokeable_spk(is_holder_tx, commitment_number, per_commitment_point, secp_ctx),
15281528
value: to_broadcaster_value_sat,
15291529
},
15301530
None,
@@ -1558,7 +1558,7 @@ impl CommitmentTransaction {
15581558
let mut htlcs = Vec::with_capacity(htlcs_with_aux.len());
15591559
for (htlc, _) in htlcs_with_aux {
15601560
let txout = TxOut {
1561-
script_pubkey: signer.get_htlc_spk(htlc, is_holder_tx, &keys.per_commitment_point, secp_ctx),
1561+
script_pubkey: signer.get_htlc_spk(htlc, is_holder_tx, per_commitment_point, secp_ctx),
15621562
value: htlc.to_bitcoin_amount(),
15631563
};
15641564
txouts.push((txout, Some(htlc)));
@@ -1674,7 +1674,7 @@ impl CommitmentTransaction {
16741674
if keys != self.keys {
16751675
return Err(());
16761676
}
1677-
let tx = self.internal_rebuild_transaction(&keys, channel_parameters, &broadcaster_keys.funding_pubkey, &countersignatory_keys.funding_pubkey, signer, secp_ctx, is_holder_tx)?;
1677+
let tx = self.internal_rebuild_transaction(&keys.per_commitment_point, channel_parameters, &broadcaster_keys.funding_pubkey, &countersignatory_keys.funding_pubkey, signer, secp_ctx, is_holder_tx)?;
16781678
if self.built.transaction != tx.transaction || self.built.txid != tx.txid {
16791679
return Err(());
16801680
}

0 commit comments

Comments
 (0)