Skip to content

Commit 8fb0681

Browse files
committed
ln: add incoming_accountable to PendingHTLCInfo
1 parent 235d5ec commit 8fb0681

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,9 @@ pub struct PendingHTLCInfo {
426426
/// This is used to allow LSPs to take fees as a part of payments, without the sender having to
427427
/// shoulder them.
428428
pub skimmed_fee_msat: Option<u64>,
429+
/// An experimental field indicating whether our node's reputation would be held accountable
430+
/// for the timely resolution of the received HTLC.
431+
pub incoming_accountable: Option<u8>,
429432
}
430433

431434
#[derive(Clone)] // See FundedChannel::revoke_and_ack for why, tl;dr: Rust bug
@@ -5048,7 +5051,7 @@ where
50485051
let current_height: u32 = self.best_block.read().unwrap().height;
50495052
create_recv_pending_htlc_info(decoded_hop, shared_secret, msg.payment_hash,
50505053
msg.amount_msat, msg.cltv_expiry, None, allow_underpay, msg.skimmed_fee_msat,
5051-
current_height)
5054+
msg.accountable, current_height)
50525055
},
50535056
onion_utils::Hop::Forward { .. } | onion_utils::Hop::BlindedForward { .. } => {
50545057
create_fwd_pending_htlc_info(msg, decoded_hop, shared_secret, next_packet_pubkey_opt)
@@ -7150,6 +7153,7 @@ where
71507153
payment_hash,
71517154
outgoing_amt_msat,
71527155
outgoing_cltv_value,
7156+
incoming_accountable,
71537157
..
71547158
},
71557159
} = payment;
@@ -7248,6 +7252,7 @@ where
72487252
Some(phantom_shared_secret),
72497253
false,
72507254
None,
7255+
incoming_accountable,
72517256
current_height,
72527257
);
72537258
match create_res {
@@ -15764,6 +15769,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
1576415769
(8, outgoing_cltv_value, required),
1576515770
(9, incoming_amt_msat, option),
1576615771
(10, skimmed_fee_msat, option),
15772+
(11, incoming_accountable, option),
1576715773
});
1576815774

1576915775
impl Writeable for HTLCFailureMsg {
@@ -19198,7 +19204,7 @@ mod tests {
1919819204
if let Err(crate::ln::channelmanager::InboundHTLCErr { reason, .. }) =
1919919205
create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1920019206
sender_intended_amt_msat - extra_fee_msat - 1, 42, None, true, Some(extra_fee_msat),
19201-
current_height)
19207+
None, current_height)
1920219208
{
1920319209
assert_eq!(reason, LocalHTLCFailureReason::FinalIncorrectHTLCAmount);
1920419210
} else { panic!(); }
@@ -19221,7 +19227,7 @@ mod tests {
1922119227
let current_height: u32 = node[0].node.best_block.read().unwrap().height;
1922219228
assert!(create_recv_pending_htlc_info(hop_data, [0; 32], PaymentHash([0; 32]),
1922319229
sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat),
19224-
current_height).is_ok());
19230+
None, current_height).is_ok());
1922519231
}
1922619232

1922719233
#[test]
@@ -19246,7 +19252,7 @@ mod tests {
1924619252
custom_tlvs: Vec::new(),
1924719253
},
1924819254
shared_secret: SharedSecret::from_bytes([0; 32]),
19249-
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, current_height);
19255+
}, [0; 32], PaymentHash([0; 32]), 100, TEST_FINAL_CLTV + 1, None, true, None, None, current_height);
1925019256

1925119257
// Should not return an error as this condition:
1925219258
// https://github.com/lightning/bolts/blob/4dcc377209509b13cf89a4b91fde7d478f5b46d8/04-onion-routing.md?plain=1#L334

lightning/src/ln/onion_payment.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,15 @@ pub(super) fn create_fwd_pending_htlc_info(
241241
outgoing_amt_msat: amt_to_forward,
242242
outgoing_cltv_value,
243243
skimmed_fee_msat: None,
244+
incoming_accountable: msg.accountable,
244245
})
245246
}
246247

247248
#[rustfmt::skip]
248249
pub(super) fn create_recv_pending_htlc_info(
249250
hop_data: onion_utils::Hop, shared_secret: [u8; 32], payment_hash: PaymentHash,
250251
amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
251-
counterparty_skimmed_fee_msat: Option<u64>, current_height: u32
252+
counterparty_skimmed_fee_msat: Option<u64>, incoming_accountable: Option<u8>, current_height: u32
252253
) -> Result<PendingHTLCInfo, InboundHTLCErr> {
253254
let (
254255
payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, onion_cltv_expiry,
@@ -416,6 +417,7 @@ pub(super) fn create_recv_pending_htlc_info(
416417
outgoing_amt_msat: onion_amt_msat,
417418
outgoing_cltv_value: onion_cltv_expiry,
418419
skimmed_fee_msat: counterparty_skimmed_fee_msat,
420+
incoming_accountable,
419421
})
420422
}
421423

@@ -480,7 +482,7 @@ where
480482
let shared_secret = hop.shared_secret().secret_bytes();
481483
create_recv_pending_htlc_info(
482484
hop, shared_secret, msg.payment_hash, msg.amount_msat, msg.cltv_expiry,
483-
None, allow_skimmed_fees, msg.skimmed_fee_msat, cur_height,
485+
None, allow_skimmed_fees, msg.skimmed_fee_msat, msg.accountable, cur_height,
484486
)?
485487
}
486488
})

0 commit comments

Comments
 (0)