From e7b70212da546c47d1cb4b701bb36d35e1541894 Mon Sep 17 00:00:00 2001 From: Edward Houston Date: Fri, 7 Aug 2026 12:34:23 +0200 Subject: [PATCH] Add TooManyUtxos error kind for utxos-limit failures The UTXO set computation in utxo_delta reused ErrorKind::TooPopular, whose display string is "Too many history entries". That message names the wrong limit: the check fires when the UTXO set exceeds utxos-limit during history replay, independent of history entry count. On deployments where electrum-txs-limit is raised but utxos-limit is not, an address could serve its full history while /address/:addr/utxo and listunspent failed with a message blaming history size. Raise a distinct TooManyUtxos kind ("Too many unspent outputs") from utxo_delta and map it to the same Electrum BadRequest code, leaving TooPopular for the Electrum history checks. Fixes #242 --- src/electrum/server.rs | 2 +- src/errors.rs | 5 +++++ src/new_index/schema.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/electrum/server.rs b/src/electrum/server.rs index 6887ccb98..fe537f813 100644 --- a/src/electrum/server.rs +++ b/src/electrum/server.rs @@ -106,7 +106,7 @@ impl JsonRpcV2Error { fn jsonrpc_code(e: &Error) -> JsonRpcV2Error { match e.kind() { ErrorKind::InvalidParams(_) => JsonRpcV2Error::InvalidParams, - ErrorKind::TooPopular => JsonRpcV2Error::BadRequest, + ErrorKind::TooPopular | ErrorKind::TooManyUtxos => JsonRpcV2Error::BadRequest, ErrorKind::RpcError(..) => JsonRpcV2Error::DaemonError, _ => JsonRpcV2Error::InternalError, } diff --git a/src/errors.rs b/src/errors.rs index dbe5f1b2d..fadc6f9ca 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -24,6 +24,11 @@ error_chain! { display("Too many history entries") } + TooManyUtxos { + description("Too many unspent outputs") + display("Too many unspent outputs") + } + InvalidParams(msg: String) { description("Invalid RPC params") display("{}", msg) diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index 8807aca39..6ee9b8732 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -872,7 +872,7 @@ impl ChainQuery { // abort if the utxo set size excedees the limit at any point in time if utxos.len() > limit { - bail!(ErrorKind::TooPopular) + bail!(ErrorKind::TooManyUtxos) } }