aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
AgeCommit message (Collapse)Author
2019-04-29Replace CScriptID and CKeyID in CTxDestination with dedicated typesGregory Sanders
2019-04-13Extract ParseDescriptorRangeBen Woosley
So as to be consistently informative when the checks fail, and to protect against unintentional divergence among the checks.
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-04rpc: RPCHelpMan: Always push_name when outer type is an objectMarcoFalke
2019-04-04rpc: Add some doxygen comments to utilsMarcoFalke
2019-03-04Merge #15288: Remove wallet -> node global function callsMarcoFalke
f7efd87c8f Change brace formatting (Russell Yanofsky) a1df1b48a8 Remove use of IsInitialBlockDownload in wallet code (Russell Yanofsky) 1106a6fde4 Remove use of uiInterface.LoadWallet in wallet code (Russell Yanofsky) 318f41fb2c circular-dependencies: Avoid treating some .h/.cpp files as a unit (Russell Yanofsky) d02b34c8a8 Remove use of AcceptToMemoryPool in wallet code (Russell Yanofsky) e2c8ba9f6e Remove uses of InitMessage/Warning/Error in wallet code (Russell Yanofsky) c5e59a96a8 Remove uses of GetAdjustedTime in wallet code (Russell Yanofsky) 6d6bcc77c0 Remove use of g_connman / PushInventory in wallet code (Russell Yanofsky) 00dfb2a440 Remove uses of g_connman in wallet code (Russell Yanofsky) cc3836e8f9 Remove uses of fPruneMode in wallet code (Russell Yanofsky) cc02c796d3 Remove uses of fee globals in wallet code (Russell Yanofsky) 1fb0a4a04e Remove use of CalculateMemPoolAncestors in wallet code (Russell Yanofsky) cd32160af0 Remove use of GetTransactionAncestry in wallet code (Russell Yanofsky) 291276f7f4 Remove use of GetCountWithDescendants in wallet code (Russell Yanofsky) bdc6628683 Remove use of IsRBFOptIn in wallet code (Russell Yanofsky) 80f52a2267 Remove uses of CheckFinalTx in wallet code (Russell Yanofsky) Pull request description: This change removes wallet calls to node functions that access global chain and mempool state. This is the next step in the larger #10973 refactoring change, which removes all other accesses to node global variables from wallet code. Doing this is useful to provide a better defined interface between the wallet and node, and necessary to allow wallet and node code to run in separate processes in #10102. Tree-SHA512: 40dbaf1f59fb22b32e70b054b30ba5638d638aa3240fa30e0f721d53c721cd6138a7ab4d423a24d7d2fda0b956e68d44c733abc2c9259c3d6c9fd6d4be89aa23
2019-02-28Support ranges arguments in RPC helpPieter Wuille
2019-02-28Add ParseRange function to parse args of the form int/[int,int]Pieter Wuille
2019-02-25Merge #15401: rpc: Actually throw help when passed invalid number of paramsWladimir J. van der Laan
fa4ce7038d444defe0b98a30097174c278054a33 rpc: Actually throw help when passed invalid number of params (MarcoFalke) fa05626ca7a0fe896ac554c79eaea4c36acdf861 rpc: Add RPCHelpMan::IsValidNumArgs() (MarcoFalke) Pull request description: Can be tested by * running the included test against an old binary (compiled without this patch) * calling `setban 1 "add" 3 4 5 6 7 8 9 0` in the gui Tree-SHA512: aa6a25bbe6f40722913ea292252a62a4012c964eed9f4035335a2e2d13be98eb60f368e8a3251a104a26a62c08b2cb926b06e5ab1418ef1cf4abdd71d87c2919
2019-02-22Remove uses of fee globals in wallet codeRussell Yanofsky
This commit does not change behavior.
2019-02-20rpc: Add RPCHelpMan::IsValidNumArgs()MarcoFalke
2019-02-18Add missing #include.Daniel Kraft
bd0dbe8763fc3029cf96531c9ccaba280b939445 introduced a dependency of rpc/util.h on RPCErrorCode, defined in rpc/protocol.h. The latter file is only included from rpc/util.cpp, though. This commit fixes the missing include, by moving the #include of rpc/protocol.h to rpc/util.h.
2019-02-14Merge #14978: Factor out PSBT utilities from RPCs for use in GUI code; ↵MeshCollider
related refactoring. 102faad81 Factor out combine / finalize / extract PSBT helpers (Glenn Willen) 78b9893d0 Remove op== on PSBTs; check compatibility in Merge (Glenn Willen) bd0dbe876 Switch away from exceptions in refactored tx code (Glenn Willen) c6c3d42a7 Move PSBT definitions and code to separate files (Glenn Willen) 81cd95884 Factor BroadcastTransaction out of sendrawtransaction (Glenn Willen) c734aaa15 Split DecodePSBT into Base64 and Raw versions (Glenn Willen) 162ffefd2 Add pf_invalid arg to std::string DecodeBase{32,64} (Glenn Willen) Pull request description: * Move most PSBT definitions into psbt.h. * Move most PSBT RPC utilities into psbt.{h,cpp}. * Move wallet-touching PSBT RPC utilities (FillPSBT) into wallet/psbtwallet.{h,cpp}. * Switch exceptions from JSONRPCError() to new PSBTException class. * Split DecodePSBT into DecodeBase64PSBT (old behavior) and DecodeRawPSBT. * Add one new version of DecodeBase64 utility in strencodings.h (and corresponding DecodeBase32 for completeness). * Factor BroadcastTransaction utility function out of sendrawtransaction RPC handler in rpc/rawtransaction.cpp Note: For those keeping score at home wondering why refactor, this is in anticipation of (and developed in parallel with) a change to actually introduce GUI use of all this stuff, which is already under development and working-ish. Tree-SHA512: 2197c448e657421f430943025357597e7b06c4c377d5d4b2622b9edea52a7193c48843dd731abb3a88ac4023a9c88d211991e0a9b740c22f2e1cbe72adefe390
2019-02-12Merge #14918: RPCHelpMan: Check default values are given at compile-timeMarcoFalke
fa0ad4e7ce RPCHelpMan: Check default values are given at compile-time (MarcoFalke) Pull request description: Remove the run time assertions on the default values and ensure that the correct default type and value is provided at compile time. Tree-SHA512: 80df2f3fab4379b500c773c27da63f22786c58be5963fe99744746320e43627a5d433eedf8b32209158df7805ebdce65ed4d242c829c4fe6e5d13deb4799ed42
2019-02-11Factor out combine / finalize / extract PSBT helpersGlenn Willen
Refactor the new CombinePSBT, FinalizePSBT, and FinalizeAndExtractPSBT general-purpose functions out of the combinepsbt and finalizepsbt RPCs, for use in the GUI code.
2019-02-11Switch away from exceptions in refactored tx codeGlenn Willen
After refactoring general-purpose PSBT and transaction code out of RPC code, for use in the GUI, it's no longer appropriate to throw exceptions. Instead we now return bools for success, and take an output parameter for an error object. We still use JSONRPCError() for the error objects, since only RPC callers actually care about the error codes.
2019-02-11RPCHelpMan: Check default values are given at compile-timeMarcoFalke
2019-02-08Move ParseConfirmTarget from rpc/mining to rpc/utilRussell Yanofsky
Util is a better home since it's called both by wallet and mining code. Suggested https://github.com/bitcoin/bitcoin/pull/15288#discussion_r254449444
2019-01-25RPCHelpMan: Pass through Result and ExamplesMarcoFalke
2018-12-10RPCHelpMan: Support required arguments after optional onesMarcoFalke
2018-12-07rpc: Assert named arguments are unique in RPCHelpManJoão Barbosa
2018-12-04RPCHelpMan: Add space after colons in extended descriptionMarcoFalke
Also, add doxygen comment to ToDescriptionString
2018-11-27rpc: Pass argument descriptions to RPCHelpManMarcoFalke
2018-11-14Use RPCHelpMan for all RPCsMarcoFalke
2018-11-12rpc: Add RPCHelpMan for machine-generated helpMarcoFalke
2018-11-06Pass chain and client variables where neededRussell Yanofsky
This commit does not change behavior. All it does is pass new function parameters. It is easiest to review this change with: git log -p -n1 -U0 --word-diff-regex=.
2018-11-04scripted-diff: Move util files to separate directory.Jim Posen
-BEGIN VERIFY SCRIPT- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmemory.h src/util/memory.h git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp sed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h sed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h sed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h sed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h sed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h sed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am sed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am sed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am sed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am sed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am sed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh sed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh sed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh sed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh sed -i 's/src\\utilstrencodings\.cpp/src\\util\\strencodings\.cpp/' build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj -END VERIFY SCRIPT-
2018-07-27Update copyright headers to 2018DrahtBot
2018-03-16Merge #12542: Remove redundant includes. Conform to header include guidelines.Pieter Wuille
7ef46d063a Remove redundant includes. Conform to header include guidelines. (practicalswift) Pull request description: From the header include guidelines ([developer-notes.md](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#source-code-organization)): > "One exception is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file." Covered in this PR: * `rpc/util.h` includes `pubkey.h` + `utilstrencodings.h`. `rpc/util.cpp` includes `rpc/util.h`. * `util.h` includes `fs.h`. `util.cpp` includes `util.h`. Tree-SHA512: a38d9ecefd8165ad151c1ffde52cfbac968526c49db2080988bf6e6a3daa2ebeceb34d08f817e275edf7c650bf3155de01369bfb352522f8e0ae136b2289b194
2018-02-27Remove redundant includes. Conform to header include guidelines.practicalswift
From the header include guidelines (developer-notes.md): "One exception is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file." * rpc/util.h includes pubkey.h + utilstrencodings.h. rpc/util.cpp includes rpc/util.h. * util.h includes fs.h. util.cpp includes util.h.
2018-02-19Split key_io (address/key encodings) off from base58Pieter Wuille
2018-02-16[rpc] Move DescribeAddressVisitor to rpc/utilJohn Newbery
2018-01-11Disallow using addresses in createmultisigAndrew Chow
Make createmultisig only accept public keys with the old functionality marked as deprecated. Splits _createmultisig_redeemscript into two functions, one for getting public keys from UniValue and one for getting addresses from UniValue and then their respective public keys. The one for retrieving address's public keys is located in rpcwallet.cpp Changes addwitnessaddress's output to be a JSON object with two fields, address and redeemscript. Adds a test to deprecated_rpc.py for testing the deprecation. Update the tests to use addwitnessaddress or give only public keys to createmultisig. Anything that used addwitnessaddress was also updated to reflect the new API.