Skip to content

Commit

Permalink
Merge bitcoin#21897: rpc: adjust incorrect RPCHelpMan types
Browse files Browse the repository at this point in the history
7031721 rpc/listaddressgroupings: redefine inner-most array as ARR_FIXED (Karl-Johan Alm)
8500f7b rpc/createrawtransaction: redefine addresses as OBJ_USER_KEYS (Karl-Johan Alm)
d9e2183 rpc: include OBJ_USER_KEY in RPCArg constructor checks (Karl-Johan Alm)

Pull request description:

  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`.

ACKs for top commit:
  MarcoFalke:
    ACK 7031721 🐀

Tree-SHA512: 769377416c6226d1738a956fb685498e009f9e7eb2d45bc679b81c5364b9520fdbcb49392c937ab45598aa0d33589e8e6a59ccc101cf8d8e7dfdafd58d4eefd0
  • Loading branch information
MarcoFalke authored and vijaydasmp committed Apr 25, 2024
1 parent f720703 commit bd5dfca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static RPCHelpMan createrawtransaction()
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
" accepted as second parameter.",
{
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
{
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the Dash address, the value (float or string) is the amount in " + CURRENCY_UNIT},
},
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct RPCArg {
m_oneline_description{std::move(oneline_description)},
m_type_str{std::move(type_str)}
{
CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ);
CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ && type != Type::OBJ_USER_KEYS);
}

RPCArg(
Expand All @@ -194,7 +194,7 @@ struct RPCArg {
m_oneline_description{std::move(oneline_description)},
m_type_str{std::move(type_str)}
{
CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ);
CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ || type == Type::OBJ_USER_KEYS);
}

bool IsOptional() const;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ static RPCHelpMan listaddressgroupings()
{
{RPCResult::Type::ARR, "", "",
{
{RPCResult::Type::ARR, "", "",
{RPCResult::Type::ARR_FIXED, "", "",
{
{RPCResult::Type::STR, "address", "The Dash address"},
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},
Expand Down

0 comments on commit bd5dfca

Please sign in to comment.