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

sendfromaddress optional parameters error "JSON value is not a string as expected (code -1)" #1179

Open
hnugz opened this issue Jan 26, 2022 · 1 comment

Comments

@hnugz
Copy link

hnugz commented Jan 26, 2022

Describe the issue

The sendfromaddress RPC help displays multiple optional parameters along with the following examples:

Examples:

raven-cli sendfromaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1
raven-cli sendfromaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1 "donation" "seans outpost"
raven-cli sendfromaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1 "" "" true

Example 1 without the optional "comment", "comment_to", and "subtractfeeamount" parameters executes successfully. Examples 2 and 3 with the optional parameters fail with the error, "JSON value is not a string as expected (code -1)".

Can you reliably reproduce the issue?

If so, please list the steps to reproduce below:

  1. Open the Debug window console in the RavenCore wallet
  2. Review the options listed by the "help sendfromaddress" command
  3. Copy the third example command and replace the 1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd addresses with valid ones
  4. Attempt to execute the command (with valid addresses substituted) and review the resulting error:
    sendfromaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1 "" "" true

Expected behaviour

The RPC command should execute as expected based upon the examples.

Actual behaviour

A JSON error is returned.

What version of Ravencoin are you using?

Raven Core version v4.3.2.1-25a2dbf41 (64-bit)

Any extra information that might be useful in the debugging process.

Looking at a similar command, sendtoaddress, the optional parameters work as expected. Comparing optional parameter entries for sendfromaddress and sendtoaddress in rpcwallet.cpp, sendfromaddress is checking params[3] for is not null but params[2] for not an empty string . Looking at sendtoaddress which works successfully, it checks the same params[2] both times. Should sendfromaddress also be comparing the same parameter and putting params[3] in the "comment" rather than params[2]?

From sendfromaddress:

    // Wallet comments
    CWalletTx wtx;
    if (!request.params[3].isNull() && !request.params[2].get_str().empty())
        wtx.mapValue["comment"] = request.params[2].get_str();
    if (!request.params[4].isNull() && !request.params[3].get_str().empty())
        wtx.mapValue["to"]      = request.params[3].get_str();

From sendtoaddress:

    // Wallet comments
    CWalletTx wtx;
    if (!request.params[2].isNull() && !request.params[2].get_str().empty())
        wtx.mapValue["comment"] = request.params[2].get_str();
    if (!request.params[3].isNull() && !request.params[3].get_str().empty())
        wtx.mapValue["to"]      = request.params[3].get_str();
@michaelmcshinsky
Copy link

Created a PR to fix this: #1223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants