Electron-Cash: orphan txes showing weirdly from Load Transaction | From Blockchain
A funny feature of the bitcoin node’s transaction index is that it never removes transactions that were in orphaned blocks. And when you ask for a transaction from electrumx, it goes straight through to the getrawtransaction rpc call.
An orphan tx like this gets returned with:
...
"blockhash": "00000000074443862b52948e2fad85aa0bafa9e6a14dd7fdeb8ec09f5caa1673",
"confirmations": 0
}
where blockhash points to the orphaned block.
What is unfortunate though is that electron cash shows the full number of confirmations as if that block were in the chain!

(The above example witnessed on @imaginaryusername’s testnet server, while playing with giant reorgs during May 2019 upgrade testing.)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 17
Probably would but I’d have to look at it – a generic mechanism to queue up a verification for tx’s not in wallet that isn’t a total hack – is indeed needed. So yes. Likely. Maybe when I do CashAccounts I can tackle this one too.
Note that even if we did this – the particular “bug” where a reorg’d tx looks like a mempool tx will still not be fixed – but at least you can be sure if you do see conf’s on a tx – it was verified and not a potential lie from ElectrumX bad actors.
i know why this is – on wallet startup it does a more thorough checkcheck_historyor something it’s called.Whereas otherwise it just looks for the tx in the wallet.transactions cache and if there, shows it, without ever going to the blockchain.Possible workaround would be if doing Load transaction -> from blockchain to never consult the transaction cache.Normally in a normal UI sequence you wouldn’t get to “re-open” a tx that disappeared after a reorg, though. This is only if you kept the window open, or if you explicitly opened it “from blockchain”. So the bug is really the “from blockchain” bit should really go to blockchain.
Is that a good assessment of how you reproduced it?
As for it showing the tx with no confs – if ElectrumX returns a tx, there’s nothing we can do about that, really. How can we distinguish that from an orginary mempool tx? We can’t… like you said bitcoind rpc has this funny ‘feature’… right?
EDIT: Unless we do the merkle checking, like you suggested – of course! EDIT2: But no merkle checks possible for mempool tx. And this “from the blockchain” of a re-org’d tx looks like a mempool tx, right?
Still I think is a problem that a wallet would be showing a transaction that doesn’t actually exist in chain… hmmm. Noticeably it does NOT say anything about the tx confirmedness status, just “Status: Signed”
Maybe Load transaction from chain needs to do merkle checking, for user safety (seems like a possibility to trick users!).
(Subtlety – users do expect transactions in mempool to be shown from Load transaction | from blockchain)