Skip to content

electrum: Trading broken on simnet. #3565

@JoeGruffins

Description

@JoeGruffins

Unable to find versions of python that make trading work. The simnet tests in client/cmd/simnet-trade-tests should consistently pass with the --all flag. None of btc/ltc/firo are passing all tests currently. It may be just a simnet issue but if we can't figure out simnet we should be overly cautious here. Unfortunately the answer may take some work and I don't think we can include these in the v1.1.0 release. Hopefully we can fix them asap though.

Electrum wallets broken - disabled for all three assets (BTC, LTC, FIRO)

Summary

Simnet trade testing for v1.1.0-rc1 revealed that electrum wallet integrations are broken across all three supported assets. Electrum wallets have been disabled in #3564 until these issues are resolved.

Test environment

  • Arch Linux with Python 3.14 (system), 3.13, 3.11, and 3.7 available
  • BTC Electrum 4.5.5 (commit 7263a49)
  • LTC Electrum-LTC 4.2.2.1 (commit c357178)
  • FIRO Electrum-Firo 4.1.5.5 (commit b99e959)
  • ElectrumX server for each asset

Issues by asset

BTC Electrum - addtransaction RPC failure

Python versions tested: 3.14, 3.11

When the maker (BTC Electrum wallet) audits the taker's swap contract, the addtransaction RPC call to Electrum fails:

[WRN] CORE:1[btc][ELECTRUM]: Failed to add tx to the wallet DB: code 2: "internal error while executing RPC"
[INF] CORE:1[btc][ELECTRUM]: Output ...cf:0 not found in unspent output list. Searching for spending txn...

The code at electrum_client.go:379 expects addtransaction to fail on counterparty transactions with "unrelated to this wallet", but Electrum 4.5.5 returns "internal error while executing RPC" instead. After this failure, the wallet cannot track the swap output or confirm the redemption. The maker's redeem is broadcast successfully, but the Electrum wallet never detects it as confirmed, causing the test to time out after 4 minutes stuck in MatchComplete.

Additionally, Cannot find mined tx block number for <hash> errors appear repeatedly, suggesting Electrum's chain state gets out of sync with the rapidly-mined simnet blocks.

Reproduces consistently on every run of ./run dcrbtcelectrum.

LTC Electrum - Wallet never sees funding balance

Python versions tested: 3.14, 3.11

The LTC Electrum wallet connects to the ElectrumX server successfully and reports block height, but never sees incoming funds. The test gets stuck in the funding loop:

[INF] T: Waiting for ltc funding tx to be mined
[INF] T: Waiting for ltc funding tx to be mined
... (forever)

The funding transaction is sent via the LTC harness (litecoind) and blocks are mined, but the Electrum wallet's getbalance RPC always returns 0. This may be an ElectrumX sync issue or the Electrum-LTC wallet not polling for updates properly.

Note: A 20s timeout was added to this loop in the same commit to prevent indefinite hangs.

FIRO Electrum - Intermittent swap output tracking failure

Python version: 3.7

FIRO Electrum performed the best of the three - passing success, nomakerswap, notakerswap, nomakerredeem, and makerghost (round 1). However, it consistently fails on makerghost round 2 with the same output tracking issue:

[INF] CORE:1[firo][ELECTRUM]: Output ...:0 not found in unspent output list. Searching for spending txn...

The Electrum wallet loses track of the swap output under rapid block mining, causing the test to time out at TakerSwapCast. This reproduced on two separate runs, always on makerghost round 2.

Root cause analysis

The common thread across all three is that Electrum wallets struggle to keep up with the rapid block mining that simnet trade tests perform. Specific contributing factors:

  1. addtransaction API change - Electrum 4.5.5 (BTC) returns a different error than expected for counterparty transactions, but even if filtered, the wallet still can't track outputs it doesn't know about.

  2. Block sync lag - Electrum wallets poll their ElectrumX server for updates rather than receiving push notifications for every block. Under rapid mining (every 2 seconds), the wallet falls behind and misses transactions.

  3. Python version sensitivity - The harness scripts had no pinned Python version. On modern Arch Linux (Python 3.14), the asyncio.get_event_loop() removal broke BTC and LTC Electrum startup entirely (separate from the swap issues). FIRO only worked because its harness was pinned to Python 3.7.

To reproduce

Start the relevant asset harness, electrumx server, electrum client, DCR harness, and dcrdex harness, then:

# BTC - fails on success test
./run dcrbtcelectrum

# LTC - hangs on funding
./run ltcelectrumdcr

# FIRO - fails on makerghost round 2
./run firoelectrumdoge --all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions