Skip to content

Commit 4131b59

Browse files
Antoine RiardTheBlueMatt
authored andcommitted
Track HTLCSource in ChannelMonitor
Insert it in current_local_signed_tx, prev_local_signed_tx, remote_claimable_outpoints. For so get it provided by Channel calls to provide_latest_{local,remote}_tx
1 parent 0dccef6 commit 4131b59

File tree

4 files changed

+85
-43
lines changed

4 files changed

+85
-43
lines changed

src/ln/channel.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ impl Channel {
751751
/// generated by the peer which proposed adding the HTLCs, and thus we need to understand both
752752
/// which peer generated this transaction and "to whom" this transaction flows.
753753
#[inline]
754-
fn build_commitment_transaction(&self, commitment_number: u64, keys: &TxCreationKeys, local: bool, generated_by_local: bool, feerate_per_kw: u64) -> (Transaction, Vec<HTLCOutputInCommitment>) {
754+
fn build_commitment_transaction(&self, commitment_number: u64, keys: &TxCreationKeys, local: bool, generated_by_local: bool, feerate_per_kw: u64) -> (Transaction, Vec<(HTLCOutputInCommitment, Option<HTLCSource>)>) {
755755
let obscured_commitment_transaction_number = self.get_commitment_transaction_number_obscure_factor() ^ (INITIAL_COMMITMENT_NUMBER - commitment_number);
756756

757757
let txins = {
@@ -765,30 +765,30 @@ impl Channel {
765765
ins
766766
};
767767

768-
let mut txouts: Vec<(TxOut, Option<HTLCOutputInCommitment>)> = Vec::with_capacity(self.pending_inbound_htlcs.len() + self.pending_outbound_htlcs.len() + 2);
768+
let mut txouts: Vec<(TxOut, Option<(HTLCOutputInCommitment, Option<HTLCSource>)>)> = Vec::with_capacity(self.pending_inbound_htlcs.len() + self.pending_outbound_htlcs.len() + 2);
769769

770770
let dust_limit_satoshis = if local { self.our_dust_limit_satoshis } else { self.their_dust_limit_satoshis };
771771
let mut remote_htlc_total_msat = 0;
772772
let mut local_htlc_total_msat = 0;
773773
let mut value_to_self_msat_offset = 0;
774774

775775
macro_rules! add_htlc_output {
776-
($htlc: expr, $outbound: expr) => {
776+
($htlc: expr, $outbound: expr, $source: expr) => {
777777
if $outbound == local { // "offered HTLC output"
778778
if $htlc.amount_msat / 1000 >= dust_limit_satoshis + (feerate_per_kw * HTLC_TIMEOUT_TX_WEIGHT / 1000) {
779779
let htlc_in_tx = get_htlc_in_commitment!($htlc, true);
780780
txouts.push((TxOut {
781781
script_pubkey: chan_utils::get_htlc_redeemscript(&htlc_in_tx, &keys).to_v0_p2wsh(),
782782
value: $htlc.amount_msat / 1000
783-
}, Some(htlc_in_tx)));
783+
}, Some((htlc_in_tx, $source))));
784784
}
785785
} else {
786786
if $htlc.amount_msat / 1000 >= dust_limit_satoshis + (feerate_per_kw * HTLC_SUCCESS_TX_WEIGHT / 1000) {
787787
let htlc_in_tx = get_htlc_in_commitment!($htlc, false);
788788
txouts.push((TxOut { // "received HTLC output"
789789
script_pubkey: chan_utils::get_htlc_redeemscript(&htlc_in_tx, &keys).to_v0_p2wsh(),
790790
value: $htlc.amount_msat / 1000
791-
}, Some(htlc_in_tx)));
791+
}, Some((htlc_in_tx, $source))));
792792
}
793793
}
794794
}
@@ -804,7 +804,7 @@ impl Channel {
804804
};
805805

