aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/misc.cpp
AgeCommit message (Collapse)Author
2021-06-22Disallow bech32m addresses for legacy wallet thingsAndrew Chow
We don't want the legacy wallet to ever have bech32m addresses so don't allow importing them. This includes addmultisigaddress as that is a legacy wallet only RPC Additionally, bech32m multisigs are not available yet, so disallow them in createmultisig.
2021-05-14test: Fix off-by-one in mockscheduler test RPCMarcoFalke
2021-04-30Merge bitcoin/bitcoin#19521: Coinstats IndexW. J. van der Laan
5f96d7d22d8e05876c6fc014e70488699950fe38 rpc: gettxoutsetinfo rejects hash_serialized_2 for specific height (Fabian Jahr) 23fe50436be641d7417152adc683192649ba206a test: Add test for coinstatsindex behavior in reorgs (Fabian Jahr) 90c966b0f3cfbd6bce5883f46d8527c6853a86a2 rpc: Allow gettxoutsetinfo and getblockstats for stale blocks (Fabian Jahr) b9362392aef2689bc106c20925859ede555d082b index, rpc: Add use_index option for gettxoutsetinfo (Fabian Jahr) bb7788b121a30489bc81a1f46dde6a9b19ae4ec1 test: Test coinstatsindex robustness across restarts (Fabian Jahr) e0938c29099635150014ffc9bb0cafa8049ec55a test: Add tests for block_info in gettxoutsetinfo (Fabian Jahr) 2501576eccb08af80471c7b7b843b189ad6758c0 rpc, index: Add verbose amounts tracking to Coinstats index (Fabian Jahr) 655d929836a71af23d2035d2e2e99ad8b8c340c3 test: add coinstatsindex getindexinfo coverage, improve current tests (Jon Atack) ca01bb8d689f93e1c7669b0ba7a4994c0206dabd rpc: Add Coinstats index to getindexinfo (Fabian Jahr) 57a026c30fef3138bb8db46e6865acb9dc2674f8 test: Add unit test for Coinstats index (Fabian Jahr) 6a4c0c09ab4d073a26c3c4a02783d5dcd88f6eef test: Add functional test for Coinstats index (Fabian Jahr) 3f166ecc125fce6ccd995687fa16572090a5d099 rpc: gettxoutsetinfo can be requested for specific blockheights (Fabian Jahr) 3c914d58ff323255b32e717d0ce28209ec0abdaa index: Coinstats index can be activated with command line flag (Fabian Jahr) dd58a4de21469d6d848ae309edc47f558628221d index: Add Coinstats index (Fabian Jahr) a8a46c4b3cfda4b95c92a36f8cebd3606377e57d refactor: Simplify ApplyStats and ApplyHash (Fabian Jahr) 9c8a265fd21a87228c18a1661df99fedc1866baf refactor: Pass hash_type to CoinsStats in stats object (Fabian Jahr) 2e2648a9021dfbb6e17dfa81472f057dacbc34e0 crypto: Make MuHash Remove method efficient (Fabian Jahr) Pull request description: This is part of the coinstats index project tracked in #18000 While the review of the new UTXO set hash algorithm (MuHash) takes longer recently #19328 was merged which added the possibility to run `gettxoutsetinfo` with a specific hash type. As the first type it added `hash_type=none` which skips the hashing of the UTXO set altogether. This alone did not make `gettxoutsetinfo` much faster but it allows the use of an index for the remaining coin statistics even before a new hashing algorithm has been added. Credit to Sjors for the idea to take this intermediate step. Features summary: - Users can start their node with the option `-coinstatsindex` which syncs the index in the background - After the index is synced the user can use `gettxoutsetinfo` with `hash_type=none` or `hash_type=muhash` and will get the response instantly out of the index - The user can specify a height or block hash when calling `gettxoutsetinfo` to see coin statistics at a specific block height ACKs for top commit: Sjors: re-tACK 5f96d7d22d8e05876c6fc014e70488699950fe38 jonatack: Code review re-ACK 5f96d7d22d8e05876c6fc014e70488699950fe38 per `git range-diff 13d27b4 07201d3 5f96d7d` promag: Tested ACK 5f96d7d22d8e05876c6fc014e70488699950fe38. Light code review ACK 5f96d7d22d8e05876c6fc014e70488699950fe38. Tree-SHA512: cbca78bee8e9605c19da4fbcd184625fb280200718396c694a56c7daab6f44ad23ca9fb5456d09f245d8b8d9659fdc2b3f3ce5e953c1c6cf4003dbc74c0463c2
2021-04-23multiprocess: Add echoipc RPC method and testRussell Yanofsky
Add simple interfaces::Echo IPC interface with one method that just takes and returns a string, to test multiprocess framework and provide an example of how it can be used to spawn and call between processes.
2021-04-19rpc: Add Coinstats index to getindexinfoFabian Jahr
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-03-01Merge #18466: rpc: fix invalid parameter error codes for ā†µWladimir J. van der Laan
{sign,verify}message RPCs a5cfb40e27bd281354bd0d14d91f83efb6bfce9f doc: release note for changed {sign,verify}message error codes (Sebastian Falbesoner) 9e399b9b2d386b28c0c0ff59fc75d31dbec31d9c test: check parameter validity in rpc_signmessage.py (Sebastian Falbesoner) e62f0c71f10def124b1c1219d790cef246a32c3e rpc: fix {sign,message}verify RPC errors for invalid address/signature (Sebastian Falbesoner) Pull request description: RPCs that accept address parameters usually return the intended error code `RPC_INVALID_ADDRESS_OR_KEY` (-5) if a passed address is invalid. The two exceptions to the rule are `signmessage` and `verifymessage`, which return `RPC_TYPE_ERROR` (-3) in this case instead. Oddly enough `verifymessage` returns `RPC_INVALID_ADDRESS_OR_KEY` when the _signature_ was malformed, where `RPC_TYPE_ERROR` would be more approriate. This PR fixes these inaccuracies and as well adds tests to `rpc_signmessage.py` that check the parameter validity and error codes for the related RPCs `signmessagewithprivkey`, `signmessage` and `verifymessage`. master branch: ``` $ ./bitcoin-cli signmessage invalid_addr message error code: -3 error message: Invalid address $ ./bitcoin-cli verifymessage invalid_addr dummy_sig message error code: -3 error message: Invalid address $ ./bitcoin-cli verifymessage 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX invalid_sig message error code: -5 error message: Malformed base64 encoding ``` PR branch: ``` $ ./bitcoin-cli signmessage invalid_addr message error code: -5 error message: Invalid address $ ./bitcoin-cli verifymessage invalid_addr dummy_sig message error code: -5 error message: Invalid address $ ./bitcoin-cli verifymessage 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX invalid_sig message error code: -3 error message: Malformed base64 encoding ``` ACKs for top commit: laanwj: Code review ACK a5cfb40e27bd281354bd0d14d91f83efb6bfce9f meshcollider: utACK a5cfb40e27bd281354bd0d14d91f83efb6bfce9f Tree-SHA512: bae0c4595a2603cea66090f6033785601837b45fd853052312b3a39d8520566c581994b68f693dd247c22586c638c3b7689c849085cce548cc36b9bf0e119d2d
2021-02-02util: Disallow negative mocktimeMarcoFalke
Signed-off-by: practicalswift <practicalswift@users.noreply.github.com>
2021-01-28rpc: Remove duplicate name and argNames from CRPCCommandMarcoFalke
2021-01-24Better error messages for invalid addressesBezdrighin
This commit addresses #20809. We add an additional 'error' property in the result of 'validateaddress' in case the address is not valid that gives a short description of why the address in invalid. We also change the error message returned by 'getaddressinfo' in case the address is invalid.
2020-09-24remove dead rpc codeMarcoFalke
Checking for fHelp, or the size of the args, is dead code because: * fHelp is always false (src/qt/test/rpcnestedtests.cpp) * It is already implicitly called by RPCHelpMan::Check (src/rpc/mining.cpp, src/rpc/misc.cpp, src/rpc/net.cpp)
2020-08-29rpc: fix {sign,message}verify RPC errors for invalid address/signatureSebastian Falbesoner
2020-08-16rpc: Add getindexinfo RPCFabian Jahr
2020-08-02rpc: Assert that RPCArg names are equal to CRPCCommand ones (misc)MarcoFalke
2020-08-02rpc: Limit echo to 10 argsMarcoFalke
2020-08-02refactor: Use C++11 range based for loops to simplify rpc codeMarcoFalke
2020-06-24refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o)Wladimir J. van der Laan
HexStr can be called with anything that bas `begin()` and `end()` functions, so clean up the redundant calls.
2020-05-13refactor: Pass NodeContext to RPC and REST methods through util::RefRussell Yanofsky
This commit does not change behavior
2020-04-26Merge #18669: log: Use Join() helper when listing log categoriesMarcoFalke
faec0638872798b58b9882ee079014555bc8393e log: Use Join() helper when listing log categories (MarcoFalke) Pull request description: This removes the global `ListLogCategories` and replaces it with a one-line member function `LogCategoriesString`, which just calls `Join`. Should be a straightforward refactor to get rid of a few LOC. ACKs for top commit: laanwj: ACK faec0638872798b58b9882ee079014555bc8393e promag: ACK faec0638872798b58b9882ee079014555bc8393e, I also think it's fine as it is (re https://github.com/bitcoin/bitcoin/pull/18669#discussion_r412944724). Tree-SHA512: 2f51f9ce1246eda5630015f3a869e36953c7eb34f311baad576b92d7829e4e88051c6189436271cd0a13732a49698506345b446b98fd28e58edfb5b62169f1c9
2020-04-16scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-04-16log: Use Join() helper when listing log categoriesMarcoFalke
2020-04-10Merge #17999: refactor: Add ChainClient setMockTime, getWallets methodsMarcoFalke
3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739 refactor: Use psbt forward declaration (Russell Yanofsky) 1dde238f2c21a0cc9bada10a2449cf9c6b2178ad Add ChainClient setMockTime, getWallets methods (Russell Yanofsky) Pull request description: This PR is part of the [process separation project](https://github.com/bitcoin/bitcoin/projects/10). These changes are needed to set mock times, and get wallet interface pointers correctly when wallet code is running in a different process from node code in #10102 ACKs for top commit: MarcoFalke: re-ACK 3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739 šŸ”™ promag: Code review ACK 3ce16ad2f91d1e2edc7e7bdc5a19f72aa8c3e739. Tree-SHA512: 6c093bfcd68adf5858a1aade4361cdb7fb015496673504ac7a93d0bd2595215047184551d6fd526baa27782331cd2819ce45c4cf923b205ce93ac29e485b5dd8
2020-04-06rpc: Avoid initialization-order-fiasco on static CRPCCommand tablesMarcoFalke
2020-03-13rpc: Document an RPCResult for all calls; Enforce at compile timeMarcoFalke
2020-03-11Merge #18268: rpc: Remove redundant types from descriptionsMarcoFalke
8a2a652e6fab5eb8224beefcc07d9011b61865a8 Remove redundant type information from rpc docs (David O'Callaghan) Pull request description: Simple edit of the RPC calls to remove redundant text ("A json object/array ...") from the beginning of help. Fixes: #18258 Top commit has no ACKs. Tree-SHA512: cbbf760e0b7b4eda61c40b420ed77f5d878318e37b0eb13e63567212240b2c4ecc15d84030e98075e21c9ae9016539adfd201e5661ea824166a76d335180c32f
2020-03-11Merge #18208: rpc: Change RPCExamples to bech32MarcoFalke
3e32499909ca8127baaa9b40ad113b25ee151bbd Change example addresses to bech32 (Yusuf Sahin HAMZA) Pull request description: This is a follow-up PR to #18197 that fixes RPCExamples. Fixes #18185. ACKs for top commit: MarcoFalke: ACK 3e32499909ca8127baaa9b40ad113b25ee151bbd jonatack: ACK 3e32499 Tree-SHA512: c7a6410ef8b6e169016c2c5eac3e6b9501caabd0e8a0871ec31e56bfc44589f056d3f5cb55b5a13bba36f6c15136c2352f883e30e4dcc0997ffd36b27f9173b9
2020-03-06scheduler: switch from boost to stdAnthony Towns
Changes from boost::chrono to std::chrono, boost::condition_var to std::condition_var, boost::mutex to sync.h Mutex, and reverselock.h to sync.h REVERSE_LOCK. Also adds threadsafety annotations to CScheduler members.
2020-03-05Merge #18263: rpc: change setmocktime check to use IsMockableChainMarcoFalke
2455aa5d7f54befeade05795ed8f5dd89d01042a [rpc] changed MineBlocksOnDemand to IsMockableChain (Gloria Zhao) Pull request description: Change: Update the if statement in `setmocktime` to use `IsMockableChain` chainparams function (aka `m_is_mockable_chain`) instead of `MineBlocksOnDemand` Rationale: It's a more appropriate check for whether or not chain is in RegTest, as [discussed](https://github.com/bitcoin/bitcoin/pull/18037#discussion_r376509388) in #18037 ACKs for top commit: MarcoFalke: ACK 2455aa5d7f54befeade05795ed8f5dd89d01042a šŸ™‡ jonatack: ACK 2455aa5d7f54befeade05795ed8f5dd89d01042a Tree-SHA512: 1d8c8b7ff0b3c1bcbf5755194969b6664fe05a35003375ad08d18e34bcefd2df4f64d0e60078a10bbef3c8f469a9b9d07db467089b55c14cf532304bc965bffc
2020-03-05[rpc] changed MineBlocksOnDemand to IsMockableChainGloria Zhao
2020-03-05Remove redundant type information from rpc docsDavid O'Callaghan
Co-Authored-By: MarcoFalke <falke.marco@gmail.com>
2020-03-01Change example addresses to bech32Yusuf Sahin HAMZA
2020-02-25rpc: Auto-format RPCResultMarcoFalke
2020-02-25Add ChainClient setMockTime, getWallets methodsRussell Yanofsky
Needed to set mock times, and get wallet interface pointers correctly when wallet code is running in a different process from node code.
2020-02-25Merge #17577: refactor: deduplicate the message sign/verify codeSamuel Dobson
e193a84fb28068e38d5f54fbfd6208428c5bb655 Refactor message hashing into a utility function (Jeffrey Czyz) f8f0d9893d7969bdaa870fadb94ec5d0dfa8334d Deduplicate the message signing code (Vasil Dimov) 2ce3447eb1e25ec7aec4b300dabf6c1e394f1906 Deduplicate the message verifying code (Vasil Dimov) Pull request description: The message signing and verifying logic was replicated in a few places in the code. Consolidate in a newly introduced `MessageSign()` and `MessageVerify()` and add unit tests for them. ACKs for top commit: Sjors: re-ACK e193a84fb28068e38d5f54fbfd6208428c5bb655 achow101: ACK e193a84fb28068e38d5f54fbfd6208428c5bb655 instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/17577/commits/e193a84fb28068e38d5f54fbfd6208428c5bb655 meshcollider: utACK e193a84fb28068e38d5f54fbfd6208428c5bb655 Tree-SHA512: b0e02a7d4623a98c8f8c77627af1725e6df07700de4630c2f75da6beacdf55414c38ba147bc6d2a757491ab07c827dddf93e8632fe600478760e255714ddab88
2020-02-20Merge #18122: rpc: update validateaddress RPCExamples to bech32fanquake
7f1475c7119e8c72bce39a63386a6ca859066b80 rpc: update validateaddress RPCExamples to bech32 (Sebastian Falbesoner) Pull request description: Another small step to get rid of legacy addresses in the RPC help texts and by that encourage the use of bech32 addresses by default. The (invalid) address is the same as in the `getaddressinfo` RPC (see 2ee0cb3330ccf70f0540cb42370796e32eff1569, kudos to jonatack!), I don't think it adds any value to have a different example address per RPC. ACKs for top commit: fanquake: ACK 7f1475c7119e8c72bce39a63386a6ca859066b80 MarcoFalke: ACK 7f1475c7119e8c72bce39a63386a6ca859066b80 Tree-SHA512: 2350f61fa942a9053f9f5c860ea446965dc7209c71c81bdb98a859d03ca23b225ad72c9c506e4a55c8d8988823d9cfbe808c1a452a1eeadb70ab186b146dd4ca
2020-02-17Merge #18037: Util: Allow scheduler to be mockedMarcoFalke
8bca30ea17cd4c1dacee28eaa27e5fa3493b021d [rpc] expose ability to mock scheduler via the rpc (Amiti Uttarwar) 7c8b6e5b5206a98f86675d0107ad99ea1d080466 [lib] add scheduler to node context (Amiti Uttarwar) 930d8375421451c8c4127608c360b0f6a0a62127 [test] add chainparams property to indicate chain allows time mocking (Amiti Uttarwar) 1cd43e83c6e8d81e950aaaede7a8a51505d0a2bc [test] unit test for new MockForward scheduler method (Amiti Uttarwar) a6f63598adb880a75e1571aac58338c17fa7ad53 [util] allow scheduler to be mocked (Amiti Uttarwar) Pull request description: This PR is to support functional tests by allowing the scheduler to be mocked via the RPC. It adds a `MockForward` method to the scheduler class that iterates through the task queue and reschedules them to be `delta_seconds` sooner. This is currently used to support functional testing of the "unbroadcast" set tracking in #18038. If this patch is accepted, it would also be useful to simplify the code in #16698. ACKs for top commit: MarcoFalke: ACK 8bca30ea17cd4c1dacee28eaa27e5fa3493b021d, only change is some style fixups šŸ•“ Tree-SHA512: 2a97fe8ade2b7fd1fb5cdfa1dcafb3227a377d7a847e3845a228bc119eb77824b4aefa43d922a06d583939b22725e223f308cf092961048079d36f6b1d9a639b
2020-02-17[rpc] expose ability to mock scheduler via the rpcAmiti Uttarwar
2020-02-14Deduplicate the message signing codeVasil Dimov
The logic of signing a message was duplicated in 3 places: src/qt/signverifymessagedialog.cpp SignVerifyMessageDialog::on_signMessageButton_SM_clicked() src/rpc/misc.cpp signmessagewithprivkey() src/wallet/rpcwallet.cpp signmessage() Move the logic into src/util/message.cpp MessageSign() and call it from all the 3 places.
2020-02-14Deduplicate the message verifying codeVasil Dimov
The logic of verifying a message was duplicated in 2 places: src/qt/signverifymessagedialog.cpp SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() src/rpc/misc.cpp verifymessage() with the only difference being the result handling. Move the logic into a dedicated src/util/message.cpp MessageVerify() which returns a set of result codes, call it from the 2 places and just handle the results differently in the callers.
2020-02-13rpc: update validateaddress RPCExamples to bech32Sebastian Falbesoner
also contains the following changes: - rpc: factor out example bech32 address for RPCExamples - doc: update developer notes wrt RPCExamples addresses (mention the EXAMPLE_ADDRESS constant as an example for an invalid bech32 address suitable for RPCExamples help documentation)
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-30Output a descriptor in createmultisig and addmultisigaddressAndrew Chow
2019-12-30scripted-diff: Bump copyright of files changed in 2019MarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2019-12-13qa: unify unix epoch time descriptionsJon Atack
to "UNIX epoch time". Call sites updated: ``` mocktime getblockheader getblock pruneblockchain getchaintxstats getblocktemplate setmocktime getpeerinfo setban getnodeaddresses getrawtransaction importmulti listtransactions listsinceblock gettransaction getwalletinfo getaddressinfo ```
2019-10-18util: Add CHECK_NONFATAL and use it in src/rpcMarcoFalke
2019-10-15Remove unused includespracticalswift
2019-08-16Give more errors for specific failure conditionsAndrew Chow
Some failure conditions implicitly fail by failing some other check. But the error messages are more helpful if they say explicitly what actually caused the failure, so add those as failure conditions and errors.
2019-08-16Return an error from descriptor Parse that gives more information about what ā†µAndrew Chow
failed