@@ -445,6 +445,7 @@ enum HTLCUpdateAwaitingACK {
445445 skimmed_fee_msat: Option<u64>,
446446 blinding_point: Option<PublicKey>,
447447 hold_htlc: Option<()>,
448+ accountable: Option<u8>,
448449 },
449450 ClaimHTLC {
450451 payment_preimage: PaymentPreimage,
@@ -8314,7 +8315,7 @@ where
83148315 skimmed_fee_msat,
83158316 blinding_point,
83168317 hold_htlc,
8317- ..
8318+ accountable,
83188319 } => {
83198320 match self.send_htlc(
83208321 amount_msat,
@@ -8326,6 +8327,7 @@ where
83268327 skimmed_fee_msat,
83278328 blinding_point,
83288329 hold_htlc.is_some(),
8330+ accountable,
83298331 fee_estimator,
83308332 logger,
83318333 ) {
@@ -12429,7 +12431,8 @@ where
1242912431 pub fn queue_add_htlc<F: Deref, L: Deref>(
1243012432 &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1243112433 source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
12432- blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
12434+ blinding_point: Option<PublicKey>, accountable: Option<u8>,
12435+ fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1243312436 ) -> Result<(), (LocalHTLCFailureReason, String)>
1243412437 where
1243512438 F::Target: FeeEstimator,
@@ -12446,6 +12449,7 @@ where
1244612449 blinding_point,
1244712450 // This method is only called for forwarded HTLCs, which are never held at the next hop
1244812451 false,
12452+ accountable,
1244912453 fee_estimator,
1245012454 logger,
1245112455 )
@@ -12477,7 +12481,7 @@ where
1247712481 &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1247812482 source: HTLCSource, onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
1247912483 skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>, hold_htlc: bool,
12480- fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
12484+ accountable: Option<u8>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1248112485 ) -> Result<bool, (LocalHTLCFailureReason, String)>
1248212486 where
1248312487 F::Target: FeeEstimator,
@@ -12559,6 +12563,7 @@ where
1255912563 skimmed_fee_msat,
1256012564 blinding_point,
1256112565 hold_htlc: hold_htlc.then(|| ()),
12566+ accountable,
1256212567 });
1256312568 return Ok(false);
1256412569 }
@@ -12807,7 +12812,8 @@ where
1280712812 pub fn send_htlc_and_commit<F: Deref, L: Deref>(
1280812813 &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1280912814 source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
12810- hold_htlc: bool, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
12815+ hold_htlc: bool, accountable: Option<u8>, fee_estimator: &LowerBoundedFeeEstimator<F>,
12816+ logger: &L,
1281112817 ) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
1281212818 where
1281312819 F::Target: FeeEstimator,
@@ -12823,6 +12829,7 @@ where
1282312829 skimmed_fee_msat,
1282412830 None,
1282512831 hold_htlc,
12832+ accountable,
1282612833 fee_estimator,
1282712834 logger,
1282812835 );
@@ -14481,6 +14488,8 @@ where
1448114488 Vec::with_capacity(holding_cell_htlc_update_count);
1448214489 let mut holding_cell_held_htlc_flags: Vec<Option<()>> =
1448314490 Vec::with_capacity(holding_cell_htlc_update_count);
14491+ let mut holding_cell_accountable_flags: Vec<Option<u8>> =
14492+ Vec::with_capacity(holding_cell_htlc_update_count);
1448414493 // Vec of (htlc_id, failure_code, sha256_of_onion)
1448514494 let mut malformed_htlcs: Vec<(u64, u16, [u8; 32])> = Vec::new();
1448614495 (holding_cell_htlc_update_count as u64).write(writer)?;
@@ -14495,6 +14504,7 @@ where
1449514504 blinding_point,
1449614505 skimmed_fee_msat,
1449714506 hold_htlc,
14507+ accountable,
1449814508 } => {
1449914509 0u8.write(writer)?;
1450014510 amount_msat.write(writer)?;
@@ -14506,6 +14516,7 @@ where
1450614516 holding_cell_skimmed_fees.push(skimmed_fee_msat);
1450714517 holding_cell_blinding_points.push(blinding_point);
1450814518 holding_cell_held_htlc_flags.push(hold_htlc);
14519+ holding_cell_accountable_flags.push(accountable);
1450914520 },
1451014521 &HTLCUpdateAwaitingACK::ClaimHTLC {
1451114522 ref payment_preimage,
@@ -14760,6 +14771,7 @@ where
1476014771 (65, self.quiescent_action, option), // Added in 0.2
1476114772 (67, pending_outbound_held_htlc_flags, optional_vec), // Added in 0.2
1476214773 (69, holding_cell_held_htlc_flags, optional_vec), // Added in 0.2
14774+ (71, holding_cell_accountable_flags, optional_vec), // Added in 0.3
1476314775 });
1476414776
1476514777 Ok(())
@@ -14928,6 +14940,7 @@ where
1492814940 skimmed_fee_msat: None,
1492914941 blinding_point: None,
1493014942 hold_htlc: None,
14943+ accountable: None,
1493114944 },
1493214945 1 => HTLCUpdateAwaitingACK::ClaimHTLC {
1493314946 payment_preimage: Readable::read(reader)?,
@@ -15127,6 +15140,7 @@ where
1512715140
1512815141 let mut pending_outbound_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
1512915142 let mut holding_cell_held_htlc_flags_opt: Option<Vec<Option<()>>> = None;
15143+ let mut holding_cell_accountable_opt: Option<Vec<Option<u8>>> = None;
1513015144
1513115145 read_tlv_fields!(reader, {
1513215146 (0, announcement_sigs, option),
@@ -15174,6 +15188,7 @@ where
1517415188 (65, quiescent_action, upgradable_option), // Added in 0.2
1517515189 (67, pending_outbound_held_htlc_flags_opt, optional_vec), // Added in 0.2
1517615190 (69, holding_cell_held_htlc_flags_opt, optional_vec), // Added in 0.2
15191+ (71, holding_cell_accountable_opt, optional_vec), // Added in 0.3
1517715192 });
1517815193
1517915194 let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -15298,6 +15313,19 @@ where
1529815313 }
1529915314 }
1530015315
15316+ if let Some(accountable_htlcs) = holding_cell_accountable_opt {
15317+ let mut iter = accountable_htlcs.into_iter();
15318+ for htlc in holding_cell_htlc_updates.iter_mut() {
15319+ if let HTLCUpdateAwaitingACK::AddHTLC { ref mut accountable, .. } = htlc {
15320+ *accountable = iter.next().ok_or(DecodeError::InvalidValue)?;
15321+ }
15322+ }
15323+ // We expect all accountable HTLC signals to be consumed above
15324+ if iter.next().is_some() {
15325+ return Err(DecodeError::InvalidValue);
15326+ }
15327+ }
15328+
1530115329 if let Some(attribution_data_list) = removed_htlc_attribution_data {
1530215330 let mut removed_htlcs = pending_inbound_htlcs.iter_mut().filter_map(|status| {
1530315331 if let InboundHTLCState::LocalRemoved(reason) = &mut status.state {
@@ -16360,6 +16388,7 @@ mod tests {
1636016388 skimmed_fee_msat: None,
1636116389 blinding_point: None,
1636216390 hold_htlc: None,
16391+ accountable: None,
1636316392 };
1636416393 let dummy_holding_cell_claim_htlc = |attribution_data| HTLCUpdateAwaitingACK::ClaimHTLC {
1636516394 payment_preimage: PaymentPreimage([42; 32]),
0 commit comments