Skip to content

Commit 8e47266

Browse files
committed
Rename PaymentForwarded::fee_earned_msat to total_fee_earned_msat
1 parent 2616f02 commit 8e47266

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

lightning/src/events/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ pub enum Event {
783783
/// The outgoing channel between the next node and us. This is only `None` for events
784784
/// generated or serialized by versions prior to 0.0.107.
785785
next_channel_id: Option<ChannelId>,
786-
/// The fee, in milli-satoshis, which was earned as a result of the payment.
786+
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
787787
///
788788
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
789789
/// was pending, the amount the next hop claimed will have been rounded down to the nearest
@@ -794,15 +794,15 @@ pub enum Event {
794794
/// If the channel which sent us the payment has been force-closed, we will claim the funds
795795
/// via an on-chain transaction. In that case we do not yet know the on-chain transaction
796796
/// fees which we will spend and will instead set this to `None`. It is possible duplicate
797-
/// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is
797+
/// `PaymentForwarded` events are generated for the same payment iff `total_fee_earned_msat` is
798798
/// `None`.
799-
fee_earned_msat: Option<u64>,
799+
total_fee_earned_msat: Option<u64>,
800800
/// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain
801801
/// transaction.
802802
claim_from_onchain_tx: bool,
803803
/// The final amount forwarded, in milli-satoshis, after the fee is deducted.
804804
///
805-
/// The caveat described above the `fee_earned_msat` field applies here as well.
805+
/// The caveat described above the `total_fee_earned_msat` field applies here as well.
806806
outbound_amount_forwarded_msat: Option<u64>,
807807
},
808808
/// Used to indicate that a channel with the given `channel_id` is being opened and pending
@@ -1083,12 +1083,12 @@ impl Writeable for Event {
10831083
});
10841084
}
10851085
&Event::PaymentForwarded {
1086-
fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
1086+
total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
10871087
next_channel_id, outbound_amount_forwarded_msat
10881088
} => {
10891089
7u8.write(writer)?;
10901090
write_tlv_fields!(writer, {
1091-
(0, fee_earned_msat, option),
1091+
(0, total_fee_earned_msat, option),
10921092
(1, prev_channel_id, option),
10931093
(2, claim_from_onchain_tx, required),
10941094
(3, next_channel_id, option),
@@ -1384,20 +1384,20 @@ impl MaybeReadable for Event {
13841384
},
13851385
7u8 => {
13861386
let f = || {
1387-
let mut fee_earned_msat = None;
1387+
let mut total_fee_earned_msat = None;
13881388
let mut prev_channel_id = None;
13891389
let mut claim_from_onchain_tx = false;
13901390
let mut next_channel_id = None;
13911391
let mut outbound_amount_forwarded_msat = None;
13921392
read_tlv_fields!(reader, {
1393-
(0, fee_earned_msat, option),
1393+
(0, total_fee_earned_msat, option),
13941394
(1, prev_channel_id, option),
13951395
(2, claim_from_onchain_tx, required),
13961396
(3, next_channel_id, option),
13971397
(5, outbound_amount_forwarded_msat, option),
13981398
});
13991399
Ok(Some(Event::PaymentForwarded {
1400-
fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
1400+
total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
14011401
outbound_amount_forwarded_msat
14021402
}))
14031403
};

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5788,14 +5788,14 @@ where
57885788
})
57895789
} else { None }
57905790
} else {
5791-
let fee_earned_msat = if let Some(forwarded_htlc_value) = forwarded_htlc_value_msat {
5791+
let total_fee_earned_msat = if let Some(forwarded_htlc_value) = forwarded_htlc_value_msat {
57925792
if let Some(claimed_htlc_value) = htlc_claim_value_msat {
57935793
Some(claimed_htlc_value - forwarded_htlc_value)
57945794
} else { None }
57955795
} else { None };
57965796
Some(MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
57975797
event: events::Event::PaymentForwarded {
5798-
fee_earned_msat,
5798+
total_fee_earned_msat,
57995799
claim_from_onchain_tx: from_onchain,
58005800
prev_channel_id: Some(prev_channel_id),
58015801
next_channel_id: Some(next_channel_id),

lightning/src/ln/functional_test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,10 @@ pub fn expect_payment_forwarded<CM: AChannelManager, H: NodeHolder<CM=CM>>(
22072207
) {
22082208
match event {
22092209
Event::PaymentForwarded {
2210-
fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
2210+
total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id,
22112211
outbound_amount_forwarded_msat: _
22122212
} => {
2213-
assert_eq!(fee_earned_msat, expected_fee);
2213+
assert_eq!(total_fee_earned_msat, expected_fee);
22142214
if !upstream_force_closed {
22152215
// Is the event prev_channel_id in one of the channels between the two nodes?
22162216
assert!(node.node().list_channels().iter().any(|x| x.counterparty.node_id == prev_node.node().get_our_node_id() && x.channel_id == prev_channel_id.unwrap()));

lightning/src/ln/functional_tests.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,8 +2889,10 @@ fn test_htlc_on_chain_success() {
28892889
}
28902890
let chan_id = Some(chan_1.2);
28912891
match forwarded_events[1] {
2892-
Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id, outbound_amount_forwarded_msat } => {
2893-
assert_eq!(fee_earned_msat, Some(1000));
2892+
Event::PaymentForwarded { total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
2893+
next_channel_id, outbound_amount_forwarded_msat
2894+
} => {
2895+
assert_eq!(total_fee_earned_msat, Some(1000));
28942896
assert_eq!(prev_channel_id, chan_id);
28952897
assert_eq!(claim_from_onchain_tx, true);
28962898
assert_eq!(next_channel_id, Some(chan_2.2));
@@ -2899,8 +2901,10 @@ fn test_htlc_on_chain_success() {
28992901
_ => panic!()
29002902
}
29012903
match forwarded_events[2] {
2902-
Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id, outbound_amount_forwarded_msat } => {
2903-
assert_eq!(fee_earned_msat, Some(1000));
2904+
Event::PaymentForwarded { total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
2905+
next_channel_id, outbound_amount_forwarded_msat
2906+
} => {
2907+
assert_eq!(total_fee_earned_msat, Some(1000));
29042908
assert_eq!(prev_channel_id, chan_id);
29052909
assert_eq!(claim_from_onchain_tx, true);
29062910
assert_eq!(next_channel_id, Some(chan_2.2));
@@ -4912,8 +4916,10 @@ fn test_onchain_to_onchain_claim() {
49124916
_ => panic!("Unexpected event"),
49134917
}
49144918
match events[1] {
4915-
Event::PaymentForwarded { fee_earned_msat, prev_channel_id, claim_from_onchain_tx, next_channel_id, outbound_amount_forwarded_msat } => {
4916-
assert_eq!(fee_earned_msat, Some(1000));
4919+
Event::PaymentForwarded { total_fee_earned_msat, prev_channel_id, claim_from_onchain_tx,
4920+
next_channel_id, outbound_amount_forwarded_msat
4921+
} => {
4922+
assert_eq!(total_fee_earned_msat, Some(1000));
49174923
assert_eq!(prev_channel_id, Some(chan_1.2));
49184924
assert_eq!(claim_from_onchain_tx, true);
49194925
assert_eq!(next_channel_id, Some(chan_2.2));

0 commit comments

Comments
 (0)