Skip to content

wallet: let sendtoaddress skip the optional future argument cleanly (#383)#456

Open
JSanchezFDZ wants to merge 1 commit into
Raptor3um:developfrom
JSanchezFDZ:fix/sendtoaddress-optional-future
Open

wallet: let sendtoaddress skip the optional future argument cleanly (#383)#456
JSanchezFDZ wants to merge 1 commit into
Raptor3um:developfrom
JSanchezFDZ:fix/sendtoaddress-optional-future

Conversation

@JSanchezFDZ

Copy link
Copy Markdown

Background

Issue #383 reports that sendtoaddress "does not work except the default/simplest
send" and that anything after the future argument fails, often with a cryptic
error: Error parsing JSON:.

Testing the current code on regtest shows the feature mostly works already — the
later arguments (comment, comment_to, subtractfeefromamount, ...) are
accepted when future is given as [], null, or a valid object, and named
arguments (-named) also work. Two rough edges remain:

  • Passing an empty object {} for future entered the future branch and
    failed with no future_maturity is specified.
  • Passing an empty string "" for future fails at the CLI layer with
    Error parsing JSON, because future is a JSON-typed positional argument and
    "" is not valid JSON.

Change

  • Treat an empty object the same as an absent future: only a non-empty
    object requests a future transaction. {}, [] and null now all mean
    "no future". A non-empty but incomplete object (e.g. only future_maturity)
    still errors exactly as before, so validation is unchanged.
  • Expand the future help text to explain that the argument is optional and how
    to skip it positionally ([]/null, not "") or via -named.

Verified (regtest)

sendtoaddress <addr> 1 {} "comment" "commentto" true        -> txid (was: error -8)
sendtoaddress <addr> 1 [] "" "" true                        -> txid (unchanged)
sendtoaddress <addr> 1 {"future_maturity":50,"future_locktime":-1} "" "" true -> txid (unchanged)
sendtoaddress <addr> 1 {"future_maturity":50} "" "" true    -> error -8 "no future_locktime" (validation preserved)

Closes #383.

…aptor3um#383)

sendtoaddress's positional "future" argument is optional, but the only ways
to skip it and still pass later arguments (comment, subtractfeefromamount,
...) were `[]` or `null`. Passing an empty object `{}` hit the future branch
and failed with "no future_maturity is specified", and the JSON-typed slot
also rejects an empty string `""` at the CLI layer with a cryptic
"Error parsing JSON".

Treat an empty object the same as an absent future (only a non-empty object
requests a future transaction), and document in the help how to skip the
argument positionally (`[]`/`null`) or via named arguments (-named). A
non-empty but incomplete future object still errors as before, so validation
is unchanged.
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

Successfully merging this pull request may close these issues.

1 participant