@@ -68,8 +68,8 @@ use crate::ln::inbound_payment;
6868use crate::ln::interactivetxs::InteractiveTxMessageSend;
6969use crate::ln::msgs;
7070use crate::ln::msgs::{
71- BaseMessageHandler, ChannelMessageHandler, CommitmentUpdate, DecodeError, LightningError ,
72- MessageSendEvent,
71+ accountable_into_bool, BaseMessageHandler, ChannelMessageHandler, CommitmentUpdate,
72+ DecodeError, LightningError, MessageSendEvent,
7373};
7474use crate::ln::onion_payment::{
7575 check_incoming_htlc_cltv, create_fwd_pending_htlc_info, create_recv_pending_htlc_info,
@@ -427,6 +427,9 @@ pub struct PendingHTLCInfo {
427427 /// This is used to allow LSPs to take fees as a part of payments, without the sender having to
428428 /// shoulder them.
429429 pub skimmed_fee_msat: Option<u64>,
430+ /// An experimental field indicating whether our node's reputation would be held accountable
431+ /// for the timely resolution of the received HTLC.
432+ pub incoming_accountable: bool,
430433}
431434
432435#[derive(Clone, Debug)] // See FundedChannel::revoke_and_ack for why, tl;dr: Rust bug
@@ -5100,7 +5103,7 @@ where
51005103 let current_height: u32 = self.best_block.read().unwrap().height;
51015104 create_recv_pending_htlc_info(decoded_hop, shared_secret, msg.payment_hash,
51025105 msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
5103- current_height)
5106+ accountable_into_bool(msg.accountable), current_height)
51045107 },
51055108 onion_utils::Hop::Forward { .. } | onion_utils::Hop::BlindedForward { .. } => {
51065109 create_fwd_pending_htlc_info(msg, decoded_hop, shared_secret, next_packet_pubkey_opt)
@@ -7222,6 +7225,7 @@ where
72227225 payment_hash,
72237226 outgoing_amt_msat,
72247227 outgoing_cltv_value,
7228+ incoming_accountable,
72257229 ..
72267230 },
72277231 } = payment;
@@ -7320,6 +7324,7 @@ where
73207324 Some(phantom_shared_secret),
73217325 false,
73227326 None,
7327+ incoming_accountable,
73237328 current_height,
73247329 );
73257330 match create_res {
@@ -15963,6 +15968,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
1596315968 (8, outgoing_cltv_value, required),
1596415969 (9, incoming_amt_msat, option),
1596515970 (10, skimmed_fee_msat, option),
15971+ (11, incoming_accountable, (default_value, false)),
1596615972});
1596715973
1596815974impl Writeable for HTLCFailureMsg {
@@ -19398,7 +19404,7 @@ mod tests {
1939819404 if let Err(crate::ln::channelmanager::InboundHTLCErr { reason, .. }) =
1939919405 create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1940019406 sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat),
19401- current_height)
19407+ false, current_height)
1940219408 {
1940319409 assert_eq!(reason, LocalHTLCFailureReason::FinalIncorrectHTLCAmount);
1940419410 } else { panic!(); }
@@ -19421,7 +19427,7 @@ mod tests {
1942119427 let current_height: u32 = node[0].node.best_block.read().unwrap().height;
1942219428 assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1942319429 sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat),
19424- current_height).is_ok());
19430+ false, current_height).is_ok());
1942519431 }
1942619432
1942719433 #[test]
@@ -19446,7 +19452,7 @@ mod tests {
1944619452 custom_tlvs: Vec::new(),
1944719453 },
1944819454 shared_secret: SharedSecret::from_bytes([0; 32]),
19449- }, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height);
19455+ }, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, false, current_height);
1945019456
1945119457 // Should not return an error as this condition:
1945219458 // https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334
0 commit comments