@@ -151,7 +151,7 @@ pub(super) struct PendingHTLCInfo {
151
151
/// The fee being skimmed off the top of this HTLC. If this is a forward, it'll be the fee we are
152
152
/// skimming. If we're receiving this HTLC, it's the fee that our counterparty skimmed.
153
153
pub(super) skimmed_fee_msat: Option<u64>,
154
- pub(super) amount_rgb : Option<u64>,
154
+ pub(super) ingoing_amount_rgb : Option<u64>,
155
155
pub(super) outgoing_amount_rgb: Option<u64>,
156
156
}
157
157
@@ -179,6 +179,7 @@ pub(super) struct PendingAddHTLCInfo {
179
179
// Note that this may be an outbound SCID alias for the associated channel.
180
180
prev_short_channel_id: u64,
181
181
prev_htlc_id: u64,
182
+ prev_htlc_value_rgb: Option<u64>,
182
183
prev_funding_outpoint: OutPoint,
183
184
prev_user_channel_id: u128,
184
185
}
@@ -198,6 +199,7 @@ pub(crate) struct HTLCPreviousHopData {
198
199
short_channel_id: u64,
199
200
user_channel_id: Option<u128>,
200
201
htlc_id: u64,
202
+ htlc_value_rgb: Option<u64>,
201
203
incoming_packet_shared_secret: [u8; 32],
202
204
phantom_shared_secret: Option<[u8; 32]>,
203
205
@@ -2957,15 +2959,15 @@ where
2957
2959
outgoing_amt_msat: amt_to_forward,
2958
2960
outgoing_cltv_value,
2959
2961
skimmed_fee_msat: None,
2960
- amount_rgb : msg.amount_rgb,
2962
+ ingoing_amount_rgb : msg.amount_rgb,
2961
2963
outgoing_amount_rgb,
2962
2964
})
2963
2965
}
2964
2966
2965
2967
fn construct_recv_pending_htlc_info(
2966
2968
&self, hop_data: msgs::InboundOnionPayload, shared_secret: [u8; 32], payment_hash: PaymentHash,
2967
2969
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>
2969
2971
) -> Result<PendingHTLCInfo, InboundOnionErr> {
2970
2972
let (payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, outgoing_cltv_value, payment_metadata, rgb_amount_to_forward) = match hop_data {
2971
2973
msgs::InboundOnionPayload::Receive {
@@ -3021,7 +3023,7 @@ where
3021
3023
msg: "Upstream node sent less than we were supposed to receive in payment",
3022
3024
});
3023
3025
}
3024
- match (rgb_amount_to_forward, amount_rgb ) {
3026
+ match (rgb_amount_to_forward, ingoing_amount_rgb ) {
3025
3027
(Some(_), None) | (None, Some(_)) => {
3026
3028
return Err(InboundOnionErr {
3027
3029
err_code: 19,
@@ -3092,8 +3094,8 @@ where
3092
3094
outgoing_amt_msat: onion_amt_msat,
3093
3095
outgoing_cltv_value,
3094
3096
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 ,
3097
3099
})
3098
3100
}
3099
3101
@@ -4311,6 +4313,7 @@ where
4311
4313
user_channel_id: Some(payment.prev_user_channel_id),
4312
4314
outpoint: payment.prev_funding_outpoint,
4313
4315
htlc_id: payment.prev_htlc_id,
4316
+ htlc_value_rgb: payment.prev_htlc_value_rgb,
4314
4317
incoming_packet_shared_secret: payment.forward_info.incoming_shared_secret,
4315
4318
phantom_shared_secret: None,
4316
4319
});
@@ -4344,10 +4347,10 @@ where
4344
4347
for forward_info in pending_forwards.drain(..) {
4345
4348
match forward_info {
4346
4349
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,
4348
4351
forward_info: PendingHTLCInfo {
4349
4352
routing, incoming_shared_secret, payment_hash, outgoing_amt_msat,
4350
- outgoing_cltv_value, amount_rgb , ..
4353
+ outgoing_cltv_value, ingoing_amount_rgb , ..
4351
4354
}
4352
4355
}) => {
4353
4356
macro_rules! failure_handler {
@@ -4359,6 +4362,7 @@ where
4359
4362
user_channel_id: Some(prev_user_channel_id),
4360
4363
outpoint: prev_funding_outpoint,
4361
4364
htlc_id: prev_htlc_id,
4365
+ htlc_value_rgb: prev_htlc_value_rgb,
4362
4366
incoming_packet_shared_secret: incoming_shared_secret,
4363
4367
phantom_shared_secret: $phantom_ss,
4364
4368
});
@@ -4415,7 +4419,7 @@ where
4415
4419
onion_utils::Hop::Receive(hop_data) => {
4416
4420
match self.construct_recv_pending_htlc_info(hop_data,
4417
4421
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 )
4419
4423
{
4420
4424
Ok(info) => phantom_receives.push((prev_short_channel_id, prev_funding_outpoint, prev_user_channel_id, vec![(info, prev_htlc_id)])),
4421
4425
Err(InboundOnionErr { err_code, err_data, msg }) => failed_payment!(msg, err_code, err_data, Some(phantom_shared_secret))
@@ -4460,7 +4464,7 @@ where
4460
4464
for forward_info in pending_forwards.drain(..) {
4461
4465
match forward_info {
4462
4466
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,
4464
4468
forward_info: PendingHTLCInfo {
4465
4469
incoming_shared_secret, payment_hash, outgoing_amt_msat, outgoing_cltv_value,
4466
4470
routing: PendingHTLCRouting::Forward { onion_packet, .. }, skimmed_fee_msat, outgoing_amount_rgb, ..
@@ -4472,6 +4476,7 @@ where
4472
4476
user_channel_id: Some(prev_user_channel_id),
4473
4477
outpoint: prev_funding_outpoint,
4474
4478
htlc_id: prev_htlc_id,
4479
+ htlc_value_rgb: prev_htlc_value_rgb,
4475
4480
incoming_packet_shared_secret: incoming_shared_secret,
4476
4481
// Phantom payments are only PendingHTLCRouting::Receive.
4477
4482
phantom_shared_secret: None,
@@ -4523,7 +4528,7 @@ where
4523
4528
'next_forwardable_htlc: for forward_info in pending_forwards.drain(..) {
4524
4529
match forward_info {
4525
4530
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,
4527
4532
forward_info: PendingHTLCInfo {
4528
4533
routing, incoming_shared_secret, payment_hash, incoming_amt_msat, outgoing_amt_msat,
4529
4534
skimmed_fee_msat, ..
@@ -4556,6 +4561,7 @@ where
4556
4561
user_channel_id: Some(prev_user_channel_id),
4557
4562
outpoint: prev_funding_outpoint,
4558
4563
htlc_id: prev_htlc_id,
4564
+ htlc_value_rgb: prev_htlc_value_rgb,
4559
4565
incoming_packet_shared_secret: incoming_shared_secret,
4560
4566
phantom_shared_secret,
4561
4567
},
@@ -4586,6 +4592,7 @@ where
4586
4592
user_channel_id: $htlc.prev_hop.user_channel_id,
4587
4593
outpoint: prev_funding_outpoint,
4588
4594
htlc_id: $htlc.prev_hop.htlc_id,
4595
+ htlc_value_rgb: $htlc.prev_hop.htlc_value_rgb,
4589
4596
incoming_packet_shared_secret: $htlc.prev_hop.incoming_packet_shared_secret,
4590
4597
phantom_shared_secret,
4591
4598
}), payment_hash,
@@ -5703,7 +5710,7 @@ where
5703
5710
}
5704
5711
5705
5712
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,
5707
5714
next_channel_counterparty_node_id: Option<PublicKey>, next_channel_outpoint: OutPoint
5708
5715
) {
5709
5716
match source {
@@ -5723,6 +5730,7 @@ where
5723
5730
},
5724
5731
HTLCSource::PreviousHopData(hop_data) => {
5725
5732
let prev_outpoint = hop_data.outpoint;
5733
+ let inbound_amount_forwarded_rgb = hop_data.htlc_value_rgb;
5726
5734
let completed_blocker = RAAMonitorUpdateBlockingAction::from_prev_hop_data(&hop_data);
5727
5735
#[cfg(debug_assertions)]
5728
5736
let claiming_chan_funding_outpoint = hop_data.outpoint;
@@ -5809,7 +5817,8 @@ where
5809
5817
prev_channel_id: Some(prev_outpoint.to_channel_id()),
5810
5818
next_channel_id: Some(next_channel_outpoint.to_channel_id()),
5811
5819
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,
5813
5822
},
5814
5823
downstream_counterparty_and_funding_outpoint: chan_to_release,
5815
5824
})
@@ -6803,10 +6812,11 @@ where
6803
6812
6804
6813
let mut forward_htlcs = self.forward_htlcs.lock().unwrap();
6805
6814
let forward_htlcs_empty = forward_htlcs.is_empty();
6815
+ let prev_htlc_value_rgb = forward_info.ingoing_amount_rgb;
6806
6816
match forward_htlcs.entry(scid) {
6807
6817
hash_map::Entry::Occupied(mut entry) => {
6808
6818
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 }));
6810
6820
},
6811
6821
hash_map::Entry::Vacant(entry) => {
6812
6822
if !is_our_scid && forward_info.incoming_amt_msat.is_some() &&
@@ -6824,13 +6834,13 @@ where
6824
6834
inbound_amount_msat: forward_info.incoming_amt_msat.unwrap(),
6825
6835
expected_outbound_amount_msat: forward_info.outgoing_amt_msat,
6826
6836
intercept_id,
6827
- inbound_rgb_amount: forward_info.amount_rgb ,
6837
+ inbound_rgb_amount: forward_info.ingoing_amount_rgb ,
6828
6838
expected_outbound_rgb_amount: forward_info.outgoing_amount_rgb,
6829
6839
is_swap,
6830
6840
prev_short_channel_id,
6831
6841
}, None));
6832
6842
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 });
6834
6844
},
6835
6845
hash_map::Entry::Occupied(_) => {
6836
6846
log_info!(self.logger, "Failed to forward incoming HTLC: detected duplicate intercepted payment over short channel id {}", scid);
@@ -6839,6 +6849,7 @@ where
6839
6849
user_channel_id: Some(prev_user_channel_id),
6840
6850
outpoint: prev_funding_outpoint,
6841
6851
htlc_id: prev_htlc_id,
6852
+ htlc_value_rgb: prev_htlc_value_rgb,
6842
6853
incoming_packet_shared_secret: forward_info.incoming_shared_secret,
6843
6854
phantom_shared_secret: None,
6844
6855
});
@@ -6856,7 +6867,7 @@ where
6856
6867
push_forward_event = true;
6857
6868
}
6858
6869
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 })));
6860
6871
}
6861
6872
}
6862
6873
}
@@ -8369,6 +8380,7 @@ where
8369
8380
short_channel_id: htlc.prev_short_channel_id,
8370
8381
user_channel_id: Some(htlc.prev_user_channel_id),
8371
8382
htlc_id: htlc.prev_htlc_id,
8383
+ htlc_value_rgb: htlc.prev_htlc_value_rgb,
8372
8384
incoming_packet_shared_secret: htlc.forward_info.incoming_shared_secret,
8373
8385
phantom_shared_secret: None,
8374
8386
outpoint: htlc.prev_funding_outpoint,
@@ -9334,7 +9346,7 @@ impl_writeable_tlv_based!(PendingHTLCInfo, {
9334
9346
(8, outgoing_cltv_value, required),
9335
9347
(9, incoming_amt_msat, option),
9336
9348
(10, skimmed_fee_msat, option),
9337
- (12, amount_rgb , required),
9349
+ (12, ingoing_amount_rgb , required),
9338
9350
(14, outgoing_amount_rgb, required),
9339
9351
});
9340
9352
@@ -9418,6 +9430,7 @@ impl_writeable_tlv_based!(HTLCPreviousHopData, {
9418
9430
(4, htlc_id, required),
9419
9431
(6, incoming_packet_shared_secret, required),
9420
9432
(7, user_channel_id, option),
9433
+ (8, htlc_value_rgb, option),
9421
9434
});
9422
9435
9423
9436
impl Writeable for ClaimableHTLC {
@@ -9569,6 +9582,7 @@ impl_writeable_tlv_based!(PendingAddHTLCInfo, {
9569
9582
(2, prev_short_channel_id, required),
9570
9583
(4, prev_htlc_id, required),
9571
9584
(6, prev_funding_outpoint, required),
9585
+ (8, prev_htlc_value_rgb, option),
9572
9586
});
9573
9587
9574
9588
impl_writeable_tlv_based_enum!(HTLCForwardInfo,
0 commit comments