Skip to content

Commit 9705a65

Browse files
committed
Move create_offer_builder to OffersMessageFlow
1 parent baee2d5 commit 9705a65

15 files changed

+301
-221
lines changed

fuzz/src/chanmon_consistency.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use lightning::events::MessageSendEventsProvider;
4747
use lightning::ln::channel::FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE;
4848
use lightning::ln::channel_state::ChannelDetails;
4949
use lightning::ln::channelmanager::{
50-
ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId, PaymentSendFailure,
51-
RecipientOnionFields,
50+
ChainParameters, ChannelManager, ChannelManagerReadArgs, OffersMessageCommons, PaymentId,
51+
PaymentSendFailure, RecipientOnionFields,
5252
};
5353
use lightning::ln::functional_test_utils::*;
5454
use lightning::ln::msgs::{

fuzz/src/full_stack.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen};
4040
use lightning::events::Event;
4141
use lightning::ln::channel_state::ChannelDetails;
4242
use lightning::ln::channelmanager::{
43-
ChainParameters, ChannelManager, InterceptId, PaymentId, RecipientOnionFields, Retry,
43+
ChainParameters, ChannelManager, InterceptId, OffersMessageCommons, PaymentId,
44+
RecipientOnionFields, Retry,
4445
};
4546
use lightning::ln::functional_test_utils::*;
4647
use lightning::ln::msgs::{self, DecodeError};

