@@ -451,6 +451,7 @@ struct OutboundHTLCOutput {
451451 skimmed_fee_msat: Option<u64>,
452452 send_timestamp: Option<Duration>,
453453 hold_htlc: Option<()>,
454+ accountable: bool,
454455}
455456
456457/// See AwaitingRemoteRevoke ChannelState for more info
@@ -9749,7 +9750,7 @@ where
97499750 skimmed_fee_msat: htlc.skimmed_fee_msat,
97509751 blinding_point: htlc.blinding_point,
97519752 hold_htlc: htlc.hold_htlc,
9752- accountable: None ,
9753+ accountable: Some(htlc.accountable) ,
97539754 });
97549755 }
97559756 }
@@ -12750,6 +12751,7 @@ where
1275012751 skimmed_fee_msat,
1275112752 send_timestamp,
1275212753 hold_htlc: hold_htlc.then(|| ()),
12754+ accountable,
1275312755 });
1275412756 self.context.next_holder_htlc_id += 1;
1275512757
@@ -14632,6 +14634,7 @@ where
1463214634 let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
1463314635 let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
1463414636 let mut pending_outbound_held_htlc_flags: Vec<Option<()>> = Vec::new();
14637+ let mut pending_outbound_accountable: Vec<bool> = Vec::new();
1463514638
1463614639 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
1463714640 for htlc in self.context.pending_outbound_htlcs.iter() {
@@ -14675,6 +14678,7 @@ where
1467514678 pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
1467614679 pending_outbound_blinding_points.push(htlc.blinding_point);
1467714680 pending_outbound_held_htlc_flags.push(htlc.hold_htlc);
14681+ pending_outbound_accountable.push(htlc.accountable);
1467814682 }
1467914683
1468014684 let holding_cell_htlc_update_count = self.context.holding_cell_htlc_updates.len();
@@ -14977,6 +14981,7 @@ where
1497714981 (73, holder_commitment_point_last_revoked, option), // Added in 0.3
1497814982 (75, inbound_committed_update_adds, optional_vec),
1497914983 (77, holding_cell_accountable_flags, optional_vec), // Added in 0.3
14984+ (79, pending_outbound_accountable, optional_vec), // Added in 0.3
1498014985 });
1498114986
1498214987 Ok(())
@@ -15144,6 +15149,7 @@ where
1514415149 blinding_point: None,
1514515150 send_timestamp: None,
1514615151 hold_htlc: None,
15152+ accountable: false,
1514715153 });
1514815154 }
1514915155
@@ -15367,6 +15373,7 @@ where
1536715373 let mut holding_cell_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1536815374 let mut inbound_committed_update_adds_opt: Option<Vec<Option<msgs::UpdateAddHTLC>>> = None;
1536915375 let mut holding_cell_accountable: Option<Vec<bool>> = None;
15376+ let mut pending_outbound_accountable: Option<Vec<bool>> = None;
1537015377
1537115378 read_tlv_fields!(reader, {
1537215379 (0, announcement_sigs, option),
@@ -15418,6 +15425,7 @@ where
1541815425 (73, holder_commitment_point_last_revoked_opt, option), // Added in 0.3
1541915426 (75, inbound_committed_update_adds_opt, optional_vec),
1542015427 (77, holding_cell_accountable, optional_vec), // Added in 0.3
15428+ (79, pending_outbound_accountable, optional_vec), // Added in 0.3
1542115429 });
1542215430
1542315431 let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -15565,7 +15573,16 @@ where
1556515573 return Err(DecodeError::InvalidValue);
1556615574 }
1556715575 }
15568-
15576+ if let Some(accountable_htlcs) = pending_outbound_accountable {
15577+ let mut iter = accountable_htlcs.into_iter();
15578+ for htlc in pending_outbound_htlcs.iter_mut() {
15579+ htlc.accountable = iter.next().ok_or(DecodeError::InvalidValue)?;
15580+ }
15581+ // We expect all accountable HTLC signals to be consumed above
15582+ if iter.next().is_some() {
15583+ return Err(DecodeError::InvalidValue);
15584+ }
15585+ }
1556915586 if let Some(attribution_data_list) = removed_htlc_attribution_data {
1557015587 let mut removed_htlcs = pending_inbound_htlcs.iter_mut().filter_map(|status| {
1557115588 if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
@@ -16169,6 +16186,7 @@ mod tests {
1616916186 blinding_point: None,
1617016187 send_timestamp: None,
1617116188 hold_htlc: None,
16189+ accountable: false,
1617216190 });
1617316191
1617416192 // Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -16624,6 +16642,7 @@ mod tests {
1662416642 blinding_point: None,
1662516643 send_timestamp: None,
1662616644 hold_htlc: None,
16645+ accountable: false,
1662716646 };
1662816647 let mut pending_outbound_htlcs = vec![dummy_outbound_output.clone(); 10];
1662916648 for (idx, htlc) in pending_outbound_htlcs.iter_mut().enumerate() {
@@ -17022,6 +17041,7 @@ mod tests {
1702217041 blinding_point: None,
1702317042 send_timestamp: None,
1702417043 hold_htlc: None,
17044+ accountable: false,
1702517045 });
1702617046
1702717047 let payment_preimage_3 =
@@ -17037,6 +17057,7 @@ mod tests {
1703717057 blinding_point: None,
1703817058 send_timestamp: None,
1703917059 hold_htlc: None,
17060+ accountable: false,
1704017061 });
1704117062
1704217063 let payment_preimage_4 =
@@ -17452,6 +17473,7 @@ mod tests {
1745217473 blinding_point: None,
1745317474 send_timestamp: None,
1745417475 hold_htlc: None,
17476+ accountable: false,
1745517477 });
1745617478
1745717479 chan.context.pending_outbound_htlcs.push(OutboundHTLCOutput {
@@ -17465,6 +17487,7 @@ mod tests {
1746517487 blinding_point: None,
1746617488 send_timestamp: None,
1746717489 hold_htlc: None,
17490+ accountable: false,
1746817491 });
1746917492
1747017493 test_commitment!("304402207d0870964530f97b62497b11153c551dca0a1e226815ef0a336651158da0f82402200f5378beee0e77759147b8a0a284decd11bfd2bc55c8fafa41c134fe996d43c8",
@@ -17706,6 +17729,7 @@ mod tests {
1770617729 blinding_point: None,
1770717730 send_timestamp: None,
1770817731 hold_htlc: None,
17732+ accountable: false,
1770917733 }),
1771017734 );
1771117735
@@ -17769,6 +17793,7 @@ mod tests {
1776917793 blinding_point: None,
1777017794 send_timestamp: None,
1777117795 hold_htlc: None,
17796+ accountable: false,
1777217797 }),
1777317798 );
1777417799
@@ -17851,6 +17876,7 @@ mod tests {
1785117876 blinding_point: None,
1785217877 send_timestamp: None,
1785317878 hold_htlc: None,
17879+ accountable: false,
1785417880 }
1785517881 }),
1785617882 );
@@ -17907,6 +17933,7 @@ mod tests {
1790717933 blinding_point: None,
1790817934 send_timestamp: None,
1790917935 hold_htlc: None,
17936+ accountable: false,
1791017937 }),
1791117938 );
1791217939
@@ -17943,6 +17970,7 @@ mod tests {
1794317970 blinding_point: None,
1794417971 send_timestamp: None,
1794517972 hold_htlc: None,
17973+ accountable: false,
1794617974 },
1794717975 ),
1794817976 );
@@ -17980,6 +18008,7 @@ mod tests {
1798018008 blinding_point: None,
1798118009 send_timestamp: None,
1798218010 hold_htlc: None,
18011+ accountable: false,
1798318012 },
1798418013 ),
1798518014 );
@@ -18017,6 +18046,7 @@ mod tests {
1801718046 blinding_point: None,
1801818047 send_timestamp: None,
1801918048 hold_htlc: None,
18049+ accountable: false,
1802018050 },
1802118051 ),
1802218052 );
@@ -18077,6 +18107,7 @@ mod tests {
1807718107 blinding_point: None,
1807818108 send_timestamp: None,
1807918109 hold_htlc: None,
18110+ accountable: false,
1808018111 }),
1808118112 );
1808218113
0 commit comments