Skip to content

Commit 434d8ce

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 d2a50b0 commit 434d8ce

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
@@ -204,7 +204,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool) {
204204
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
205205
assert_eq!(payment_hash_1, *payment_hash);
206206
assert_eq!(amount_msat, 1_000_000);
207-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
207+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
208208
match &purpose {
209209
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
210210
assert!(payment_preimage.is_none());
@@ -573,7 +573,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
573573
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
574574
assert_eq!(payment_hash_2, *payment_hash);
575575
assert_eq!(amount_msat, 1_000_000);
576-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
576+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
577577
match &purpose {
578578
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
579579
assert!(payment_preimage.is_none());
@@ -691,7 +691,7 @@ fn test_monitor_update_fail_cs() {
691691
Event::PaymentReceived { payment_hash, ref purpose, amount_msat, our_node_id } => {
692692
assert_eq!(payment_hash, our_payment_hash);
693693
assert_eq!(amount_msat, 1_000_000);
694-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
694+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
695695
match &purpose {
696696
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
697697
assert!(payment_preimage.is_none());
@@ -1666,7 +1666,7 @@ fn test_monitor_update_fail_claim() {
16661666
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
16671667
assert_eq!(payment_hash_2, *payment_hash);
16681668
assert_eq!(1_000_000, amount_msat);
1669-
assert_eq!(our_node_id, nodes[0].node.get_our_node_id());
1669+
assert_eq!(our_node_id.unwrap(), nodes[0].node.get_our_node_id());
16701670
match &purpose {
16711671
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
16721672
assert!(payment_preimage.is_none());
@@ -1681,7 +1681,7 @@ fn test_monitor_update_fail_claim() {
16811681
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
16821682
assert_eq!(payment_hash_3, *payment_hash);
16831683
assert_eq!(1_000_000, amount_msat);
1684-
assert_eq!(our_node_id, nodes[0].node.get_our_node_id());
1684+
assert_eq!(our_node_id.unwrap(), nodes[0].node.get_our_node_id());
16851685
match &purpose {
16861686
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
16871687
assert!(payment_preimage.is_none());

lightning/src/ln/channelmanager.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3360,7 +3360,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
33603360
} else if total_value == $payment_data.total_msat {
33613361
htlcs.push(claimable_htlc);
33623362
new_events.push(events::Event::PaymentReceived {
3363-
our_node_id: self.our_network_pubkey,
3363+
our_node_id: Some(self.our_network_pubkey),
33643364
payment_hash,
33653365
purpose: purpose(),
33663366
amount_msat: total_value,
@@ -3403,7 +3403,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
34033403
let purpose = events::PaymentPurpose::SpontaneousPayment(preimage);
34043404
e.insert((purpose.clone(), vec![claimable_htlc]));
34053405
new_events.push(events::Event::PaymentReceived {
3406-
our_node_id: self.our_network_pubkey,
3406+
our_node_id: Some(self.our_network_pubkey),
34073407
payment_hash,
34083408
amount_msat: amt_to_forward,
34093409
purpose,
@@ -4101,7 +4101,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
41014101

41024102
if claimed_any_htlcs {
41034103
self.pending_events.lock().unwrap().push(events::Event::PaymentClaimed {
4104-
our_node_id: self.our_network_pubkey,
4104+
our_node_id: Some(self.our_network_pubkey),
41054105
payment_hash,
41064106
purpose: payment_purpose,
41074107
amount_msat: claimable_amt_msat,
@@ -7228,7 +7228,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
72287228
}
72297229
}
72307230
pending_events_read.push(events::Event::PaymentClaimed {
7231-
our_node_id: our_network_pubkey,
7231+
our_node_id: Some(our_network_pubkey),
72327232
payment_hash,
72337233
purpose: payment_purpose,
72347234
amount_msat: claimable_amt_msat,

lightning/src/ln/functional_test_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ macro_rules! expect_payment_received {
13831383
$crate::util::events::Event::PaymentReceived {ref payment_hash, ref purpose, amount_msat, our_node_id } => {
13841384
assert_eq!($expected_payment_hash, *payment_hash);
13851385
assert_eq!($expected_recv_value, amount_msat);
1386-
assert_eq!($node.node.get_our_node_id(), our_node_id);
1386+
assert_eq!($node.node.get_our_node_id(), our_node_id.unwrap());
13871387
match purpose {
13881388
$crate::util::events::PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
13891389
assert_eq!(&$expected_payment_preimage, payment_preimage);
@@ -1663,7 +1663,7 @@ pub fn do_pass_along_path<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_p
16631663
match events_2[0] {
16641664
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
16651665
assert_eq!(our_payment_hash, *payment_hash);
1666-
assert_eq!(node.node.get_our_node_id(), our_node_id);
1666+
assert_eq!(node.node.get_our_node_id(), our_node_id.unwrap());
16671667
match &purpose {
16681668
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
16691669
assert_eq!(expected_preimage, *payment_preimage);

lightning/src/ln/functional_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
19581958
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
19591959
assert_eq!(our_payment_hash_21, *payment_hash);
19601960
assert_eq!(recv_value_21, amount_msat);
1961-
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id);
1961+
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id.unwrap());
19621962
match &purpose {
19631963
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
19641964
assert!(payment_preimage.is_none());
@@ -1973,7 +1973,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
19731973
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
19741974
assert_eq!(our_payment_hash_22, *payment_hash);
19751975
assert_eq!(recv_value_22, amount_msat);
1976-
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id);
1976+
assert_eq!(nodes[2].node.get_our_node_id(), our_node_id.unwrap());
19771977
match &purpose {
19781978
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
19791979
assert!(payment_preimage.is_none());
@@ -3731,7 +3731,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8, simulate_broken
37313731
Event::PaymentReceived { ref payment_hash, ref purpose, amount_msat, our_node_id } => {
37323732
assert_eq!(payment_hash_1, *payment_hash);
37333733
assert_eq!(amount_msat, 1_000_000);
3734-
assert_eq!(our_node_id, nodes[1].node.get_our_node_id());
3734+
assert_eq!(our_node_id.unwrap(), nodes[1].node.get_our_node_id());
37353735
match &purpose {
37363736
PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
37373737
assert!(payment_preimage.is_none());

lightning/src/util/events.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub enum Event {
250250
/// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
251251
PaymentReceived {
252252
/// The node that recieved the payment, ie our node
253-
our_node_id: PublicKey,
253+
our_node_id: Option<PublicKey>,
254254
/// The hash for which the preimage should be handed to the ChannelManager. Note that LDK will
255255
/// not stop you from registering duplicate payment hashes for inbound payments.
256256
payment_hash: PaymentHash,
@@ -276,7 +276,7 @@ pub enum Event {
276276
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
277277
PaymentClaimed {
278278
/// The node that recieved the payment, ie our node
279-
our_node_id: PublicKey,
279+
our_node_id: Option<PublicKey>,
280280
/// The payment hash of the claimed payment. Note that LDK will not stop you from
281281
/// registering duplicate payment hashes for inbound payments.
282282
payment_hash: PaymentHash,
@@ -635,7 +635,7 @@ impl Writeable for Event {
635635
(4, amount_msat, required),
636636
(6, 0u64, required), // user_payment_id required for compatibility with 0.0.103 and earlier
637637
(8, payment_preimage, option),
638-
(10, our_node_id, required),
638+
(10, our_node_id, option),
639639
});
640640
},
641641
&Event::PaymentSent { ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat } => {
@@ -732,7 +732,7 @@ impl Writeable for Event {
732732
(0, payment_hash, required),
733733
(2, purpose, required),
734734
(4, amount_msat, required),
735-
(6, our_node_id, required),
735+
(6, our_node_id, option),
736736
});
737737
},
738738
&Event::ProbeSuccessful { ref payment_id, ref payment_hash, ref path } => {
@@ -797,7 +797,7 @@ impl MaybeReadable for Event {
797797
None => return Err(msgs::DecodeError::InvalidValue),
798798
};
799799
Ok(Some(Event::PaymentReceived {
800-
our_node_id: our_node_id.unwrap(),
800+
our_node_id,
801801
payment_hash,
802802
amount_msat,
803803
purpose,
@@ -972,12 +972,12 @@ impl MaybeReadable for Event {
972972
(0, payment_hash, required),
973973
(2, purpose, ignorable),
974974
(4, amount_msat, required),
975-
(6, our_node_id, required),
975+
(6, our_node_id, option),
976976
});
977977
if purpose.is_none() { return Ok(None); }
978978

979979
Ok(Some(Event::PaymentClaimed {
980-
our_node_id: our_node_id.unwrap(),
980+
our_node_id,
981981
payment_hash,
982982
purpose: purpose.unwrap(),
983983
amount_msat,

0 commit comments

Comments
 (0)