@@ -62,7 +62,7 @@ use crate::ln::interactivetxs::{
6262 InteractiveTxSigningSession, NegotiationError, SharedOwnedInput, SharedOwnedOutput,
6363 TX_COMMON_FIELDS_WEIGHT,
6464};
65- use crate::ln::msgs;
65+ use crate::ln::msgs::{self, accountable_from_bool} ;
6666use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError, OnionErrorPacket};
6767use crate::ln::onion_utils::{
6868 AttributionData, HTLCFailReason, LocalHTLCFailureReason, HOLD_TIME_UNIT_MILLIS,
@@ -444,6 +444,7 @@ struct OutboundHTLCOutput {
444444 skimmed_fee_msat: Option<u64>,
445445 send_timestamp: Option<Duration>,
446446 hold_htlc: Option<()>,
447+ accountable: Option<bool>,
447448}
448449
449450/// See AwaitingRemoteRevoke ChannelState for more info
@@ -9721,7 +9722,7 @@ where
97219722 skimmed_fee_msat: htlc.skimmed_fee_msat,
97229723 blinding_point: htlc.blinding_point,
97239724 hold_htlc: htlc.hold_htlc,
9724- accountable: None ,
9725+ accountable: accountable_from_bool(htlc.accountable.unwrap_or(false)) ,
97259726 });
97269727 }
97279728 }
@@ -12703,6 +12704,7 @@ where
1270312704 skimmed_fee_msat,
1270412705 send_timestamp,
1270512706 hold_htlc: hold_htlc.then(|| ()),
12707+ accountable: Some(accountable),
1270612708 });
1270712709 self.context.next_holder_htlc_id += 1;
1270812710
@@ -14583,6 +14585,7 @@ where
1458314585 let mut pending_outbound_skimmed_fees: Vec<Option<u64>> = Vec::new();
1458414586 let mut pending_outbound_blinding_points: Vec<Option<PublicKey>> = Vec::new();
1458514587 let mut pending_outbound_held_htlc_flags: Vec<Option<()>> = Vec::new();
14588+ let mut pending_outbound_accountable: Vec<Option<bool>> = Vec::new();
1458614589
1458714590 (self.context.pending_outbound_htlcs.len() as u64).write(writer)?;
1458814591 for htlc in self.context.pending_outbound_htlcs.iter() {
@@ -14626,6 +14629,7 @@ where
1462614629 pending_outbound_skimmed_fees.push(htlc.skimmed_fee_msat);
1462714630 pending_outbound_blinding_points.push(htlc.blinding_point);
1462814631 pending_outbound_held_htlc_flags.push(htlc.hold_htlc);
14632+ pending_outbound_accountable.push(htlc.accountable);
1462914633 }
1463014634
1463114635 let holding_cell_htlc_update_count = self.context.holding_cell_htlc_updates.len();
@@ -14927,6 +14931,7 @@ where
1492714931 (71, holder_commitment_point_previous_revoked, option), // Added in 0.3
1492814932 (73, holder_commitment_point_last_revoked, option), // Added in 0.3
1492914933 (75, holding_cell_accountable_flags, optional_vec), // Added in 0.3
14934+ (77, pending_outbound_accountable, optional_vec), // Added in 0.3
1493014935 });
1493114936
1493214937 Ok(())
@@ -15094,6 +15099,7 @@ where
1509415099 blinding_point: None,
1509515100 send_timestamp: None,
1509615101 hold_htlc: None,
15102+ accountable: None,
1509715103 });
1509815104 }
1509915105
@@ -15316,6 +15322,7 @@ where
1531615322 let mut pending_outbound_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1531715323 let mut holding_cell_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1531815324 let mut holding_cell_accountable: Option<Vec<bool>> = None;
15325+ let mut pending_outbound_accountable_opt: Option<Vec<Option<bool>>> = None;
1531915326
1532015327 read_tlv_fields!(reader, {
1532115328 (0, announcement_sigs, option),
@@ -15366,6 +15373,7 @@ where
1536615373 (71, holder_commitment_point_previous_revoked_opt, option), // Added in 0.3
1536715374 (73, holder_commitment_point_last_revoked_opt, option), // Added in 0.3
1536815375 (75, holding_cell_accountable, optional_vec), // Added in 0.3
15376+ (77, pending_outbound_accountable_opt, optional_vec), // Added in 0.3
1536915377 });
1537015378
1537115379 let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -15502,7 +15510,16 @@ where
1550215510 return Err(DecodeError::InvalidValue);
1550315511 }
1550415512 }
15505-
15513+ if let Some(held_htlcs) = pending_outbound_accountable_opt {
15514+ let mut iter = held_htlcs.into_iter();
15515+ for htlc in pending_outbound_htlcs.iter_mut() {
15516+ htlc.accountable = iter.next().ok_or(DecodeError::InvalidValue)?;
15517+ }
15518+ // We expect all accountable HTLC signals to be consumed above
15519+ if iter.next().is_some() {
15520+ return Err(DecodeError::InvalidValue);
15521+ }
15522+ }
1550615523 if let Some(attribution_data_list) = removed_htlc_attribution_data {
1550715524 let mut removed_htlcs = pending_inbound_htlcs.iter_mut().filter_map(|status| {
1550815525 if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
@@ -16106,6 +16123,7 @@ mod tests {
1610616123 blinding_point: None,
1610716124 send_timestamp: None,
1610816125 hold_htlc: None,
16126+ accountable: None,
1610916127 });
1611016128
1611116129 // Make sure when Node A calculates their local commitment transaction, none of the HTLCs pass
@@ -16561,6 +16579,7 @@ mod tests {
1656116579 blinding_point: None,
1656216580 send_timestamp: None,
1656316581 hold_htlc: None,
16582+ accountable: None,
1656416583 };
1656516584 let mut pending_outbound_htlcs = vec![dummy_outbound_output.clone(); 10];
1656616585 for (idx, htlc) in pending_outbound_htlcs.iter_mut().enumerate() {
@@ -16959,6 +16978,7 @@ mod tests {
1695916978 blinding_point: None,
1696016979 send_timestamp: None,
1696116980 hold_htlc: None,
16981+ accountable: None,
1696216982 });
1696316983
1696416984 let payment_preimage_3 =
@@ -16974,6 +16994,7 @@ mod tests {
1697416994 blinding_point: None,
1697516995 send_timestamp: None,
1697616996 hold_htlc: None,
16997+ accountable: None,
1697716998 });
1697816999
1697917000 let payment_preimage_4 =
@@ -17389,6 +17410,7 @@ mod tests {
1738917410 blinding_point: None,
1739017411 send_timestamp: None,
1739117412 hold_htlc: None,
17413+ accountable: None,
1739217414 });
1739317415
1739417416 chan.context.pending_outbound_htlcs.push(OutboundHTLCOutput {
@@ -17402,6 +17424,7 @@ mod tests {
1740217424 blinding_point: None,
1740317425 send_timestamp: None,
1740417426 hold_htlc: None,
17427+ accountable: None,
1740517428 });
1740617429
1740717430 test_commitment!("304402207d0870964530f97b62497b11153c551dca0a1e226815ef0a336651158da0f82402200f5378beee0e77759147b8a0a284decd11bfd2bc55c8fafa41c134fe996d43c8",
@@ -17643,6 +17666,7 @@ mod tests {
1764317666 blinding_point: None,
1764417667 send_timestamp: None,
1764517668 hold_htlc: None,
17669+ accountable: None,
1764617670 }),
1764717671 );
1764817672
@@ -17788,6 +17812,7 @@ mod tests {
1778817812 blinding_point: None,
1778917813 send_timestamp: None,
1779017814 hold_htlc: None,
17815+ accountable: None,
1779117816 }
1779217817 }),
1779317818 );
@@ -17844,6 +17869,7 @@ mod tests {
1784417869 blinding_point: None,
1784517870 send_timestamp: None,
1784617871 hold_htlc: None,
17872+ accountable: None,
1784717873 }),
1784817874 );
1784917875
@@ -18014,6 +18040,7 @@ mod tests {
1801418040 blinding_point: None,
1801518041 send_timestamp: None,
1801618042 hold_htlc: None,
18043+ accountable: None,
1801718044 }),
1801818045 );
1801918046
0 commit comments