lightning-dns-resolver/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ mod test {
162162
use lightning::blinded_path::message::{BlindedMessagePath, MessageContext};
163163
use lightning::blinded_path::NodeIdLookUp;
164164
use lightning::events::{Event, PaymentPurpose};
165-
use lightning::ln::channelmanager::{PaymentId, Retry};
165+
use lightning::ln::channelmanager::{OffersMessageCommons, PaymentId, Retry};
166166
use lightning::ln::functional_test_utils::*;
167167
use lightning::ln::msgs::{ChannelMessageHandler, Init, OnionMessageHandler};
168168
use lightning::ln::peer_handler::IgnoringMessageHandler;
@@ -391,7 +391,7 @@ mod test {
391391
let name = HumanReadableName::from_encoded("[email protected]").unwrap();
392392

393393
// When we get the proof back, override its contents to an offer from nodes[1]
394-
let bs_offer = nodes[1].node.create_offer_builder(None).unwrap().build().unwrap();
394+
let bs_offer = nodes[1].offers_handler.create_offer_builder(None).unwrap().build().unwrap();
395395
nodes[0]
396396
.node
397397
.testing_dnssec_proof_offer_resolution_override

lightning/src/chain/chainmonitor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ impl<ChannelSigner: EcdsaChannelSigner, C: Deref, T: Deref, F: Deref, L: Deref,
921921

922922
#[cfg(test)]
923923
mod tests {
924+
use crate::ln::channelmanager::OffersMessageCommons;
924925
use crate::{check_added_monitors, check_closed_event};
925926
use crate::{expect_payment_path_successful, get_event_msg};
926927
use crate::{get_htlc_update_msgs, get_revoke_commit_msgs};

lightning/src/events/mod.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ pub enum PaymentPurpose {
8989
Bolt11InvoicePayment {
9090
/// The preimage to the payment_hash, if the payment hash (and secret) were fetched via
9191
/// [`OffersMessageCommons::create_inbound_payment`]. When handling [`Event::PaymentClaimable`],
92-
/// this can be passed directly to [`ChannelManager::claim_funds`] to claim the payment. No
92+
/// this can be passed directly to [`OffersMessageCommons::claim_funds`] to claim the payment. No
9393
/// action is needed when seen in [`Event::PaymentClaimed`].
9494
///
9595
/// [`OffersMessageCommons::create_inbound_payment`]: crate::ln::channelmanager::OffersMessageCommons::create_inbound_payment
96-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
96+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
9797
payment_preimage: Option<PaymentPreimage>,
9898
/// The "payment secret". This authenticates the sender to the recipient, preventing a
9999
/// number of deanonymization attacks during the routing process.
@@ -112,10 +112,10 @@ pub enum PaymentPurpose {
112112
/// [`Offer`]: crate::offers::offer::Offer
113113
Bolt12OfferPayment {
114114
/// The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be
115-
/// passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed
115+
/// passed directly to [`OffersMessageCommons::claim_funds`], if provided. No action is needed
116116
/// when seen in [`Event::PaymentClaimed`].
117117
///
118-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
118+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
119119
payment_preimage: Option<PaymentPreimage>,
120120
/// The secret used to authenticate the sender to the recipient, preventing a number of
121121
/// de-anonymization attacks while routing a payment.
@@ -138,10 +138,10 @@ pub enum PaymentPurpose {
138138
/// [`Refund`]: crate::offers::refund::Refund
139139
Bolt12RefundPayment {
140140
/// The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be
141-
/// passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed
141+
/// passed directly to [`OffersMessageCommons::claim_funds`], if provided. No action is needed
142142
/// when seen in [`Event::PaymentClaimed`].
143143
///
144-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
144+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
145145
payment_preimage: Option<PaymentPreimage>,
146146
/// The secret used to authenticate the sender to the recipient, preventing a number of
147147
/// de-anonymization attacks while routing a payment.
@@ -678,7 +678,7 @@ pub enum Event {
678678
former_temporary_channel_id: ChannelId,
679679
},
680680
/// Indicates that we've been offered a payment and it needs to be claimed via calling
681-
/// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`].
681+
/// [`OffersMessageCommons::claim_funds`] with the preimage given in [`PaymentPurpose`].
682682
///
683683
/// Note that if the preimage is not known, you should call
684684
/// [`ChannelManager::fail_htlc_backwards`] or [`ChannelManager::fail_htlc_backwards_with_reason`]
@@ -689,9 +689,9 @@ pub enum Event {
689689
/// [`FailureCode::InvalidOnionPayload`] if you fail to understand and handle the contents, or
690690
/// [`ChannelManager::claim_funds_with_known_custom_tlvs`] upon successful handling.
691691
/// If you don't intend to check for custom TLVs, you can simply use
692-
/// [`ChannelManager::claim_funds`], which will automatically fail back even custom TLVs.
692+
/// [`OffersMessageCommons::claim_funds`], which will automatically fail back even custom TLVs.
693693
///
694-
/// If you fail to call [`ChannelManager::claim_funds`],
694+
/// If you fail to call [`OffersMessageCommons::claim_funds`],
695695
/// [`ChannelManager::claim_funds_with_known_custom_tlvs`],
696696
/// [`ChannelManager::fail_htlc_backwards`], or
697697
/// [`ChannelManager::fail_htlc_backwards_with_reason`] within the HTLC's timeout, the HTLC will
@@ -710,7 +710,7 @@ pub enum Event {
710710
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
711711
/// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
712712
///
713-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
713+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
714714
/// [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs
715715
/// [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload
716716
/// [`ChannelManager::fail_htlc_backwards`]: crate::ln::channelmanager::ChannelManager::fail_htlc_backwards
@@ -760,10 +760,10 @@ pub enum Event {
760760
/// The block height at which this payment will be failed back and will no longer be
761761
/// eligible for claiming.
762762
///
763-
/// Prior to this height, a call to [`ChannelManager::claim_funds`] is guaranteed to
763+
/// Prior to this height, a call to [`OffersMessageCommons::claim_funds`] is guaranteed to
764764
/// succeed, however you should wait for [`Event::PaymentClaimed`] to be sure.
765765
///
766-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
766+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
767767
claim_deadline: Option<u32>,
768768
/// A unique ID describing this payment (derived from the list of HTLCs in the payment).
769769
///
@@ -776,22 +776,22 @@ pub enum Event {
776776
},
777777
/// Indicates a payment has been claimed and we've received money!
778778
///
779-
/// This most likely occurs when [`ChannelManager::claim_funds`] has been called in response
779+
/// This most likely occurs when [`OffersMessageCommons::claim_funds`] has been called in response
780780
/// to an [`Event::PaymentClaimable`]. However, if we previously crashed during a
781-
/// [`ChannelManager::claim_funds`] call you may see this event without a corresponding
781+
/// [`OffersMessageCommons::claim_funds`] call you may see this event without a corresponding
782782
/// [`Event::PaymentClaimable`] event.
783783
///
784784
/// # Note
785785
/// LDK will not stop an inbound payment from being paid multiple times, so multiple
786786
/// `PaymentClaimable` events may be generated for the same payment. If you then call
787-
/// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
787+
/// [`OffersMessageCommons::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get
788788
/// multiple `PaymentClaimed` events.
789789
///
790790
/// # Failure Behavior and Persistence
791791
/// This event will eventually be replayed after failures-to-handle (i.e., the event handler
792792
/// returning `Err(ReplayEvent ())`) and will be persisted across restarts.
793793
///
794-
/// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds
794+
/// [`OffersMessageCommons::claim_funds`]: crate::ln::channelmanager::OffersMessageCommons::claim_funds
795795
PaymentClaimed {
796796
/// The node that received the payment.
797797
/// This is useful to identify payments which were received via [phantom nodes].

lightning/src/ln/blinded_payment_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::blinded_path::payment::{BlindedPaymentPath, PaymentForwardNode, Forwa
1616
use crate::events::{Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider, PaymentFailureReason};
1717
use crate::ln::types::ChannelId;
1818
use crate::types::payment::{PaymentHash, PaymentSecret};
19-
use crate::ln::channelmanager;
19+
use crate::ln::channelmanager::{self, OffersMessageCommons};
2020
use crate::ln::channelmanager::{HTLCFailureMsg, PaymentId, RecipientOnionFields};
2121
use crate::types::features::{BlindedHopFeatures, ChannelFeatures, NodeFeatures};
2222
use crate::ln::functional_test_utils::*;

lightning/src/ln/chanmon_update_fail_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor};
1919
use crate::chain::transaction::OutPoint;
2020
use crate::chain::{ChannelMonitorUpdateStatus, Listen, Watch};
2121
use crate::events::{Event, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose, ClosureReason, HTLCDestination};
22-
use crate::ln::channelmanager::{RAACommitmentOrder, PaymentSendFailure, PaymentId, RecipientOnionFields};
22+
use crate::ln::channelmanager::{OffersMessageCommons, PaymentId, PaymentSendFailure, RAACommitmentOrder, RecipientOnionFields};
2323
use crate::ln::channel::{AnnouncementSigsState, ChannelPhase};
2424
use crate::ln::msgs;
2525
use crate::ln::types::ChannelId;

0 commit comments

Comments
 (0)