ElectrsCash get_history RPC command should send height=-1 for unconfirmed tx's with unconfirmed ancestors
Created by: cculianu
HI @dagurval et al,
ElectrsCash sends an unexpected history for transactions in the mempool with an unconfirmed parent. Electron Cash expects tx's with unconfirmed parents to have height
set to -1
, and mempool tx's with no unconfirmed parents to have height 0
. ElectrsCash sends 0
for either of the two. This isn't a huge deal but it has the following two negative consequences:
-
It produces a different/unexpected history and/or scripthash_status for Electron Cash if you have unconfirmed tx's with unconfirmed ancestors. So when switching to an ElectrsCash server from an ElectrumX/ElectronX or Fulcrum server, you end up having to do a full history re-download, which can be a little slow on some wallets.
-
It causes the UI of Electron Cash to not actually show the "unconfirmed parent" icon which users are accustomed to seeing for such tx's.
Aaaand.. of course.. the Electrum protocol spec 1.4 doesn't actually say it requires this or to expect it.. but.. It's definitely there in the code. Here is the spec which doesn't mention this detail: https://bitcoincash.network/electrum/protocol-methods.html#blockchain-scripthash-get-history.
Here is a set of tx's that are a chain with 1 unconfirmed parent and 1 descendant tx.
Fulcrum server and ElectrumX:
[{'height': 1318547, 'tx_hash': '7e3ffab560803c2fa210864486c078f33267d38a4dec5ea0f04260e3c817f1a1'}, {'height': 1326457, 'tx_hash': '55fdf7b243fe566a20668a4dd2c247c93b2aa2a960e1b8a3bf9c955634c53c1f'}, {'fee': 185, 'height': 0, 'tx_hash': '8775777b5cee1fa5827c30f3868d12cd082a3aca6d01464a70c87f6f3954bcd6'}, {'fee': 185, 'height': -1, 'tx_hash': '2577829ab0227f2dd74fde1717d8bddc8c146753b3143530a52132bd20035742'}]
Notice how tx 2577829...
has height -1
as it should.. it has an unconfirmed parent.
ElectrsCash result for the same history:
(Ignore the fact that they end up in a differently-ordered dict -- that's a Python implementation detail):
[{'height': 0, 'tx_hash': '2577829ab0227f2dd74fde1717d8bddc8c146753b3143530a52132bd20035742'}, {'height': 0, 'tx_hash': '8775777b5cee1fa5827c30f3868d12cd082a3aca6d01464a70c87f6f3954bcd6'}, {'height': 1318547, 'tx_hash': '7e3ffab560803c2fa210864486c078f33267d38a4dec5ea0f04260e3c817f1a1'}, {'height': 1326457, 'tx_hash': '55fdf7b243fe566a20668a4dd2c247c93b2aa2a960e1b8a3bf9c955634c53c1f'}]
And in the Electron Cash UI this manifests as a different UI:
Fulcrum/ElectronX/ElectrumX:
vs ElectrsCash: