Skip to content

Commit f465396

Browse files
committed
Rename PaymentClaimed to PaymentReceived
1 parent 22d74bf commit f465396

12 files changed

+72
-72
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out) {
870870
}
871871
},
872872
events::Event::PaymentSent { .. } => {},
873-
events::Event::PaymentClaimed { .. } => {},
873+
events::Event::PaymentReceived { .. } => {},
874874
events::Event::PaymentPathSuccessful { .. } => {},
875875
events::Event::PaymentPathFailed { .. } => {},
876876
events::Event::ProbeSuccessful { .. } | events::Event::ProbeFailed { .. } => {

lightning/src/chain/chainmonitor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ mod tests {
788788
use bitcoin::{BlockHeader, TxMerkleNode};
789789
use bitcoin::hashes::Hash;
790790
use crate::{check_added_monitors, check_closed_broadcast, check_closed_event};
791-
use crate::{expect_payment_sent, expect_payment_claimed, expect_payment_sent_without_paths, expect_payment_path_successful, get_event_msg};
791+
use crate::{expect_payment_sent, expect_payment_received, expect_payment_sent_without_paths, expect_payment_path_successful, get_event_msg};
792792
use crate::{get_htlc_update_msgs, get_local_commitment_txn, get_revoke_commit_msgs, get_route_and_payment_hash, unwrap_send_err};
793793
use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Watch};
794794
use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
@@ -818,10 +818,10 @@ mod tests {
818818

819819
nodes[1].node.claim_funds(payment_preimage_1);
820820
check_added_monitors!(nodes[1], 1);
821-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
821+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
822822
nodes[1].node.claim_funds(payment_preimage_2);
823823
check_added_monitors!(nodes[1], 1);
824-
expect_payment_claimed!(nodes[1], payment_hash_2, 1_000_000);
824+
expect_payment_received!(nodes[1], payment_hash_2, 1_000_000);
825825

826826
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
827827

@@ -908,7 +908,7 @@ mod tests {
908908
// First route a payment that we will claim on chain and give the recipient the preimage.
909909
let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], 1_000_000);
910910
nodes[1].node.claim_funds(payment_preimage);
911-
expect_payment_claimed!(nodes[1], payment_hash, 1_000_000);
911+
expect_payment_received!(nodes[1], payment_hash, 1_000_000);
912912
nodes[1].node.get_and_clear_pending_msg_events();
913913
check_added_monitors!(nodes[1], 1);
914914
let remote_txn = get_local_commitment_txn!(nodes[1], channel.2);

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ fn test_monitor_and_persister_update_fail() {
133133

134134
// Try to update ChannelMonitor
135135
nodes[1].node.claim_funds(preimage);
136-
expect_payment_claimed!(nodes[1], payment_hash, 9_000_000);
136+
expect_payment_received!(nodes[1], payment_hash, 9_000_000);
137137
check_added_monitors!(nodes[1], 1);
138138

139139
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
@@ -298,7 +298,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
298298
// but nodes[0] won't respond since it is frozen.
299299
nodes[1].node.claim_funds(payment_preimage_1);
300300
check_added_monitors!(nodes[1], 1);
301-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
301+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
302302

303303
let events_2 = nodes[1].node.get_and_clear_pending_msg_events();
304304
assert_eq!(events_2.len(), 1);
@@ -1106,7 +1106,7 @@ fn test_monitor_update_fail_reestablish() {
11061106

11071107
nodes[2].node.claim_funds(payment_preimage);
11081108
check_added_monitors!(nodes[2], 1);
1109-
expect_payment_claimed!(nodes[2], payment_hash, 1_000_000);
1109+
expect_payment_received!(nodes[2], payment_hash, 1_000_000);
11101110

11111111
let mut updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
11121112
assert!(updates.update_add_htlcs.is_empty());
@@ -1311,7 +1311,7 @@ fn claim_while_disconnected_monitor_update_fail() {
13111311

13121312
nodes[1].node.claim_funds(payment_preimage_1);
13131313
check_added_monitors!(nodes[1], 1);
1314-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
1314+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
13151315

13161316
nodes[0].node.peer_connected(&nodes[1].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
13171317
nodes[1].node.peer_connected(&nodes[0].node.get_our_node_id(), &msgs::Init { features: channelmanager::provided_init_features(), remote_network_address: None }).unwrap();
@@ -1590,7 +1590,7 @@ fn test_monitor_update_fail_claim() {
15901590

15911591
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
15921592
nodes[1].node.claim_funds(payment_preimage_1);
1593-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
1593+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
15941594
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
15951595
check_added_monitors!(nodes[1], 1);
15961596

@@ -1785,7 +1785,7 @@ fn monitor_update_claim_fail_no_response() {
17851785

17861786
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
17871787
nodes[1].node.claim_funds(payment_preimage_1);
1788-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
1788+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
17891789
check_added_monitors!(nodes[1], 1);
17901790

17911791
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
@@ -2103,7 +2103,7 @@ fn test_fail_htlc_on_broadcast_after_claim() {
21032103

21042104
nodes[2].node.claim_funds(payment_preimage);
21052105
check_added_monitors!(nodes[2], 1);
2106-
expect_payment_claimed!(nodes[2], payment_hash, 2000);
2106+
expect_payment_received!(nodes[2], payment_hash, 2000);
21072107

21082108
let cs_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
21092109
nodes[1].node.handle_update_fulfill_htlc(&nodes[2].node.get_our_node_id(), &cs_updates.update_fulfill_htlcs[0]);
@@ -2271,7 +2271,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
22712271
chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
22722272
nodes[0].node.claim_funds(payment_preimage_0);
22732273
check_added_monitors!(nodes[0], 1);
2274-
expect_payment_claimed!(nodes[0], payment_hash_0, 100_000);
2274+
expect_payment_received!(nodes[0], payment_hash_0, 100_000);
22752275

22762276
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &send.msgs[0]);
22772277
nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &send.commitment_msg);
@@ -2455,7 +2455,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
24552455
} else {
24562456
nodes[2].node.claim_funds(payment_preimage);
24572457
check_added_monitors!(nodes[2], 1);
2458-
expect_payment_claimed!(nodes[2], payment_hash, 100_000);
2458+
expect_payment_received!(nodes[2], payment_hash, 100_000);
24592459

24602460
let cs_updates = get_htlc_update_msgs!(nodes[2], nodes[1].node.get_our_node_id());
24612461
assert_eq!(cs_updates.update_fulfill_htlcs.len(), 1);
@@ -2632,15 +2632,15 @@ fn double_temp_error() {
26322632
// `claim_funds` results in a ChannelMonitorUpdate.
26332633
nodes[1].node.claim_funds(payment_preimage_1);
26342634
check_added_monitors!(nodes[1], 1);
2635-
expect_payment_claimed!(nodes[1], payment_hash_1, 1_000_000);
2635+
expect_payment_received!(nodes[1], payment_hash_1, 1_000_000);
26362636
let (funding_tx, latest_update_1, _) = nodes[1].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&channel_id).unwrap().clone();
26372637

26382638
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress);
26392639
// Previously, this would've panicked due to a double-call to `Channel::monitor_update_failed`,
26402640
// which had some asserts that prevented it from being called twice.
26412641
nodes[1].node.claim_funds(payment_preimage_2);
26422642
check_added_monitors!(nodes[1], 1);
2643-
expect_payment_claimed!(nodes[1], payment_hash_2, 1_000_000);
2643+
expect_payment_received!(nodes[1], payment_hash_2, 1_000_000);
26442644
chanmon_cfgs[1].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed);
26452645

26462646
let (_, latest_update_2, _) = nodes[1].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&channel_id).unwrap().clone();

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
38873887
///
38883888
/// While LDK will never claim a payment automatically on your behalf (i.e. without you calling
38893889
/// [`ChannelManager::claim_funds`]), you should still monitor for
3890-
/// [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on
3890+
/// [`events::Event::PaymentReceived`] events even for payments you intend to fail, especially on
38913891
/// startup during which time claims that were in-progress at shutdown may be replayed.
38923892
pub fn fail_htlc_backwards(&self, payment_hash: &PaymentHash) {
38933893
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(&self.total_consistency_lock, &self.persistence_notifier);
@@ -4175,7 +4175,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
41754175
/// [`MessageSendEvent`]s needed to claim the payment.
41764176
///
41774177
/// Note that calling this method does *not* guarantee that the payment has been claimed. You
4178-
/// *must* wait for an [`Event::PaymentClaimed`] event which upon a successful claim will be
4178+
/// *must* wait for an [`Event::PaymentReceived`] event which upon a successful claim will be
41794179
/// provided to your [`EventHandler`] when [`process_pending_events`] is next called.
41804180
///
41814181
/// Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or
@@ -4184,7 +4184,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
41844184
/// the sender "proof-of-payment" when they did not fulfill the full expected payment.
41854185
///
41864186
/// [`Event::PaymentClaimable`]: crate::util::events::Event::PaymentClaimable
4187-
/// [`Event::PaymentClaimed`]: crate::util::events::Event::PaymentClaimed
4187+
/// [`Event::PaymentReceived`]: crate::util::events::Event::PaymentReceived
41884188
/// [`process_pending_events`]: EventsProvider::process_pending_events
41894189
/// [`create_inbound_payment`]: Self::create_inbound_payment
41904190
/// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash
@@ -4302,7 +4302,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
43024302
}
43034303

43044304
if claimed_any_htlcs {
4305-
self.pending_events.lock().unwrap().push(events::Event::PaymentClaimed {
4305+
self.pending_events.lock().unwrap().push(events::Event::PaymentReceived {
43064306
receiver_node_id,
43074307
payment_hash,
43084308
purpose: payment_purpose,
@@ -7736,7 +7736,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
77367736
previous_hop_monitor.provide_payment_preimage(&payment_hash, &payment_preimage, &args.tx_broadcaster, &bounded_fee_estimator, &args.logger);
77377737
}
77387738
}
7739-
pending_events_read.push(events::Event::PaymentClaimed {
7739+
pending_events_read.push(events::Event::PaymentReceived {
77407740
receiver_node_id,
77417741
payment_hash,
77427742
purpose: payment_purpose,
@@ -7959,7 +7959,7 @@ mod tests {
79597959
// payment to be put in the holding cell, which confuses the test utilities. So we exchange the
79607960
// lightning messages manually.
79617961
nodes[1].node.claim_funds(payment_preimage);
7962-
expect_payment_claimed!(nodes[1], our_payment_hash, 200_000);
7962+
expect_payment_received!(nodes[1], our_payment_hash, 200_000);
79637963
check_added_monitors!(nodes[1], 2);
79647964

79657965
let bs_first_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
@@ -8542,7 +8542,7 @@ pub mod bench {
85428542
expect_pending_htlcs_forwardable!(NodeHolder { node: &$node_b });
85438543
expect_payment_claimable!(NodeHolder { node: &$node_b }, payment_hash, payment_secret, 10_000);
85448544
$node_b.claim_funds(payment_preimage);
8545-
expect_payment_claimed!(NodeHolder { node: &$node_b }, payment_hash, 10_000);
8545+
expect_payment_received!(NodeHolder { node: &$node_b }, payment_hash, 10_000);
85468546

85478547
match $node_b.get_and_clear_pending_msg_events().pop().unwrap() {
85488548
MessageSendEvent::UpdateHTLCs { node_id, updates } => {

lightning/src/ln/functional_test_utils.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,12 +1498,12 @@ macro_rules! expect_payment_claimable {
14981498

14991499
#[macro_export]
15001500
#[cfg(any(test, feature = "_bench_unstable", feature = "_test_utils"))]
1501-
macro_rules! expect_payment_claimed {
1501+
macro_rules! expect_payment_received {
15021502
($node: expr, $expected_payment_hash: expr, $expected_recv_value: expr) => {
15031503
let events = $node.node.get_and_clear_pending_events();
15041504
assert_eq!(events.len(), 1);
15051505
match events[0] {
1506-
$crate::util::events::Event::PaymentClaimed { ref payment_hash, amount_msat, .. } => {
1506+
$crate::util::events::Event::PaymentReceived { ref payment_hash, amount_msat, .. } => {
15071507
assert_eq!($expected_payment_hash, *payment_hash);
15081508
assert_eq!($expected_recv_value, amount_msat);
15091509
},
@@ -1838,10 +1838,10 @@ pub fn do_claim_payment_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>,
18381838
let claim_event = expected_paths[0].last().unwrap().node.get_and_clear_pending_events();
18391839
assert_eq!(claim_event.len(), 1);
18401840
match claim_event[0] {
1841-
Event::PaymentClaimed { purpose: PaymentPurpose::SpontaneousPayment(preimage), .. }|
1842-
Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { payment_preimage: Some(preimage), ..}, .. } =>
1841+
Event::PaymentReceived { purpose: PaymentPurpose::SpontaneousPayment(preimage), .. }|
1842+
Event::PaymentReceived { purpose: PaymentPurpose::InvoicePayment { payment_preimage: Some(preimage), ..}, .. } =>
18431843
assert_eq!(preimage, our_payment_preimage),
1844-
Event::PaymentClaimed { purpose: PaymentPurpose::InvoicePayment { .. }, payment_hash, .. } =>
1844+
Event::PaymentReceived { purpose: PaymentPurpose::InvoicePayment { .. }, payment_hash, .. } =>
18451845
assert_eq!(&payment_hash.0, &Sha256::hash(&our_payment_preimage.0)[..]),
18461846
_ => panic!(),
18471847
}

0 commit comments

Comments
 (0)