doc: Properly report optional RPC args #26706

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2212-doc-rpc-🐵 changing 2 files +52 −50
  1. maflcko commented at 4:07 pm on December 15, 2022: member

    OMITTED_NAMED_ARG and OMITTED are a confusing burden:

    • It puts the burden on developers to pick the right one of the two
    • They can be interchanged without introducing a compile failure or other error
    • Picking the wrong one is leading to incorrect docs
    • They are redundant, because the correct one can already be determined by the surrounding type

    Fix all issues by making them an alias of each other; Pick the right one based on the outer type.

  2. DrahtBot commented at 4:07 pm on December 15, 2022: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK fanquake

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #26485 (RPC: Accept options as named-only parameters by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot added the label Docs on Dec 15, 2022
  4. maflcko commented at 4:08 pm on December 15, 2022: member
      0diff --git a/fundrawtransaction b/fundrawtransaction
      1index a482315..1421b27 100644
      2--- a/fundrawtransaction
      3+++ b/fundrawtransaction
      4@@ -22,7 +22,7 @@ Arguments:
      5                                       Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
      6                                       If that happens, you will need to fund the transaction with different inputs and republish it.
      7        "minconf": n,                  (numeric, optional, default=0) If add_inputs is specified, require inputs with at least this many confirmations.
      8-       "maxconf": n,                  (numeric) If add_inputs is specified, require inputs with at most this many confirmations.
      9+       "maxconf": n,                  (numeric, optional) If add_inputs is specified, require inputs with at most this many confirmations.
     10        "changeAddress": "str",        (string, optional, default=automatic) The bitcoin address to receive the change
     11        "changePosition": n,           (numeric, optional, default=random) The index of the change output
     12        "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".
     13diff --git a/importdescriptors b/importdescriptors
     14index e8d2dd2..44e9ef0 100644
     15--- a/importdescriptors
     16+++ b/importdescriptors
     17@@ -12,8 +12,8 @@ Arguments:
     18        {                                    (json object)
     19          "desc": "str",                     (string, required) Descriptor to import.
     20          "active": bool,                    (boolean, optional, default=false) Set this descriptor to be the active descriptor for the corresponding output type/externality
     21-         "range": n or [n,n],               (numeric or array) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
     22-         "next_index": n,                   (numeric) If a ranged descriptor is set to active, this specifies the next index to generate addresses from
     23+         "range": n or [n,n],               (numeric or array, optional) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
     24+         "next_index": n,                   (numeric, optional) If a ranged descriptor is set to active, this specifies the next index to generate addresses from
     25          "timestamp": timestamp | "now",    (integer / string, required) Time from which to start rescanning the blockchain for this descriptor, in UNIX epoch time
     26                                             Use the string "now" to substitute the current synced blockchain time.
     27                                             "now" can be specified to bypass scanning, for outputs which are known to never have been used, and
     28diff --git a/importmulti b/importmulti
     29index 6433ec3..aa238e2 100644
     30--- a/importmulti
     31+++ b/importmulti
     32@@ -14,7 +14,7 @@ Arguments:
     33 1. requests                                                         (json array, required) Data to be imported
     34      [
     35        {                                                            (json object)
     36-         "desc": "str",                                             (string) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
     37+         "desc": "str",                                             (string, optional) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
     38          "scriptPubKey": "<script>" | { "address":"<address>" },    (string / json, required) Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor
     39          "timestamp": timestamp | "now",                            (integer / string, required) Creation time of the key expressed in UNIX epoch time,
     40                                                                     or the string "now" to substitute the current synced blockchain time. The timestamp of the oldest
     41@@ -22,8 +22,8 @@ Arguments:
     42                                                                     "now" can be specified to bypass scanning, for keys which are known to never have been used, and
     43                                                                     0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key
     44                                                                     creation time of all keys being imported by the importmulti call will be scanned.
     45-         "redeemscript": "str",                                     (string) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
     46-         "witnessscript": "str",                                    (string) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
     47+         "redeemscript": "str",                                     (string, optional) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
     48+         "witnessscript": "str",                                    (string, optional) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
     49          "pubkeys": [                                               (json array, optional, default=[]) Array of strings giving pubkeys to import. They must occur in P2PKH or P2WPKH scripts. They are not required when the private key is also provided (see the "keys" argument).
     50            "pubKey",                                                (string)
     51            ...
     52@@ -32,7 +32,7 @@ Arguments:
     53            "key",                                                   (string)
     54            ...
     55          ],
     56-         "range": n or [n,n],                                       (numeric or array) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
     57+         "range": n or [n,n],                                       (numeric or array, optional) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
     58          "internal": bool,                                          (boolean, optional, default=false) Stating whether matching outputs should be treated as not incoming payments (also known as change)
     59          "watchonly": bool,                                         (boolean, optional, default=false) Stating whether matching outputs should be considered watchonly.
     60          "label": "str",                                            (string, optional, default="") Label to assign to the address, only allowed with internal=false
     61diff --git a/scanblocks b/scanblocks
     62index 25d8be5..f1626dc 100644
     63--- a/scanblocks
     64+++ b/scanblocks
     65@@ -8,7 +8,7 @@ Arguments:
     66                                           "start" for starting a scan
     67                                           "abort" for aborting the current scan (returns true when abort was successful)
     68                                           "status" for progress report (in %) of the current scan
     69-2. scanobjects                            (json array) Array of scan objects. Required for "start" action
     70+2. scanobjects                            (json array, optional) Array of scan objects. Required for "start" action
     71                                           Every scan object is either a string descriptor or an object:
     72      [
     73        "descriptor",                      (string) An output descriptor
     74diff --git a/scantxoutset b/scantxoutset
     75index 31ed769..654c806 100644
     76--- a/scantxoutset
     77+++ b/scantxoutset
     78@@ -19,7 +19,7 @@ Arguments:
     79                                  "start" for starting a scan
     80                                  "abort" for aborting the current scan (returns true when abort was successful)
     81                                  "status" for progress report (in %) of the current scan
     82-2. scanobjects                   (json array) Array of scan objects. Required for "start" action
     83+2. scanobjects                   (json array, optional) Array of scan objects. Required for "start" action
     84                                  Every scan object is either a string descriptor or an object:
     85      [
     86        "descriptor",             (string) An output descriptor
     87diff --git a/send b/send
     88index 43e53c2..5308b8c 100644
     89--- a/send
     90+++ b/send
     91@@ -32,7 +32,7 @@ Arguments:
     92                                          Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
     93                                          If that happens, you will need to fund the transaction with different inputs and republish it.
     94        "minconf": n,                     (numeric, optional, default=0) If add_inputs is specified, require inputs with at least this many confirmations.
     95-       "maxconf": n,                     (numeric) If add_inputs is specified, require inputs with at most this many confirmations.
     96+       "maxconf": n,                     (numeric, optional) If add_inputs is specified, require inputs with at most this many confirmations.
     97        "add_to_wallet": bool,            (boolean, optional, default=true) When false, returns a serialized transaction which will not be added to the wallet or broadcast
     98        "change_address": "str",          (string, optional, default=automatic) The bitcoin address to receive the change
     99        "change_position": n,             (numeric, optional, default=random) The index of the change output
    100diff --git a/sendall b/sendall
    101index af67fec..8f3e9a7 100644
    102--- a/sendall
    103+++ b/sendall
    104@@ -44,7 +44,7 @@ Arguments:
    105        "psbt": bool,                (boolean, optional, default=automatic) Always return a PSBT, implies add_to_wallet=false.
    106        "send_max": bool,            (boolean, optional, default=false) When true, only use UTXOs that can pay for their own fees to maximize the output amount. When 'false' (default), no UTXO is left behind. send_max is incompatible with providing specific inputs.
    107        "minconf": n,                (numeric, optional, default=0) Require inputs with at least this many confirmations.
    108-       "maxconf": n,                (numeric) Require inputs with at most this many confirmations.
    109+       "maxconf": n,                (numeric, optional) Require inputs with at most this many confirmations.
    110        "conf_target": n,            (numeric, optional, default=wallet -txconfirmtarget) Confirmation target in blocks
    111        "estimate_mode": "str",      (string, optional, default="unset") The fee estimate mode, must be one of (case insensitive):
    112                                     "unset"
    113diff --git a/signrawtransactionwithkey b/signrawtransactionwithkey
    114index cd163d9..d042181 100644
    115--- a/signrawtransactionwithkey
    116+++ b/signrawtransactionwithkey
    117@@ -19,9 +19,9 @@ Arguments:
    118          "txid": "hex",             (string, required) The transaction id
    119          "vout": n,                 (numeric, required) The output number
    120          "scriptPubKey": "hex",     (string, required) script key
    121-         "redeemScript": "hex",     (string) (required for P2SH) redeem script
    122-         "witnessScript": "hex",    (string) (required for P2WSH or P2SH-P2WSH) witness script
    123-         "amount": amount,          (numeric or string) (required for Segwit inputs) the amount spent
    124+         "redeemScript": "hex",     (string, optional) (required for P2SH) redeem script
    125+         "witnessScript": "hex",    (string, optional) (required for P2WSH or P2SH-P2WSH) witness script
    126+         "amount": amount,          (numeric or string, optional) (required for Segwit inputs) the amount spent
    127        },
    128        ...
    129      ]
    130diff --git a/signrawtransactionwithwallet b/signrawtransactionwithwallet
    131index e41e3d0..22d1a2c 100644
    132--- a/signrawtransactionwithwallet
    133+++ b/signrawtransactionwithwallet
    134@@ -13,9 +13,9 @@ Arguments:
    135          "txid": "hex",             (string, required) The transaction id
    136          "vout": n,                 (numeric, required) The output number
    137          "scriptPubKey": "hex",     (string, required) script key
    138-         "redeemScript": "hex",     (string) (required for P2SH) redeem script
    139-         "witnessScript": "hex",    (string) (required for P2WSH or P2SH-P2WSH) witness script
    140-         "amount": amount,          (numeric or string) (required for Segwit inputs) the amount spent
    141+         "redeemScript": "hex",     (string, optional) (required for P2SH) redeem script
    142+         "witnessScript": "hex",    (string, optional) (required for P2WSH or P2SH-P2WSH) witness script
    143+         "amount": amount,          (numeric or string, optional) (required for Segwit inputs) the amount spent
    144        },
    145        ...
    146      ]
    147diff --git a/walletcreatefundedpsbt b/walletcreatefundedpsbt
    148index e6ad9d3..511bb43 100644
    149--- a/walletcreatefundedpsbt
    150+++ b/walletcreatefundedpsbt
    151@@ -39,7 +39,7 @@ Arguments:
    152                                       Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
    153                                       If that happens, you will need to fund the transaction with different inputs and republish it.
    154        "minconf": n,                  (numeric, optional, default=0) If add_inputs is specified, require inputs with at least this many confirmations.
    155-       "maxconf": n,                  (numeric) If add_inputs is specified, require inputs with at most this many confirmations.
    156+       "maxconf": n,                  (numeric, optional) If add_inputs is specified, require inputs with at most this many confirmations.
    157        "changeAddress": "str",        (string, optional, default=automatic) The bitcoin address to receive the change
    158        "changePosition": n,           (numeric, optional, default=random) The index of the change output
    159        "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".
    
  5. maflcko force-pushed on Jan 3, 2023
  6. hebasto commented at 11:57 am on January 17, 2023: member
    FWIW, the first commit has been cherry-picked into #26707.
  7. refactor: Remove const to fix performance-move-const-arg clang-tidy errors
    The warnings look like:
    
    src/rpc/util.h:192:19: error: std::move of the const variable 'name' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
            : m_names{std::move(name)},
                      ^~~~~~~~~~    ~
    fab92a5a5a
  8. refactor: Introduce is_top_level_arg fa09cb6086
  9. doc: Properly report optional RPC args fad56f7dd6
  10. maflcko force-pushed on Jan 17, 2023
  11. fanquake approved
  12. fanquake commented at 5:07 pm on January 17, 2023: member
    ACK fad56f7dd6ecac772e1bf590b38cd34ba67db5d7
  13. fanquake merged this on Jan 18, 2023
  14. fanquake closed this on Jan 18, 2023

  15. maflcko deleted the branch on Jan 18, 2023
  16. sidhujag referenced this in commit f8b5019d4e on Jan 19, 2023
  17. in src/rpc/util.h:163 in fad56f7dd6
    162-        OMITTED_NAMED_ARG,
    163-        /**
    164+         * `null`.
    165+         *
    166          * Optional argument with default value omitted because they are
    167-         * implicitly clear. That is, elements in an array or object may not
    


    kouloumos commented at 1:26 pm on January 20, 2023:
    Is there a reason that “or object” was removed from here? My understanding is that RPCArg::Optional::OMITTED still applies to elements in objects, such as here https://github.com/bitcoin/bitcoin/blob/392dc68e37be9fc7adb32496b13d9b50262e317d/src/wallet/rpc/backup.cpp#L1258-L1293

    maflcko commented at 1:52 pm on January 20, 2023:

    “or object” is covered by the first of the two reasons:

    Optional arg that is a named argument and has a default value of null

    (named arguments are basically keys in a dictionary/object)


    kouloumos commented at 3:17 pm on January 20, 2023:
    Thank you, the root of my confusion was the definition of named arguments.

    maflcko commented at 3:21 pm on January 20, 2023:
    If there are improvements, they can be appended to #26919, which is a follow-up
  18. bitcoin locked this on Jan 20, 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-12-19 06:12 UTC

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