Skip to content

Commit a813095

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 <johncantrell97@gmail.com> Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
1 parent eff40cf commit a813095

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 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 {
@@ -3263,7 +3266,8 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
32633266
forward_info: PendingHTLCInfo {
32643267
routing: PendingHTLCRouting::Forward {
32653268
onion_packet, ..
3266-
}, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value
3269+
}, incoming_shared_secret, payment_hash, amt_to_forward, outgoing_cltv_value,
3270+
amt_incoming: _
32673271
},
32683272
}) => {
32693273
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);
@@ -6471,7 +6475,8 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
64716475
(2, incoming_shared_secret, required),
64726476
(4, payment_hash, required),
64736477
(6, amt_to_forward, required),
6474-
(8, outgoing_cltv_value, required)
6478+
(8, outgoing_cltv_value, required),
6479+
(9, amt_incoming, option),
64756480
});
64766481

64776482

0 commit comments

Comments
 (0)