Skip to content
4 changes: 2 additions & 2 deletions src/rpc/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static RPCHelpMan coinjoin()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -231,7 +231,7 @@ static RPCHelpMan coinjoinsalt()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
52 changes: 47 additions & 5 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,16 @@ static RPCHelpMan protx_list()
{"detailed", RPCArg::Type::BOOL, RPCArg::Default{false}, "If not specified, only the hashes of the ProTx will be returned."},
{"height", RPCArg::Type::NUM, RPCArg::DefaultHint{"current chain-tip"}, ""},
},
RPCResults{},
RPCResult{
RPCResult::Type::ARR, "", "List of masternodes",
{
RPCResult{"when detailed=false", RPCResult::Type::STR, "", "ProTx hash"},
RPCResult{"when detailed=true", RPCResult::Type::OBJ, "", "",
{
// TODO: document fields of the detailed entry
{RPCResult::Type::ELISION, "", ""}
}},
}},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -1511,6 +1520,7 @@ static RPCHelpMan protx_info()
RPCResult{
RPCResult::Type::OBJ, "", "Details about a specific deterministic masternode",
{
// TODO: implement proper doc for protx info
{RPCResult::Type::ELISION, "", ""}
}
},
Expand Down Expand Up @@ -1644,8 +1654,40 @@ static RPCHelpMan protx_listdiff()
{"baseBlock", RPCArg::Type::NUM, RPCArg::Optional::NO, "The starting block height."},
{"block", RPCArg::Type::NUM, RPCArg::Optional::NO, "The ending block height."},
},
RPCResults{},
RPCExamples{""},
RPCResult {
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::NUM, "baseHeight", "Height of base (starting) block"},
{RPCResult::Type::NUM, "blockHeight", "Height of target (ending) block"},
{RPCResult::Type::ARR, "addedMNs", "Added masternodes",
{
{RPCResult::Type::OBJ, "", "",
{
// TODO: list fields of output for RPC help instead ELISION
{RPCResult::Type::ELISION, "", ""}
}},
},
},
{RPCResult::Type::ARR, "removedMns", "Removed masternodes",
{
{RPCResult::Type::STR_HEX, "protx", "ProTx of removed masternode"},
},
},
{RPCResult::Type::ARR, "updatedMNs", "Updated masternodes",
{
{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::OBJ, "protx", "ProTx of updated masternode",
{
// TODO: list fields of output for RPC help instead ELISION
{RPCResult::Type::ELISION, "", ""}
}},
}},
},
},
},
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const NodeContext& node = EnsureAnyNodeContext(request.context);
Expand Down Expand Up @@ -1743,7 +1785,7 @@ static RPCHelpMan protx_help()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -1833,7 +1875,7 @@ static RPCHelpMan bls_help()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
94 changes: 81 additions & 13 deletions src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ static RPCHelpMan gobject_count()
{
{"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "Output format: json (\"json\") or string in free form (\"all\")"},
},
RPCResults{},
{
RPCResult{"for mode = json",
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::NUM, "objects_total", "Total number of all governance objects"},
{RPCResult::Type::NUM, "proposals", "Number of governance proposals"},
{RPCResult::Type::NUM, "triggers", "Number of triggers"},
{RPCResult::Type::NUM, "other", "Total number of unknown governance objects"},
{RPCResult::Type::NUM, "erased", "Number of removed (expired) objects"},
{RPCResult::Type::NUM, "votes", "Total number of votes"},
}
},
RPCResult{"for mode = all", RPCResult::Type::STR, "", "Human-friendly summary string for proposals and votes"},
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -71,7 +84,7 @@ static RPCHelpMan gobject_deserialize()
{
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
},
RPCResults{},
RPCResult{RPCResult::Type::STR, "", "JSON string of the deserialized governance object"},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand All @@ -96,7 +109,12 @@ static RPCHelpMan gobject_check()
{
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string format"},
},
RPCResults{},
RPCResult{"if object is valid",
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "Object status", "OK"},
}
},
Comment on lines +112 to +117
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix misleading field description.

The description parameter should describe what the field contains, not show the literal value. Line 115 currently has "OK" as the description, but it should explain that this field contains the validation status.

