aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/server.cpp
AgeCommit message (Collapse)Author
2021-04-17rpc: Keep default argument value in correct typeJoão Barbosa
2021-04-01rpc: Fail to return undocumented return valuesMarcoFalke
2021-03-29refactor: replace util::Ref by std::any (C++17)Sebastian Falbesoner
2021-01-29Remove pointer cast in CRPCTable::dumpArgMapRussell Yanofsky
CRPCTable::dumpArgMap currently works by casting RPC command unique_id integer field to a function pointer, and then calling the function. The unique_id field wasn't supposed to be used this way (it's meant to be used to detect RPC aliases), and this code segfaults in the rpc_help.py test in multiprocess PR https://github.com/bitcoin/bitcoin/pull/10102 because wallet RPC functions aren't directly accessible from the node process. Fix this by adding a new GET_ARGS request mode to retrieve argument information similar to the way the GET_HELP mode retrieves help information.
2021-01-29refactor: Add RPC server ExecuteCommands functionRussell Yanofsky
No change in behavior. New function is split from CRPCTable::execute and used in the next commit.
2021-01-29refactor: Replace JSONRPCRequest fHelp field with mode fieldRussell Yanofsky
No change in behavior
2021-01-28rpc: Remove duplicate name and argNames from CRPCCommandMarcoFalke
2021-01-28rpc: Use RPCHelpMan for check-rpc-mappings linterMarcoFalke
2020-08-14rpc: Remove unused return type from appendCommandMarcoFalke
2020-08-02refactor: Use C++11 range based for loops to simplify rpc codeMarcoFalke
2020-07-15Merge #19386: rpc: Assert that RPCArg names are equal to CRPCCommand ones ↵MarcoFalke
(server) fa7592bfa8691eb0289b21da3571709a18391b0f rpc: Update server to use new RPCHelpMan (MarcoFalke) aaaaad562790cd4dce1568ae193f5393aacacedf rpc: Add option to hide RPCArg (MarcoFalke) fa9708f94c01cb8bf2971bdf404af38c38fa341b rpc: Assert that passed arg names are equal to hardcoded ones (MarcoFalke) faaeb2b0b347b40ce456a951eec5e820587e5b02 rpc: Add CRPCCommand constructor which takes RPCHelpMan (MarcoFalke) fa8ec00061567e56333bb69c5623919d45a9a92d rpc: Check that left section is not multiline (MarcoFalke) Pull request description: This is split out from #18531 to just touch the RPC methods in server. Description from the main pr: ### Motivation RPCArg names in the rpc help are currently only used for documentation. However, in the future they could be used to teach the server the named arguments. Named arguments are currently registered by the `CRPCCommand`s and duplicate the RPCArg names from the documentation. This redundancy is fragile, and has lead to errors in the past (despite having linters to catch those kind of errors). See section "bugs found" for a list of bugs that have been found as a result of the changes here. ### Changes The changes here add an assert in the `CRPCCommand` constructor that the RPCArg names are identical to the ones in the `CRPCCommand`. ### Future work > Here or follow up, makes sense to also assert type of returned UniValue? Sure, but let's not get ahead of ourselves. I am going to submit any further works as follow-ups, including: * Removing the CRPCCommand arguments, now that they are asserted to be equal and thus redundant * Removing all python regex linters on the args, now that RPCMan can be used to generate any output, including the cli.cpp table * Auto-formatting and sanity checking the RPCExamples with RPCMan * Checking passed-in json in self-check. Removing redundant checks * Checking returned json against documentation to avoid regressions or false documentation * Compile the RPC documentation at compile-time to ensure it doesn't change at runtime and is completely static ### Bugs found * The assert identified issue #18607 * The changes itself fixed bug #19250 ACKs for top commit: laanwj: ACK fa7592bfa8691eb0289b21da3571709a18391b0f ryanofsky: Code review ACK fa7592bfa8691eb0289b21da3571709a18391b0f. Looks great! Just some hidden arg and Check() and comment cleanups since last review Tree-SHA512: e64b6a212f4a3aeedeee47557559bde104d5fd40cdc1746b27eb2f3d4c8885d5e6e4dd287595ea11cdbc6a939654fe103cae765fd505875444d851f0abb11308
2020-07-03rpc: Update server to use new RPCHelpManMarcoFalke
Also, move Check to inside HandleRequest
2020-06-28refactor: Replace RecursiveMutex with Mutex in rpc/server.cppHennadii Stepanov
2020-05-29Limit scope of all global std::once_flagMarcoFalke
2020-05-29Merge #18452: qt: Fix shutdown when waitfor* cmds are called from RPC consoleJonas Schnelli
da73f1513a637a9f347b64de66564d6cdb2541f8 qt: Fix shutdown when waitfor* cmds are called from RPC console (Hennadii Stepanov) Pull request description: On master (7eed413e72a236b6f1475a198f7063fd24929e23), if the GUI has been started with`-server=1`, `bitcoin-qt` hangs on shutdown during calling any of the `waitfor*` commands in the GUI RPC console. This PR suggests minimal changes to fix this bug. Fix #17495 ACKs for top commit: jonasschnelli: utACK da73f1513a637a9f347b64de66564d6cdb2541f8 Tree-SHA512: 469f5332945a5f2c57d19336cda5df79b123ccc494aea6d58a85eb1293be52708b2b9c5bb6bc2c402a90b7b4e9e8d7ab8fe84cf201cf7ce612c9290c57e43681
2020-05-22rpc: factor out RpcInterruptionPoint from dumptxoutsetMarcoFalke
2020-05-13qt: Fix shutdown when waitfor* cmds are called from RPC consoleHennadii Stepanov
2020-04-29rpc: Add mutex to guard deadlineTimersJoão Barbosa
2020-03-13rpc: Document an RPCResult for all calls; Enforce at compile timeMarcoFalke
2020-03-06Merge #16117: util: Replace boost sleep with std sleepfanquake
fae86c38bca5c960462e53975314a0749db5d17d util: Remove unused MilliSleep (MarcoFalke) fa9af06d91e9357e86863781746f0e78a509967e scripted-diff: Replace MilliSleep with UninterruptibleSleep (MarcoFalke) fa4620be782c2bf6b5ffddf4f671194fdd1536f3 util: Add UnintrruptibleSleep (MarcoFalke) Pull request description: We don't use the interruptible feature of boost's sleep anywhere, so replace it with the sleep in `std::thread` ACKs for top commit: ajtowns: ACK fae86c38bca5c960462e53975314a0749db5d17d quick code review practicalswift: ACK fae86c38bca5c960462e53975314a0749db5d17d -- patch looks correct sipa: Concept and code review ACK fae86c38bca5c960462e53975314a0749db5d17d fanquake: ACK fae86c38bca5c960462e53975314a0749db5d17d - note that an instance of `DHAVE_WORKING_BOOST_SLEEP_FOR` was missed in the [linter](https://github.com/bitcoin/bitcoin/blob/master/test/lint/extended-lint-cppcheck.sh#L69), but that can be cleaned up later. Tree-SHA512: 7c0f8eb197664b9f7d9fe6c472c77d384f11c797c913afc31de4b532e3b4fd9ea6dd174f92062ff9d1ec39b25e0900ca7c597435add87f0f2477d9557204848c
2020-02-25rpc: Auto-format RPCResultMarcoFalke
2020-02-21scripted-diff: Replace MilliSleep with UninterruptibleSleepMarcoFalke
This is safe because MilliSleep is never executed in a boost::thread, the only type of thread that is interruptible. * The RPC server uses std::thread * The wallet is either executed in an RPC thread or the main thread * bitcoin-cli, benchmarks and tests are only one thread (the main thread) -BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/MilliSleep\((\S+)\);/UninterruptibleSleep(std::chrono::milliseconds{\1});/g' $(git grep -l MilliSleep) -END VERIFY SCRIPT-
2020-02-09scripted-diff: Add missing spaces in RPCResult, Fix type namesMarcoFalke
This makes the rendered diff smaller when the RPCResult is machine generated later on -BEGIN VERIFY SCRIPT- # Add space after dictionary key and before colon sed -i --regexp-extended -e 's/(^ +" +\\"[a-zA-Z_]+\\"): ?/\1 : /g' $(git grep -l '\\":') # Rename (array) to (json array) sed -i -e 's/ (array) / (json array) /g' $(git grep -l '(array)' ./src) # Rename (object) to (json object) sed -i -e 's/ (object) / (json object) /g' $(git grep -l '(object)' ./src) # Rename (bool) to (boolean) sed -i -e 's/ (bool) / (boolean) /g' $(git grep -l '(bool)' ./src) # Rename (int) to (numeric) sed -i -e 's/ (int) / (numeric) /g' $(git grep -l '(int)' ./src) -END VERIFY SCRIPT-
2020-01-15scripted-diff: Bump copyright of files changed in 2020MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-01-15scripted-diff: Replace CCriticalSection with RecursiveMutexMarcoFalke
-BEGIN VERIFY SCRIPT- # Delete outdated alias for RecursiveMutex sed -i -e '/CCriticalSection/d' ./src/sync.h # Replace use of outdated alias with RecursiveMutex sed -i -e 's/CCriticalSection/RecursiveMutex/g' $(git grep -l CCriticalSection) -END VERIFY SCRIPT-
2019-10-15Remove unused includespracticalswift
2019-08-01log: harmonize bitcoind server loggingJon Atack
Harmonize the user-facing output of the `bitcoind -daemon`, `bitcoin-cli help stop`, `bitcoin-cli stop`, and `bitcoind -version` commands to be consistent with each other as well as with the "Bitcoin Core is probably already running" messages, e.g. `git grep 'probably already running.")'`.
2019-07-09Merge #16240: JSONRPCRequest-aware RPCHelpManMarcoFalke
b6fb617aaaad5f9cdd7f2ad2825b253ca792055d rpc: switch to using RPCHelpMan.Check() (Karl-Johan Alm) c7a9fc234f3ce400ce78b9b434d2d210b2646c50 Make the RPCHelpMan aware of JSONRPCRequest and add Check() helper (Karl-Johan Alm) 5c5e32bbe3dfa790dd8bb421fbd6301ae10b09f5 rpc: migrate JSONRPCRequest functionality into request.cpp (Karl-Johan Alm) 0ab8ba1ac65b70f044a5e323b13d098cef33695a rpc: fix RPC help requirements for getblocktemplate (Karl-Johan Alm) Pull request description: Every single RPC call has a helper-section at the start, which throws a help string if the user asks for help or if the user provided too few/many arguments. ```C++ const RPCHelpMan help{...}; if (request.fHelp || !help.IsValidNumArgs(request.params.size())) { throw std::runtime_error(help.ToString()); } ``` or (older version) ```C++ if (request.fHelp || request.params.size() < min || request.params.size() > max) throw std::runtime_error( RPCHelpMan{...}.ToString() ); ``` It seems like an obvious improvement, and less copy-pasting, to make `RPCHelpMan` aware of `JSONRPCRequest`, and to let it handle the checks instead. Both of the above become ```C++ RPCHelpMan{...}.Check(request); ``` which means we save roughly 3 lines per RPC command, and the `RPCHelpMan` instance is never referenced afterwards, so the approach is a tiny fraction cleaner. This is a complete update, sans a few special case locations that had special rules. 623 lines turn into 284 (which includes the addition to `RPCHelpMan`). ACKs for top commit: laanwj: code rview and lightly tested ACK b6fb617aaaad5f9cdd7f2ad2825b253ca792055d MarcoFalke: ACK b6fb617aaa, looked at the diff, verified move-only where applicable Tree-SHA512: eb73f47f812512905b852e313281d1c8df803db40a6188aa39d5a7586631664db6764491152a8a96769946c796dc56d38c6e3a66ddd06ba3fb9d20050e6274e1
2019-07-08rpc: switch to using RPCHelpMan.Check()Karl-Johan Alm
2019-07-05rpc: migrate JSONRPCRequest functionality into request.cppKarl-Johan Alm
2019-07-03Add logpath description for getrpcinfoGregory Sanders
2019-07-03Merge #15483: rpc: Adding a 'logpath' entry to getrpcinfoWladimir J. van der Laan
8a6810d0d2759c69f63b53c48aa79e0cfdd88ffb Add a 'logpath' field to getrpcinfo (darosior) Pull request description: as discussed in #15438 ACKs for top commit: laanwj: Tested ACK 8a6810d0d2759c69f63b53c48aa79e0cfdd88ffb Tree-SHA512: 752c7d90f670677c8144efb338c5c97c2264f85f1e65e031fd5a44f04230b6eafbabd0f634db263eb42c25642ecc1c4b1b602d4735e3fab07ec00b566134ddab
2019-06-02Make reasoning about dependencies easier by not including unused dependenciespracticalswift
2019-05-16Add a 'logpath' field to getrpcinfodarosior
2019-04-10Merge #15638: Move-only: Pull wallet code out of libbitcoin_serverWladimir J. van der Laan
4d074e84a2cf419510e2920417799f62747f4b07 [build] Move AnalyzePSBT from psbt.cpp to node/psbt.cpp (Russell Yanofsky) fd509bd1f71df628b933ea7a135a9a957a5e0136 [docs] Document src subdirectories and different libraries (John Newbery) 9eaeb7fb8d4ab0d4493849e6c17e314fd75fea9c [build] Move wallet load functions to wallet/load unit (John Newbery) 91a25d1e711bfc0617027eee18b9777ff368d6b9 [build] Add several util units (John Newbery) 99517866b62c261f990e1f897502855afc12f2a7 [build] Move several units into common libraries (John Newbery) 0509465542d63a5bbe7296f283f44dd491e74f78 [build] Move rpc rawtransaction util functions to rpc/rawtransaction_util.cpp (John Newbery) 1acc61f8746bc6efb905e121a9f607c4f5982b35 [build] Move rpc utility methods to rpc/util (John Newbery) 4a75c9d6512a5580e60104103ea11d2cd9586354 [build] Move policy settings to new src/policy/settings unit (John Newbery) fdf8888b6f0c63e8a4cb1459752625e642d6a4dd [build] Move CheckTransaction from lib_server to lib_consensus (John Newbery) Pull request description: This is a move-only commit. No code is changing and the moves can be easily verified with: ```sh git log -p -n1 --color-moved=dimmed_zebra ``` This commit moves functions and variables that wallet code depends on out of libbitcoin_server.a, so the bitcoin-wallet tool can be built without libbitcoin_server.a in #15639, and attempting to access server state from wallet code will result in link errors instead of silently broken code. List of moves: - `CheckTransaction` moves from `consensus/tx_verify.cpp` to `consensus/tx_check.cpp` - `urlDecode` moves from `httpserver.cpp` to `util/url.cpp` - `TransactionErrorString` moves from `node/transaction.cpp` to `util/error.cpp` - `StringForFeeReason` and `FeeModeFromString` move from `policy/fees.cpp` to `util/fees.cpp` - `incrementalRelayFee` `dustRelayFee` and `nBytesPerSigOp` move from `policy/policy.cpp` to `policy/settings.cpp` - `SignalsOptInRBF` moves from `policy/rbf.cpp` to `util/rbf.cpp` - `fIsBareMultisigStd` moves from `validation.cpp` to `policy/settings.cpp` - `ConstructTransaction` `TxInErrorToJSON` and `SignTransaction` move from `rpc/rawtransaction.cpp` to `rpc/rawtransaction_util.cpp` - `RPCTypeCheck` `RPCTypeCheckArgument` `RPCTypeCheckObj` `AmountFromValue` `ParseHashV``ParseHashO` `ParseHexV` `ParseHexO` `HelpExampleCli` and `HelpExampleRpc` move from `rpc/server.cpp` to `rpc/util.cpp` - `AmountHighWarn` and `AmountErrMsg` move from `ui_interface.cpp` to `util/error.cpp` - `FormatStateMessage` and `strMessageMagic` move from `validation.cpp` to `util/validation.cpp` - `VerifyWallets` `LoadWallets` `StartWallets` `FlushWallets` `StopWallets` and `UnloadWallets` move from `wallet/init.cpp` to `wallet/node.cpp` ACKs for commit 4d074e: jnewbery: utACK 4d074e84a2cf419510e2920417799f62747f4b07 (checked by doing the rebase myself and verifying no difference between my branch and 4d074e84a2cf419510e2920417799f62747f4b07) Tree-SHA512: 5e1604a9fb06475f2b96da0de0baa8330f4dda834dc20a0183ef11e1e4c27631d1d1bbb9abf0054efc03d56945fdf9920f63366b6a4f200f665b742a479ff75c
2019-04-09[build] Move rpc utility methods to rpc/utilJohn Newbery
Moves the following utility methods to rpc/util and moves that unit to libbitcoin_common so they can be accessed by all libraries. - `RPCTypeCheck` - `RPCTypeCheckArgument` - `RPCTypeCheckObj` - `AmountFromValue` - `ParseHashV``ParseHashO` - `ParseHexV` - `ParseHexO` - `HelpExampleCli` - `HelpExampleRpc`
2019-04-05rpc: getrpcinfo docsBen Carman
2019-03-05Remove use of CRPCTable::appendCommand in wallet codeRussell Yanofsky
This commit does not change behavior.
2019-02-11RPCHelpMan: Check default values are given at compile-timeMarcoFalke
2019-01-29Merge #14987: RPCHelpMan: Pass through Result and ExamplesMarcoFalke
faa1522e5e RPCHelpMan: Pass through Result and Examples (MarcoFalke) Pull request description: Passing the rpc result and rpc examples through `RPCHelpMan` makes it clear in what order they appear in the stringified version. Future improvements could then autoformat or autogenerate them. Tree-SHA512: b32a5c178cc80f50a7e9b93a38e2b26d5994188ecafe9e61bbc599941b44b9b0e4e4be6413d4464fac6e8e73661a191a77d34917f2e6293de19fb59519dd4487
2019-01-27rpc: Compile on GCC4.8MarcoFalke
2019-01-25RPCHelpMan: Pass through Result and ExamplesMarcoFalke
2019-01-14Merge #14982: rpc: Add getrpcinfo commandWladimir J. van der Laan
a0ac15459a0df598e1ee1fd36a3899a129cecaeb doc: Add getrpcinfo release notes (João Barbosa) 251a91c1bf245b3674c2612149382a0f1e18dc98 qa: Add tests for getrpcinfo (João Barbosa) d0730f5ce475e5a84da7c61fe79bcd6ed24d693e rpc: Add getrpcinfo command (João Barbosa) 068a8fc05f8dbec198bdc3fe46f955d8a5255303 rpc: Track active commands (João Barbosa) bf4383277d6761cc5b7a91975752c08df829af72 rpc: Remove unused PreCommand signal (João Barbosa) Pull request description: The new `getrpcinfo` command exposes details of the RPC interface. The details can be configuration properties or runtime values/stats. This can be particular useful to coordinate concurrent functional tests (see #14958 from where this was extracted). Tree-SHA512: 7292cb6087f4c429973d991aa2b53ffa1327d5a213df7d6ba5fc69b01b2e1a411f6d1609fed9234896293317dab05f65064da48b8f2b4a998eba532591d31882
2019-01-02rpc: Add getrpcinfo commandJoão Barbosa
2019-01-02rpc: Track active commandsJoão Barbosa
2018-12-29Merge #13743: refactor: Replace boost::bind with std::bindMarcoFalke
cb53b825c2 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51821 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
2018-12-18rpc: Fix data race (UB) in InterruptRPC()practicalswift
2018-12-14rpc: Remove unused PreCommand signalJoão Barbosa
2018-12-10Merge #14877: rpc: Document default values for optional argumentsMarcoFalke
fa0c24c96e rpc: Document default values for optional arguments (MarcoFalke) Pull request description: Tree-SHA512: e1f5ea67d7ac67526ae87bffaeb308a9ad68632e161fe0148cd431a340bb7a30def18f1dbc7e98c6c1c269ac8942fd5d5334c85c48e4fb1cead70a42536b6eef
2018-12-07rpc: Document default values for optional argumentsMarcoFalke