@@ -433,6 +433,7 @@ struct OutboundHTLCOutput {
433433 skimmed_fee_msat: Option<u64>,
434434 send_timestamp: Option<Duration>,
435435 hold_htlc: Option<()>,
436+ accountable: Option<bool>,
436437}
437438
438439/// See AwaitingRemoteRevoke ChannelState for more info
@@ -9654,7 +9655,7 @@ where
96549655 skimmed_fee_msat: htlc.skimmed_fee_msat,
96559656 blinding_point: htlc.blinding_point,
96569657 hold_htlc: htlc.hold_htlc,
9657- accountable: None ,
9658+ accountable: accountable_from_bool(htlc.accountable.unwrap_or(false)) ,
96589659 });
96599660 }
96609661 }
@@ -12614,6 +12615,7 @@ where
1261412615 skimmed_fee_msat,
1261512616 send_timestamp,
1261612617 hold_htlc: hold_htlc.then(|| ()),
12618+ accountable: Some(accountable),
1261712619 });
1261812620 self.context.next_holder_htlc_id += 1;
1261912621
@@ -14468,6 +14470,7 @@ where
1446814470 let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
1446914471 let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
1447014472 let mut pending_outbound_held_htlc_flags: Vec<Option<()>> = Vec::new();
14473+ let mut pending_outbound_accountable: Vec<Option<bool>> = Vec::new();
1447114474
1447214475 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
1447314476 for htlc in self.context.pending_outbound_htlcs.iter() {
@@ -14511,6 +14514,7 @@ where
1451114514 pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
1451214515 pending_outbound_blinding_points.push(htlc.blinding_point);
1451314516 pending_outbound_held_htlc_flags.push(htlc.hold_htlc);
14517+ pending_outbound_accountable.push(htlc.accountable);
1451414518 }
1451514519
1451614520 let holding_cell_htlc_update_count = self.context.holding_cell_htlc_updates.len();
@@ -14806,6 +14810,7 @@ where
1480614810 (67, pending_outbound_held_htlc_flags, optional_vec), // Added in 0.2
1480714811 (69, holding_cell_held_htlc_flags, optional_vec), // Added in 0.2
1480814812 (71, holding_cell_accountable_flags, optional_vec), // Added in 0.3
14813+ (73, pending_outbound_accountable, optional_vec), // Added in 0.3
1480914814 });
1481014815
1481114816 Ok(())
@@ -14955,6 +14960,7 @@ where
1495514960 blinding_point: None,
1495614961 send_timestamp: None,
1495714962 hold_htlc: None,
14963+ accountable: None,
1495814964 });
1495914965 }
1496014966
@@ -15174,6 +15180,7 @@ where
1517415180
1517515181 let mut pending_outbound_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1517615182 let mut holding_cell_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
15183+ let mut pending_outbound_accountable_opt: Option<Vec<Option<bool>>> = None;
1517715184 let mut holding_cell_accountable_opt: Option<Vec<Option<bool>>> = None;
1517815185
1517915186 read_tlv_fields!(reader, {
@@ -15223,6 +15230,7 @@ where
1522315230 (67, pending_outbound_held_htlc_flags_opt, optional_vec), // Added in 0.2
1522415231 (69, holding_cell_held_htlc_flags_opt, optional_vec), // Added in 0.2
1522515232 (71, holding_cell_accountable_opt, optional_vec), // Added in 0.3
15233+ (73, pending_outbound_accountable_opt, optional_vec), // Added in 0.3
1522615234 });
1522715235
1522815236 let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -15359,7 +15367,16 @@ where
1535915367 return Err(DecodeError::InvalidValue);
1536015368 }
1536115369 }
15362-
15370+ if let Some(held_htlcs) = pending_outbound_accountable_opt {
15371+ let mut iter = held_htlcs.into_iter();
15372+ for htlc in pending_outbound_htlcs.iter_mut() {
15373+ htlc.accountable = iter.next().ok_or(DecodeError::InvalidValue)?;
15374+ }
15375+ // We expect all accountable HTLC signals to be consumed above
15376+ if iter.next().is_some() {
15377+ return Err(DecodeError::InvalidValue);
15378+ }
15379+ }
1536315380 if let Some(attribution_data_list) = removed_htlc_attribution_data {
1536415381 let mut removed_htlcs = pending_inbound_htlcs.iter_mut().filter_map(|status| {
1536515382 if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
@@ -15932,6 +15949,7 @@ mod tests {
1593215949 blinding_point: None,
1593315950 send_timestamp: None,
1593415951 hold_htlc: None,
15952+ accountable: None,
1593515953 });
1593615954
1593715955 // Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -16387,6 +16405,7 @@ mod tests {
1638716405 blinding_point: None,
1638816406 send_timestamp: None,
1638916407 hold_htlc: None,
16408+ accountable: None,
1639016409 };
1639116410 let mut pending_outbound_htlcs = vec![dummy_outbound_output.clone(); 10];
1639216411 for (idx, htlc) in pending_outbound_htlcs.iter_mut().enumerate() {
@@ -16785,6 +16804,7 @@ mod tests {
1678516804 blinding_point: None,
1678616805 send_timestamp: None,
1678716806 hold_htlc: None,
16807+ accountable: None,
1678816808 });
1678916809
1679016810 let payment_preimage_3 =
@@ -16800,6 +16820,7 @@ mod tests {
1680016820 blinding_point: None,
1680116821 send_timestamp: None,
1680216822 hold_htlc: None,
16823+ accountable: None,
1680316824 });
1680416825
1680516826 let payment_preimage_4 =
@@ -17215,6 +17236,7 @@ mod tests {
1721517236 blinding_point: None,
1721617237 send_timestamp: None,
1721717238 hold_htlc: None,
17239+ accountable: None,
1721817240 });
1721917241
1722017242 chan.context.pending_outbound_htlcs.push(OutboundHTLCOutput {
@@ -17228,6 +17250,7 @@ mod tests {
1722817250 blinding_point: None,
1722917251 send_timestamp: None,
1723017252 hold_htlc: None,
17253+ accountable: None,
1723117254 });
1723217255
1723317256 test_commitment!("304402207d0870964530f97b62497b11153c551dca0a1e226815ef0a336651158da0f82402200f5378beee0e77759147b8a0a284decd11bfd2bc55c8fafa41c134fe996d43c8",
@@ -17469,6 +17492,7 @@ mod tests {
1746917492 blinding_point: None,
1747017493 send_timestamp: None,
1747117494 hold_htlc: None,
17495+ accountable: None,
1747217496 }),
1747317497 );
1747417498
@@ -17559,6 +17583,7 @@ mod tests {
1755917583 blinding_point: None,
1756017584 send_timestamp: None,
1756117585 hold_htlc: None,
17586+ accountable: None,
1756217587 }
1756317588 }),
1756417589 );
@@ -17633,6 +17658,7 @@ mod tests {
1763317658 blinding_point: None,
1763417659 send_timestamp: None,
1763517660 hold_htlc: None,
17661+ accountable: None,
1763617662 }),
1763717663 );
1763817664
0 commit comments