ElementsProject / ElementsProject/elements

signmessage and signmessagewithprivkey don't work unless the address you use is of type legacy

Open
#976 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.2k
Forks
416
Avg merge
1d 23h
Merged PRs (30d)
15

Description

elements-0.18.1.9

signmessage and signmessagewithprivkey only seem to work with p2pkh which is not the default in elements.

With a default address type this errors on signing:

```
elements-cli getnewaddress
AzpoUdjKavd8ZL4NTnaWt4bEYfVo4a5J42pDdAzCrzH3F7M5xk5iNSNCR3RfV9XndGEdnFv5uTs1EBmN

elements-cli signmessage AzpoUdjKavd8ZL4NTnaWt4bEYfVo4a5J42pDdAzCrzH3F7M5xk5iNSNCR3RfV9XndGEdnFv5uTs1EBmN "test"

error code: -3
error message:
Address does not refer to key
```

This will work if you use a legacy address type:

```
elements-cli getnewaddress "" "legacy"
CTEy43xUzkSCZGFnx2YjdoNpN6v8tVRUeBfyAb4N4K7UbqwNvaxjcxJJ5w3aeUtUbznpasycz1RnZksM

elements-cli signmessage CTEy43xUzkSCZGFnx2YjdoNpN6v8tVRUeBfyAb4N4K7UbqwNvaxjcxJJ5w3aeUtUbznpasycz1RnZksM "test"
IAEC8m8LC8DPUNVdKVnWlV00XqoYLWPWn83iP8ZAQ33ZKNyPnoU5cuDCpZCeKdpjqblgz9hKa9xKPW8Uhzue8Us=

elements-cli verifymessage CTEy43xUzkSCZGFnx2YjdoNpN6v8tVRUeBfyAb4N4K7UbqwNvaxjcxJJ5w3aeUtUbznpasycz1RnZksM IAEC8m8LC8DPUNVdKVnWlV00XqoYLWPWn83iP8ZAQ33ZKNyPnoU5cuDCpZCeKdpjqblgz9hKa9xKPW8Uhzue8Us= "test"
true
```

signmessagewithprivkey appears to work but verify stage fails:

```
elements-cli dumpprivkey AzpoUdjKavd8ZL4NTnaWt4bEYfVo4a5J42pDdAzCrzH3F7M5xk5iNSNCR3RfV9XndGEdnFv5uTs1EBmN
cSKSEM2nt24PRNMntCpExVhQbrmk5MffaNgWDS9zxWCt1yJgXvEF

elements-cli signmessagewithprivkey cSKSEM2nt24PRNMntCpExVhQbrmk5MffaNgWDS9zxWCt1yJgXvEF "test"
Hy5mGfJvFmLy6ZWXxxxLwymMvyOBI+vkFpFo8s+oWuFuFQiFN/Rb13L9ZjoUGWjJjGuvGDuhFfHx+Vgsl08xWqY=

elements-cli verifymessage AzpoUdjKavd8ZL4NTnaWt4bEYfVo4a5J42pDdAzCrzH3F7M5xk5iNSNCR3RfV9XndGEdnFv5uTs1EBmN "Hy5mGfJvFmLy6ZWXxxxLwymMvyOBI+vkFpFo8s+oWuFuFQiFN/Rb13L9ZjoUGWjJjGuvGDuhFfHx+Vgsl08xWqY=" "test"
error code: -3
error message:
Address does not refer to key
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported behavior using the elements-cli getnewaddress, signmessage, signmessagewithprivkey, and verifymessage commands shown in the issue. Trace the RPC entry points for these signing and verification operations, then add or run coverage for default and legacy address types. Done means messages can be signed and verified for the default address type as well as legacy addresses.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend, blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.