Skip to content

Commit 8aec70a

Browse files
committed
more cleanup
1 parent 3c49cab commit 8aec70a

File tree

3 files changed

+83
-94
lines changed

3 files changed

+83
-94
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ pub(crate) enum ChannelMonitorUpdateStep {
502502
impl Writeable for ChannelMonitorUpdateStep {
503503
fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
504504
match self {
505-
&ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_info: ref commitment_tx, ref htlc_outputs } => {
505+
&ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { ref commitment_info, ref htlc_outputs } => {
506506
0u8.write(w)?;
507-
commitment_tx.write(w)?;
507+
commitment_info.write(w)?;
508508
(htlc_outputs.len() as u64).write(w)?;
509509
for &(ref output, ref signature, ref source) in htlc_outputs.iter() {
510510
output.write(w)?;
@@ -954,19 +954,26 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
954954

955955
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), channel_static_info.clone());
956956

957-
let current_holder_commitment_number = initial_holder_commitment_info.info.commitment_number;
958957
let secp_ctx = Secp256k1::new();
959958

960959
let txid = initial_holder_commitment_info.txid(channel_static_info, &secp_ctx);
961-
let holder_commitment_tx = HolderSignedTx {
962-
txid,
963-
revocation_key: initial_holder_commitment_info.info.keys.revocation_key,
964-
a_htlc_key: initial_holder_commitment_info.info.keys.broadcaster_htlc_key,
965-
b_htlc_key: initial_holder_commitment_info.info.keys.countersignatory_htlc_key,
966-
delayed_payment_key: initial_holder_commitment_info.info.keys.broadcaster_delayed_payment_key,
967-
per_commitment_point: initial_holder_commitment_info.info.keys.per_commitment_point,
968-
feerate_per_kw: initial_holder_commitment_info.info.feerate_per_kw,
969-
htlc_outputs: Vec::new(), // There are never any HTLCs in the initial commitment transactions
960+
961+
// block for Rust 1.34 compat
962+
let (holder_commitment_tx, current_holder_commitment_number) = {
963+
let info = &initial_holder_commitment_info.info;
964+
let tx_keys = &info.keys;
965+
let current_holder_commitment_number = info.commitment_number;
966+
let holder_commitment_tx = HolderSignedTx {
967+
txid,
968+
revocation_key: tx_keys.revocation_key,
969+
a_htlc_key: tx_keys.broadcaster_htlc_key,
970+
b_htlc_key: tx_keys.countersignatory_htlc_key,
971+
delayed_payment_key: tx_keys.broadcaster_delayed_payment_key,
972+
per_commitment_point: tx_keys.per_commitment_point,
973+
feerate_per_kw: info.feerate_per_kw,
974+
htlc_outputs: Vec::new(), // There are never any HTLCs in the initial commitment transactions
975+
};
976+
(holder_commitment_tx, current_holder_commitment_number)
970977
};
971978
onchain_tx_handler.provide_latest_holder_tx(initial_holder_commitment_info);
972979

@@ -1018,7 +1025,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
10181025
holder_tx_signed: false,
10191026

10201027
last_block_hash: Default::default(),
1021-
secp_ctx: secp_ctx,
1028+
secp_ctx,
10221029
}
10231030
}
10241031

@@ -1128,17 +1135,23 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
11281135
/// Panics if set_on_holder_tx_csv has never been called.
11291136
fn provide_latest_holder_commitment_tx_info(&mut self, commitment_info: HolderCommitmentTransactionInfo, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>) -> Result<(), MonitorUpdateError> {
11301137
let txid = commitment_info.txid(&self.onchain_tx_handler.channel_static_info, &self.secp_ctx);
1131-
let mut new_holder_commitment_tx = HolderSignedTx {
1132-
txid,
1133-
revocation_key: commitment_info.info.keys.revocation_key,
1134-
a_htlc_key: commitment_info.info.keys.broadcaster_htlc_key,
1135-
b_htlc_key: commitment_info.info.keys.countersignatory_htlc_key,
1136-
delayed_payment_key: commitment_info.info.keys.broadcaster_delayed_payment_key,
1137-
per_commitment_point: commitment_info.info.keys.per_commitment_point,
1138-
feerate_per_kw: commitment_info.info.feerate_per_kw,
1139-
htlc_outputs,
1138+
1139+
// block for Rust 1.34 compat
1140+
let mut new_holder_commitment_tx = {
1141+
let info = &commitment_info.info;
1142+
let tx_keys = &info.keys;
1143+
self.current_holder_commitment_number = info.commitment_number;
1144+
HolderSignedTx {
1145+
txid,
1146+
revocation_key: tx_keys.revocation_key,
1147+
a_htlc_key: tx_keys.broadcaster_htlc_key,
1148+
b_htlc_key: tx_keys.countersignatory_htlc_key,
1149+
delayed_payment_key: tx_keys.broadcaster_delayed_payment_key,
1150+
per_commitment_point: tx_keys.per_commitment_point,
1151+
feerate_per_kw: info.feerate_per_kw,
1152+
htlc_outputs,
1153+
}
11401154
};
1141-
self.current_holder_commitment_number = commitment_info.info.commitment_number;
11421155
self.onchain_tx_handler.provide_latest_holder_tx(commitment_info);
11431156
mem::swap(&mut new_holder_commitment_tx, &mut self.current_holder_commitment_tx);
11441157
self.prev_holder_signed_commitment_tx = Some(new_holder_commitment_tx);
@@ -1177,9 +1190,9 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
11771190
}
11781191
for update in updates.updates.iter() {
11791192
match update {
1180-
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_info: commitment_tx, htlc_outputs } => {
1193+
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_info, htlc_outputs } => {
11811194
if self.lockdown_from_offchain { panic!(); }
1182-
self.provide_latest_holder_commitment_tx_info(commitment_tx.clone(), htlc_outputs.clone())?
1195+
self.provide_latest_holder_commitment_tx_info(commitment_info.clone(), htlc_outputs.clone())?
11831196
},
11841197
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { unsigned_commitment_tx, htlc_outputs, commitment_number, their_revocation_point } =>
11851198
self.provide_latest_counterparty_commitment_tx_info(&unsigned_commitment_tx, htlc_outputs.clone(), *commitment_number, *their_revocation_point, logger),

lightning/src/ln/chan_utils.rs

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -604,16 +604,18 @@ impl ChannelStaticInfo {
604604
}
605605
}
606606

607-
/// This class tracks the information needed to build a holder's commitment transaction and to actually
608-
/// build and sign. It is used for holder transactions that we sign only when needed.
607+
/// This class tracks the information needed to build a holder's commitment transaction.
608+
/// It is used for holder transactions that we sign only when needed.
609+
///
610+
/// TODO(devrandom): take over signing functionality from HolderCommitmentTransaction
609611
#[derive(Clone)]
610612
pub struct HolderCommitmentTransactionInfo {
611613
/// The non-party-specific transaction information
612614
pub info: CommitmentTransactionInfo,
613615
/// Our counterparty's signature for the transaction
614616
pub counterparty_sig: Signature,
615617
/// All non-dust counterparty HTLC signatures, in the order they appear in the transaction
616-
pub htlc_sigs: Vec<Signature>,
618+
pub counterparty_htlc_sigs: Vec<Signature>,
617619
}
618620

619621
impl PartialEq for HolderCommitmentTransactionInfo {
@@ -624,7 +626,7 @@ impl PartialEq for HolderCommitmentTransactionInfo {
624626
}
625627

626628
impl_writeable!(HolderCommitmentTransactionInfo, 0, {
627-
info, counterparty_sig, htlc_sigs
629+
info, counterparty_sig, counterparty_htlc_sigs
628630
});
629631

630632
impl HolderCommitmentTransactionInfo {
@@ -649,7 +651,7 @@ impl HolderCommitmentTransactionInfo {
649651
}
650652
},
651653
counterparty_sig: dummy_sig,
652-
htlc_sigs: Vec::new()
654+
counterparty_htlc_sigs: Vec::new()
653655
}
654656
}
655657
pub(crate) fn txid<T: secp256k1::Signing + secp256k1::Verification>(&self, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<T>) -> Txid {
@@ -659,7 +661,7 @@ impl HolderCommitmentTransactionInfo {
659661

660662
impl HolderCommitmentTransactionInfo {
661663
pub(crate) fn to_holder_commitment_tx<T: secp256k1::Signing + secp256k1::Verification>(&self, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<T>) -> HolderCommitmentTransaction {
662-
let opt_sigs: Vec<Option<Signature>> = self.htlc_sigs.iter().map(|s| Some(s.clone())).collect();
664+
let opt_sigs: Vec<Option<Signature>> = self.counterparty_htlc_sigs.iter().map(|s| Some(s.clone())).collect();
663665
let mut htlcs = self.info.htlcs.clone();
664666
let htlcs_with_sig = htlcs.drain(..).zip(opt_sigs).collect();
665667
self.info.to_holder_commitment_tx(self.counterparty_sig, htlcs_with_sig, channel_static_info, secp_ctx)
@@ -683,7 +685,9 @@ pub struct CommitmentTransactionInfo {
683685
pub to_countersignatory_value_sat: u64,
684686
/// The feerate paid per 1000-weight-unit in this commitment transaction.
685687
pub feerate_per_kw: u32,
686-
/// The HTLCs which were included in this commitment transaction in output order.
688+
/// The non-dust HTLCs (direction, amt, height expiration, hash, transaction output index)
689+
/// which were included in this commitment transaction in output order.
690+
/// The transaction index is always populated.
687691
pub htlcs: Vec<HTLCOutputInCommitment>,
688692
// A cache of pubkeys required to construct the transaction
689693
pub(crate) keys: TxCreationKeys,
@@ -728,21 +732,12 @@ impl_writeable!(CommitmentTransactionInfo, 0, {
728732
impl CommitmentTransactionInfo {
729733
/// Construct an object of the class while assigning transaction output indices to HTLCs.
730734
///
731-
/// Also keeps track of associated HTLC data and returns it along with the mutated HTLCs.
732-
pub fn new_with_auxiliary_htlc_data<T: Copy>(
733-
commitment_number: u64,
734-
to_broadcaster_value_sat: u64,
735-
to_countersignatory_value_sat: u64,
736-
keys: TxCreationKeys,
737-
feerate_per_kw: u32,
738-
htlcs_with_aux: Vec<(HTLCOutputInCommitment, T)>,
739-
broadcaster_pubkeys: &ChannelPublicKeys,
740-
countersignatory_pubkeys: &ChannelPublicKeys,
741-
contest_delay: u16,
742-
secp_ctx: &Secp256k1<secp256k1::All>
743-
) -> (CommitmentTransactionInfo, Vec<(HTLCOutputInCommitment, T)>) {
744-
// Populate output indices while keeping track of the auxiliary data
745-
let mut txouts = Self::do_build_outputs(&keys, to_broadcaster_value_sat, to_countersignatory_value_sat, &htlcs_with_aux, broadcaster_pubkeys, countersignatory_pubkeys, contest_delay, &secp_ctx).unwrap();
735+
/// Also keeps track of auxiliary HTLC data and returns it along with the mutated and sorted HTLCs.
736+
/// This allows the caller to match the HTLC output index with the auxiliary data.
737+
/// This auxiliary data is not stored in this object.
738+
pub fn new_with_auxiliary_htlc_data<T: Copy>(commitment_number: u64, to_broadcaster_value_sat: u64, to_countersignatory_value_sat: u64, keys: TxCreationKeys, feerate_per_kw: u32, htlcs_with_aux: Vec<(HTLCOutputInCommitment, T)>, holder: bool, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<secp256k1::All>) -> (CommitmentTransactionInfo, Vec<(HTLCOutputInCommitment, T)>) {
739+
// Sort outputs and populate output indices while keeping track of the auxiliary data
740+
let mut txouts = Self::do_build_outputs(&keys, to_broadcaster_value_sat, to_countersignatory_value_sat, &htlcs_with_aux, holder, channel_static_info, &secp_ctx).unwrap();
746741
let mut result_htlcs_with_aux = Vec::new();
747742
let mut htlcs = Vec::new();
748743
for (idx, mut out) in txouts.drain(..).enumerate() {
@@ -769,15 +764,8 @@ impl CommitmentTransactionInfo {
769764
tx.txid()
770765
}
771766

772-
/// Build the Bitcoin transaction.
773-
///
774-
/// Required channel-static fields are provided by the caller.
775-
pub fn build<T: secp256k1::Signing + secp256k1::Verification>(
776-
&self,
777-
holder: bool,
778-
channel_static_info: &ChannelStaticInfo,
779-
secp_ctx: &Secp256k1<T>,
780-
) -> Result<(bitcoin::Transaction, Vec<HTLCOutputInCommitment>, Vec<Script>), ()> {
767+
/// Build the Bitcoin transaction
768+
pub fn build<T: secp256k1::Signing + secp256k1::Verification>(&self, holder: bool, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<T>) -> Result<(bitcoin::Transaction, Vec<HTLCOutputInCommitment>, Vec<Script>), ()> {
781769
let (obscured_commitment_transaction_number, txins) = self.build_inputs(holder, channel_static_info);
782770

783771
let mut txouts = self.build_outputs(holder, channel_static_info, secp_ctx)?;
@@ -808,18 +796,15 @@ impl CommitmentTransactionInfo {
808796

809797
fn build_outputs<T: secp256k1::Signing + secp256k1::Verification>(&self, holder: bool, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<T>) -> Result<Vec<(TxOut, (Script, Option<HTLCOutputInCommitment>))>, ()> {
810798
let htlcs = self.htlcs.iter().map(|h| (h.clone(), ())).collect();
811-
let (broadcaster_pubkeys, countersignatory_pubkeys) = channel_static_info.pubkeys(holder);
812-
let mut txouts = Self::do_build_outputs(&self.keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &htlcs, broadcaster_pubkeys, countersignatory_pubkeys, channel_static_info.contest_delay(holder), secp_ctx)?;
799+
let mut txouts = Self::do_build_outputs(&self.keys, self.to_broadcaster_value_sat, self.to_countersignatory_value_sat, &htlcs, holder, channel_static_info, secp_ctx)?;
813800
let outs = txouts.drain(..).map(|(out, (s, extra))| (out, (s, extra.map(|(p, _)| p)))).collect();
814801
Ok(outs)
815802
}
816803

817-
fn do_build_outputs<T: Copy, S: secp256k1::Signing + secp256k1::Verification>(
818-
keys: &TxCreationKeys,
819-
to_broadcaster_value_sat: u64,
820-
to_countersignatory_value_sat: u64,
821-
htlcs: &Vec<(HTLCOutputInCommitment, T)>,
822-
broadcaster_pubkeys: &ChannelPublicKeys, countersignatory_pubkeys: &ChannelPublicKeys, contest_delay: u16, secp_ctx: &Secp256k1<S>) -> Result<Vec<(TxOut, (Script, Option<(HTLCOutputInCommitment, T)>))>, ()> {
804+
fn do_build_outputs<T: Copy, S: secp256k1::Signing + secp256k1::Verification>(keys: &TxCreationKeys, to_broadcaster_value_sat: u64, to_countersignatory_value_sat: u64, htlcs: &Vec<(HTLCOutputInCommitment, T)>, holder: bool, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<S>) -> Result<Vec<(TxOut, (Script, Option<(HTLCOutputInCommitment, T)>))>, ()> {
805+
let (broadcaster_pubkeys, countersignatory_pubkeys) = channel_static_info.pubkeys(holder);
806+
let contest_delay = channel_static_info.contest_delay(holder);
807+
823808
let per_commitment_point = &keys.per_commitment_point;
824809
let to_broadcaster_delayed_pubkey = derive_public_key(
825810
&secp_ctx,
@@ -928,6 +913,7 @@ impl CommitmentTransactionInfo {
928913
(sighash, unsigned_tx)
929914
}
930915

916+
// TODO(devrandom): remove this and subsume the HolderCommitmentTransaction signing functionality
931917
pub(crate) fn to_holder_commitment_tx<T: secp256k1::Signing + secp256k1::Verification>(&self, counterparty_sig: Signature, htlcs_with_sig: Vec<(HTLCOutputInCommitment, Option<Signature>)>, channel_static_info: &ChannelStaticInfo, secp_ctx: &Secp256k1<T>) -> HolderCommitmentTransaction {
932918
let (broadcaster_pubkeys, countersignatory_pubkeys) = channel_static_info.pubkeys(true);
933919
let (tx, _, _) = self.build(true, channel_static_info, secp_ctx).unwrap();

lightning/src/ln/channel.rs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -981,24 +981,16 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
981981
value_to_b = 0;
982982
}
983983

984-
let (broadcaster_pubkeys, countersignatory_pubkeys, contest_delay) = if local {
985-
(self.holder_keys.pubkeys(), self.counterparty_pubkeys.as_ref().unwrap(), self.counterparty_selected_contest_delay)
986-
} else {
987-
(self.counterparty_pubkeys.as_ref().unwrap(), self.holder_keys.pubkeys(), self.holder_selected_contest_delay)
988-
};
989-
990984
let count = included_non_dust_htlcs.len();
991985

992-
let (info, mut htlcs_included) = CommitmentTransactionInfo::new_with_auxiliary_htlc_data(
993-
commitment_number,
986+
let (info, mut htlcs_included) = CommitmentTransactionInfo::new_with_auxiliary_htlc_data(commitment_number,
994987
value_to_a as u64,
995988
value_to_b as u64,
996989
keys.clone(),
997990
feerate_per_kw,
998991
included_non_dust_htlcs,
999-
broadcaster_pubkeys,
1000-
countersignatory_pubkeys,
1001-
contest_delay,
992+
local,
993+
&self.get_channel_static_info(),
1002994
&self.secp_ctx
1003995
);
1004996

@@ -1525,7 +1517,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15251517
let holder_info = HolderCommitmentTransactionInfo {
15261518
info: initial_commitment_info,
15271519
counterparty_sig: msg.signature,
1528-
htlc_sigs: Vec::new(),
1520+
counterparty_htlc_sigs: Vec::new(),
15291521
};
15301522

15311523
let channel_static_info = self.get_channel_static_info();
@@ -1584,7 +1576,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
15841576
let holder_info = HolderCommitmentTransactionInfo {
15851577
info: initial_commitment_info,
15861578
counterparty_sig: msg.signature,
1587-
htlc_sigs: Vec::new()
1579+
counterparty_htlc_sigs: Vec::new()
15881580
};
15891581

15901582
let counterparty_funding_pubkey = &self.counterparty_pubkeys.as_ref().unwrap().funding_pubkey;
@@ -1971,23 +1963,21 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
19711963

19721964
let channel_static_info = self.get_channel_static_info();
19731965

1974-
let mut commitment_tx = {
1966+
let (num_htlcs, mut htlcs_cloned, commitment_info, commitment_txid) = {
19751967
let commitment_info = self.build_commitment_transaction(self.cur_holder_commitment_transaction_number, &keys, true, false, feerate_per_kw, logger);
1976-
let commitment_tx = commitment_info.0.build(true, &channel_static_info, &self.secp_ctx).unwrap().0;
1968+
let (sighash, tx) = commitment_info.0.get_sighash(true, &channel_static_info, &funding_script, self.channel_value_satoshis, &self.secp_ctx);
19771969

19781970
let htlcs_cloned: Vec<_> = commitment_info.2.iter().map(|htlc| (htlc.0.clone(), htlc.1.map(|h| h.clone()))).collect();
1979-
(commitment_tx, commitment_info.1, htlcs_cloned, commitment_info.0)
1971+
let commitment_txid = tx.txid();
1972+
log_trace!(logger, "Checking commitment tx signature {} by key {} against tx {} (sighash {}) with redeemscript {}", log_bytes!(msg.signature.serialize_compact()[..]), log_bytes!(self.counterparty_funding_pubkey().serialize()), encode::serialize_hex(&tx), log_bytes!(sighash[..]), encode::serialize_hex(&funding_script));
1973+
if let Err(_) = self.secp_ctx.verify(&sighash, &msg.signature, &self.counterparty_funding_pubkey()) {
1974+
return Err((None, ChannelError::Close("Invalid commitment tx signature from peer".to_owned())));
1975+
}
1976+
(commitment_info.1, htlcs_cloned, commitment_info.0, commitment_txid)
19801977
};
1981-
let commitment_txid = commitment_tx.0.txid();
1982-
let sighash = hash_to_message!(&bip143::SigHashCache::new(&commitment_tx.0).signature_hash(0, &funding_script, self.channel_value_satoshis, SigHashType::All)[..]);
1983-
log_trace!(logger, "Checking commitment tx signature {} by key {} against tx {} (sighash {}) with redeemscript {}", log_bytes!(msg.signature.serialize_compact()[..]), log_bytes!(self.counterparty_funding_pubkey().serialize()), encode::serialize_hex(&commitment_tx.0), log_bytes!(sighash[..]), encode::serialize_hex(&funding_script));
1984-
if let Err(_) = self.secp_ctx.verify(&sighash, &msg.signature, &self.counterparty_funding_pubkey()) {
1985-
return Err((None, ChannelError::Close("Invalid commitment tx signature from peer".to_owned())));
1986-
}
19871978

19881979
//If channel fee was updated by funder confirm funder can afford the new fee rate when applied to the current local commitment transaction
19891980
if update_fee {
1990-
let num_htlcs = commitment_tx.1;
19911981
let total_fee = feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + (num_htlcs as u64) * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
19921982

19931983
let counterparty_reserve_we_require = Channel::<ChanSigner>::get_holder_selected_channel_reserve_satoshis(self.channel_value_satoshis);
@@ -1996,15 +1986,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
19961986
}
19971987
}
19981988

1999-
if msg.htlc_signatures.len() != commitment_tx.1 {
2000-
return Err((None, ChannelError::Close(format!("Got wrong number of HTLC signatures ({}) from remote. It must be {}", msg.htlc_signatures.len(), commitment_tx.1))));
1989+
if msg.htlc_signatures.len() != num_htlcs {
1990+
return Err((None, ChannelError::Close(format!("Got wrong number of HTLC signatures ({}) from remote. It must be {}", msg.htlc_signatures.len(), num_htlcs))));
20011991
}
20021992

20031993
// TODO: Merge these two, sadly they are currently both required to be passed separately to
20041994
// ChannelMonitor:
2005-
let mut htlcs_without_source = Vec::with_capacity(commitment_tx.2.len());
2006-
let mut htlcs_and_sigs = Vec::with_capacity(commitment_tx.2.len());
2007-
for (idx, (htlc, source)) in commitment_tx.2.drain(..).enumerate() {
1995+
let mut htlcs_without_source = Vec::with_capacity(htlcs_cloned.len());
1996+
let mut htlcs_and_sigs = Vec::with_capacity(htlcs_cloned.len());
1997+
for (idx, (htlc, source)) in htlcs_cloned.drain(..).enumerate() {
20081998
if let Some(_) = htlc.transaction_output_index {
20091999
let htlc_tx = self.build_htlc_transaction(&commitment_txid, &htlc, true, &keys, feerate_per_kw);
20102000
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &keys);
@@ -2022,9 +2012,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
20222012
}
20232013

20242014
let holder_info = HolderCommitmentTransactionInfo {
2025-
info: commitment_tx.3,
2015+
info: commitment_info,
20262016
counterparty_sig: msg.signature,
2027-
htlc_sigs: msg.htlc_signatures.clone()
2017+
counterparty_htlc_sigs: msg.htlc_signatures.clone()
20282018
};
20292019

20302020
let next_per_commitment_point = self.holder_keys.get_per_commitment_point(self.cur_holder_commitment_transaction_number - 1, &self.secp_ctx);

0 commit comments

Comments
 (0)