diff --git a/CHANGELOG.md b/CHANGELOG.md index a1b31e77..75632ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ASB: The maker will take Monero funds needed for ongoing swaps into consideration when making a quote. A warning will be displayed if the Monero funds do not cover all ongoing swaps. +- ASB: Return a zero quote when quoting fails instead of letting the request time out ## [1.1.7] - 2025-06-04 diff --git a/swap/src/asb/event_loop.rs b/swap/src/asb/event_loop.rs index f34f78a9..c1d7d276 100644 --- a/swap/src/asb/event_loop.rs +++ b/swap/src/asb/event_loop.rs @@ -259,8 +259,17 @@ where // The error is already logged in the make_quote_or_use_cached function // We don't log it here to avoid spamming on each request Err(_) => { - // TODO: Respond with the error to Bob. Currently this will timeout on Bob's side. - continue; + // We respond with a zero quote. This will stop Bob from trying to start a swap but doesn't require + // a breaking network change by changing the definition of the quote protocol + if self + .swarm + .behaviour_mut() + .quote + .send_response(channel, BidQuote::ZERO) + .is_err() + { + tracing::debug!(%peer, "Failed to respond with zero quote"); + } } } } diff --git a/swap/src/network/quote.rs b/swap/src/network/quote.rs index 277ceff2..e3e3b1f9 100644 --- a/swap/src/network/quote.rs +++ b/swap/src/network/quote.rs @@ -40,6 +40,15 @@ pub struct BidQuote { pub max_quantity: bitcoin::Amount, } +impl BidQuote { + /// A zero quote with all amounts set to zero + pub const ZERO: Self = Self { + price: bitcoin::Amount::ZERO, + min_quantity: bitcoin::Amount::ZERO, + max_quantity: bitcoin::Amount::ZERO, + }; +} + #[derive(Clone, Copy, Debug, thiserror::Error)] #[error("Received quote of 0")] pub struct ZeroQuoteReceived;