Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wallet load error on incomplete gettransaction (Failed to load utxos, IndexError: list index out of range) #2467

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Aug 1, 2024

  1. Fix wallet load error on incomplete gettransaction

    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 bitcoin/bitcoin#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>"
          }
        }
      ]
    }
    leon-costa committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    d74d4ab View commit details
    Browse the repository at this point in the history
  2. Apply black formatting

    leon-costa committed Aug 1, 2024
    Configuration menu
    Copy the full SHA
    ec5e1b2 View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2024

  1. Use embit to decode the raw transaction

    Because the decoderawtransaction RPC is not available in Spectrum and
    the tools to decode the raw transaction are already there.
    leon-costa committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    2efd56c View commit details
    Browse the repository at this point in the history