Skip to content

Commit d6c31c2

Browse files
committed
internal_build_outputs does not need TxCreationKeys
1 parent 534934e commit d6c31c2

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
@@ -1457,7 +1457,7 @@ impl CommitmentTransaction {
14571457
let to_countersignatory_value_sat = Amount::from_sat(to_countersignatory_value_sat);
14581458

14591459
// Sort outputs and populate output indices while keeping track of the auxiliary data
1460-
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();
1460+
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();
14611461

14621462
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(commitment_number, channel_parameters);
14631463
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
@@ -1486,11 +1486,11 @@ impl CommitmentTransaction {
14861486
self
14871487
}
14881488

1489-
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, ()> {
1489+
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, ()> {
14901490
let (obscured_commitment_transaction_number, txins) = Self::internal_build_inputs(self.commitment_number, channel_parameters);
14911491

14921492
let mut htlcs_with_aux = self.htlcs.iter().map(|h| (h.clone(), ())).collect();
1493-
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)?;
1493+
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)?;
14941494

14951495
let transaction = Self::make_transaction(obscured_commitment_transaction_number, txins, outputs);
14961496
let txid = transaction.compute_txid();
@@ -1514,7 +1514,7 @@ impl CommitmentTransaction {
15141514
// - initial sorting of outputs / HTLCs in the constructor, in which case T is auxiliary data the
15151515
// caller needs to have sorted together with the HTLCs so it can keep track of the output index
15161516
// - building of a bitcoin transaction during a verify() call, in which case T is just ()
1517-
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>), ()> {
1517+
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>), ()> {
15181518
let mut txouts: Vec<(TxOut, Option<&mut HTLCOutputInCommitment>)> = Vec::new();
15191519

15201520
if to_countersignatory_value_sat > Amount::ZERO {
@@ -1530,7 +1530,7 @@ impl CommitmentTransaction {
15301530
if to_broadcaster_value_sat > Amount::ZERO {
15311531
txouts.push((
15321532
TxOut {
1533-
script_pubkey: signer.get_revokeable_spk(is_holder_tx, commitment_number, &keys.per_commitment_point, secp_ctx),
1533+
script_pubkey: signer.get_revokeable_spk(is_holder_tx, commitment_number, per_commitment_point, secp_ctx),
15341534
value: to_broadcaster_value_sat,
15351535
},
15361536
None,
@@ -1564,7 +1564,7 @@ impl CommitmentTransaction {
15641564
let mut htlcs = Vec::with_capacity(htlcs_with_aux.len());
15651565
for (htlc, _) in htlcs_with_aux {
15661566
let txout = TxOut {
1567-
script_pubkey: signer.get_htlc_spk(htlc, is_holder_tx, &keys.per_commitment_point, secp_ctx),
1567+
script_pubkey: signer.get_htlc_spk(htlc, is_holder_tx, per_commitment_point, secp_ctx),
15681568
value: htlc.to_bitcoin_amount(),
15691569
};
15701570
txouts.push((txout, Some(htlc)));
@@ -1680,7 +1680,7 @@ impl CommitmentTransaction {
16801680
if keys != self.keys {
16811681
return Err(());
16821682
}
1683-
let tx = self.internal_rebuild_transaction(&keys, channel_parameters, &broadcaster_keys.funding_pubkey, &countersignatory_keys.funding_pubkey, signer, secp_ctx, is_holder_tx)?;
1683+
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)?;
16841684
if self.built.transaction != tx.transaction || self.built.txid != tx.txid {
16851685
return Err(());
16861686
}

0 commit comments

Comments
 (0)