bitcoin-cli output help text - (json object) not utilizing RPCArg::Optional value #27828

issue miketwenty1 openend this issue on June 5, 2023
  1. miketwenty1 commented at 3:42 pm on June 5, 2023: contributor

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    When executing: bitcoin-cli walletcreatefundedpsbt or bitcoin-cli createpsbt without args you will get a help output that looks like this:

     0Creates and funds a transaction in the Partially Signed Transaction format.
     1Implements the Creator and Updater roles.
     2All existing inputs must either have their previous output transaction be in the wallet
     3or be in the UTXO set. Solving data must be provided for non-wallet inputs.
     4
     5Arguments:
     61. inputs                             (json array, optional) Leave empty to add inputs automatically. See add_inputs option.
     7     [
     8       {                              (json object)
     9         "txid": "hex",               (string, required) The transaction id
    10         "vout": n,                   (numeric, required) The output number
    11         "sequence": n,               (numeric, optional, default=depends on the value of the 'locktime' and 'options.replaceable' arguments) The sequence number
    12         "weight": n,                 (numeric, optional, default=Calculated from wallet and solving data) The maximum weight for this input, including the weight of the outpoint and sequence number. Note that signature sizes are not guaranteed to be consistent, so the maximum DER signatures size of 73 bytes should be used when considering ECDSA signatures.Remember to convert serialized sizes to weight units when necessary.
    13       },
    14       ...
    15     ]
    162. outputs                            (json array, required) The outputs (key-value pairs), where none of the keys are duplicated.
    17                                      That is, each address can only appear once and there can only be one 'data' object.
    18                                      For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
    19                                      accepted as second parameter.
    20     [
    21       {                              (json object)
    22         "address": amount,           (numeric or string, required) A key-value pair. The key (string) is the bitcoin address,
    23                                      the value (float or string) is the amount in BTC
    24         ...
    25       },
    26       {                              (json object)
    27         "data": "hex",               (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
    28       },
    29       ...
    30     ]
    313. locktime                           (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
    324. options                            (json object, optional)
    33     {
    34       "add_inputs": bool,            (boolean, optional, default=false when "inputs" are specified, true otherwise) Automatically include coins from the wallet to cover the target amount.
    35                                      
    36       "include_unsafe": bool,        (boolean, optional, default=false) Include inputs that are not safe to spend (unconfirmed transactions from outside keys and unconfirmed replacement transactions).
    37                                      Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
    38                                      If that happens, you will need to fund the transaction with different inputs and republish it.
    39       "minconf": n,                  (numeric, optional, default=0) If add_inputs is specified, require inputs with at least this many confirmations.
    40       "maxconf": n,                  (numeric, optional) If add_inputs is specified, require inputs with at most this many confirmations.
    41       "changeAddress": "str",        (string, optional, default=automatic) The bitcoin address to receive the change
    42       "changePosition": n,           (numeric, optional, default=random) The index of the change output
    43       "change_type": "str",          (string, optional, default=set by -changetype) The output type to use. Only valid if changeAddress is not specified. Options are "legacy", "p2sh-segwit", "bech32", and "bech32m".
    44       "includeWatching": bool,       (boolean, optional, default=true for watch-only wallets, otherwise false) Also select inputs which are watch only
    45       "lockUnspents": bool,          (boolean, optional, default=false) Lock selected unspent outputs
    46       "fee_rate": amount,            (numeric or string, optional, default=not set, fall back to wallet fee estimation) Specify a fee rate in sat/vB.
    47       "feeRate": amount,             (numeric or string, optional, default=not set, fall back to wallet fee estimation) Specify a fee rate in BTC/kvB.
    48       "subtractFeeFromOutputs": [    (json array, optional, default=[]) The outputs to subtract the fee from.
    49                                      The fee will be equally deducted from the amount of each specified output.
    50                                      Those recipients will receive less bitcoins than you enter in their corresponding amount field.
    51                                      If no outputs are specified here, the sender pays the fee.
    52         vout_index,                  (numeric) The zero-based output index, before a change output is added.
    53         ...
    54       ],
    55       "conf_target": n,              (numeric, optional, default=wallet -txconfirmtarget) Confirmation target in blocks
    56       "estimate_mode": "str",        (string, optional, default="unset") The fee estimate mode, must be one of (case insensitive):
    57                                      "unset"
    58                                      "economical"
    59                                      "conservative"
    60       "replaceable": bool,           (boolean, optional, default=wallet default) Marks this transaction as BIP125-replaceable.
    61                                      Allows this transaction to be replaced by a transaction with higher fees
    62       "solving_data": {              (json object, optional) Keys and scripts needed for producing a final transaction with a dummy signature.
    63                                      Used for fee estimation during coin selection.
    64         "pubkeys": [                 (json array, optional, default=[]) Public keys involved in this transaction.
    65           "pubkey",                  (string) A public key
    66           ...
    67         ],
    68         "scripts": [                 (json array, optional, default=[]) Scripts involved in this transaction.
    69           "script",                  (string) A script
    70           ...
    71         ],
    72         "descriptors": [             (json array, optional, default=[]) Descriptors that provide solving data for this transaction.
    73           "descriptor",              (string) A descriptor
    74           ...
    75         ],
    76       },
    77     }
    785. bip32derivs                        (boolean, optional, default=true) Include BIP 32 derivation paths for public keys if we know them
    79
    80Result:
    81{                     (json object)
    82  "psbt" : "str",     (string) The resulting raw transaction (base64-encoded string)
    83  "fee" : n,          (numeric) Fee in BTC the resulting transaction pays
    84  "changepos" : n     (numeric) The position of the added change output, or -1
    85}
    86
    87Examples:
    88
    89Create a transaction with no inputs
    90> bitcoin-cli walletcreatefundedpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
    

    The (json object)’s within outputs are not being populated with “required” or “optional”

    Expected behaviour

    (json object, optional) or (json object, required) appears in help text. Edit: This is more complicated as 1 of the 2 are minimally needed. Instead helper text was added.

    Steps to reproduce

    Running v25 of bitcoin core and using bitcoin-cli.

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Pre-built binaries

    What version of Bitcoin Core are you using?

    v25.0

    Operating system and version

    Ubuntu 22 LTS

    Machine specifications

    No response

  2. maflcko commented at 3:50 pm on June 5, 2023: member
    Should be a trivial patch to change the bool from true to false, no? Mind creating a pull?
  3. miketwenty1 commented at 6:13 pm on June 5, 2023: contributor

    After chatting with @sipa here #27829 The original bug/request of making “data” optional is not the right move. I believe this may still be a bug with (json object) not being noted as required or optional.

    This seems to be more of a display issue with RPCArg::Type::OBJ and the corresponding RPCArg::Optional::OMITTED perhaps?

    https://github.com/bitcoin/bitcoin/blob/master/src/rpc/rawtransaction.cpp#L160 https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpc/spend.cpp#L971

    Seems there are some examples of arrays, strings, objs, and other things that are picking up on this RPCArg::Optional::<VAL> to populate the display with either optional or required. Not sure which piece of code is responsible for this.

  4. miketwenty1 renamed this:
    bitcoin-cli requires unnecessary data field for certain commands
    bitcoin-cli output help text confusing for optional (json object)
    on Jun 5, 2023
  5. miketwenty1 renamed this:
    bitcoin-cli output help text confusing for optional (json object)
    bitcoin-cli output help text - optional (json object)
    on Jun 5, 2023
  6. miketwenty1 commented at 6:31 pm on June 5, 2023: contributor
    Unsure why https://github.com/bitcoin/bitcoin/blob/master/src/rpc/util.cpp#L853 this isn’t triggering. Happy to work on this with maybe a guiding hand.
  7. miketwenty1 renamed this:
    bitcoin-cli output help text - optional (json object)
    bitcoin-cli output help text - (json object) not utilizing RPCArg::Optional value
    on Jun 5, 2023
  8. miketwenty1 commented at 8:48 pm on June 5, 2023: contributor
    Got clarity that 1 of the 2 fields is required either address or data. Maybe just a clean up of the description is fine.
  9. miketwenty1 referenced this in commit 30acffa320 on Jun 5, 2023
  10. achow101 closed this on Aug 23, 2023

  11. Frank-GER referenced this in commit 950247f9de on Sep 8, 2023
  12. BlackcoinDev referenced this in commit 23f3f402fc on Feb 5, 2024
  13. bitcoin locked this on Aug 22, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-29 01:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me