Skip to content

Commit 203394f

Browse files
Track incoming amount in PendingHTLCInfo
Used in upcoming commit(s) when we generate the PaymentIntercepted event for intercepted payments. Co-authored-by: John Cantrell <[email protected]> Co-authored-by: Valentine Wallace <[email protected]>
1 parent b3d257d commit 203394f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub(super) struct PendingHTLCInfo {
113113
pub(super) incoming_shared_secret: [u8; 32],
114114
payment_hash: PaymentHash,
115115
pub(super) amt_to_forward: u64,
116+
pub(super) amt_incoming: Option<u64>, // Added in 0.0.113
116117
pub(super) outgoing_cltv_value: u32,
117118
}
118119

@@ -2196,6 +2197,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
21962197
routing,
21972198
payment_hash,
21982199
incoming_shared_secret: shared_secret,
2200+
amt_incoming: Some(amt_msat),
21992201
amt_to_forward: amt_msat,
22002202
outgoing_cltv_value: hop_data.outgoing_cltv_value,
22012203
})
@@ -2292,6 +2294,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
22922294
},
22932295
payment_hash: msg.payment_hash.clone(),
22942296
incoming_shared_secret: shared_secret,
2297+
amt_incoming: Some(msg.amount_msat),
22952298
amt_to_forward: next_hop_data.amt_to_forward,
22962299
outgoing_cltv_value: next_hop_data.outgoing_cltv_value,
22972300
})
@@ -3155,7 +3158,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
31553158
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint,
31563159
forward_info: PendingHTLCInfo {
31573160
routing, incoming_shared_secret, payment_hash, amt_to_forward,
3158-
outgoing_cltv_value
3161+
outgoing_cltv_value, amt_incoming: _
31593162
}
31603163
}) => {
31613164
macro_rules! failure_handler {
@@ -3262,7 +3265,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
32623265
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint ,
32633266
forward_info: PendingHTLCInfo {
32643267
incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value,
3265-
routing: PendingHTLCRouting::Forward { onion_packet, .. },
3268+
routing: PendingHTLCRouting::Forward { onion_packet, .. }, amt_incoming: _,
32663269
},
32673270
}) => {
32683271
log_trace!(self.logger, "Adding HTLC from short id {} with payment_hash {} to channel with short id {} after delay", prev_short_channel_id, log_bytes!(payment_hash.0), short_chan_id);
@@ -6470,7 +6473,8 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
64706473
(2, incoming_shared_secret, required),
64716474
(4, payment_hash, required),
64726475
(6, amt_to_forward, required),
6473-
(8, outgoing_cltv_value, required)
6476+
(8, outgoing_cltv_value, required),
6477+
(9, amt_incoming, option),
64746478
});
64756479

64766480

0 commit comments

Comments
 (0)