spesmilo / spesmilo/electrum

RPC doesn't support "OP_RETURN <data hex bytes>" feature of GUI

Open
#4,547 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CLI/RPC ▶ enhancement ✨
Dominant language
Python
Stars
8.6k
Forks
3.5k
Avg merge
2d 8h
Merged PRs (30d)
61

Description

Running version 3.2.2, cloned off master as of yesterday.

Using the GUI it's possible to create OP_RETURN data transactions by simply specifying the "Pay to" as "OP_RETURN 3210", for example, storing bytes 32 10 as data in the op_return transaction. So far so good.

The issue is that this appears to work only in the GUI, not on the command line interface (CLI), or the RPC server, or the python console. In those cases, the argument parser throws Invalid Bitcoin address or alias when the destination is supplied in that format. For example, the commands:

# see ~/electrum/config for rpcuser, rpcpassword and rpcport
electrum start daemon
electrum load_wallet  # enter walletpassword
curl --data-binary '{"id":"curltext","method":"payto","params":{"destination":"OP_RETURN 3210", "amount":"0.000001", "fee":"0.000001", "password": "walletpassword"}}' http://rpcuser:rpcpassword==@127.0.0.1:rpcport 

Returns an error:

Exception: ('Invalid Bitcoin address or alias', 'OP_RETURN 3210') {"id": "curltext", "result": null, "error": {"message": "Server error: File \"/home/pbnelson/repos/electrum/lib/contacts.py\", line 95, in resolve | Exception: ('Invalid Bitcoin address or alias', 'OP_RETURN 3210')\n", "code": -32603}}

Changing to lowercase, eliminating the hex data and just using 'op_return' alone, doesn't change the error message at all. Nor does it help to add "nocheck":true to the parameter list.

Similarly, using the command line interface directly also gives an error:

electrum payto --fee 0.000001 "OP_RETURN 3210" 0.0

Returns

File "/home/pbnelson/.local/lib/python3.5/site-packages/electrum/contacts.py", line 95, in resolve raise Exception("Invalid Bitcoin address or alias", k) Exception: ('Invalid Bitcoin address or alias', 'OP_RETURN 3210')

Final example, this statement in the python console:

payto('OP_RETURN 3210',[{"amount":"0.0", "fee":"0.000001"}])

Returns:

File "/home/pbnelson/repos/electrum/lib/contacts.py", line 95, in resolve raise Exception("Invalid Bitcoin address or alias", k) Exception: ('Invalid Bitcoin address or alias', 'OP_RETURN 3210')

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/contacts.py line 95, where the CLI, RPC request, and Python console reject the OP_RETURN destination, and compare that path with the GUI handling described in the report. Reproduce the shown payto commands and verify that OP_RETURN hex data is accepted consistently through all three non-GUI interfaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.