@@ -76,7 +76,7 @@ use crate::offers::signer;
76
76
use crate::offers::static_invoice::StaticInvoice;
77
77
use crate::onion_message::async_payments::{AsyncPaymentsMessage, HeldHtlcAvailable, ReleaseHeldHtlc, AsyncPaymentsMessageHandler};
78
78
use crate::onion_message::dns_resolution::HumanReadableName;
79
- use crate::onion_message::messenger::{Destination, MessageRouter, Responder, ResponseInstruction, MessageSendInstructions };
79
+ use crate::onion_message::messenger::{DefaultMessageRouter, Destination, MessageRouter, MessageSendInstructions, Responder, ResponseInstruction };
80
80
use crate::onion_message::offers::OffersMessage;
81
81
use crate::sign::{EntropySource, NodeSigner, Recipient, SignerProvider};
82
82
use crate::sign::ecdsa::EcdsaChannelSigner;
@@ -90,13 +90,10 @@ use crate::util::logger::{Level, Logger, WithContext};
90
90
use crate::util::errors::APIError;
91
91
92
92
#[cfg(feature = "dnssec")]
93
- use crate::blinded_path::message::DNSResolverContext;
94
- #[cfg(feature = "dnssec")]
95
- use crate::onion_message::dns_resolution::{DNSResolverMessage, DNSResolverMessageHandler, DNSSECQuery, DNSSECProof, OMNameResolver};
93
+ use crate::onion_message::dns_resolution::{DNSResolverMessage, OMNameResolver};
96
94
97
95
#[cfg(not(c_bindings))]
98
96
use {
99
- crate::onion_message::messenger::DefaultMessageRouter,
100
97
crate::routing::router::DefaultRouter,
101
98
crate::routing::gossip::NetworkGraph,
102
99
crate::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringFeeParameters},
@@ -2426,14 +2423,6 @@ where
2426
2423
#[cfg(feature = "dnssec")]
2427
2424
pending_dns_onion_messages: Mutex<Vec<(DNSResolverMessage, MessageSendInstructions)>>,
2428
2425
2429
- #[cfg(feature = "_test_utils")]
2430
- /// In testing, it is useful be able to forge a name -> offer mapping so that we can pay an
2431
- /// offer generated in the test.
2432
- ///
2433
- /// This allows for doing so, validating proofs as normal, but, if they pass, replacing the
2434
- /// offer they resolve to to the given one.
2435
- pub testing_dnssec_proof_offer_resolution_override: Mutex<HashMap<HumanReadableName, Offer>>,
2436
-
2437
2426
#[cfg(test)]
2438
2427
pub(super) entropy_source: ES,
2439
2428
#[cfg(not(test))]
@@ -3364,9 +3353,6 @@ where
3364
3353
hrn_resolver: OMNameResolver::new(current_timestamp, params.best_block.height),
3365
3354
#[cfg(feature = "dnssec")]
3366
3355
pending_dns_onion_messages: Mutex::new(Vec::new()),
3367
-
3368
- #[cfg(feature = "_test_utils")]
3369
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
3370
3356
}
3371
3357
}
3372
3358
@@ -9871,6 +9857,18 @@ where
9871
9857
9872
9858
self.enqueue_invoice_request(invoice_request, reply_paths)
9873
9859
}
9860
+
9861
+ #[cfg(feature = "dnssec")]
9862
+ fn amt_msats_for_payment_awaiting_offer(&self, payment_id: PaymentId) -> Result<u64, ()> {
9863
+ self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id)
9864
+ }
9865
+
9866
+ #[cfg(feature = "dnssec")]
9867
+ fn received_offer(
9868
+ &self, payment_id: PaymentId, retryable_invoice_request: Option<RetryableInvoiceRequest>,
9869
+ ) -> Result<(), ()> {
9870
+ self.pending_outbound_payments.received_offer(payment_id, retryable_invoice_request)
9871
+ }
9874
9872
}
9875
9873
9876
9874
/// Defines the maximum number of [`OffersMessage`] including different reply paths to be sent
@@ -11430,69 +11428,6 @@ where
11430
11428
}
11431
11429
}
11432
11430
11433
- #[cfg(feature = "dnssec")]
11434
- impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11435
- DNSResolverMessageHandler for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11436
- where
11437
- M::Target: chain::Watch<<SP::Target as SignerProvider>::EcdsaSigner>,
11438
- T::Target: BroadcasterInterface,
11439
- ES::Target: EntropySource,
11440
- NS::Target: NodeSigner,
11441
- SP::Target: SignerProvider,
11442
- F::Target: FeeEstimator,
11443
- R::Target: Router,
11444
- MR::Target: MessageRouter,
11445
- L::Target: Logger,
11446
- {
11447
- fn handle_dnssec_query(
11448
- &self, _message: DNSSECQuery, _responder: Option<Responder>,
11449
- ) -> Option<(DNSResolverMessage, ResponseInstruction)> {
11450
- None
11451
- }
11452
-
11453
- fn handle_dnssec_proof(&self, message: DNSSECProof, context: DNSResolverContext) {
11454
- let offer_opt = self.hrn_resolver.handle_dnssec_proof_for_offer(message, context);
11455
- #[cfg_attr(not(feature = "_test_utils"), allow(unused_mut))]
11456
- if let Some((completed_requests, mut offer)) = offer_opt {
11457
- for (name, payment_id) in completed_requests {
11458
- #[cfg(feature = "_test_utils")]
11459
- if let Some(replacement_offer) = self.testing_dnssec_proof_offer_resolution_override.lock().unwrap().remove(&name) {
11460
- // If we have multiple pending requests we may end up over-using the override
11461
- // offer, but tests can deal with that.
11462
- offer = replacement_offer;
11463
- }
11464
- if let Ok(amt_msats) = self.pending_outbound_payments.amt_msats_for_payment_awaiting_offer(payment_id) {
11465
- let offer_pay_res =
11466
- self.pay_for_offer_intern(&offer, None, Some(amt_msats), None, payment_id, Some(name),
11467
- |invoice_request, nonce| {
11468
- let retryable_invoice_request = RetryableInvoiceRequest {
11469
- invoice_request: invoice_request.clone(),
11470
- nonce,
11471
- };
11472
- self.pending_outbound_payments
11473
- .received_offer(payment_id, Some(retryable_invoice_request))
11474
- .map_err(|_| Bolt12SemanticError::DuplicatePaymentId)
11475
- });
11476
- if offer_pay_res.is_err() {
11477
- // The offer we tried to pay is the canonical current offer for the name we
11478
- // wanted to pay. If we can't pay it, there's no way to recover so fail the
11479
- // payment.
11480
- // Note that the PaymentFailureReason should be ignored for an
11481
- // AwaitingInvoice payment.
11482
- self.pending_outbound_payments.abandon_payment(
11483
- payment_id, PaymentFailureReason::RouteNotFound, &self.pending_events,
11484
- );
11485
- }
11486
- }
11487
- }
11488
- }
11489
- }
11490
-
11491
- fn release_pending_messages(&self) -> Vec<(DNSResolverMessage, MessageSendInstructions)> {
11492
- core::mem::take(&mut self.pending_dns_onion_messages.lock().unwrap())
11493
- }
11494
- }
11495
-
11496
11431
impl<M: Deref, T: Deref, ES: Deref, NS: Deref, SP: Deref, F: Deref, R: Deref, MR: Deref, L: Deref>
11497
11432
NodeIdLookUp for ChannelManager<M, T, ES, NS, SP, F, R, MR, L>
11498
11433
where
@@ -13372,9 +13307,6 @@ where
13372
13307
hrn_resolver: OMNameResolver::new(highest_seen_timestamp, best_block_height),
13373
13308
#[cfg(feature = "dnssec")]
13374
13309
pending_dns_onion_messages: Mutex::new(Vec::new()),
13375
-
13376
- #[cfg(feature = "_test_utils")]
13377
- testing_dnssec_proof_offer_resolution_override: Mutex::new(new_hash_map()),
13378
13310
};
13379
13311
13380
13312
for (_, monitor) in args.channel_monitors.iter() {
0 commit comments