@@ -73,7 +73,7 @@ use crate::offers::signer;
73
73
use crate::offers::static_invoice::StaticInvoice;
74
74
use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
75
75
use crate::onion_message::dns_resolution::HumanReadableName;
76
- use crate::onion_message::messenger::{Destination, MessageRouter, Responder, ResponseInstruction, MessageSendInstructions };
76
+ use crate::onion_message::messenger::{DefaultMessageRouter, Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction };
77
77
use crate::onion_message::offers::OffersMessage;
78
78
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
79
79
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -87,13 +87,10 @@ use crate::util::logger::{Level, Logger, WithContext};
87
87
use crate::util::errors::APIError;
88
88
89
89
#[cfg(feature = "dnssec")]
90
- use crate::blinded_path::message::DNSResolverContext;
91
- #[cfg(feature = "dnssec")]
92
- use crate::onion_message::dns_resolution::{DNSResolverMessage, DNSResolverMessageHandler, DNSSECQuery, DNSSECProof, OMNameResolver};
90
+ use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver};
93
91
94
92
#[cfg(not(c_bindings))]
95
93
use {
96
- crate::onion_message::messenger::DefaultMessageRouter,
97
94
crate::routing::router::DefaultRouter,
98
95
crate::routing::gossip::NetworkGraph,
99
96
crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters},
@@ -2397,14 +2394,6 @@ where
2397
2394
#[cfg(feature = "dnssec")]
2398
2395
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
2399
2396
2400
- #[cfg(feature = "_test_utils")]
2401
- /// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
2402
- /// offer generated in the test.
2403
- ///
2404
- /// This allows for doing so, validating proofs as normal, but, if they pass, replacing the
2405
- /// offer they resolve to to the given one.
2406
- pub testing_dnssec_proof_offer_resolution_override: Mutex<HashMap<HumanReadableName, Offer>>,
2407
-
2408
2397
#[cfg(test)]
2409
2398
pub(super) entropy_source: ES,
2410
2399
#[cfg(not(test))]
@@ -3278,9 +3267,6 @@ where
3278
3267
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3279
3268
#[cfg(feature = "dnssec")]
3280
3269
pending_dns_onion_messages: Mutex::new(Vec::new()),
3281
-
3282
- #[cfg(feature = "_test_utils")]
3283
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
3284
3270
}
3285
3271
}
3286
3272
@@ -9514,6 +9500,7 @@ pub trait OffersMessageCommons {
9514
9500
/// Get pending offers messages
9515
9501
fn get_pending_offers_messages(&self) -> MutexGuard<'_, Vec<(OffersMessage, MessageSendInstructions)>>;
9516
9502
9503
+ #[cfg(feature = "dnssec")]
9517
9504
/// Get pending DNS onion messages
9518
9505
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>>;
9519
9506
@@ -9646,6 +9633,16 @@ pub trait OffersMessageCommons {
9646
9633
payer_note: Option<String>, payment_id: PaymentId,
9647
9634
human_readable_name: Option<HumanReadableName>, create_pending_payment: CPP,
9648
9635
) -> Result<(), Bolt12SemanticError>;
9636
+
9637
+ #[cfg(feature = "dnssec")]
9638
+ /// Amount for payment awaiting offer
9639
+ fn amt_msats_for_payment_awaiting_offer(&self, payment_id: PaymentId) -> Result<u64, ()>;
9640
+
9641
+ #[cfg(feature = "dnssec")]
9642
+ /// Received Offer
9643
+ fn received_offer(
9644
+ &self, payment_id: PaymentId, retryable_invoice_request: Option<RetryableInvoiceRequest>,
9645
+ ) -> Result<(), ()>;
9649
9646
}
9650
9647
9651
9648
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref> OffersMessageCommons for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
@@ -9664,6 +9661,7 @@ where
9664
9661
self.pending_offers_messages.lock().expect("Mutex is locked by other thread.")
9665
9662
}
9666
9663
9664
+ #[cfg(feature = "dnssec")]
9667
9665
fn get_pending_dns_onion_messages(&self) -> MutexGuard<'_, Vec<(DNSResolverMessage, MessageSendInstructions)>> {
9668
9666
self.pending_dns_onion_messages.lock().expect("Mutex is locked by other thread.")
9669
9667
}
@@ -9897,6 +9895,18 @@ where
9897
9895
9898
9896
self.enqueue_invoice_request(invoice_request, reply_paths)
9899
9897
}
9898
+
9899
+ #[cfg(feature = "dnssec")]
9900
+ fn amt_msats_for_payment_awaiting_offer(&self, payment_id: PaymentId) -> Result<u64, ()> {
9901
+ self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id)
9902
+ }
9903
+
9904
+ #[cfg(feature = "dnssec")]
9905
+ fn received_offer(
9906
+ &self, payment_id: PaymentId, retryable_invoice_request: Option<RetryableInvoiceRequest>,
9907
+ ) -> Result<(), ()> {
9908
+ self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
9909
+ }
9900
9910
}
9901
9911
9902
9912
/// Defines the maximum number of [`OffersMessage`] including different reply paths to be sent
@@ -11448,69 +11458,6 @@ where
11448
11458
}
11449
11459
}
11450
11460
11451
- #[cfg(feature = "dnssec")]
11452
- impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11453
- DNSResolverMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11454
- where
11455
- M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
11456
- T::Target: BroadcasterInterface,
11457
- ES::Target: EntropySource,
11458
- NS::Target: NodeSigner,
11459
- SP::Target: SignerProvider,
11460
- F::Target: FeeEstimator,
11461
- R::Target: Router,
11462
- MR::Target: MessageRouter,
11463
- L::Target: Logger,
11464
- {
11465
- fn handle_dnssec_query(
11466
- &self, _message: DNSSECQuery, _responder: Option<Responder>,
11467
- ) -> Option<(DNSResolverMessage, ResponseInstruction)> {
11468
- None
11469
- }
11470
-
11471
- fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext) {
11472
- let offer_opt = self.hrn_resolver.handle_dnssec_proof_for_offer(message, context);
11473
- #[cfg_attr(not(feature = "_test_utils"), allow(unused_mut))]
11474
- if let Some((completed_requests, mut offer)) = offer_opt {
11475
- for (name, payment_id) in completed_requests {
11476
- #[cfg(feature = "_test_utils")]
11477
- if let Some(replacement_offer) = self.testing_dnssec_proof_offer_resolution_override.lock().unwrap().remove(&name) {
11478
- // If we have multiple pending requests we may end up over-using the override
11479
- // offer, but tests can deal with that.
11480
- offer = replacement_offer;
11481
- }
11482
- if let Ok(amt_msats) = self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id) {
11483
- let offer_pay_res =
11484
- self.pay_for_offer_intern(&offer, None, Some(amt_msats), None, payment_id, Some(name),
11485
- |invoice_request, nonce| {
11486
- let retryable_invoice_request = RetryableInvoiceRequest {
11487
- invoice_request: invoice_request.clone(),
11488
- nonce,
11489
- };
11490
- self.pending_outbound_payments
11491
- .received_offer(payment_id, Some(retryable_invoice_request))
11492
- .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)
11493
- });
11494
- if offer_pay_res.is_err() {
11495
- // The offer we tried to pay is the canonical current offer for the name we
11496
- // wanted to pay. If we can't pay it, there's no way to recover so fail the
11497
- // payment.
11498
- // Note that the PaymentFailureReason should be ignored for an
11499
- // AwaitingInvoice payment.
11500
- self.pending_outbound_payments.abandon_payment(
11501
- payment_id, PaymentFailureReason::RouteNotFound, &self.pending_events,
11502
- );
11503
- }
11504
- }
11505
- }
11506
- }
11507
- }
11508
-
11509
- fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
11510
- core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
11511
- }
11512
- }
11513
-
11514
11461
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11515
11462
NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11516
11463
where
@@ -13363,9 +13310,6 @@ where
13363
13310
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13364
13311
#[cfg(feature = "dnssec")]
13365
13312
pending_dns_onion_messages: Mutex::new(Vec::new()),
13366
-
13367
- #[cfg(feature = "_test_utils")]
13368
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
13369
13313
};
13370
13314
13371
13315
for (_, monitor) in args.channel_monitors.iter() {
0 commit comments