@@ -33,7 +33,7 @@ use bitcoin::secp256k1::Secp256k1;
33
33
use bitcoin::{secp256k1, Sequence, Weight};
34
34
35
35
use crate::events::FundingInfo;
36
- use crate::blinded_path::message::{AsyncPaymentsContext, MessageContext, OffersContext};
36
+ use crate::blinded_path::message::{MessageContext, OffersContext};
37
37
use crate::blinded_path::NodeIdLookUp;
38
38
use crate::blinded_path::message::{BlindedMessagePath, MessageForwardNode};
39
39
use crate::blinded_path::payment::{BlindedPaymentPath, Bolt12RefundContext, PaymentConstraints, PaymentContext, UnauthenticatedReceiveTlvs};
@@ -72,9 +72,8 @@ use crate::offers::offer::{Offer, OfferBuilder};
72
72
use crate::offers::parse::Bolt12SemanticError;
73
73
use crate::offers::refund::{Refund, RefundBuilder};
74
74
use crate::offers::signer;
75
- use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
76
75
use crate::onion_message::dns_resolution::HumanReadableName;
77
- use crate::onion_message::messenger::{Destination, MessageRouter, Responder, ResponseInstruction, MessageSendInstructions};
76
+ use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions};
78
77
use crate::onion_message::offers::OffersMessage;
79
78
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
80
79
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -87,6 +86,7 @@ use crate::util::ser::TransactionU16LenLimited;
87
86
use crate::util::logger::{Level, Logger, WithContext};
88
87
use crate::util::errors::APIError;
89
88
#[cfg(async_payments)] use {
89
+ crate::blinded_path::message::AsyncPaymentsContext,
90
90
crate::blinded_path::payment::AsyncBolt12OfferContext,
91
91
crate::offers::offer::Amount,
92
92
crate::offers::static_invoice::{DEFAULT_RELATIVE_EXPIRY as STATIC_INVOICE_DEFAULT_RELATIVE_EXPIRY, StaticInvoice, StaticInvoiceBuilder},
@@ -2529,7 +2529,10 @@ where
2529
2529
2530
2530
our_network_pubkey: PublicKey,
2531
2531
2532
- pub(super) inbound_payment_key: inbound_payment::ExpandedKey,
2532
+ /// The [`ExpandedKey`] for use in encrypting and decrypting inbound payment data.
2533
+ ///
2534
+ /// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
2535
+ pub inbound_payment_key: inbound_payment::ExpandedKey,
2533
2536
2534
2537
/// LDK puts the [fake scids] that it generates into namespaces, to identify the type of an
2535
2538
/// incoming payment. To make it harder for a third-party to identify the type of a payment,
@@ -2622,7 +2625,6 @@ where
2622
2625
pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
2623
2626
#[cfg(any(test, feature = "_test_utils"))]
2624
2627
pub(crate) pending_offers_messages: Mutex<Vec<(OffersMessage, MessageSendInstructions)>>,
2625
- pending_async_payments_messages: Mutex<Vec<(AsyncPaymentsMessage, MessageSendInstructions)>>,
2626
2628
2627
2629
/// Tracks the message events that are to be broadcasted when we are connected to some peer.
2628
2630
pending_broadcast_messages: Mutex<Vec<MessageSendEvent>>,
@@ -3555,7 +3557,6 @@ where
3555
3557
funding_batch_states: Mutex::new(BTreeMap::new()),
3556
3558
3557
3559
pending_offers_messages: Mutex::new(Vec::new()),
3558
- pending_async_payments_messages: Mutex::new(Vec::new()),
3559
3560
pending_broadcast_messages: Mutex::new(Vec::new()),
3560
3561
3561
3562
last_days_feerates: Mutex::new(VecDeque::new()),
@@ -4724,45 +4725,6 @@ where
4724
4725
res
4725
4726
}
4726
4727
4727
- #[cfg(async_payments)]
4728
- fn initiate_async_payment(
4729
- &self, invoice: &StaticInvoice, payment_id: PaymentId
4730
- ) -> Result<(), Bolt12PaymentError> {
4731
-
4732
- self.handle_static_invoice_received(invoice, payment_id)?;
4733
-
4734
- let nonce = Nonce::from_entropy_source(&*self.entropy_source);
4735
- let hmac = payment_id.hmac_for_async_payment(nonce, &self.inbound_payment_key);
4736
- let reply_paths = match self.create_blinded_paths(
4737
- MessageContext::AsyncPayments(
4738
- AsyncPaymentsContext::OutboundPayment { payment_id, nonce, hmac }
4739
- )
4740
- ) {
4741
- Ok(paths) => paths,
4742
- Err(()) => {
4743
- self.abandon_payment_with_reason(payment_id, PaymentFailureReason::BlindedPathCreationFailed);
4744
- return Err(Bolt12PaymentError::BlindedPathCreationFailed);
4745
- }
4746
- };
4747
-
4748
- let mut pending_async_payments_messages = self.pending_async_payments_messages.lock().unwrap();
4749
- const HTLC_AVAILABLE_LIMIT: usize = 10;
4750
- reply_paths
4751
- .iter()
4752
- .flat_map(|reply_path| invoice.message_paths().iter().map(move |invoice_path| (invoice_path, reply_path)))
4753
- .take(HTLC_AVAILABLE_LIMIT)
4754
- .for_each(|(invoice_path, reply_path)| {
4755
- let instructions = MessageSendInstructions::WithSpecifiedReplyPath {
4756
- destination: Destination::BlindedPath(invoice_path.clone()),
4757
- reply_path: reply_path.clone(),
4758
- };
4759
- let message = AsyncPaymentsMessage::HeldHtlcAvailable(HeldHtlcAvailable {});
4760
- pending_async_payments_messages.push((message, instructions));
4761
- });
4762
-
4763
- Ok(())
4764
- }
4765
-
4766
4728
#[cfg(async_payments)]
4767
4729
fn send_payment_for_static_invoice(
4768
4730
&self, payment_id: PaymentId
@@ -9900,6 +9862,18 @@ where
9900
9862
self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
9901
9863
}
9902
9864
9865
+ #[cfg(async_payments)]
9866
+ fn handle_static_invoice_received(
9867
+ &self, invoice: &StaticInvoice, payment_id: PaymentId
9868
+ ) -> Result<(), Bolt12PaymentError> {
9869
+ self.handle_static_invoice_received(invoice, payment_id)
9870
+ }
9871
+
9872
+ #[cfg(async_payments)]
9873
+ fn send_payment_for_static_invoice(&self, payment_id: PaymentId) -> Result<(), Bolt12PaymentError> {
9874
+ self.send_payment_for_static_invoice(payment_id)
9875
+ }
9876
+
9903
9877
// ----Temporary Functions----
9904
9878
// Set of functions temporarily moved to OffersMessageCommons for easier
9905
9879
// transition of code from ChannelManager to OffersMessageFlow
@@ -9919,13 +9893,6 @@ where
9919
9893
) -> Result<(), Bolt12SemanticError> {
9920
9894
self.pay_for_offer_intern(offer, quantity, amount_msats, payer_note, payment_id, human_readable_name, create_pending_payment)
9921
9895
}
9922
-
9923
- #[cfg(async_payments)]
9924
- fn initiate_async_payment(
9925
- &self, invoice: &StaticInvoice, payment_id: PaymentId
9926
- ) -> Result<(), Bolt12PaymentError> {
9927
- self.initiate_async_payment(invoice, payment_id)
9928
- }
9929
9896
}
9930
9897
9931
9898
/// Defines the maximum number of [`OffersMessage`] including different reply paths to be sent
@@ -11904,48 +11871,6 @@ where
11904
11871
}
11905
11872
}
11906
11873
11907
- impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11908
- AsyncPaymentsMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11909
- where
11910
- M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
11911
- T::Target: BroadcasterInterface,
11912
- ES::Target: EntropySource,
11913
- NS::Target: NodeSigner,
11914
- SP::Target: SignerProvider,
11915
- F::Target: FeeEstimator,
11916
- R::Target: Router,
11917
- MR::Target: MessageRouter,
11918
- L::Target: Logger,
11919
- {
11920
- fn handle_held_htlc_available(
11921
- &self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
11922
- _responder: Option<Responder>
11923
- ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
11924
- None
11925
- }
11926
-
11927
- fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
11928
- #[cfg(async_payments)] {
11929
- let (payment_id, nonce, hmac) = match _context {
11930
- AsyncPaymentsContext::OutboundPayment { payment_id, hmac, nonce } => {
11931
- (payment_id, nonce, hmac)
11932
- },
11933
- _ => return
11934
- };
11935
- if payment_id.verify_for_async_payment(hmac, nonce, &self.inbound_payment_key).is_err() { return }
11936
- if let Err(e) = self.send_payment_for_static_invoice(payment_id) {
11937
- log_trace!(
11938
- self.logger, "Failed to release held HTLC with payment id {}: {:?}", payment_id, e
11939
- );
11940
- }
11941
- }
11942
- }
11943
-
11944
- fn release_pending_messages(&self) -> Vec<(AsyncPaymentsMessage, MessageSendInstructions)> {
11945
- core::mem::take(&mut self.pending_async_payments_messages.lock().unwrap())
11946
- }
11947
- }
11948
-
11949
11874
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11950
11875
NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11951
11876
where
@@ -13862,7 +13787,6 @@ where
13862
13787
funding_batch_states: Mutex::new(BTreeMap::new()),
13863
13788
13864
13789
pending_offers_messages: Mutex::new(Vec::new()),
13865
- pending_async_payments_messages: Mutex::new(Vec::new()),
13866
13790
13867
13791
pending_broadcast_messages: Mutex::new(Vec::new()),
13868
13792
0 commit comments