Skip to content

Commit 671aeac

Browse files
committed
Revert "makes our_node_id not be an Option<>, this forces it to be required"
Keeps our_node_id as optional This reverts commit d2a50b0.
1 parent d01ddf8 commit 671aeac

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
203203
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
204204
assert_eq!(payment_hash_1, *payment_hash);
205205
assert_eq!(amount_msat, 1_000_000);
206-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
206+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
207207
match &purpose {
208208
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
209209
assert!(payment_preimage.is_none());
@@ -572,7 +572,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
572572
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
573573
assert_eq!(payment_hash_2, *payment_hash);
574574
assert_eq!(amount_msat, 1_000_000);
575-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
575+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
576576
match &purpose {
577577
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
578578
assert!(payment_preimage.is_none());
@@ -690,7 +690,7 @@ fn test_monitor_update_fail_cs() {
690690
Event::PaymentReceived { payment_hash, ref purpose, amount_msat, our_node_id } => {
691691
assert_eq!(payment_hash, our_payment_hash);
692692
assert_eq!(amount_msat, 1_000_000);
693-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
693+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
694694
match &purpose {
695695
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
696696
assert!(payment_preimage.is_none());
@@ -1665,7 +1665,7 @@ fn test_monitor_update_fail_claim() {
16651665
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
16661666
assert_eq!(payment_hash_2, *payment_hash);
16671667
assert_eq!(1_000_000, amount_msat);
1668-
assert_eq!(our_node_id, nodes[0].node.get_our_node_id());
1668+
assert_eq!(our_node_id.unwrap(), nodes[0].node.get_our_node_id());
16691669
match &purpose {
16701670
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
16711671
assert!(payment_preimage.is_none());
@@ -1680,7 +1680,7 @@ fn test_monitor_update_fail_claim() {
16801680
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
16811681
assert_eq!(payment_hash_3, *payment_hash);
16821682
assert_eq!(1_000_000, amount_msat);
1683-
assert_eq!(our_node_id, nodes[0].node.get_our_node_id());
1683+
assert_eq!(our_node_id.unwrap(), nodes[0].node.get_our_node_id());
16841684
match &purpose {
16851685
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
16861686
assert!(payment_preimage.is_none());

lightning/src/ln/channelmanager.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
34863486
} else if total_value == $payment_data.total_msat {
34873487
htlcs.push(claimable_htlc);
34883488
new_events.push(events::Event::PaymentReceived {
3489-
our_node_id: self.our_network_pubkey,
3489+
our_node_id: Some(self.our_network_pubkey),
34903490
payment_hash,
34913491
purpose: purpose(),
34923492
amount_msat: total_value,
@@ -3529,7 +3529,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
35293529
let purpose = events::PaymentPurpose::SpontaneousPayment(preimage);
35303530
e.insert((purpose.clone(), vec![claimable_htlc]));
35313531
new_events.push(events::Event::PaymentReceived {
3532-
our_node_id: self.our_network_pubkey,
3532+
our_node_id: Some(self.our_network_pubkey),
35333533
payment_hash,
35343534
amount_msat: outgoing_amt_msat,
35353535
purpose,
@@ -4276,7 +4276,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
42764276

42774277
if claimed_any_htlcs {
42784278
self.pending_events.lock().unwrap().push(events::Event::PaymentClaimed {
4279-
our_node_id: self.our_network_pubkey,
4279+
our_node_id: Some(self.our_network_pubkey),
42804280
payment_hash,
42814281
purpose: payment_purpose,
42824282
amount_msat: claimable_amt_msat,
@@ -7517,7 +7517,7 @@ impl<'a, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
75177517
}
75187518
}
75197519
pending_events_read.push(events::Event::PaymentClaimed {
7520-
our_node_id: our_network_pubkey,
7520+
our_node_id: Some(our_network_pubkey),
75217521
payment_hash,
75227522
purpose: payment_purpose,
75237523
amount_msat: claimable_amt_msat,

lightning/src/ln/functional_test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ macro_rules! expect_payment_received {
14471447
$crate::util::events::Event::PaymentReceived {ref payment_hash, ref purpose, amount_msat, our_node_id } => {
14481448
assert_eq!($expected_payment_hash, *payment_hash);
14491449
assert_eq!($expected_recv_value, amount_msat);
1450-
assert_eq!($node.node.get_our_node_id(), our_node_id);
1450+
assert_eq!($node.node.get_our_node_id(), our_node_id.unwrap());
14511451
match purpose {
14521452
$crate::util::events::PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
14531453
assert_eq!(&$expected_payment_preimage, payment_preimage);
@@ -1741,7 +1741,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_p
17411741
match events_2[0] {
17421742
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
17431743
assert_eq!(our_payment_hash, *payment_hash);
1744-
assert_eq!(node.node.get_our_node_id(), our_node_id);
1744+
assert_eq!(node.node.get_our_node_id(), our_node_id.unwrap());
17451745
match &purpose {
17461746
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
17471747
assert_eq!(expected_preimage, *payment_preimage);

lightning/src/ln/functional_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
19591959
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
19601960
assert_eq!(our_payment_hash_21, *payment_hash);
19611961
assert_eq!(recv_value_21, amount_msat);
1962-
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id);
1962+
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id.unwrap());
19631963
match &purpose {
19641964
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
19651965
assert!(payment_preimage.is_none());
@@ -1974,7 +1974,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
19741974
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
19751975
assert_eq!(our_payment_hash_22, *payment_hash);
19761976
assert_eq!(recv_value_22, amount_msat);
1977-
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id);
1977+
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id.unwrap());
19781978
match &purpose {
19791979
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
19801980
assert!(payment_preimage.is_none());
@@ -3728,7 +3728,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
37283728
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
37293729
assert_eq!(payment_hash_1, *payment_hash);
37303730
assert_eq!(amount_msat, 1_000_000);
3731-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
3731+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
37323732
match &purpose {
37333733
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
37343734
assert!(payment_preimage.is_none());

lightning/src/util/events.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ pub enum Event {
343343
/// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
344344
PaymentReceived {
345345
/// The node that recieved the payment, ie our node
346-
our_node_id: PublicKey,
346+
our_node_id: Option<PublicKey>,
347347
/// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
348348
/// not stop you from registering duplicate payment hashes for inbound payments.
349349
payment_hash: PaymentHash,
@@ -369,7 +369,7 @@ pub enum Event {
369369
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
370370
PaymentClaimed {
371371
/// The node that recieved the payment, ie our node
372-
our_node_id: PublicKey,
372+
our_node_id: Option<PublicKey>,
373373
/// The payment hash of the claimed payment. Note that LDK will not stop you from
374374
/// registering duplicate payment hashes for inbound payments.
375375
payment_hash: PaymentHash,
@@ -762,7 +762,7 @@ impl Writeable for Event {
762762
(4, amount_msat, required),
763763
(6, 0u64, required), // user_payment_id required for compatibility with 0.0.103 and earlier
764764
(8, payment_preimage, option),
765-
(10, our_node_id, required),
765+
(10, our_node_id, option),
766766
});
767767
},
768768
&Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
@@ -865,7 +865,7 @@ impl Writeable for Event {
865865
(0, payment_hash, required),
866866
(2, purpose, required),
867867
(4, amount_msat, required),
868-
(6, our_node_id, required),
868+
(6, our_node_id, option),
869869
});
870870
},
871871
&Event::ProbeSuccessful { ref payment_id, ref payment_hash, ref path } => {
@@ -948,7 +948,7 @@ impl MaybeReadable for Event {
948948
None => return Err(msgs::DecodeError::InvalidValue),
949949
};
950950
Ok(Some(Event::PaymentReceived {
951-
our_node_id: our_node_id.unwrap(),
951+
our_node_id,
952952
payment_hash,
953953
amount_msat,
954954
purpose,
@@ -1131,12 +1131,12 @@ impl MaybeReadable for Event {
11311131
(0, payment_hash, required),
11321132
(2, purpose, ignorable),
11331133
(4, amount_msat, required),
1134-
(6, our_node_id, required),
1134+
(6, our_node_id, option),
11351135
});
11361136
if purpose.is_none() { return Ok(None); }
11371137

11381138
Ok(Some(Event::PaymentClaimed {
1139-
our_node_id: our_node_id.unwrap(),
1139+
our_node_id,
11401140
payment_hash,
11411141
purpose: purpose.unwrap(),
11421142
amount_msat,

0 commit comments

Comments
 (0)