specter-desktop
specter-desktop copied to clipboard
Fix wallet load error on incomplete gettransaction (Failed to load utxos, IndexError: list index out of range)
The error happens when the wallet has some locked outputs in listlockunspent
and the corresponding gettransaction
doesn't contain the details of this particular output.
It may be related to https://github.com/bitcoin/bitcoin/issues/28555. It is at least the same symptom.
The locked outputs were locked by creating a transaction in Specter. This has happened to me multiple times.
The UI says it failed to load the wallet with the following error: Failed to load utxos, IndexError: list index out of range
The raw transaction does contain the missing output so we use that instead.
Here's an example that generates the error:
listlockunspent:
[
{
"txid": "<some txid>",
"vout": 0
}
]
gettransaction <some txid>:
{
"amount": <redacted>,
"fee": <redacted>,
"confirmations": <redacted>,
"blockhash": "<redacted>",
"blockheight": <redacted>,
"blockindex": <redacted>,
"blocktime": <redacted>,
"txid": "<some tx id>",
"wtxid": "<redacted>",
"walletconflicts": [
],
"time": <redacted>,
"timereceived": <redacted>,
"bip125-replaceable": "no",
"details": [
{
"address": "<redacted>",
"category": "send",
"amount": <redacted>,
"label": "<redacted>",
"vout": 1,
"fee": <redacted>,
"abandoned": false
}
],
"hex": "<some raw tx hex>",
"lastprocessedblock": {
"hash": "<redacted>",
"height": <redacted>
}
}
decoderawtransaction <some raw tx hex>:
{
"txid": "<some txid>",
"hash": "<redacted>",
"version": 2,
"size": <redacted>,
"vsize": <redacted>,
"weight": <redacted>,
"locktime": <redacted>,
"vin": [
{
"txid": "<some other txid>",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"<redacted>",
"<redacted>"
],
"sequence": <redacted>
}
],
"vout": [
{
"value": <redacted>,
"n": 0,
"scriptPubKey": {
"asm": "<redacted>",
"desc": "<redacted>",
"hex": "<redacted>",
"address": "<redacted>",
"type": "<redacted>"
}
},
{
"value": <redacted>,
"n": 1,
"scriptPubKey": {
"asm": "<redacted>",
"desc": "<redacted>",
"hex": "<redacted>",
"address": "<redacted>",
"type": "<redacted>"
}
}
]
}
Note: I'm connecting to a Bitcoin Core version v27.1.0.