Skip to content

Commit 2a22d90

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21897: rpc: adjust incorrect RPCHelpMan types
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
2 parents 3028a1e + 7031721 commit 2a22d90

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static RPCHelpMan createrawtransaction()
397397
"For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
398398
" accepted as second parameter.",
399399
{
400-
{"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
400+
{"", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::OMITTED, "",
401401
{
402402
{"address", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT},
403403
},

src/rpc/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct RPCArg {
173173
m_oneline_description{std::move(oneline_description)},
174174
m_type_str{std::move(type_str)}
175175
{
176-
CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ);
176+
CHECK_NONFATAL(type != Type::ARR && type != Type::OBJ && type != Type::OBJ_USER_KEYS);
177177
}
178178

179179
RPCArg(
@@ -193,7 +193,7 @@ struct RPCArg {
193193
m_oneline_description{std::move(oneline_description)},
194194
m_type_str{std::move(type_str)}
195195
{
196-
CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ);
196+
CHECK_NONFATAL(type == Type::ARR || type == Type::OBJ || type == Type::OBJ_USER_KEYS);
197197
}
198198

199199
bool IsOptional() const;

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ static RPCHelpMan listaddressgroupings()
540540
{
541541
{RPCResult::Type::ARR, "", "",
542542
{
543-
{RPCResult::Type::ARR, "", "",
543+
{RPCResult::Type::ARR_FIXED, "", "",
544544
{
545545
{RPCResult::Type::STR, "address", "The bitcoin address"},
546546
{RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + CURRENCY_UNIT},

0 commit comments

Comments
 (0)