Merge pull request #1529 from cypherstack/fix/electrs-vanished-tx
What changed, and why it matters
This update fixes how Stack Wallet detects Bitcoin transactions that have disappeared from the memory pool (unconfirmed transactions). Previously, the wallet only recognized a specific error message format used by some server software. Now it recognizes the same message across more server types, including electrs. Without this fix, the wallet could fail to clean up transactions that no longer exist, potentially leaving stale or misleading transaction records.
Review whether other wallet mixins or interfaces use the same hard-coded ElectrumX/Fulcrum error string and apply a consistent substring match. Consider normalizing Electrum server errors to a backend-agnostic exception instead of relying on string matching.
Security signals we found
Error-handling robustness improvement
Data consistency fix for local transaction database
Server-backend compatibility broadening
Evidence from the diff
The patch broadens the string match used to detect a missing mempool/blockchain transaction when fetching transaction details. Previously the code matched the exact wrapped error string produced by ElectrumX/Fulcrum (“JSON-RPC error 2: daemon error: DaemonError({‘code’: -5, ‘message’: ‘No such mempool or blockchain transaction”). The new code matches only the inner message (“No such mempool or blockchain transaction”), which is also the format returned by electrs. This allows the wallet to correctly delete vanished unconfirmed transactions from the local Isar database regardless of the Electrum server backend.
Changed components
lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dartPaynymInterface mixintransactionV2 local database cleanup logicInspect captured patch +4 / −3
### lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart
@@ -1738,10 +1738,11 @@ mixin PaynymInterface<T extends PaynymCurrencyInterface>
cryptoCurrency: cryptoCurrency,
);
} catch (e) {
- // tx no longer exists then delete from local db
+ // tx no longer exists then delete from local db. Match bitcoind's
+ // message alone: ElectrumX and Fulcrum wrap it in "daemon error:
+ // DaemonError(...)", electrs does not.
if (e.toString().contains(
- "JSON-RPC error 2: daemon error: DaemonError({'code': -5, "
- "'message': 'No such mempool or blockchain transaction",
+ "No such mempool or blockchain transaction",
)) {
await mainDB.isar.writeTxn(
() async => await mainDB.isar.transactionV2sWhy this scored 36/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.