Skip to content

Commit 2e6d8f2

Browse files
Merge #6872: docs(rpc): introduce GetJsonHelp() to complement ToJson() for Dash-specific objects to aid generating RPC help text
56514c7 chore: move RpcResult map outside `GetRpcResult()` (Kittywhiskers Van Gogh) f01930b chore: remove redundant `[[nodiscard]]` attributions in source file (Kittywhiskers Van Gogh) b7eb196 rpc: `GetJsonHelp()` defs for `DeterministicMN{,State{,{Diff}}}` (Kittywhiskers Van Gogh) 1be2226 rpc: `GetJsonHelp()` defs for `Quorum{Rotation,Snapshot}`,`RecoveredSig` (Kittywhiskers Van Gogh) ae4e05c rpc: `GetJsonHelp()` defs for `MNHFTx`, `CAsset{Un,}lock` (Kittywhiskers Van Gogh) ddc698b refactor: move pending `evo/`-specific definitions to `core_write.cpp` (Kittywhiskers Van Gogh) 73da03e refactor: move LLMQ-specific `ToJson()` definitions to separate file (Kittywhiskers Van Gogh) 7219a29 rpc: `GetJsonHelp()` defs for `CbTx`, `SimplifiedMNList`, final commitm. (Kittywhiskers Van Gogh) 9de8c9c trivial: add missing headers (Kittywhiskers Van Gogh) a9218b1 rpc: introduce `GetJsonHelp()` to provide help text for Dash RPC objects (Kittywhiskers Van Gogh) Pull request description: ## Motivation When working on extended addresses, we deprecated `service`, `platformHTTPPort` and `platformP2PPort` and had the _method_ of deprecation changed for `service` due to feedback. During that process, it was apparent that there wasn't a way to convey deprecation status outside of release notes as we didn't generate RPC help text for objects that feature the affected fields. Currently, the authoritative source of documentation is Dash Core developer documentation ([source](https://docs.dash.org/en/stable/docs/core/)) and it has been used as a source for the description of various fields described in the PR _but_ changes, reorganizations and deprecations are not reflected in real time when they are done in-source, they need to feature in a release in order for the corresponding documentation to reflect it. This makes development on nightlies relatively painful and makes decisions like deprecations noted in release notes with little to show for it in-source. This pull request aims to take the first step to remedying that. ## Additional Information * The description of a `GetJsonHelp()`'s `RPCResult` is suppressed if the `key` is blank, this is because if the object is part of an array, the description should be set in the higher level entity. * `clang-format` suggestions have been intentionally ignored in the interest of legibility, the extent of nesting and construction in this PR requires us to make an exception to standard linting practices. This is a general pain point in RPC code but is mentioned here for posterity. * This pull request is **not** exhaustive, the scope of this pull request is to define the help text for _objects_ and integrate them where convenient, if there are RPCs that have more complex structures, they will not benefit from this PR as no existing structure is present for `GetJsonHelp()` to slot into. Work on this can be addressed in future pull requests. * We have used `const std::string&` instead of `std::string_view` due to limitations in `RPCResult` and the UniValue API. If these limitations have been resolved, we can switch over to it trivially. This will **not** help make `RPCRESULT_MAP` `constexpr` as `std::map`s cannot be standalone `constexpr` objects even in C++26 ([source](https://en.cppreference.com/w/cpp/container/map.html)). ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests **(note: N/A)** - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 56514c7 UdjinM6: utACK 56514c7 Tree-SHA512: 2371163ad4f845aa896887373f982ffe30a232aff3332b01b38902b30023455c0b6319f9935ca5609ebcdb6fef6177e7692a9f060b9e2bdf8888ad104f76ace1
2 parents 2148106 + 56514c7 commit 2e6d8f2

23 files changed

+687
-228
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ libbitcoin_common_a_SOURCES = \
906906
init/common.cpp \
907907
key.cpp \
908908
key_io.cpp \
909+
llmq/core_write.cpp \
909910
merkleblock.cpp \
910911
net_types.cpp \
911912
netaddress.cpp \

src/core_io.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#ifndef BITCOIN_CORE_IO_H
66
#define BITCOIN_CORE_IO_H
77

8-
#include <consensus/amount.h>
98
#include <attributes.h>
9+
#include <consensus/amount.h>
1010

1111
#include <string>
1212
#include <vector>
@@ -15,12 +15,13 @@ class CBlock;
1515
class CBlockHeader;
1616
class CScript;
1717
class CTransaction;
18-
struct CMutableTransaction;
19-
class uint256;
20-
class UniValue;
2118
class CTxUndo;
22-
19+
class uint256;
20+
struct CMutableTransaction;
2321
struct CSpentIndexTxInfo;
22+
struct RPCResult;
23+
24+
class UniValue;
2425

2526
/**
2627
* Verbose level for block's transaction
@@ -57,4 +58,7 @@ std::string SighashToStr(unsigned char sighash_type);
5758
void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex = true, bool include_address = false);
5859
void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS, const CSpentIndexTxInfo* ptxSpentInfo = nullptr);
5960

61+
// evo/core_write.cpp
62+
RPCResult GetRpcResult(const std::string& key, bool optional = false);
63+
6064
#endif // BITCOIN_CORE_IO_H

src/evo/assetlocktx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
class CBlockIndex;
1818
class CRangesSet;
1919
class TxValidationState;
20+
struct RPCResult;
2021
namespace llmq {
2122
class CQuorumManager;
2223
} // namespace llmq
@@ -51,6 +52,7 @@ class CAssetLockPayload
5152

5253
std::string ToString() const;
5354

55+
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional);
5456
[[nodiscard]] UniValue ToJson() const;
5557

5658
// getters
@@ -108,6 +110,7 @@ class CAssetUnlockPayload
108110

109111
std::string ToString() const;
110112

113+
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional);
111114
[[nodiscard]] UniValue ToJson() const;
112115

113116
bool VerifySig(const llmq::CQuorumManager& qman, const uint256& msgHash, gsl::not_null<const CBlockIndex*> pindexTip, TxValidationState& state) const;

src/evo/cbtx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
#define BITCOIN_EVO_CBTX_H
77

88
#include <bls/bls.h>
9+
910
#include <primitives/transaction.h>
11+
1012
#include <univalue.h>
1113

1214
#include <optional>
15+
#include <string>
1316

1417
class BlockValidationState;
1518
class CBlock;
1619
class CBlockIndex;
1720
class CDeterministicMNList;
1821
class TxValidationState;
22+
struct RPCResult;
1923

2024
namespace llmq {
2125
class CQuorumBlockProcessor;
@@ -57,6 +61,7 @@ class CCbTx
5761

5862
}
5963

64+
[[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional);
6065
std::string ToString() const;
6166

6267
[[nodiscard]] UniValue ToJson() const;

0 commit comments

Comments
 (0)