@@ -151,7 +151,7 @@ pub(super) struct PendingHTLCInfo {
151151 /// The fee being skimmed off the top of this HTLC. If this is a forward, it'll be the fee we are
152152 /// skimming. If we're receiving this HTLC, it's the fee that our counterparty skimmed.
153153 pub(super) skimmed_fee_msat: Option<u64>,
154- pub(super) amount_rgb : Option<u64>,
154+ pub(super) ingoing_amount_rgb : Option<u64>,
155155 pub(super) outgoing_amount_rgb: Option<u64>,
156156}
157157
@@ -179,6 +179,7 @@ pub(super) struct PendingAddHTLCInfo {
179179 // Note that this may be an outbound SCID alias for the associated channel.
180180 prev_short_channel_id: u64,
181181 prev_htlc_id: u64,
182+ prev_htlc_value_rgb: Option<u64>,
182183 prev_funding_outpoint: OutPoint,
183184 prev_user_channel_id: u128,
184185}
@@ -198,6 +199,7 @@ pub(crate) struct HTLCPreviousHopData {
198199 short_channel_id: u64,
199200 user_channel_id: Option<u128>,
200201 htlc_id: u64,
202+ htlc_value_rgb: Option<u64>,
201203 incoming_packet_shared_secret: [u8; 32],
202204 phantom_shared_secret: Option<[u8; 32]>,
203205
@@ -2957,15 +2959,15 @@ where
29572959 outgoing_amt_msat: amt_to_forward,
29582960 outgoing_cltv_value,
29592961 skimmed_fee_msat: None,
2960- amount_rgb : msg.amount_rgb,
2962+ ingoing_amount_rgb : msg.amount_rgb,
29612963 outgoing_amount_rgb,
29622964 })
29632965 }
29642966
29652967 fn construct_recv_pending_htlc_info(
29662968 &self, hop_data: msgs::InboundOnionPayload, shared_secret: [u8; 32], payment_hash: PaymentHash,
29672969 amt_msat: u64, cltv_expiry: u32, phantom_shared_secret: Option<[u8; 32]>, allow_underpay: bool,
2968- counterparty_skimmed_fee_msat: Option<u64>, amount_rgb : Option<u64>
2970+ counterparty_skimmed_fee_msat: Option<u64>, ingoing_amount_rgb : Option<u64>
29692971 ) -> Result<PendingHTLCInfo, InboundOnionErr> {
29702972 let (payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, outgoing_cltv_value, payment_metadata, rgb_amount_to_forward) = match hop_data {
29712973 msgs::InboundOnionPayload::Receive {
@@ -3021,7 +3023,7 @@ where
30213023 msg: "Upstream node sent less than we were supposed to receive in payment",
30223024 });
30233025 }
3024- match (rgb_amount_to_forward, amount_rgb ) {
3026+ match (rgb_amount_to_forward, ingoing_amount_rgb ) {
30253027 (Some(_), None) | (None, Some(_)) => {
30263028 return Err(InboundOnionErr {
30273029 err_code: 19,
@@ -3092,8 +3094,8 @@ where
30923094 outgoing_amt_msat: onion_amt_msat,
30933095 outgoing_cltv_value,
30943096 skimmed_fee_msat: counterparty_skimmed_fee_msat,
3095- amount_rgb ,
3096- outgoing_amount_rgb: amount_rgb ,
3097+ ingoing_amount_rgb ,
3098+ outgoing_amount_rgb: rgb_amount_to_forward ,
30973099 })
30983100 }
30993101
@@ -4311,6 +4313,7 @@ where
43114313 user_channel_id: Some(payment.prev_user_channel_id),
43124314 outpoint: payment.prev_funding_outpoint,
43134315 htlc_id: payment.prev_htlc_id,
4316+ htlc_value_rgb: payment.prev_htlc_value_rgb,
43144317 incoming_packet_shared_secret: payment.forward_info.incoming_shared_secret,
43154318 phantom_shared_secret: None,
43164319 });
@@ -4344,10 +4347,10 @@ where
43444347 for forward_info in pending_forwards.drain(..) {
43454348 match forward_info {
43464349 HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
4347- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
4350+ prev_short_channel_id, prev_htlc_id, prev_htlc_value_rgb, prev_funding_outpoint, prev_user_channel_id,
43484351 forward_info: PendingHTLCInfo {
43494352 routing, incoming_shared_secret, payment_hash, outgoing_amt_msat,
4350- outgoing_cltv_value, amount_rgb , ..
4353+ outgoing_cltv_value, ingoing_amount_rgb , ..
43514354 }
43524355 }) => {
43534356 macro_rules! failure_handler {
@@ -4359,6 +4362,7 @@ where
43594362 user_channel_id: Some(prev_user_channel_id),
43604363 outpoint: prev_funding_outpoint,
43614364 htlc_id: prev_htlc_id,
4365+ htlc_value_rgb: prev_htlc_value_rgb,
43624366 incoming_packet_shared_secret: incoming_shared_secret,
43634367 phantom_shared_secret: $phantom_ss,
43644368 });
@@ -4415,7 +4419,7 @@ where
44154419 onion_utils::Hop::Receive(hop_data) => {
44164420 match self.construct_recv_pending_htlc_info(hop_data,
44174421 incoming_shared_secret, payment_hash, outgoing_amt_msat,
4418- outgoing_cltv_value, Some(phantom_shared_secret), false, None, amount_rgb )
4422+ outgoing_cltv_value, Some(phantom_shared_secret), false, None, ingoing_amount_rgb )
44194423 {
44204424 Ok(info) => phantom_receives.push((prev_short_channel_id, prev_funding_outpoint, prev_user_channel_id, vec![(info, prev_htlc_id)])),
44214425 Err(InboundOnionErr { err_code, err_data, msg }) => failed_payment!(msg, err_code, err_data, Some(phantom_shared_secret))
@@ -4460,7 +4464,7 @@ where
44604464 for forward_info in pending_forwards.drain(..) {
44614465 match forward_info {
44624466 HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
4463- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
4467+ prev_short_channel_id, prev_htlc_id, prev_htlc_value_rgb, prev_funding_outpoint, prev_user_channel_id,
44644468 forward_info: PendingHTLCInfo {
44654469 incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
44664470 routing: PendingHTLCRouting::Forward { onion_packet, .. }, skimmed_fee_msat, outgoing_amount_rgb, ..
@@ -4472,6 +4476,7 @@ where
44724476 user_channel_id: Some(prev_user_channel_id),
44734477 outpoint: prev_funding_outpoint,
44744478 htlc_id: prev_htlc_id,
4479+ htlc_value_rgb: prev_htlc_value_rgb,
44754480 incoming_packet_shared_secret: incoming_shared_secret,
44764481 // Phantom payments are only PendingHTLCRouting::Receive.
44774482 phantom_shared_secret: None,
@@ -4523,7 +4528,7 @@ where
45234528 'next_forwardable_htlc: for forward_info in pending_forwards.drain(..) {
45244529 match forward_info {
45254530 HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
4526- prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
4531+ prev_short_channel_id, prev_htlc_id, prev_htlc_value_rgb, prev_funding_outpoint, prev_user_channel_id,
45274532 forward_info: PendingHTLCInfo {
45284533 routing, incoming_shared_secret, payment_hash, incoming_amt_msat, outgoing_amt_msat,
45294534 skimmed_fee_msat, ..
@@ -4556,6 +4561,7 @@ where
45564561 user_channel_id: Some(prev_user_channel_id),
45574562 outpoint: prev_funding_outpoint,
45584563 htlc_id: prev_htlc_id,
4564+ htlc_value_rgb: prev_htlc_value_rgb,
45594565 incoming_packet_shared_secret: incoming_shared_secret,
45604566 phantom_shared_secret,
45614567 },
@@ -4586,6 +4592,7 @@ where
45864592 user_channel_id: $htlc.prev_hop.user_channel_id,
45874593 outpoint: prev_funding_outpoint,
45884594 htlc_id: $htlc.prev_hop.htlc_id,
4595+ htlc_value_rgb: $htlc.prev_hop.htlc_value_rgb,
45894596 incoming_packet_shared_secret: $htlc.prev_hop.incoming_packet_shared_secret,
45904597 phantom_shared_secret,
45914598 }), payment_hash,
@@ -5703,7 +5710,7 @@ where
57035710 }
57045711
57055712 fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage,
5706- forwarded_htlc_value_msat: Option<u64>, forwarded_htlc_rgb : Option<u64>, from_onchain: bool, startup_replay: bool,
5713+ forwarded_htlc_value_msat: Option<u64>, outbound_amount_forwarded_rgb : Option<u64>, from_onchain: bool, startup_replay: bool,
57075714 next_channel_counterparty_node_id: Option<PublicKey>, next_channel_outpoint: OutPoint
57085715 ) {
57095716 match source {
@@ -5723,6 +5730,7 @@ where
57235730 },
57245731 HTLCSource::PreviousHopData(hop_data) => {
57255732 let prev_outpoint = hop_data.outpoint;
5733+ let inbound_amount_forwarded_rgb = hop_data.htlc_value_rgb;
57265734 let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
57275735 #[cfg(debug_assertions)]
57285736 let claiming_chan_funding_outpoint = hop_data.outpoint;
@@ -5809,7 +5817,8 @@ where
58095817 prev_channel_id: Some(prev_outpoint.to_channel_id()),
58105818 next_channel_id: Some(next_channel_outpoint.to_channel_id()),
58115819 outbound_amount_forwarded_msat: forwarded_htlc_value_msat,
5812- outbound_amount_forwarded_rgb: forwarded_htlc_rgb,
5820+ outbound_amount_forwarded_rgb,
5821+ inbound_amount_forwarded_rgb,
58135822 },
58145823 downstream_counterparty_and_funding_outpoint: chan_to_release,
58155824 })
@@ -6803,10 +6812,11 @@ where
68036812
68046813 let mut forward_htlcs = self.forward_htlcs.lock().unwrap();
68056814 let forward_htlcs_empty = forward_htlcs.is_empty();
6815+ let prev_htlc_value_rgb = forward_info.ingoing_amount_rgb;
68066816 match forward_htlcs.entry(scid) {
68076817 hash_map::Entry::Occupied(mut entry) => {
68086818 entry.get_mut().push(HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
6809- prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_user_channel_id, forward_info }));
6819+ prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_htlc_value_rgb, prev_user_channel_id, forward_info }));
68106820 },
68116821 hash_map::Entry::Vacant(entry) => {
68126822 if !is_our_scid && forward_info.incoming_amt_msat.is_some() &&
@@ -6824,13 +6834,13 @@ where
68246834 inbound_amount_msat: forward_info.incoming_amt_msat.unwrap(),
68256835 expected_outbound_amount_msat: forward_info.outgoing_amt_msat,
68266836 intercept_id,
6827- inbound_rgb_amount: forward_info.amount_rgb ,
6837+ inbound_rgb_amount: forward_info.ingoing_amount_rgb ,
68286838 expected_outbound_rgb_amount: forward_info.outgoing_amount_rgb,
68296839 is_swap,
68306840 prev_short_channel_id,
68316841 }, None));
68326842 entry.insert(PendingAddHTLCInfo {
6833- prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_user_channel_id, forward_info });
6843+ prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_htlc_value_rgb, prev_user_channel_id, forward_info });
68346844 },
68356845 hash_map::Entry::Occupied(_) => {
68366846 log_info!(self.logger, "Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}", scid);
@@ -6839,6 +6849,7 @@ where
68396849 user_channel_id: Some(prev_user_channel_id),
68406850 outpoint: prev_funding_outpoint,
68416851 htlc_id: prev_htlc_id,
6852+ htlc_value_rgb: prev_htlc_value_rgb,
68426853 incoming_packet_shared_secret: forward_info.incoming_shared_secret,
68436854 phantom_shared_secret: None,
68446855 });
@@ -6856,7 +6867,7 @@ where
68566867 push_forward_event = true;
68576868 }
68586869 entry.insert(vec!(HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
6859- prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_user_channel_id, forward_info })));
6870+ prev_short_channel_id, prev_funding_outpoint, prev_htlc_id, prev_htlc_value_rgb, prev_user_channel_id, forward_info })));
68606871 }
68616872 }
68626873 }
@@ -8369,6 +8380,7 @@ where
83698380 short_channel_id: htlc.prev_short_channel_id,
83708381 user_channel_id: Some(htlc.prev_user_channel_id),
83718382 htlc_id: htlc.prev_htlc_id,
8383+ htlc_value_rgb: htlc.prev_htlc_value_rgb,
83728384 incoming_packet_shared_secret: htlc.forward_info.incoming_shared_secret,
83738385 phantom_shared_secret: None,
83748386 outpoint: htlc.prev_funding_outpoint,
@@ -9334,7 +9346,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
93349346 (8, outgoing_cltv_value, required),
93359347 (9, incoming_amt_msat, option),
93369348 (10, skimmed_fee_msat, option),
9337- (12, amount_rgb , required),
9349+ (12, ingoing_amount_rgb , required),
93389350 (14, outgoing_amount_rgb, required),
93399351});
93409352
@@ -9418,6 +9430,7 @@ impl_writeable_tlv_based!(HTLCPreviousHopData, {
94189430 (4, htlc_id, required),
94199431 (6, incoming_packet_shared_secret, required),
94209432 (7, user_channel_id, option),
9433+ (8, htlc_value_rgb, option),
94219434});
94229435
94239436impl Writeable for ClaimableHTLC {
@@ -9569,6 +9582,7 @@ impl_writeable_tlv_based!(PendingAddHTLCInfo, {
95699582 (2, prev_short_channel_id, required),
95709583 (4, prev_htlc_id, required),
95719584 (6, prev_funding_outpoint, required),
9585+ (8, prev_htlc_value_rgb, option),
95729586});
95739587
95749588impl_writeable_tlv_based_enum!(HTLCForwardInfo,
0 commit comments