Skip to content

Commit 2e71a9a

Browse files
Merge #6886: fix: multiple help string for RPC result
9af4c55 fix: typos and capitalizations (Konstantin Akimov) 690ff3a fix: apply suggestions from code review (Konstantin Akimov) 6e89094 fix: multiple code-review comments (Konstantin Akimov) 661db51 fix: add missing RPC help result for quorum RPCs (Konstantin Akimov) 72284b5 fix: add missing RPC help result for RPC getrawtransactionmulti (Konstantin Akimov) 7d6b606 fix: add missing RPC help result for evo RPCs (Konstantin Akimov) 3b4095c fix: add proper RPC result for governance RPC (Konstantin Akimov) b216d13 fix: set proper RPCResult for coinjoin RPC (Konstantin Akimov) b174fe0 fix: add missing RPC help result for RPC mockscheduler (Konstantin Akimov) cc1a8fd fix: add missing RPC help result for masternode RPCs (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented For many dash specific RPC we use stub `RPCResults` instead real documentation for returned values. It was possible because some important changes from backport bitcoin#20495 has been skipped. ## What was done? Replaced all stub RPCResults{} in RPC code to real help, or map with ELISION inside. For some RPC replaced ELISION to real description. ## How Has This Been Tested? See PR #6887: done extra testing with backports bitcoin#20495, bitcoin#25161, bitcoin#25170, bitcoin#24408, bitcoin#25237 and fixed all failures in functional tests. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK 9af4c55 kwvg: utACK 9af4c55 Tree-SHA512: 7b8842255050a9154ea4e2d8e7245888dfe96543c856b0e299b95e861156a2fc22a20abb882153ede75f901cfe420df344bbfd1c82364a7b44eb357c38fab4bb
2 parents c44bc8c + 9af4c55 commit 2e71a9a

File tree

8 files changed

+275
-46
lines changed

8 files changed

+275
-46
lines changed

src/rpc/coinjoin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static RPCHelpMan coinjoin()
5858
{
5959
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
6060
},
61-
RPCResults{},
61+
RPCResult{RPCResult::Type::NONE, "", ""},
6262
RPCExamples{""},
6363
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
6464
{
@@ -230,7 +230,7 @@ static RPCHelpMan coinjoinsalt()
230230
{
231231
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
232232
},
233-
RPCResults{},
233+
RPCResult{RPCResult::Type::NONE, "", ""},
234234
RPCExamples{""},
235235
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
236236
{

src/rpc/evo.cpp

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,16 @@ static RPCHelpMan protx_list()
14041404
{"detailed", RPCArg::Type::BOOL, RPCArg::Default{false}, "If not specified, only the hashes of the ProTx will be returned."},
14051405
{"height", RPCArg::Type::NUM, RPCArg::DefaultHint{"current chain-tip"}, ""},
14061406
},
1407-
RPCResults{},
1407+
RPCResult{
1408+
RPCResult::Type::ARR, "", "List of masternodes",
1409+
{
1410+
RPCResult{"when detailed=false", RPCResult::Type::STR, "", "ProTx hash"},
1411+
RPCResult{"when detailed=true", RPCResult::Type::OBJ, "", "",
1412+
{
1413+
// TODO: document fields of the detailed entry
1414+
{RPCResult::Type::ELISION, "", ""}
1415+
}},
1416+
}},
14081417
RPCExamples{""},
14091418
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
14101419
{
@@ -1511,6 +1520,7 @@ static RPCHelpMan protx_info()
15111520
RPCResult{
15121521
RPCResult::Type::OBJ, "", "Details about a specific deterministic masternode",
15131522
{
1523+
// TODO: implement proper doc for protx info
15141524
{RPCResult::Type::ELISION, "", ""}
15151525
}
15161526
},
@@ -1644,8 +1654,40 @@ static RPCHelpMan protx_listdiff()
16441654
{"baseBlock", RPCArg::Type::NUM, RPCArg::Optional::NO, "The starting block height."},
16451655
{"block", RPCArg::Type::NUM, RPCArg::Optional::NO, "The ending block height."},
16461656
},
1647-
RPCResults{},
1648-
RPCExamples{""},
1657+
RPCResult {
1658+
RPCResult::Type::OBJ, "", "",
1659+
{
1660+
{RPCResult::Type::NUM, "baseHeight", "Height of base (starting) block"},
1661+
{RPCResult::Type::NUM, "blockHeight", "Height of target (ending) block"},
1662+
{RPCResult::Type::ARR, "addedMNs", "Added masternodes",
1663+
{
1664+
{RPCResult::Type::OBJ, "", "",
1665+
{
1666+
// TODO: list fields of output for RPC help instead ELISION
1667+
{RPCResult::Type::ELISION, "", ""}
1668+
}},
1669+
},
1670+
},
1671+
{RPCResult::Type::ARR, "removedMns", "Removed masternodes",
1672+
{
1673+
{RPCResult::Type::STR_HEX, "protx", "ProTx of removed masternode"},
1674+
},
1675+
},
1676+
{RPCResult::Type::ARR, "updatedMNs", "Updated masternodes",
1677+
{
1678+
{RPCResult::Type::OBJ, "", "",
1679+
{
1680+
{RPCResult::Type::OBJ, "protx", "ProTx of updated masternode",
1681+
{
1682+
// TODO: list fields of output for RPC help instead ELISION
1683+
{RPCResult::Type::ELISION, "", ""}
1684+
}},
1685+
}},
1686+
},
1687+
},
1688+
},
1689+
},
1690+
RPCExamples{""},
16491691
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
16501692
{
16511693
const NodeContext& node = EnsureAnyNodeContext(request.context);
@@ -1743,7 +1785,7 @@ static RPCHelpMan protx_help()
17431785
{
17441786
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
17451787
},
1746-
RPCResults{},
1788+
RPCResult{RPCResult::Type::NONE, "", ""},
17471789
RPCExamples{""},
17481790
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
17491791
{
@@ -1833,7 +1875,7 @@ static RPCHelpMan bls_help()
18331875
{
18341876
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
18351877
},
1836-
RPCResults{},
1878+
RPCResult{RPCResult::Type::NONE, "", ""},
18371879
RPCExamples{""},
18381880
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
18391881
{

src/rpc/governance.cpp

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,20 @@ static RPCHelpMan gobject_count()
4343
{
4444
{"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "Output format: json (\"json\") or string in free form (\"all\")"},
4545
},
46-
RPCResults{},
46+
{
47+
RPCResult{"for mode = json",
48+
RPCResult::Type::OBJ, "", "",
49+
{
50+
{RPCResult::Type::NUM, "objects_total", "Total number of all governance objects"},
51+
{RPCResult::Type::NUM, "proposals", "Number of governance proposals"},
52+
{RPCResult::Type::NUM, "triggers", "Number of triggers"},
53+
{RPCResult::Type::NUM, "other", "Total number of unknown governance objects"},
54+
{RPCResult::Type::NUM, "erased", "Number of removed (expired) objects"},
55+
{RPCResult::Type::NUM, "votes", "Total number of votes"},
56+
}
57+
},
58+
RPCResult{"for mode = all", RPCResult::Type::STR, "", "Human-friendly summary string for proposals and votes"},
59+
},
4760
RPCExamples{""},
4861
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
4962
{
@@ -71,7 +84,7 @@ static RPCHelpMan gobject_deserialize()
7184
{
7285
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
7386
},
74-
RPCResults{},
87+
RPCResult{RPCResult::Type::STR, "", "JSON string of the deserialized governance object"},
7588
RPCExamples{""},
7689
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
7790
{
@@ -96,7 +109,12 @@ static RPCHelpMan gobject_check()
96109
{
97110
{"hex_data", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string format"},
98111
},
99-
RPCResults{},
112+
RPCResult{"if object is valid",
113+
RPCResult::Type::OBJ, "", "",
114+
{
115+
{RPCResult::Type::STR, "Object status", "OK"},
116+
}
117+
},
100118
RPCExamples{""},
101119
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
102120
{
@@ -145,7 +163,7 @@ static RPCHelpMan gobject_prepare()
145163
{"outputHash", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "the single output to submit the proposal fee from"},
146164
{"outputIndex", RPCArg::Type::NUM, RPCArg::Default{0}, "The output index."},
147165
},
148-
RPCResults{},
166+
{RPCResult{"if object valid", RPCResult::Type::STR_HEX, "", "The collateral transaction id (txid)"}},
149167
RPCExamples{""},
150168
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
151169
{
@@ -254,7 +272,16 @@ static RPCHelpMan gobject_list_prepared()
254272
{
255273
{"count", RPCArg::Type::NUM, RPCArg::Default{10}, "Maximum number of objects to return."},
256274
},
257-
RPCResults{},
275+
RPCResult{
276+
RPCResult::Type::ARR, "", "list of governance objects",
277+
{
278+
{RPCResult::Type::OBJ, "", "",
279+
{
280+
// TODO: list fields of output for RPC help instead ELISION
281+
{RPCResult::Type::ELISION, "", ""}
282+
}},
283+
}
284+
},
258285
RPCExamples{""},
259286
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
260287
{
@@ -303,7 +330,7 @@ static RPCHelpMan gobject_submit()
303330
{"data-hex", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "data in hex string form"},
304331
{"fee-txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "txid of the corresponding proposal fee transaction"},
305332
},
306-
RPCResults{},
333+
RPCResult{RPCResult::Type::STR_HEX, "hash", "Hash of the submitted governance object"},
307334
RPCExamples{""},
308335
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
309336
{
@@ -482,6 +509,23 @@ static bool CheckWalletOwnsKey(const CWallet& wallet, const CKeyID& keyid)
482509
return wallet.IsMine(script) == isminetype::ISMINE_SPENDABLE;
483510
}
484511

512+
namespace {
513+
const RPCResult vote_results{
514+
RPCResult::Type::OBJ, "", "",
515+
{
516+
{RPCResult::Type::STR, "overall", "Total number of successful and failed votes"},
517+
{RPCResult::Type::OBJ, "detail", "Detailed information for each vote",
518+
{
519+
{RPCResult::Type::OBJ, "protx", "ProTx of masternode for voting",
520+
{
521+
{RPCResult::Type::STR, "result", "Result of voting: {success|failed}"},
522+
{RPCResult::Type::STR, "errorMessage", /*optional=*/true, "Error message if failed"},
523+
}},
524+
}},
525+
},
526+
};
527+
} // anonymous namespace
528+
485529
static RPCHelpMan gobject_vote_many()
486530
{
487531
return RPCHelpMan{"gobject vote-many",
@@ -492,7 +536,7 @@ static RPCHelpMan gobject_vote_many()
492536
{"vote", RPCArg::Type::STR, RPCArg::Optional::NO, "vote, possible values: [funding|valid|delete|endorsed]"},
493537
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
494538
},
495-
RPCResults{},
539+
vote_results,
496540
RPCExamples{""},
497541
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
498542
{
@@ -545,7 +589,7 @@ static RPCHelpMan gobject_vote_alias()
545589
{"vote-outcome", RPCArg::Type::STR, RPCArg::Optional::NO, "vote outcome, possible values: [yes|no|abstain]"},
546590
{"protx-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "masternode's proTxHash"},
547591
},
548-
RPCResults{},
592+
vote_results,
549593
RPCExamples{""},
550594
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
551595
{
@@ -667,7 +711,18 @@ static RPCHelpMan gobject_list_helper(const bool make_a_diff)
667711
{"signal", RPCArg::Type::STR, RPCArg::Default{"valid"}, "cached signal, possible values: [valid|funding|delete|endorsed|all]"},
668712
{"type", RPCArg::Type::STR, RPCArg::Default{"all"}, "object type, possible values: [proposals|triggers|all]"},
669713
},
670-
RPCResults{},
714+
{
715+
RPCResult{"If request is valid",
716+
RPCResult::Type::OBJ, "hash", "Object details",
717+
{
718+
// TODO: list fields of output for RPC help instead ELISION
719+
{RPCResult::Type::ELISION, "", ""}
720+
},
721+
},
722+
RPCResult{"If request is invalid",
723+
RPCResult::Type::STR, "", "Error string"
724+
},
725+
},
671726
RPCExamples{""},
672727
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
673728
{
@@ -713,7 +768,15 @@ static RPCHelpMan gobject_get()
713768
{
714769
{"governance-hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "object id"},
715770
},
716-
RPCResults{},
771+
{
772+
RPCResult{
773+
RPCResult::Type::OBJ, "", "",
774+
{
775+
// TODO: list fields of output for RPC help instead ELISION
776+
{RPCResult::Type::ELISION, "", ""}
777+
}
778+
},
779+
},
717780
RPCExamples{""},
718781
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
719782
{
@@ -809,7 +872,12 @@ static RPCHelpMan gobject_getcurrentvotes()
809872
{"txid", RPCArg::Type::STR_HEX, RPCArg::Default{""}, "masternode collateral txid"},
810873
{"vout", RPCArg::Type::STR, RPCArg::Default{""}, "masternode collateral output index, required if <txid> present"},
811874
},
812-
RPCResults{},
875+
RPCResult{
876+
RPCResult::Type::OBJ_DYN, "", "Keys are hashes of vote, values are votes",
877+
{
878+
{RPCResult::Type::STR, "votes", "Human-friendly presentation of vote"},
879+
},
880+
},
813881
RPCExamples{""},
814882
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
815883
{
@@ -875,7 +943,7 @@ static RPCHelpMan gobject()
875943
{
876944
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
877945
},
878-
RPCResults{},
946+
RPCResult{RPCResult::Type::NONE, "", ""},
879947
RPCExamples{""},
880948
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
881949
{
@@ -897,7 +965,7 @@ static RPCHelpMan voteraw()
897965
{"time", RPCArg::Type::NUM, RPCArg::Optional::NO, ""},
898966
{"vote-sig", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, ""},
899967
},
900-
RPCResults{},
968+
RPCResult{RPCResult::Type::STR, "", "Result of voting"},
901969
RPCExamples{""},
902970
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
903971
{

src/rpc/masternode.cpp

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ static RPCHelpMan masternode_connect()
4949
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the masternode to connect"},
5050
{"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol"},
5151
},
52-
RPCResults{},
52+
RPCResult{
53+
RPCResult::Type::STR, "status", "Returns 'successfully connected' if successful"
54+
},
5355
RPCExamples{""},
5456
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
5557
{
@@ -85,7 +87,28 @@ static RPCHelpMan masternode_count()
8587
return RPCHelpMan{"masternode count",
8688
"Get information about number of masternodes.\n",
8789
{},
88-
RPCResults{},
90+
RPCResult{
91+
RPCResult::Type::OBJ, "", "",
92+
{
93+
{RPCResult::Type::NUM, "total", "Total number of Masternodes"},
94+
{RPCResult::Type::NUM, "enabled", "Number of enabled Masternodes"},
95+
{RPCResult::Type::OBJ, "details", "Breakdown of masternodes by type",
96+
{{RPCResult::Type::OBJ, "", "",
97+
{
98+
{RPCResult::Type::OBJ, "regular", "Details for regular masternodes",
99+
{
100+
{RPCResult::Type::NUM, "total", "Total number of regular Masternodes"},
101+
{RPCResult::Type::NUM, "enabled", "Number of enabled regular Masternodes"}
102+
}},
103+
{RPCResult::Type::OBJ, "evo", "Details for Evo nodes",
104+
{
105+
{RPCResult::Type::NUM, "total", "Total number of Evo nodes"},
106+
{RPCResult::Type::NUM, "enabled", "Number of enabled Evo nodes"}
107+
}},
108+
}},
109+
}}
110+
}
111+
},
89112
RPCExamples{""},
90113
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
91114
{
@@ -157,7 +180,13 @@ static RPCHelpMan masternode_status()
157180
return RPCHelpMan{"masternode status",
158181
"Print masternode status information\n",
159182
{},
160-
RPCResults{},
183+
RPCResult{
184+
RPCResult::Type::OBJ, "", "",
185+
{
186+
// TODO: implement proper type validator instead ELISION
187+
{RPCResult::Type::ELISION, "", ""}
188+
}
189+
},
161190
RPCExamples{""},
162191
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
163192
{
@@ -232,7 +261,12 @@ static RPCHelpMan masternode_winners()
232261
{"count", RPCArg::Type::NUM, RPCArg::Default{10}, "number of last winners to return"},
233262
{"filter", RPCArg::Type::STR, RPCArg::Default{""}, "filter for returned winners"},
234263
},
235-
RPCResults{},
264+
RPCResult{
265+
RPCResult::Type::OBJ_DYN, "", "Keys are block heights (as strings); values describe the payees for that height",
266+
{
267+
{RPCResult::Type::STR, "payee", "Payee for the height"}
268+
}
269+
},
236270
RPCExamples{""},
237271
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
238272
{
@@ -454,7 +488,7 @@ static RPCHelpMan masternode_help()
454488
{
455489
{"command", RPCArg::Type::STR, RPCArg::Optional::NO, "The command to execute"},
456490
},
457-
RPCResults{},
491+
RPCResult{RPCResult::Type::NONE, "", ""},
458492
RPCExamples{""},
459493
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
460494
{
@@ -491,7 +525,13 @@ static RPCHelpMan masternodelist_helper(bool is_composite)
491525
{"mode", RPCArg::Type::STR, RPCArg::DefaultHint{"json"}, "The mode to run list in"},
492526
{"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"},
493527
},
494-
RPCResults{},
528+
RPCResult{
529+
RPCResult::Type::OBJ, "", "",
530+
{
531+
// TODO: implement proper type validator instead ELISION
532+
{RPCResult::Type::ELISION, "", ""}
533+
}
534+
},
495535
RPCExamples{""},
496536
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
497537
{

src/rpc/node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static RPCHelpMan mockscheduler()
827827
{
828828
{"delta_time", RPCArg::Type::NUM, RPCArg::Optional::NO, "Number of seconds to forward the scheduler into the future." },
829829
},
830-
RPCResults{},
830+
RPCResult{RPCResult::Type::NONE, "", ""},
831831
RPCExamples{""},
832832
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
833833
{

0 commit comments

Comments
 (0)