rpc: adjust incorrect RPCHelpMan types #21897

pull kallewoof wants to merge 3 commits into bitcoin:master from kallewoof:202104-rpctypes changing 3 files +4 −4
  1. kallewoof commented at 1:00 PM on May 9, 2021: member

    This PR adjusts the two issues I encountered while developing a tool that converts RPCHelpMan objects into bindings for other language(s).

    The first is in createrawtransaction, where the address part, e.g. bc1qabc in

    createrawtransaction '[]' '[{"bc1qabc": 1.0}]'

    is declared as a Type::OBJ, when in reality it should be a Type::OBJ_USER_KEYS, defined as such:

    https://github.com/bitcoin/bitcoin/blob/5925f1e652768a9502831b9ccf78d16cf3c37d29/src/rpc/util.h#L126

    (coincidentally, this is the first and only (afaict) usage of this RPCArg::Type).

    The second is in the listaddressgroupings RPC, which returns an array of arrays of arrays, where the innermost one is a tuple-thingie with an optional 3rd item; this is an ARR_FIXED, not an ARR.

  2. fanquake added the label RPC/REST/ZMQ on May 9, 2021
  3. rpc: include OBJ_USER_KEY in RPCArg constructor checks d9e2183c50
  4. rpc/createrawtransaction: redefine addresses as OBJ_USER_KEYS
    The OBJ type is for actual objects with defined keys; OBJ_USER_KEYS is for objects with user-defined keys (such as the bitcoin address(es) in the createrawtransaction output object.
    8500f7bf54
  5. rpc/listaddressgroupings: redefine inner-most array as ARR_FIXED
    ARR_FIXED is for cases like this, where the elements are in an array for convenience, rather than due to being dynamically sized lists.
    7031721f2c
  6. kallewoof force-pushed on May 9, 2021
  7. MarcoFalke commented at 6:42 AM on May 10, 2021: member

    Nice find. Rendered diff:

    diff --git a/createrawtransaction b/createrawtransaction
    index b488df3..cd68d55 100644
    --- a/createrawtransaction
    +++ b/createrawtransaction
    @@ -1,4 +1,4 @@
    -createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )
    +createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )
     
     Create a transaction spending the given inputs and creating new outputs.
     Outputs can be addresses or data.
    @@ -23,6 +23,7 @@ Arguments:
          [
            {                       (json object)
              "address": amount,    (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
    +         ...
            },
            {                       (json object)
              "data": "hex",        (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
    diff --git a/listaddressgroupings b/listaddressgroupings
    index 860fe09..552faaa 100644
    --- a/listaddressgroupings
    +++ b/listaddressgroupings
    @@ -10,8 +10,7 @@ Result:
         [           (json array)
           "str",    (string) The bitcoin address
           n,        (numeric) The amount in BTC
    -      "str",    (string, optional) The label
    -      ...
    +      "str"     (string, optional) The label
         ],
         ...
       ],
    
  8. MarcoFalke commented at 6:43 AM on May 10, 2021: member

    ACK 7031721f2cc3eef30c46ff50c52328e9ba8090e0 🐀

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    ACK 7031721f2cc3eef30c46ff50c52328e9ba8090e0 🐀
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUharwv9Hh5fzDU3kxyvsQzhU8YcNU+wBVd4QW8Abe4VoJQIyNqQPRC4z7VCHVV1
    /3Hl8lHVpc7IwqrhFFMGWBSpzYN5WUPgxsv9uarGhS9OtzcwQQDi5m/u+XoDQLf7
    gzWk3didSwZ00nL5hMheC4WG3FYhSOPEXR9dqB4hRllVn6aUPibKf5Qq2wlsb1A8
    b9aM2tNVl1FVlUyraNLt7L1ECmedvJq/X8g1nZjZ0IwX9fQ6g/VmCMDzXI9WFDGB
    XH6FKFicK6ckKupzQxQeAN7R/PjCrMeQn0ED7JefFCWn0w20sHpDGlRYJ1f73pi5
    6YWiccycvctKtMwjK4QAYdq/CHGgwEA/5DySZ8X4LcKHcmdBh2yq5Y+H1lPnWvDj
    W1pjjePMolhJF08sFZQDqE7xxdo/zu9VOMJNVlJby3/E/HRQMlP7BrcfuG8Eib8b
    FJNL1QI7X3i7KJioPGd23rQbFpaUeGvy2yYFN2PsM2LIumqrUXzU+MIPmgWCmjDT
    fjoOz+7C
    =CcfS
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash cea78a19ab915d79f1fd04d67ae9ab391a7807d117131861f2c3f94c0f7e29e7 -

    </details>

  9. MarcoFalke merged this on May 10, 2021
  10. MarcoFalke closed this on May 10, 2021

  11. kallewoof deleted the branch on May 10, 2021
  12. sidhujag referenced this in commit 4cc8f84d32 on May 10, 2021
  13. MarcoFalke referenced this in commit ea8b2e8e12 on May 20, 2021
  14. sidhujag referenced this in commit d9eb594fe7 on May 20, 2021
  15. gwillen referenced this in commit c40a9ecf0f on Jun 1, 2022
  16. DrahtBot locked this on Aug 18, 2022

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: 2026-04-13 15:14 UTC

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