Apply this diff:

             {
-                {RPCResult::Type::STR, "Object status", "OK"},
+                {RPCResult::Type::STR, "Object status", "Validation status (\"OK\" if valid)"},
             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RPCResult{"if object is valid",
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "Object status", "OK"},
}
},
RPCResult{"if object is valid",
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "Object status", "Validation status (\"OK\" if valid)"},
}
},
🤖 Prompt for AI Agents
In src/rpc/governance.cpp around lines 112 to 117, the RPCResult entry uses a
misleading description label for the "Object status" field by setting the
description to the literal "OK"; change that description to a brief explanatory
string indicating it contains the object's validation/verification status (for
example "validation status, e.g., 'OK' or an error code") so the description
explains the content rather than showing a sample value.

RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -145,7 +163,7 @@ static RPCHelpMan gobject_prepare()
{"outputHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "the single output to submit the proposal fee from"},
{"outputIndex", RPCArg::Type::NUM, RPCArg::Default{0}, "The output index."},
},
RPCResults{},
{RPCResult{"if object valid", RPCResult::Type::STR_HEX, "", "The collateral transaction id (txid)"}},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -254,7 +272,16 @@ static RPCHelpMan gobject_list_prepared()
{
{"count", RPCArg::Type::NUM, RPCArg::Default{10}, "Maximum number of objects to return."},
},
RPCResults{},
RPCResult{
RPCResult::Type::ARR, "", "list of governance objects",
{
{RPCResult::Type::OBJ, "", "",
{
// TODO: list fields of output for RPC help instead ELISION
{RPCResult::Type::ELISION, "", ""}
}},
}
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -303,7 +330,7 @@ static RPCHelpMan gobject_submit()
{"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
{"fee-txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "txid of the corresponding proposal fee transaction"},
},
RPCResults{},
RPCResult{RPCResult::Type::STR_HEX, "hash", "Hash of the submitted governance object"},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -484,6 +511,23 @@ static bool CheckWalletOwnsKey(const CWallet& wallet, const CKeyID& keyid)
return wallet.IsMine(script) == isminetype::ISMINE_SPENDABLE;
}

namespace {
const RPCResult vote_results{
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "overall", "Total number of successful and failed votes"},
{RPCResult::Type::OBJ, "detail", "Detailed information for each vote",
{
{RPCResult::Type::OBJ, "protx", "ProTx of masternode for voting",
{
{RPCResult::Type::STR, "result", "Result of voting: {success|failed}"},
{RPCResult::Type::STR, "errorMessage", /*optional=*/true, "Error message if failed"},
}},
}},
},
};
} // anonymous namespace

