Skip to content

Commit ef58f94

Browse files
committed
[approach1]: Set outgoing_accountable in PendingHTLCInfo
Downside: - We create this struct early on, so have to set this value to none and then mutate it. Upside: - We coherently store the accountable signal with the other forwarding information that we'll be using later on.
1 parent 8fb0681 commit ef58f94

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ pub struct PendingHTLCInfo {
429429
/// An experimental field indicating whether our node's reputation would be held accountable
430430
/// for the timely resolution of the received HTLC.
431431
pub incoming_accountable: Option<u8>,
432+
/// An experimental field indicating whether the outgoing node's reputation would be held
433+
/// accountable for the timely resolution of the offered HTLC.
434+
pub outgoing_accountable: Option<u8>,
432435
}
433436

434437
#[derive(Clone)] // See FundedChannel::revoke_and_ack for why, tl;dr: Rust bug
@@ -11226,7 +11229,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1122611229
Some(prev_channel_id),
1122711230
Some(payment_hash),
1122811231
);
11229-
let pending_add = PendingAddHTLCInfo {
11232+
let mut pending_add = PendingAddHTLCInfo {
1123011233
prev_outbound_scid_alias,
1123111234
prev_counterparty_node_id,
1123211235
prev_funding_outpoint,
@@ -11320,6 +11323,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1132011323
},
1132111324
}
1132211325
} else {
11326+
// Set the value for our outgoing accountable signal to copy the received
11327+
// incoming value (or just set zero if not present). This point is where we
11328+
// could introduce an interceptor that provides us with custom accountable
11329+
// values if desired.
11330+
pending_add.forward_info.outgoing_accountable =
11331+
pending_add.forward_info.incoming_accountable.or(Some(0));
11332+
1132311333
match self.forward_htlcs.lock().unwrap().entry(scid) {
1132411334
hash_map::Entry::Occupied(mut entry) => {
1132511335
entry.get_mut().push(HTLCForwardInfo::AddHTLC(pending_add));
@@ -15770,6 +15780,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
1577015780
(9, incoming_amt_msat, option),
1577115781
(10, skimmed_fee_msat, option),
1577215782
(11, incoming_accountable, option),
15783+
(13, outgoing_accountable, option),
1577315784
});
1577415785

1577515786
impl Writeable for HTLCFailureMsg {

lightning/src/ln/onion_payment.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ pub(super) fn create_fwd_pending_htlc_info(
242242
outgoing_cltv_value,
243243
skimmed_fee_msat: None,
244244
incoming_accountable: msg.accountable,
245+
outgoing_accountable: None,
245246
})
246247
}
247248

@@ -418,6 +419,7 @@ pub(super) fn create_recv_pending_htlc_info(
418419
outgoing_cltv_value: onion_cltv_expiry,
419420
skimmed_fee_msat: counterparty_skimmed_fee_msat,
420421
incoming_accountable,
422+
outgoing_accountable: None,
421423
})
422424
}
423425

0 commit comments

Comments
 (0)