Electrum outpoint sync silently ignores transaction fetch errors
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
Línea de trabajo
Comienza en crates/electrum/src/bdk_electrum_client.rs:362-368 y compara el manejo de outpoints con populate_with_txids, que ya distingue los errores de protocolo de otros fallos de obtención. Ejecuta crates/electrum/tests/test_outpoint_fetch_errors.rs con cargo test -p bdk_electrum --test test_outpoint_fetch_errors. Está hecho cuando sync informa de los errores de red de los outpoints solicitados, mientras que las respuestas de transacción no encontrada siguen pudiéndose omitir.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
BdkElectrumClient::sync discards every error returned by fetch_tx while collecting the requested outpoints (crates/electrum/src/bdk_electrum_client.rs:362-368):
for op in outpoints {
if let Ok(tx) = self.fetch_tx(op.txid) {
Only a "transaction not found" response (Error::Protocol) means there is nothing to sync for that outpoint. Connection, TLS and timeout errors are swallowed too, so the outpoint is skipped and sync reports success without any data for it. A spend of that outpoint is missed and the wallet keeps treating the UTXO as unspent until a later sync happens to succeed.
The txid path (populate_with_txids) treats the same situation differently: it skips only on Error::Protocol(_) and propagates every other error.
This issue was found by AI.
To Reproduce
Add crates/electrum/tests/test_outpoint_fetch_errors.rs and run cargo test -p bdk_electrum --test test_outpoint_fetch_errors. No Electrum server is needed:
use std::net::TcpListener;
use bdk_chain::bitcoin::{hashes::Hash, OutPoint, Txid};
use bdk_chain::spk_client::SyncRequest;
use bdk_electrum::electrum_client::{Client, ConfigBuilder};
use bdk_electrum::BdkElectrumClient;
#[test]
fn outpoint_sync_reports_connection_errors() {
// A "server" that accepts the connection and immediately closes it.
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let url = format!("tcp://{}", listener.local_addr().unwrap());
std::thread::spawn(move || listener.incoming().for_each(drop));
let config = ConfigBuilder::new().retry(0).build();
let client = BdkElectrumClient::new(Client::from_config(&url, config).unwrap());
let outpoint = OutPoint::new(Txid::from_byte_array([1; 32]), 0);
let request = SyncRequest::<()>::builder_at(0).outpoints([outpoint]);
let response = client.sync(request, 1, false);
assert!(response.is_err(), "sync dropped the outpoint and returned {response:?}");
}
The assertion fails with Ok(SyncResponse { tx_update: TxUpdate { txs: [], .. }, chain_update: None }). The same request built with .txids([outpoint.txid]) instead of .outpoints(..) returns Err(AllAttemptsErrored(..)).
Expected behavior
A sync that could not fetch the transaction of a requested outpoint because of a network error should not be reported as successful. The outpoint and txid paths should handle fetch errors consistently.
- Lenguaje dominante
- Rust
- Estrellas
- 1.1k
- Forks
- 516
- Merge medio
- 7 d 10 h
- PR fusionados (30 d)
- 10
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bitcoindevkit/bdk
-
feat(chain): derive Copy and implement AddAssign, Sub, SubAssign, Sum for BalancePosiblemente ocupada @bhuvan-somisetty la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk#2366 ·
Los mantenedores suelen responder en 2 días
-
bdk_esplora: document that prevout values inserted during sync are unverified server-reported dataPosiblemente ocupada @h55n la tomó hace 10 días. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
bitcoindevkit/bdk#2343 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Document the predictable-hashing behavior of the `hashbrown` featurePosiblemente ocupada @Romansage6 la tomó hace 9 días. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk#2342 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk#2338 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
BDK logo svgPosiblemente ocupada @notmandatory la tomó hace 18 días. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
bitcoindevkit/bdk#2326 · 5 comentarios · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de bitcoindevkit/bdk
Issues similares
-
founders_reward panics on a configured Testnet when the slow-start subsidy is not a multiple of 5Abiertoexternal-contribution
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ZcashFoundation/zebra#11792 ·
Los mantenedores suelen responder en 1 día
-
area/cli bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
bherbruck/solvecraft#2167 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bitcoindevkit/bdk-cli#357 ·
Los mantenedores suelen responder en 3 días