static RPCHelpMan gobject_vote_many()
{
return RPCHelpMan{"gobject vote-many",
Expand All @@ -494,7 +538,7 @@ static RPCHelpMan gobject_vote_many()
{"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"},
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
},
RPCResults{},
vote_results,
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -547,7 +591,7 @@ static RPCHelpMan gobject_vote_alias()
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
{"protx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "masternode's proTxHash"},
},
RPCResults{},
vote_results,
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -669,7 +713,18 @@ static RPCHelpMan gobject_list_helper(const bool make_a_diff)
{"signal", RPCArg::Type::STR, RPCArg::Default{"valid"}, "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
{"type", RPCArg::Type::STR, RPCArg::Default{"all"}, "object type, possible values: [proposals|triggers|all]"},
},
RPCResults{},
{
RPCResult{"If request is valid",
RPCResult::Type::OBJ, "hash", "Object details",
{
// TODO: list fields of output for RPC help instead ELISION
{RPCResult::Type::ELISION, "", ""}
},
},
RPCResult{"If request is invalid",
RPCResult::Type::STR, "", "Error string"
},
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -715,7 +770,15 @@ static RPCHelpMan gobject_get()
{
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"},
},
RPCResults{},
{
RPCResult{
RPCResult::Type::OBJ, "", "",
{
// TODO: list fields of output for RPC help instead ELISION
{RPCResult::Type::ELISION, "", ""}
}
},
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -811,7 +874,12 @@ static RPCHelpMan gobject_getcurrentvotes()
{"txid", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "masternode collateral txid"},
{"vout", RPCArg::Type::STR, RPCArg::Default{""}, "masternode collateral output index, required if <txid> present"},
},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ_DYN, "", "Keys are hashes of vote, values are votes",
{
{RPCResult::Type::STR, "votes", "Human-friendly presentation of vote"},
},
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -877,7 +945,7 @@ static RPCHelpMan gobject()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand All @@ -899,7 +967,7 @@ static RPCHelpMan voteraw()
{"time", RPCArg::Type::NUM, RPCArg::Optional::NO, ""},
{"vote-sig", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""},
},
RPCResults{},
RPCResult{RPCResult::Type::STR, "", "Result of voting"},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
52 changes: 46 additions & 6 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ static RPCHelpMan masternode_connect()
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the masternode to connect"},
{"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol"},
},
RPCResults{},
RPCResult{
RPCResult::Type::STR, "status", "Returns 'successfully connected' if successful"
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -85,7 +87,28 @@ static RPCHelpMan masternode_count()
return RPCHelpMan{"masternode count",
"Get information about number of masternodes.\n",
{},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::NUM, "total", "Total number of Masternodes"},
{RPCResult::Type::NUM, "enabled", "Number of enabled Masternodes"},
{RPCResult::Type::OBJ, "details", "Breakdown of masternodes by type",
{{RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::OBJ, "regular", "Details for regular masternodes",
{
{RPCResult::Type::NUM, "total", "Total number of regular Masternodes"},
{RPCResult::Type::NUM, "enabled", "Number of enabled regular Masternodes"}
}},
{RPCResult::Type::OBJ, "evo", "Details for Evo nodes",
{
{RPCResult::Type::NUM, "total", "Total number of Evo nodes"},
{RPCResult::Type::NUM, "enabled", "Number of enabled Evo nodes"}
}},
}},
}}
}
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -157,7 +180,13 @@ static RPCHelpMan masternode_status()
return RPCHelpMan{"masternode status",
"Print masternode status information\n",
{},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
// TODO: implement proper type validator instead ELISION
{RPCResult::Type::ELISION, "", ""}
}
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -232,7 +261,12 @@ static RPCHelpMan masternode_winners()
{"count", RPCArg::Type::NUM, RPCArg::Default{10}, "number of last winners to return"},
{"filter", RPCArg::Type::STR, RPCArg::Default{""}, "filter for returned winners"},
},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ_DYN, "", "Keys are block heights (as strings); values describe the payees for that height",
{
{RPCResult::Type::STR, "payee", "Payee for the height"}
}
},
Comment on lines +264 to +269
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Clarify that values are comma-separated payment strings, not single payees.

The description at line 267 says "Payee for the height", but the implementation returns a comma-separated string that can include multiple addresses: the masternode owner payout, operator reward payout (line 233), and superblock payees (lines 241-251). This will mislead API consumers expecting a single payee.

Apply this diff to clarify:

-                {RPCResult::Type::STR, "payee", "Payee for the height"}
+                {RPCResult::Type::STR, "payments", "Comma-separated list of payment addresses (masternode payout, operator reward if applicable, and superblock payees if triggered)"}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RPCResult{
RPCResult::Type::OBJ_DYN, "", "Keys are block heights (as strings); values describe the payees for that height",
{
{RPCResult::Type::STR, "payee", "Payee for the height"}
}
},
RPCResult{
RPCResult::Type::OBJ_DYN, "", "Keys are block heights (as strings); values describe the payees for that height",
{
{RPCResult::Type::STR, "payments", "Comma-separated list of payment addresses (masternode payout, operator reward if applicable, and superblock payees if triggered)"}
}
},
🤖 Prompt for AI Agents
In src/rpc/masternode.cpp around lines 264 to 269, the RPC result description
currently says "Payee for the height" but the implementation returns a
comma-separated string containing potentially multiple payment entries
(masternode owner payout, operator reward payout, and superblock payees). Update
the RPCResult description to indicate that values are comma-separated payment
strings (e.g., "Comma-separated payment strings: masternode owner payout,
operator reward payout, and any superblock payees") so API consumers understand
multiple payees can be present.

RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -454,7 +488,7 @@ static RPCHelpMan masternode_help()
{
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down Expand Up @@ -491,7 +525,13 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
{"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "The mode to run list in"},
{"filter", RPCArg::Type::STR, RPCArg::Default{""}, "Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available"},
},
RPCResults{},
RPCResult{
RPCResult::Type::OBJ, "", "",
{
// TODO: implement proper type validator instead ELISION
{RPCResult::Type::ELISION, "", ""}
}
},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ static RPCHelpMan mockscheduler()
{
{"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, "Number of seconds to forward the scheduler into the future." },
},
RPCResults{},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{""},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
Expand Down
Loading
Loading