@@ -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
@@ -9690,7 +9691,7 @@ where
96909691 skimmed_fee_msat: htlc.skimmed_fee_msat,
96919692 blinding_point: htlc.blinding_point,
96929693 hold_htlc: htlc.hold_htlc,
9693- accountable: None ,
9694+ accountable: accountable_from_bool(htlc.accountable.unwrap_or(false)) ,
96949695 });
96959696 }
96969697 }
@@ -12675,6 +12676,7 @@ where
1267512676 skimmed_fee_msat,
1267612677 send_timestamp,
1267712678 hold_htlc: hold_htlc.then(|| ()),
12679+ accountable: Some(accountable),
1267812680 });
1267912681 self.context.next_holder_htlc_id += 1;
1268012682
@@ -14529,6 +14531,7 @@ where
1452914531 let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
1453014532 let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
1453114533 let mut pending_outbound_held_htlc_flags: Vec<Option<()>> = Vec::new();
14534+ let mut pending_outbound_accountable: Vec<Option<bool>> = Vec::new();
1453214535
1453314536 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
1453414537 for htlc in self.context.pending_outbound_htlcs.iter() {
@@ -14572,6 +14575,7 @@ where
1457214575 pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
1457314576 pending_outbound_blinding_points.push(htlc.blinding_point);
1457414577 pending_outbound_held_htlc_flags.push(htlc.hold_htlc);
14578+ pending_outbound_accountable.push(htlc.accountable);
1457514579 }
1457614580
1457714581 let holding_cell_htlc_update_count = self.context.holding_cell_htlc_updates.len();
@@ -14873,6 +14877,7 @@ where
1487314877 (71, holder_commitment_point_previous_revoked, option), // Added in 0.3
1487414878 (73, holder_commitment_point_last_revoked, option), // Added in 0.3
1487514879 (75, holding_cell_accountable_flags, optional_vec), // Added in 0.3
14880+ (77, pending_outbound_accountable, optional_vec), // Added in 0.3
1487614881 });
1487714882
1487814883 Ok(())
@@ -15022,6 +15027,7 @@ where
1502215027 blinding_point: None,
1502315028 send_timestamp: None,
1502415029 hold_htlc: None,
15030+ accountable: None,
1502515031 });
1502615032 }
1502715033
@@ -15243,6 +15249,7 @@ where
1524315249
1524415250 let mut pending_outbound_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1524515251 let mut holding_cell_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
15252+ let mut pending_outbound_accountable_opt: Option<Vec<Option<bool>>> = None;
1524615253 let mut holding_cell_accountable_opt: Option<Vec<Option<bool>>> = None;
1524715254
1524815255 read_tlv_fields!(reader, {
@@ -15294,6 +15301,7 @@ where
1529415301 (71, holder_commitment_point_previous_revoked_opt, option), // Added in 0.3
1529515302 (73, holder_commitment_point_last_revoked_opt, option), // Added in 0.3
1529615303 (75, holding_cell_accountable_opt, optional_vec), // Added in 0.3
15304+ (77, pending_outbound_accountable_opt, optional_vec), // Added in 0.3
1529715305 });
1529815306
1529915307 let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -15430,7 +15438,16 @@ where
1543015438 return Err(DecodeError::InvalidValue);
1543115439 }
1543215440 }
15433-
15441+ if let Some(held_htlcs) = pending_outbound_accountable_opt {
15442+ let mut iter = held_htlcs.into_iter();
15443+ for htlc in pending_outbound_htlcs.iter_mut() {
15444+ htlc.accountable = iter.next().ok_or(DecodeError::InvalidValue)?;
15445+ }
15446+ // We expect all accountable HTLC signals to be consumed above
15447+ if iter.next().is_some() {
15448+ return Err(DecodeError::InvalidValue);
15449+ }
15450+ }
1543415451 if let Some(attribution_data_list) = removed_htlc_attribution_data {
1543515452 let mut removed_htlcs = pending_inbound_htlcs.iter_mut().filter_map(|status| {
1543615453 if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
@@ -16034,6 +16051,7 @@ mod tests {
1603416051 blinding_point: None,
1603516052 send_timestamp: None,
1603616053 hold_htlc: None,
16054+ accountable: None,
1603716055 });
1603816056
1603916057 // Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -16489,6 +16507,7 @@ mod tests {
1648916507 blinding_point: None,
1649016508 send_timestamp: None,
1649116509 hold_htlc: None,
16510+ accountable: None,
1649216511 };
1649316512 let mut pending_outbound_htlcs = vec![dummy_outbound_output.clone(); 10];
1649416513 for (idx, htlc) in pending_outbound_htlcs.iter_mut().enumerate() {
@@ -16887,6 +16906,7 @@ mod tests {
1688716906 blinding_point: None,
1688816907 send_timestamp: None,
1688916908 hold_htlc: None,
16909+ accountable: None,
1689016910 });
1689116911
1689216912 let payment_preimage_3 =
@@ -16902,6 +16922,7 @@ mod tests {
1690216922 blinding_point: None,
1690316923 send_timestamp: None,
1690416924 hold_htlc: None,
16925+ accountable: None,
1690516926 });
1690616927
1690716928 let payment_preimage_4 =
@@ -17317,6 +17338,7 @@ mod tests {
1731717338 blinding_point: None,
1731817339 send_timestamp: None,
1731917340 hold_htlc: None,
17341+ accountable: None,
1732017342 });
1732117343
1732217344 chan.context.pending_outbound_htlcs.push(OutboundHTLCOutput {
@@ -17330,6 +17352,7 @@ mod tests {
1733017352 blinding_point: None,
1733117353 send_timestamp: None,
1733217354 hold_htlc: None,
17355+ accountable: None,
1733317356 });
1733417357
1733517358 test_commitment!("304402207d0870964530f97b62497b11153c551dca0a1e226815ef0a336651158da0f82402200f5378beee0e77759147b8a0a284decd11bfd2bc55c8fafa41c134fe996d43c8",
@@ -17571,6 +17594,7 @@ mod tests {
1757117594 blinding_point: None,
1757217595 send_timestamp: None,
1757317596 hold_htlc: None,
17597+ accountable: None,
1757417598 }),
1757517599 );
1757617600
@@ -17661,6 +17685,7 @@ mod tests {
1766117685 blinding_point: None,
1766217686 send_timestamp: None,
1766317687 hold_htlc: None,
17688+ accountable: None,
1766417689 }
1766517690 }),
1766617691 );
@@ -17717,6 +17742,7 @@ mod tests {
1771717742 blinding_point: None,
1771817743 send_timestamp: None,
1771917744 hold_htlc: None,
17745+ accountable: None,
1772017746 }),
1772117747 );
1772217748
@@ -17776,6 +17802,7 @@ mod tests {
1777617802 blinding_point: None,
1777717803 send_timestamp: None,
1777817804 hold_htlc: None,
17805+ accountable: None,
1777917806 }),
1778017807 );
1778117808
0 commit comments