aboutsummaryrefslogtreecommitdiff
path: root/src/univalue
AgeCommit message (Collapse)Author
2023-07-27Remove unused raw-pointer read helper from univalueMarcoFalke
2023-06-20scripted-diff: Following the C++ Standard rules for identifiers with _.Brotcrunsher
Any identifier starting with two _, or one _ followed by a capital letter is reserved for the compiler and thus must not be used. See: https://stackoverflow.com/a/228797/7130273 -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s '__pushKV' 'pushKVEnd' s '_EraseTx' 'EraseTxNoLock' s '_Other' 'Other' -END VERIFY SCRIPT-
2023-06-02Merge bitcoin/bitcoin#27256: refactor: rpc: Remove unnecessary uses of ↵fanquake
ParseNonRFCJSONValue() and rename it cfbc8a623b5133f1d0b0c0c9be73b2b107e0d687 refactor: rpc: hide and rename ParseNonRFCJSONValue() (stickies-v) 6c8bde6d54d03224709dce54b8ba32b8c3e37ac7 test: move coverage on ParseNonRFCJSONValue() to UniValue::read() (stickies-v) Pull request description: Follow-up to https://github.com/bitcoin/bitcoin/pull/26612#issuecomment-1453623741. As per https://github.com/bitcoin/bitcoin/pull/26506#pullrequestreview-1211984059, `ParseNonRFCJSONValue()` is no longer necessary and we can use `UniValue::read()` directly: > IIRC before that PR UniValue::read could only parse JSON object and array values, but now it will parse string/number/boolean/null values as well. laanwj pointed this out in https://github.com/bitcoin/bitcoin/issues/9028#issuecomment-257885368 The implementation of `ParseNonRFCJSONValue()` was already [simplified in #26612](https://github.com/bitcoin/bitcoin/pull/26612/files#diff-84c7a7f36362b9724c31e5dec9879b2f81eae0d0addbc9c0933c3558c577de65R259-R263) and [test coverage updated](https://github.com/bitcoin/bitcoin/pull/26612/files#diff-fc0f86b6c3bb23b0e983bcf79d7546d1c9eaa15d6e4d8a7b03b5b85955f585abR292-R312) to ensure behaviour didn't change. To avoid code duplication, we keep the function to throw on invalid input data but rename it to `Parse()` and remove it from the header. The existing test coverage we had on `ParseNonRFCJSONValue()` is moved over to `UniValue::read()`. ACKs for top commit: ryanofsky: Code review ACK cfbc8a623b5133f1d0b0c0c9be73b2b107e0d687. Only change since last review is adding a new test Tree-SHA512: 89be959d2353af7ace0c1348ba1600b9ac1d3c7b3cf7f0b59f6e005b7fb9d695ce3e8720e1be3cf77fe7e318a4017c880df108928e7179ec50447583d13bc781
2023-05-09Remove unused find_value global functionMarcoFalke
2023-05-09Add UniValue::find_value methodMarcoFalke
2023-03-23test: move coverage on ParseNonRFCJSONValue() to UniValue::read()stickies-v
Preparation to deprecate ParseNonRFCJSONValue() but keep test coverage on the underlying UniValue::read() unaffected. The test coverage on AmountFromValue is no longer included, since that is already tested in the rpc_parse_monetary_values test case. Fuzzing coverage on ParseNonRFCJSONValue() was duplicated between string.cpp and parse_univalue.cpp, only the one in parse_univalue.cpp is kept.
2023-03-03Merge bitcoin/bitcoin#26612: refactor: RPC: pass named argument value as ↵fanquake
string_view 545ff924ab6303ffabd91fdfc4f0a4962daf133c refactor: use string_view for RPC named argument values (stickies-v) 7727603e44f8f674e0fc8389e78047e2b56e6052 refactor: reduce unnecessary complexity in ParseNonRFCJSONValue (stickies-v) 1d02e599012721549d4c20b1b37fcc5ee7b961b6 test: add cases to JSON parsing (stickies-v) Pull request description: Inspired by MarcoFalke's [comment](https://github.com/bitcoin/bitcoin/pull/26506#discussion_r1036149426). Main purpose of this PR is to minimize copying (potentially large) RPC named arguments when calling `.substr()` by using `std::string_view` instead of `std::string`. Furthermore, cleans up the code by removing unnecessary complexity in `ParseNonRFCJSONValue()` (done first to avoid refactoring required to concatenate `string` and `string_view`), updates some naming and adds a few test cases. Should not introduce any behaviour change. ## Questions - ~Was there actually any merit to `ParseNonRFCJSONValue()` surrounding the value with brackets and then parsing it as an array? I don't see it, and the new approach doesn't fail any tests. Still a bit suspicious about it though.~ - Cleared up by https://github.com/bitcoin/bitcoin/pull/26506#pullrequestreview-1211984059 - If there are no objections to 7727603e44f8f674e0fc8389e78047e2b56e6052, I think we should follow up with a PR to rename `ParseNonRFCJSONValue()` to a local `Parse()` helper function (that throws if invalid), remove it from `client.h` and merge the test coverage we currently have on `ParseNonRFCJSONValue()` with the coverage we have on `UniValue::read()`. ACKs for top commit: ryanofsky: Code review ACK 545ff924ab6303ffabd91fdfc4f0a4962daf133c MarcoFalke: review ACK 545ff924ab6303ffabd91fdfc4f0a4962daf133c 📻 Tree-SHA512: b1c89fb010ac9c3054b023cac1acbba2a539a09cf39a7baffbd7f7571ee268d5a6d98701c7ac10d68a814526e8fd0fe96ac1d1fb072f272033e415b753f64a5c
2023-01-31clang-tidy: Fix `modernize-use-default-member-init` in headersHennadii Stepanov
See https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-default-member-init.html
2023-01-18refactor: use string_view for RPC named argument valuesstickies-v
Minimize copying RPC named argument values when calling .substr() by using std::string_view instead of std::string.
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-12-09univalue: Remove confusing getBool methodRyan Ofsky
Drop UniValue::getBool method because it is easy to confuse with the UniValue::get_bool method, and could potentially cause bugs. Unlike get_bool, getBool doesn't ensure that the value is a boolean and returns false for all integer, string, array, and object values instead of throwing an exceptions. The getBool method is also redundant because it is an alias for isTrue. There were only 5 getBool() calls in the codebase, so this commit replaces them with isTrue() or get_bool() calls as appropriate. These changes were originally made by MarcoFalke in https://github.com/bitcoin/bitcoin/pull/26213 but were dropped to limit the scope of that PR. Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
2022-11-14Merge bitcoin/bitcoin#25714: univalue: Avoid std::string copiesMacroFake
fa095257511e53d7a593c6714724aafb484e6b6f univalue: string_view test (MacroFake) 1111c7e3f1f5c550f62016d71ccc518aafd97acf univalue: Avoid std::string copies (MacroFake) Pull request description: This shouldn't matter too much, unless a really large string is pushed into a json struct, but I think it also clarifies the code. ACKs for top commit: martinus: Code review ACK https://github.com/bitcoin/bitcoin/commit/fa095257511e53d7a593c6714724aafb484e6b6f aureleoules: reACK fa095257511e53d7a593c6714724aafb484e6b6f ryanofsky: Code review ACK fa095257511e53d7a593c6714724aafb484e6b6f Tree-SHA512: 74c441912bd0b00cdb9ea7890121f71ae5d62a7594e7d29aa402c9e3f033710c5d3afb27a37c552e6513804b249aa37e375ce013a3db853a25d1fd7b6e6cd3a8
2022-11-07univalue: string_view testMacroFake
2022-09-15rpc: treat univalue type check error as RPC_TYPE_ERROR, not RPC_MISC_ERRORfurszy
By throwing a custom exception from `Univalue::checkType` (instead of a plain std::runtime_error) and catching it on the RPC server request handler. So we properly return RPC_TYPE_ERROR (-3) on arg type errors and not the general RPC_MISC_ERROR (-1).
2022-09-05univalue: Avoid std::string copiesMacroFake
2022-08-20Fix issues when calling std::move(const&)MacroFake
2022-07-29univalue: Remove unused and confusing set*() return valueMacroFake
2022-07-25Merge bitcoin/bitcoin#25611: univalue: Avoid brittle, narrowing and verbose ↵fanquake
integral type confusions fa23c197509f692a815193acc1b50bad2fcbedfe univalue: Avoid narrowing and verbose int constructors (MacroFake) fa3a9a1e8d9b6dffda772e97c279f3c0af6813f9 rpc: Select int-UniValue constructor for enum value in upgradewallet RPC (MacroFake) Pull request description: As UniValue provides several constructors for integral types, the compiler is unable to select one if the passed type does not exactly match. This is unintuitive for developers and forces them to write verbose and brittle code. (Refer to `-Wnarrowing` compiler warning) For example, there are many places where an unsigned int is cast to a signed int. While the cast is safe in practice, it is still needlessly verbose and confusing as the value can never be negative. In fact it might even be unsafe if the unsigned value is large enough to map to a negative signed one. Fix this issue and other (minor) type issues. ACKs for top commit: aureleoules: ACK fa23c197509f692a815193acc1b50bad2fcbedfe. Tree-SHA512: 7d99b5b90c7d8eed2e3448167255a59e817dd6b8fcfc1b17c69ddefd0db33d1bf4344fbcd8b7f8685b58182c0f572ab9ffa99467afa666ac21843df7ea645033
2022-07-18univalue: Return more detailed type check error messagesMacroFake
2022-07-18move-only: Move UniValue::getInt definition to keep class with definitions onlyMacroFake
Can be reviewed with the git options --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-07-18refactor: remove BOOST_*_TEST_ macrosfanquake
2022-07-18refactor: integrate no_nul into univalue unitesterfanquake
2022-07-18doc: remove references to downstreamfanquake
Having references to downstream no-longer make sense now that we've unsubtree'd.
2022-07-14univalue: Avoid narrowing and verbose int constructorsMacroFake
As UniValue provides several constructors for integral types, the compiler is unable to select one if the passed type does not exactly match. This is unintuitive for developers and forces them to write verbose and brittle code. For example, there are many places where an unsigned int is cast to a signed int. While the cast is safe in practice, it is still needlessly verbose and confusing as the value can never be negative. In fact it might even be unsafe if the unsigned value is large enough to map to a negative signed one.
2022-07-13univalue: Throw exception on invalid pushes over silent ignoreMacroFake
2022-06-24rpc: Fix Univalue push_backV OOM in listtransactionsMacroFake
2022-06-15refactor: cleanups post unsubtree'ing univaluefanquake
Mostly changes to remove src/univalue exceptions from the various linters, and the required code changes to make them happy. As well as minor doc changes.
2022-06-15refactor: un-subtree univaluefanquake
Remove all the files we don't use. This should not change behavior, or anything at all, as none of these files are currently used in our build system.
2022-05-30Bump univalue subtreeMacroFake
2022-05-12Bump univalue subtreeMacroFake
2021-10-11Update univalue subtree to latest upstreamfanquake
2020-11-19Update univalue subtreeMarcoFalke
2020-02-09Update univalue subtreeMarcoFalke
2019-10-30Update univalue subtreeMarcoFalke
2018-09-07Update univalue subtreeMarcoFalke
2018-02-10univalue: Bump subtreeMarcoFalke
2017-12-19univalue: Bump subtreeMarcoFalke
2017-09-29Bump univalue and fix json formatting in testsMarcoFalke
This merge commit bumps the univalue subtree and also updates the whitespace for some failing tests.
2017-08-16Declare single-argument (non-converting) constructors "explicit"practicalswift
In order to avoid unintended implicit conversions.
2016-09-30Merge commit '2ca7faab4205822b06dc2ab2bbda0a9a70fce7e0' into HEADMarcoFalke
2016-09-25Merge commit '3650668cdbbf369dd8f30c8e8eb5bb883325942d' into HEADMarcoFalke
2016-06-10Merge commit '60ab9b200654ef0914459711cf2b22be16be3dc2'Wladimir J. van der Laan
2015-12-02Merge commit '982709199f1b4e9e35211c419a81938f9f1dd4ed' into bitcoinMarcoFalke
2015-10-09Merge commit '313e7f5c89d6e72e06efe9255089765b4c5815fe' into HEADMarcoFalke
2015-10-01Merge commit '2f9f082b5ef3c495c70598ef23383effef675f9a' as 'src/univalue'Jonas Schnelli
2015-10-01remove univalue, prepare for subtreeJonas Schnelli
2015-08-20Stop parsing JSON after first finished construct.Daniel Kraft
Fix https://github.com/bitcoin/bitcoin/issues/6558. In particular, stop parsing JSON after the first object or array is finished. Check that no other garbage follows, and fail the parser if it does.
2015-07-18univalue: Avoid unnecessary roundtrip through double for numbersWladimir J. van der Laan
JSON makes no distinction between numbers and reals, and our code doesn't need to do so either. This removes VREAL, as well as its specific post-processing in `UniValue::write`. Non-monetary amounts do not need to be forcibly formatted with 8 decimals, so the extra roundtrip was unnecessary (and potentially loses precision).
2015-06-25UniValue: don't escape solidus, keep espacing of reverse solidusJonas Schnelli
2015-06-11Fix univalue handling of \u0000 characters.Daniel Kraft
Univalue's parsing of \u escape sequences did not handle NUL characters correctly. They were, effectively, dropped. The extended test-case fails with the old code, and is fixed with this patch.