806806
if include {
807-
add_htlc_output!(htlc, false);
807+
add_htlc_output!(htlc, false, None);
808808
remote_htlc_total_msat += htlc.amount_msat;
809809
} else {
810810
match &htlc.state {
@@ -830,7 +830,7 @@ impl Channel {
830830
};
831831

832832
if include {
833-
add_htlc_output!(htlc, true);
833+
add_htlc_output!(htlc, true, Some(htlc.source.clone()));
834834
local_htlc_total_msat += htlc.amount_msat;
835835
} else {
836836
match htlc.state {
@@ -901,12 +901,12 @@ impl Channel {
901901
transaction_utils::sort_outputs(&mut txouts);
902902

903903
let mut outputs: Vec<TxOut> = Vec::with_capacity(txouts.len());
904-
let mut htlcs_used: Vec<HTLCOutputInCommitment> = Vec::with_capacity(txouts.len());
904+
let mut htlcs_used: Vec<(HTLCOutputInCommitment, Option<HTLCSource>)> = Vec::with_capacity(txouts.len());
905905
for (idx, out) in txouts.drain(..).enumerate() {
906906
outputs.push(out.0);
907-
if let Some(out_htlc) = out.1 {
908-
htlcs_used.push(out_htlc);
909-
htlcs_used.last_mut().unwrap().transaction_output_index = idx as u32;
907+
if let Some(mut out_htlc) = out.1 {
908+
out_htlc.0.transaction_output_index = idx as u32;
909+
htlcs_used.push((out_htlc.0, out_htlc.1));
910910
}
911911
}
912912

@@ -1692,7 +1692,7 @@ impl Channel {
16921692
new_local_commitment_txn.push(local_commitment_tx.0.clone());
16931693

16941694
let mut htlcs_and_sigs = Vec::with_capacity(local_commitment_tx.1.len());
1695-
for (idx, ref htlc) in local_commitment_tx.1.iter().enumerate() {
1695+
for (idx, &(ref htlc, ref htlc_source)) in local_commitment_tx.1.iter().enumerate() {
16961696
let mut htlc_tx = self.build_htlc_transaction(&local_commitment_txid, htlc, true, &local_keys, feerate_per_kw);
16971697
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &local_keys);
16981698
let htlc_sighash = Message::from_slice(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0], &htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();
@@ -1704,7 +1704,7 @@ impl Channel {
17041704
} else {
17051705
self.create_htlc_tx_signature(&htlc_tx, htlc, &local_keys)?.1
17061706
};
1707-
htlcs_and_sigs.push(((*htlc).clone(), msg.htlc_signatures[idx], htlc_sig));
1707+
htlcs_and_sigs.push(((*htlc).clone(), msg.htlc_signatures[idx], htlc_sig, (*htlc_source).clone()));
17081708
}
17091709

17101710
let next_per_commitment_point = PublicKey::from_secret_key(&self.secp_ctx, &self.build_local_commitment_secret(self.cur_local_commitment_transaction_number - 1));
@@ -3240,7 +3240,7 @@ impl Channel {
32403240

32413241
/// Only fails in case of bad keys. Used for channel_reestablish commitment_signed generation
32423242
/// when we shouldn't change HTLC/channel state.
3243-
fn send_commitment_no_state_update(&self) -> Result<(msgs::CommitmentSigned, (Transaction, Vec<HTLCOutputInCommitment>)), ChannelError> {
3243+
fn send_commitment_no_state_update(&self) -> Result<(msgs::CommitmentSigned, (Transaction, Vec<(HTLCOutputInCommitment, Option<HTLCSource>)>)), ChannelError> {
32443244
let funding_script = self.get_funding_redeemscript();
32453245

32463246
let mut feerate_per_kw = self.feerate_per_kw;
@@ -3258,7 +3258,7 @@ impl Channel {
32583258

32593259
let mut htlc_sigs = Vec::new();
32603260

3261-
for ref htlc in remote_commitment_tx.1.iter() {
3261+
for &(ref htlc, _) in remote_commitment_tx.1.iter() {
32623262
let htlc_tx = self.build_htlc_transaction(&remote_commitment_txid, htlc, false, &remote_keys, feerate_per_kw);
32633263
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &remote_keys);
32643264
let htlc_sighash = Message::from_slice(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0], &htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();
@@ -3979,7 +3979,7 @@ mod tests {
39793979
let htlc_basepoint = PublicKey::from_secret_key(&secp_ctx, &chan.local_keys.htlc_base_key);
39803980
let keys = TxCreationKeys::new(&secp_ctx, &per_commitment_point, &delayed_payment_base, &htlc_basepoint, &chan.their_revocation_basepoint.unwrap(), &chan.their_payment_basepoint.unwrap(), &chan.their_htlc_basepoint.unwrap()).unwrap();
39813981

3982-
let mut unsigned_tx: (Transaction, Vec<HTLCOutputInCommitment>);
3982+
let mut unsigned_tx: (Transaction, Vec<(HTLCOutputInCommitment, Option<HTLCSource>)>);
39833983

39843984
macro_rules! test_commitment {
39853985
( $their_sig_hex: expr, $our_sig_hex: expr, $tx_hex: expr) => {
@@ -3999,7 +3999,7 @@ mod tests {
39993999
( $htlc_idx: expr, $their_sig_hex: expr, $our_sig_hex: expr, $tx_hex: expr ) => {
40004000
let remote_signature = Signature::from_der(&secp_ctx, &hex::decode($their_sig_hex).unwrap()[..]).unwrap();
40014001

4002-
let ref htlc = unsigned_tx.1[$htlc_idx];
4002+
let (ref htlc, _) = unsigned_tx.1[$htlc_idx];
40034003
let mut htlc_tx = chan.build_htlc_transaction(&unsigned_tx.0.txid(), &htlc, true, &keys, chan.feerate_per_kw);
40044004
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &keys);
40054005
let htlc_sighash = Message::from_slice(&bip143::SighashComponents::new(&htlc_tx).sighash_all(&htlc_tx.input[0], &htlc_redeemscript, htlc.amount_msat / 1000)[..]).unwrap();

src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ mod channel_held_info {
9090
}
9191

9292
/// Tracks the inbound corresponding to an outbound HTLC
93-
#[derive(Clone)]
93+
#[derive(Clone, PartialEq)]
9494
pub struct HTLCPreviousHopData {
9595
pub(super) short_channel_id: u64,
9696
pub(super) htlc_id: u64,
9797
pub(super) incoming_packet_shared_secret: [u8; 32],
9898
}
9999

100100
/// Tracks the inbound corresponding to an outbound HTLC
101-
#[derive(Clone)]
101+
#[derive(Clone, PartialEq)]
102102
pub enum HTLCSource {
103103
PreviousHopData(HTLCPreviousHopData),
104104
OutboundRoute {

src/ln/channelmonitor.rs

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use secp256k1;
2929
use ln::msgs::DecodeError;
3030
use ln::chan_utils;
3131
use ln::chan_utils::HTLCOutputInCommitment;
32+
use ln::channelmanager::HTLCSource;
3233
use chain::chaininterface::{ChainListener, ChainWatchInterface, BroadcasterInterface};
3334
use chain::transaction::OutPoint;
3435
use chain::keysinterface::SpendableOutputDescriptor;
@@ -258,7 +259,7 @@ struct LocalSignedTx {
258259
b_htlc_key: PublicKey,
259260
delayed_payment_key: PublicKey,
260261
feerate_per_kw: u64,
261-
htlc_outputs: Vec<(HTLCOutputInCommitment, Signature, Signature)>,
262+
htlc_outputs: Vec<(HTLCOutputInCommitment, Signature, Signature, Option<HTLCSource>)>,
262263
}
263264

264265
const SERIALIZATION_VERSION: u8 = 1;
@@ -283,7 +284,7 @@ pub struct ChannelMonitor {
283284
their_to_self_delay: Option<u16>,
284285

285286
old_secrets: [([u8; 32], u64); 49],
286-
remote_claimable_outpoints: HashMap<Sha256dHash, Vec<HTLCOutputInCommitment>>,
287+
remote_claimable_outpoints: HashMap<Sha256dHash, Vec<(HTLCOutputInCommitment, Option<HTLCSource>)>>,
287288
/// We cannot identify HTLC-Success or HTLC-Timeout transactions by themselves on the chain.
288289
/// Nor can we figure out their commitment numbers without the commitment transaction they are
289290
/// spending. Thus, in order to claim them via revocation key, we track all the remote
@@ -439,13 +440,13 @@ impl ChannelMonitor {
439440
let remote_hash_commitment_number = &mut self.remote_hash_commitment_number;
440441

441442
self.payment_preimages.retain(|&k, _| {
442-
for &(ref htlc, _, _) in &local_signed_commitment_tx.htlc_outputs {
443+
for &(ref htlc, _, _, _) in &local_signed_commitment_tx.htlc_outputs {
443444
if k == htlc.payment_hash {
444445
return true
445446
}
446447
}
447448
if let Some(prev_local_commitment_tx) = prev_local_signed_commitment_tx {
448-
for &(ref htlc, _, _) in prev_local_commitment_tx.htlc_outputs.iter() {
449+
for &(ref htlc, _, _, _) in prev_local_commitment_tx.htlc_outputs.iter() {
449450
if k == htlc.payment_hash {
450451
return true
451452
}
@@ -471,14 +472,21 @@ impl ChannelMonitor {
471472
/// The monitor watches for it to be broadcasted and then uses the HTLC information (and
472473
/// possibly future revocation/preimage information) to claim outputs where possible.
473474
/// We cache also the mapping hash:commitment number to lighten pruning of old preimages by watchtowers.
474-
pub(super) fn provide_latest_remote_commitment_tx_info(&mut self, unsigned_commitment_tx: &Transaction, htlc_outputs: Vec<HTLCOutputInCommitment>, commitment_number: u64, their_revocation_point: PublicKey) {
475+
pub(super) fn provide_latest_remote_commitment_tx_info(&mut self, unsigned_commitment_tx: &Transaction, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<HTLCSource>)>, commitment_number: u64, their_revocation_point: PublicKey) {
475476
// TODO: Encrypt the htlc_outputs data with the single-hash of the commitment transaction
476477
// so that a remote monitor doesn't learn anything unless there is a malicious close.
477478
// (only maybe, sadly we cant do the same for local info, as we need to be aware of
478479
// timeouts)
479-
for htlc in &htlc_outputs {
480+
for &(ref htlc, _) in &htlc_outputs {
480481
self.remote_hash_commitment_number.insert(htlc.payment_hash, commitment_number);
481482
}
483+
// We prune old claimable outpoints, useless to pass backward state when remote commitment
484+
// tx get revoked, optimize for storage
485+
for (_, htlc_data) in self.remote_claimable_outpoints.iter_mut() {
486+
for &mut(_, ref mut source) in htlc_data.iter_mut() {
487+
source.take();
488+
}
489+
}
482490
self.remote_claimable_outpoints.insert(unsigned_commitment_tx.txid(), htlc_outputs);
483491
self.current_remote_commitment_number = commitment_number;
484492
//TODO: Merge this into the other per-remote-transaction output storage stuff
@@ -509,7 +517,7 @@ impl ChannelMonitor {
509517
/// Panics if set_their_to_self_delay has never been called.
510518
/// Also update Storage with latest local per_commitment_point to derive local_delayedkey in
511519
/// case of onchain HTLC tx
512-
pub(super) fn provide_latest_local_commitment_tx_info(&mut self, signed_commitment_tx: Transaction, local_keys: chan_utils::TxCreationKeys, feerate_per_kw: u64, htlc_outputs: Vec<(HTLCOutputInCommitment, Signature, Signature)>) {
520+
pub(super) fn provide_latest_local_commitment_tx_info(&mut self, signed_commitment_tx: Transaction, local_keys: chan_utils::TxCreationKeys, feerate_per_kw: u64, htlc_outputs: Vec<(HTLCOutputInCommitment, Signature, Signature, Option<HTLCSource>)>) {
513521
assert!(self.their_to_self_delay.is_some());
514522
self.prev_local_signed_commitment_tx = self.current_local_signed_commitment_tx.take();
515523
self.current_local_signed_commitment_tx = Some(LocalSignedTx {
@@ -753,12 +761,25 @@ impl ChannelMonitor {
753761
}
754762
}
755763

764+
macro_rules! serialize_htlc_source {
765+
($htlc_source: expr) => {
766+
if let &Some(ref source) = $htlc_source {
767+
writer.write_all(&[1; 1])?;
768+
source.write(writer)?;
769+
} else {
770+
writer.write_all(&[0; 1])?;
771+
}
772+
}
773+
}
774+
775+
756776
writer.write_all(&byte_utils::be64_to_array(self.remote_claimable_outpoints.len() as u64))?;
757-
for (ref txid, ref htlc_outputs) in self.remote_claimable_outpoints.iter() {
777+
for (ref txid, ref htlc_infos) in self.remote_claimable_outpoints.iter() {
758778
writer.write_all(&txid[..])?;
759-
writer.write_all(&byte_utils::be64_to_array(htlc_outputs.len() as u64))?;
760-
for htlc_output in htlc_outputs.iter() {
779+
writer.write_all(&byte_utils::be64_to_array(htlc_infos.len() as u64))?;
780+
for &(ref htlc_output, ref htlc_source) in htlc_infos.iter() {
761781
serialize_htlc_in_commitment!(htlc_output);
782+
serialize_htlc_source!(htlc_source);
762783
}
763784
}
764785

@@ -798,10 +819,11 @@ impl ChannelMonitor {
798819

799820
writer.write_all(&byte_utils::be64_to_array($local_tx.feerate_per_kw))?;
800821
writer.write_all(&byte_utils::be64_to_array($local_tx.htlc_outputs.len() as u64))?;
801-
for &(ref htlc_output, ref their_sig, ref our_sig) in $local_tx.htlc_outputs.iter() {
822+
for &(ref htlc_output, ref their_sig, ref our_sig, ref htlc_source) in $local_tx.htlc_outputs.iter() {
802823
serialize_htlc_in_commitment!(htlc_output);
803824
writer.write_all(&their_sig.serialize_compact(&self.secp_ctx))?;
804825
writer.write_all(&our_sig.serialize_compact(&self.secp_ctx))?;
826+
serialize_htlc_source!(htlc_source);
805827
}
806828
}
807829
}
@@ -985,7 +1007,7 @@ impl ChannelMonitor {
9851007
let (sig, redeemscript) = match self.key_storage {
9861008
Storage::Local { ref revocation_base_key, .. } => {
9871009
let redeemscript = if $htlc_idx.is_none() { revokeable_redeemscript.clone() } else {
988-
let htlc = &per_commitment_option.unwrap()[$htlc_idx.unwrap()];
1010+
let htlc = &per_commitment_option.unwrap()[$htlc_idx.unwrap()].0;
9891011
chan_utils::get_htlc_redeemscript_with_explicit_keys(htlc, &a_htlc_key, &b_htlc_key, &revocation_pubkey)
9901012
};
9911013
let sighash = ignore_error!(Message::from_slice(&$sighash_parts.sighash_all(&$input, &redeemscript, $amount)[..]));
@@ -1011,7 +1033,7 @@ impl ChannelMonitor {
10111033
if let Some(per_commitment_data) = per_commitment_option {
10121034
inputs.reserve_exact(per_commitment_data.len());
10131035

1014-
for (idx, htlc) in per_commitment_data.iter().enumerate() {
1036+
for (idx, &(ref htlc, _)) in per_commitment_data.iter().enumerate() {
10151037
let expected_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &a_htlc_key, &b_htlc_key, &revocation_pubkey);
10161038
if htlc.transaction_output_index as usize >= tx.output.len() ||
10171039
tx.output[htlc.transaction_output_index as usize].value != htlc.amount_msat / 1000 ||
@@ -1140,7 +1162,7 @@ impl ChannelMonitor {
11401162
{
11411163
let (sig, redeemscript) = match self.key_storage {
11421164
Storage::Local { ref htlc_base_key, .. } => {
1143-
let htlc = &per_commitment_option.unwrap()[$input.sequence as usize];
1165+
let htlc = &per_commitment_option.unwrap()[$input.sequence as usize].0;
11441166
let redeemscript = chan_utils::get_htlc_redeemscript_with_explicit_keys(htlc, &a_htlc_key, &b_htlc_key, &revocation_pubkey);
11451167
let sighash = ignore_error!(Message::from_slice(&$sighash_parts.sighash_all(&$input, &redeemscript, $amount)[..]));
11461168
let htlc_key = ignore_error!(chan_utils::derive_private_key(&self.secp_ctx, revocation_point, &htlc_base_key));
@@ -1158,7 +1180,7 @@ impl ChannelMonitor {
11581180
}
11591181
}
11601182

1161-
for (idx, htlc) in per_commitment_data.iter().enumerate() {
1183+
for (idx, &(ref htlc, _)) in per_commitment_data.iter().enumerate() {
11621184
let expected_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &a_htlc_key, &b_htlc_key, &revocation_pubkey);
11631185
if htlc.transaction_output_index as usize >= tx.output.len() ||
11641186
tx.output[htlc.transaction_output_index as usize].value != htlc.amount_msat / 1000 ||
@@ -1352,7 +1374,7 @@ impl ChannelMonitor {
13521374
}
13531375
}
13541376

1355-
for &(ref htlc, ref their_sig, ref our_sig) in local_tx.htlc_outputs.iter() {
1377+
for &(ref htlc, ref their_sig, ref our_sig, _) in local_tx.htlc_outputs.iter() {
13561378
if htlc.offered {
13571379
let mut htlc_timeout_tx = chan_utils::build_htlc_transaction(&local_tx.txid, local_tx.feerate_per_kw, self.their_to_self_delay.unwrap(), htlc, &local_tx.delayed_payment_key, &local_tx.revocation_key);
13581380

@@ -1558,7 +1580,7 @@ impl ChannelMonitor {
15581580

15591581
pub(super) fn would_broadcast_at_height(&self, height: u32) -> bool {
15601582
if let Some(ref cur_local_tx) = self.current_local_signed_commitment_tx {
1561-
for &(ref htlc, _, _) in cur_local_tx.htlc_outputs.iter() {
1583+
for &(ref htlc, _, _, _) in cur_local_tx.htlc_outputs.iter() {
15621584
// For inbound HTLCs which we know the preimage for, we have to ensure we hit the
15631585
// chain with enough room to claim the HTLC without our counterparty being able to
15641586
// time out the HTLC first.
@@ -1692,14 +1714,31 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
16921714
}
16931715
}
16941716

1717+
macro_rules! read_htlc_source {
1718+
() => {
1719+
{
1720+
match <u8 as Readable<R>>::read(reader)? {
1721+
0 => None,
1722+
1 => {
1723+
let htlc_source: HTLCSource = Readable::read(reader)?;
1724+
Some(htlc_source)
1725+
},
1726+
_ => return Err(DecodeError::InvalidValue),
1727+
}
1728+
}
1729+
}
1730+
}
1731+
16951732
let remote_claimable_outpoints_len: u64 = Readable::read(reader)?;
16961733
let mut remote_claimable_outpoints = HashMap::with_capacity(cmp::min(remote_claimable_outpoints_len as usize, MAX_ALLOC_SIZE / 64));
16971734
for _ in 0..remote_claimable_outpoints_len {
16981735
let txid: Sha256dHash = Readable::read(reader)?;
16991736
let outputs_count: u64 = Readable::read(reader)?;
17001737
let mut outputs = Vec::with_capacity(cmp::min(outputs_count as usize, MAX_ALLOC_SIZE / 32));
17011738
for _ in 0..outputs_count {
1702-
outputs.push(read_htlc_in_commitment!());
1739+
let out = read_htlc_in_commitment!();
1740+
let source = read_htlc_source!();
1741+
outputs.push((out, source));
17031742
}
17041743
if let Some(_) = remote_claimable_outpoints.insert(txid, outputs) {
17051744
return Err(DecodeError::InvalidValue);
@@ -1756,7 +1795,10 @@ impl<R: ::std::io::Read> ReadableArgs<R, Arc<Logger>> for (Sha256dHash, ChannelM
17561795
let htlc_outputs_len: u64 = Readable::read(reader)?;
17571796
let mut htlc_outputs = Vec::with_capacity(cmp::min(htlc_outputs_len as usize, MAX_ALLOC_SIZE / 128));
17581797
for _ in 0..htlc_outputs_len {
1759-
htlc_outputs.push((read_htlc_in_commitment!(), Readable::read(reader)?, Readable::read(reader)?));
1798+
let out = read_htlc_in_commitment!();
1799+
let sigs = (Readable::read(reader)?, Readable::read(reader)?);
1800+
let source = read_htlc_source!();
1801+
htlc_outputs.push((out, sigs.0, sigs.1, source));
17601802
}
17611803

17621804
LocalSignedTx {
@@ -2245,13 +2287,13 @@ mod tests {
22452287
{
22462288
let mut res = Vec::new();
22472289
for (idx, preimage) in $preimages_slice.iter().enumerate() {
2248-
res.push(HTLCOutputInCommitment {
2290+
res.push((HTLCOutputInCommitment {
22492291
offered: true,
22502292
amount_msat: 0,
22512293
cltv_expiry: 0,
22522294
payment_hash: preimage.1.clone(),
22532295
transaction_output_index: idx as u32,
2254-
});
2296+
}, None));
22552297
}
22562298
res
22572299
}
@@ -2261,7 +2303,7 @@ mod tests {
22612303
($preimages_slice: expr) => {
22622304
{
22632305
let mut inp = preimages_slice_to_htlc_outputs!($preimages_slice);
2264-
let res: Vec<_> = inp.drain(..).map(|e| { (e, dummy_sig.clone(), dummy_sig.clone()) }).collect();
2306+
let res: Vec<_> = inp.drain(..).map(|e| { (e.0, dummy_sig.clone(), dummy_sig.clone(), e.1) }).collect();
22652307
res
22662308
}
22672309
}

0 commit comments

Comments
 (0)