electrum icon indicating copy to clipboard operation
electrum copied to clipboard

[4.6.0] AttributeError('str' object has no attribute 'get_addresses')

Open harryqt opened this issue 5 months ago • 5 comments

Description

After upgrading to v4.6.0 RPC calls broken

/path/to/electrum stop
/path/to/electrum daemon -d
/path/to/electrum load_wallet -w /home/harry/.electrum/wallets/wallet_1
{
  "id": "curltext",
  "method": "listaddresses",
  "params": {
    "wallet": "/home/harry/.electrum/wallets/wallet_1",
    "receiving": true,
    "unused": true
  }
}

response:

{
  "id": "curltext",
  "jsonrpc": "2.0",
  "error": {
    "code": 2,
    "message": "internal error while executing RPC",
    "data": {
      "exception": "AttributeError(\"'str' object has no attribute 'get_addresses'\")",
      "traceback": "Traceback (most recent call last):\n  File \"/home/harry/cliapps/electrum/lib/python3.11/site-packages/electrum/daemon.py\", line 266, in handle\n    response['result'] = await f(**params)\n                         ^^^^^^^^^^^^^^^^^\n  File \"/home/harry/cliapps/electrum/lib/python3.11/site-packages/electrum/commands.py\", line 194, in func_wrapper\n    return await func(*args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/home/harry/cliapps/electrum/lib/python3.11/site-packages/electrum/commands.py\", line 1164, in listaddresses\n    for addr in wallet.get_addresses():\n                ^^^^^^^^^^^^^^^^^^^^\nAttributeError: 'str' object has no attribute 'get_addresses'\n"
    }
  }
}

harryqt avatar Aug 02 '25 09:08 harryqt

yes, this behavior changed between 4.5.8 and 4.6.0. I proposed a fix in https://github.com/spesmilo/electrum/pull/10105 to make both wallet_path and wallet arguments work. As a workaround you can just replace wallet with wallet_path and then your rpc call should work. E.g.:

{
  "id": "curltext",
  "method": "listaddresses",
  "params": {
    "wallet_path": "/home/harry/.electrum/wallets/wallet_1",
    "receiving": true,
    "unused": true
  }
}

f321x avatar Aug 04 '25 10:08 f321x

I proposed a fix in https://github.com/spesmilo/electrum/pull/10105 to make both wallet_path and wallet arguments work.

why? I do not think that is desirable. I made that change specifically in order to get rid of polymorphism of that parameter. The consequence is that RPCs need to pass wallet_path instead of wallet. That's a breaking change, but it is acceptable for a major release.

ecdsa avatar Sep 26 '25 13:09 ecdsa

That's a breaking change, but it is acceptable for a major release.

Right. However we should at least add some better error-handling to better inform the user what's going on.

SomberNight avatar Sep 26 '25 14:09 SomberNight

That's a breaking change, but it is acceptable for a major release.

Major release? That would mean bumping the first digit. Going from 4.5.8 → 4.6 is just a minor release under Semantic Versioning.

harryqt avatar Sep 27 '25 03:09 harryqt

why? I do not think that is desirable. I made that change specifically in order to get rid of polymorphism of that parameter. The consequence is that RPCs need to pass wallet_path instead of wallet.

@ecdsa i wasn't aware this is a intentional change and considered it to be a regression. We can close #10105 if you prefer to keep the new api.

f321x avatar Sep 29 '25 13:09 f321x