aboutsummaryrefslogtreecommitdiff
path: root/src/util
AgeCommit message (Collapse)Author
2019-09-06Testchains: Generic selection with -chain=<str> in addition of -testnet and ↵Jorge Timón
-regtest
2019-08-28util: Make util/error bilingual_str (refactor)MarcoFalke
Translated strings should not end up in the debug log, stderr, or returned by an RPC. Changing the util methods in util/error to return a bilingual_str paves the way to achieve this goal in the long term.
2019-08-20util: Add Join helper to join a list of stringsMarcoFalke
2019-08-19Merge #15864: Fix datadir handlingMarcoFalke
ffea41f5301d5582665cf10ba5c2b9547a1443de Enable all tests in feature_config_args.py (Hennadii Stepanov) 66f5c17f8a3fe06fc65191e379ffc04e43cbbc86 Use CheckDataDirOption() for code uniformity (Hennadii Stepanov) 7e33a18a34b1a9b0f115076c142661d6d30c0585 Fix datadir handling in bitcoin-cli (Hennadii Stepanov) b28dada37465c0a773cf08b0e6766f0081bcb943 Fix datadir handling in bitcoin-qt (Hennadii Stepanov) 50824093bb2d68fe1393dfd636fab5f8795faa5d Fix datadir handling in bitcoind (Hennadii Stepanov) 740d41ce9f7fdf209366e930bd0fdcc6b1bc6b79 Add CheckDataDirOption() function (Hennadii Stepanov) c1f325126cf51d28dce8da74bfdf5cd05ab237ea Return absolute path early in AbsPathForConfigVal (Hennadii Stepanov) Pull request description: Fix #15240, see: https://github.com/bitcoin/bitcoin/issues/15240#issuecomment-487353760 Fix #15745 Fix broken `feature_config_args.py` tests (disabled by MarcoFalke@fabe28a0cdcfa13e0e595a0905e3642a960d3077). All test are enabled now. This PR is alternative to #13621. User's `$HOME` directory is not touched unnecessarily now. ~To make reviewing easier only `bitcoind` code is modified (neither `bitcoin-cli` nor `bitcoin-qt`).~ Refs: - https://github.com/bitcoin/bitcoin/issues/15745#issuecomment-479852569 by **laanwj** - #16220 Top commit has no ACKs. Tree-SHA512: 4a4cda10e0b67c8f374da0c9567003d2b566d948e7f8550fe246868b5794c15010e88ea206009480b9cd2f737f310a15e984f920730448f99a895893bed351df
2019-08-15util: Move ResolveErrMsg to util/errorMarcoFalke
2019-08-08util: refactor upper/lowercase functionsKarl-Johan Alm
This includes renaming Downcase() to ToLower() and make it return a string rather than modify referenced arg. Also adds ToUpper() string version.
2019-07-31Revamp option negating policyHennadii Stepanov
2019-07-27Replace IsArgKnown() with FlagsOfKnownArg()Hennadii Stepanov
2019-07-27Use ArgsManager::NETWORK_ONLY flagHennadii Stepanov
2019-07-27Remove unused m_debug_only member from Arg structHennadii Stepanov
2019-07-27scripted-diff: Use ArgsManager::DEBUG_ONLY flagHennadii Stepanov
-BEGIN VERIFY SCRIPT- sed -i 's/unsigned int flags, const bool debug_only,/unsigned int flags,/' src/util/system.h src/util/system.cpp sed -i 's/ArgsManager::NONE, debug_only/flags, false/' src/util/system.cpp sed -i 's/arg.second.m_debug_only/(arg.second.m_flags \& ArgsManager::DEBUG_ONLY)/' src/util/system.cpp sed -i 's/ArgsManager::ALLOW_ANY, true, OptionsCategory::/ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src) sed -i 's/ArgsManager::ALLOW_ANY, false, OptionsCategory::/ArgsManager::ALLOW_ANY, OptionsCategory::/' $(git grep --files-with-matches 'AddArg(' src) -END VERIFY SCRIPT-
2019-07-27scripted-diff: Use Flags enum in AddArg()Hennadii Stepanov
-BEGIN VERIFY SCRIPT- sed -i 's/const bool debug_only,/unsigned int flags, &/' src/util/system.h src/util/system.cpp sed -i -E 's/(true|false), OptionsCategory::/ArgsManager::ALLOW_ANY, &/' $(git grep --files-with-matches 'AddArg(' src) -END VERIFY SCRIPT-
2019-07-27Add Flags enum to ArgsManagerHennadii Stepanov
2019-07-27Refactor InterpretNegatedOption() functionHennadii Stepanov
- added args parameter - renamed to InterpretOption() - removed code duplication
2019-07-27refactoring: Check IsArgKnown() earlyHennadii Stepanov
2019-07-24Fix datadir handling in bitcoindHennadii Stepanov
This prevents premature tries to access or create the default datadir. This is useful when the -datadir option is specified and the default datadir is unreachable.
2019-07-24Add CheckDataDirOption() functionHennadii Stepanov
2019-07-24Return absolute path early in AbsPathForConfigValHennadii Stepanov
This prevents premature GetDataDir() calls, e.g., when config file is not read yet.
2019-07-24scripted-diff: Make translation bilingualHennadii Stepanov
-BEGIN VERIFY SCRIPT- sed -i 's/inline std::string _(const char\* psz)/inline bilingual_str _(const char\* psz)/' src/util/translation.h sed -i 's/return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz;/return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};/' src/util/translation.h sed -i 's/\b_("\([^"]\|\\"\)*")/&.translated/g' $(git grep --files-with-matches '\b_("' src) echo Hard cases - multiline strings. sed -i 's/"Visit %s for further information about the software.")/&.translated/g' src/init.cpp sed -i "s/\"Only rebuild the block database if you are sure that your computer's date and time are correct\")/&.translated/g" src/init.cpp sed -i 's/" restore from a backup.")/&.translated/g' src/wallet/db.cpp sed -i 's/" or address book entries might be missing or incorrect.")/&.translated/g' src/wallet/wallet.cpp echo Special case. sed -i 's/_(COPYRIGHT_HOLDERS)/&.translated/' src/util/system.cpp test/lint/lint-format-strings.py -END VERIFY SCRIPT-
2019-07-24Add bilingual message typeHennadii Stepanov
2019-07-24Refactor out translation.hHennadii Stepanov
This is a prerequisite for introducing bilingual error messages. Note: #includes are arranged by clang-format-diff.py script.
2019-07-08Merge #16291: gui: Stop translating PACKAGE_NAMEMarcoFalke
fa64b947bb3075ff8737656706b941af691908ab util: No translation of `Bitcoin Core` in the copyright (MarcoFalke) fab85208f678ba1be53bdb73a73ce3c5c937d448 qt: Run «make translate» in ./src/ (MarcoFalke) fabe87d2c923ab3a70b8cde2666a4d1cda8b22fb scripted-diff: Avoid passing PACKAGE_NAME for translation (MarcoFalke) fa5e9f157e568b7fbbea1482b393181f0733f2ba build: Stop translating PACKAGE_NAME (MarcoFalke) Pull request description: Generally the package name is not translated, but the package description is. E.g. `GIMP` or `Firefox` are always called that way regardless of the system language. However, "`Firefox` webbrowser" or "`GIMP` image manipulation program" are translated. ACKs for top commit: hebasto: ACK fa64b947bb3075ff8737656706b941af691908ab, I have not tested the code, but I have reviewed it and it looks OK, I agree it can be merged. Tree-SHA512: 626f811531182d0ba0ef1044930d32726773349bcb49b10261288a86ee6b80a183db30a87d817d5b0d501fad058ac22d6272311716b4f5a154f17c6f391a5a1a
2019-07-05[build]: use #if HAVE_SYSTEM instead of defined(HAVE_SYSTEM)Sjors Provoost
2019-07-05Merge #15457: Check std::system for -[alert|block|wallet]notifyWladimir J. van der Laan
f874e14cd3c84cd412bd3fb42b3ee1706ca6a267 [build]: check std::system for -[alert|block|wallet]notify (Sjors Provoost) cc3ad56ff2bc2583fe68c4a9e0b41072a47c0b07 [build] MSVC: set HAVE_SYSTEM for desktop apps (Sjors Provoost) c1c91bb78d7267f01ee3a3c156c218b46a92cd39 [build] detect std::system or ::wsystem (Sjors Provoost) Pull request description: Platforms such as iOs and Universal Windows Platform do not support launching a process through system(). ACKs for top commit: laanwj: code review ACK f874e14cd3c84cd412bd3fb42b3ee1706ca6a267 Tree-SHA512: 16bb4a8fa1896046ccb22a46c8985e1aa45f5b11ecf5539eb2299e9a58f1a5b085c0c12cb6939c7493d93abce7e84fadcbfc73374c887db63da6d00c08aa476d
2019-07-01Merge #16257: [wallet] abort when attempting to fund a transaction above ↵Wladimir J. van der Laan
-maxtxfee 806b0052c3b45415862f74f20ba5f389e5b673de [wallet] abort when attempting to fund a transaction above maxtxfee (Sjors Provoost) Pull request description: `FundTransaction` calls `GetMinimumFee` which, when the fee rate is absurdly high, quietly reduces the fee to `-maxtxfee`. Becaue an absurdly high fee rate is usually the result of a fat finger, aborting seems safer behavior. Before: ``` bitcoin-cli walletcreatefundedpsbt '[]' '[{"tb1q...": 0.01}]' 0 '{"feeRate": 10}' true { "psbt": "cHNidP8...gAA=", "fee": 0.10000000, "changepos": 1 } ``` After: ``` bitcoin-cli walletcreatefundedpsbt '[]' '[{"tb1q...": 0.01}]' 0 '{"feeRate": 10}' true error code: -25 error message: Fee exceeds maximum configured by -maxtxfee ``` QT still checks the max fee rate as expected: <img width="566" alt="Schermafbeelding 2019-06-20 om 19 52 00" src="https://user-images.githubusercontent.com/10217/59888424-a2aa7100-9395-11e9-8ae6-8a3c1f7de585.png"> ACKs for top commit: laanwj: Code review ACK 806b0052c3b45415862f74f20ba5f389e5b673de Tree-SHA512: bee95811711cdab100b614d2347921407af3b400aea613ca156953ed3f60b924ad29a1d335bd0e240c0b7c0fbb360226bab03294d226a5560cdf2a3f21e6d406
2019-06-28[wallet] abort when attempting to fund a transaction above maxtxfeeSjors Provoost
FundTransaction calls GetMinimumFee which, when the fee rate is absurdly high, quietly reduced the fee to -maxtxfee. Becaue an absurdly high fee rate is usually the result of a fat finger, aborting seems safer behavior.
2019-06-27util: No translation of `Bitcoin Core` in the copyrightMarcoFalke
2019-06-27util: Explain why the path is cachedMarcoFalke
2019-06-13scripted-diff: Replace fprintf with tfm::formatMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/fprintf\(std(err|out), /tfm::format(std::c\1, /g' $(git grep -l 'fprintf(' -- ':(exclude)src/crypto' ':(exclude)src/leveldb' ':(exclude)src/univalue' ':(exclude)src/secp256k1') -END VERIFY SCRIPT- fixup! scripted-diff: Replace fprintf with tfm::format
2019-06-06[build]: check std::system for -[alert|block|wallet]notifySjors Provoost
Platforms such as iOs do not support launching a process through system().
2019-06-02Make reasoning about dependencies easier by not including unused dependenciespracticalswift
2019-05-23util: Add type safe GetTimeMarcoFalke
2019-05-07Fix portability issue with pthreadsgrim-trigger
This change resolves the following issue: https://github.com/bitcoin/bitcoin/issues/15951 Only tested on OpenBSD 6.5/amd64
2019-05-02Merge #15650: Handle the result of posix_fallocate system callMarcoFalke
5d35ae3326 Handle the result of posix_fallocate system call (Luca Venturini) Pull request description: The system call `posix_fallocate` is not supported on some filesystems. - catches the result of posix_allocate and fall back to the default behaviour if the return value is different from 0 (success) Fixes #15624 ACKs for commit 5d35ae: MarcoFalke: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab sipa: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab, though the Yoda condition is an uncommon style in this project. hebasto: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab practicalswift: utACK 5d35ae3326624da3fe5dcb4047c9a7cec6665cab Tree-SHA512: 7ab3b35fb633926f28a58b2b07ffde8e31bb997c80a716b1b45ee716fe9ff4ddcef0a05810bd4423530e220cfc62f8925517d27a8b92b05a524272063e43f746
2019-04-29threads: introduce util/threadnames, refactor thread namingJames O'Beirne
This work is prerequisite to attaching thread names to log lines and deadlock debug utilities. This code allows setting of an "internal" threadname per thread on platforms where thread_local is available. This commit also moves RenameThread() out of a more general module and adds a numeric suffix to disambiguate between threads with the same name. It explicitly names a few main threads using the new util::ThreadRename().
2019-04-09[build] Add several util unitsJohn Newbery
Adds the following util units and adds them to libbitcoin_util: - `util/url.cpp` takes `urlDecode` from `httpserver.cpp` - `util/error.cpp` takes `TransactionErrorString` from `node/transaction.cpp` and `AmountHighWarn` and `AmountErrMsg` from `ui_interface.cpp` - `util/fees.cpp` takes `StringForFeeReason` and `FeeModeFromString` from `policy/fees.cpp` - `util/rbf.cpp` takes `SignalsOptInRBF` from `policy/rbf.cpp` - 'util/validation.cpp` takes `FormatStateMessage` and `strMessageMagic` from 'validation.cpp`
2019-03-23Handle the result of posix_fallocate system callLuca Venturini
2019-03-10dead code: Remove dead option in HexStr conversionLenny Maiorani
Problem: - Nothing uses the `fspaces` argument to `HexStr()` besides unit tests. This argument results in extra complexity and a small performance decrease within the function for branch evalulation. Solution: - Remove unused `fspaces` option.
2019-03-02Merge #15118: Refactor block file logicWladimir J. van der Laan
04cca330944f859b4ed68cb8da8a79f5206fd630 Style cleanup. (Jim Posen) 4c01e4e159db82ce4b2acce75f709cac996367d7 flatfile: Unit tests for FlatFileSeq methods. (Jim Posen) 65a489e93d181d3c0f7a9cf79f7c11ff8cf2b0f0 scripted-diff: Rename CBlockDiskPos to FlatFilePos. (Jim Posen) d6d8a78f26f52fdfe43293686135e2fc6919926c Move CDiskBlockPos from chain to flatfile. (Jim Posen) e0380933e3745214331d358bda8c5e79299c84d2 validation: Refactor file flush logic into FlatFileSeq. (Jim Posen) 992404b31ed2f8cabeed59d074552f0ae10fda94 validation: Refactor block file pre-allocation into FlatFileSeq. (Jim Posen) e2d2abb99fe353ffc2ff3bc1ff578fad31065335 validation: Refactor OpenDiskFile into method on FlatFileSeq. (Jim Posen) 9183d6ef656c8f3ed406821b99827f9b5f047665 validation: Extract basic block file logic into FlatFileSeq class. (Jim Posen) 62e7addb632cad77cbd5fbccbaee51c7b32505d0 util: Move CheckDiskSpace to util. (Jim Posen) Pull request description: This cleans up and refactors block file helpers so that they may be used by the block filter indexer. Per [design discussion](https://github.com/bitcoin/bitcoin/pull/14121#issuecomment-451252591) about storing BIP 157 block filters, it has been suggested that they are stored in the same way as block and undo data. This refactor is sufficient to simplify file operations for this use case, though in the future perhaps more pruning-related logic ought to be moved into the new classes. The basic abstraction is a `FlatFileSeq` which manages access to a sequence of numbered files into which raw data is written. Tree-SHA512: b2108756777f2dad8964a1a2ef2764486e708a4a4a8cfac47b5de8bcb0625388964438eb096b10cfd9ea39212c299b5cb32fa943e768db2333cf49ea7def157e
2019-03-02Merge #15335: Fix lack of warning of unrecognized section namesMarcoFalke
1a7ba84e11 Fix lack of warning of unrecognized section names (Akio Nakamura) Pull request description: In #14708, It was introduced that to warn when unrecognized section names are exist in the config file. But ```m_config_sections.clear()``` in ```ArgsManager::ReadConfigStream()``` is called every time when reading each configuration file, so it can warn about only last reading file if ```includeconf``` exists. This PR fix lack of warning by collecting all section names by moving ```m_config_sections.clear()``` to ```ArgsManager::ReadConfigFiles()``` . Also add a test code to confirm this situation. Tree-SHA512: 26aa0cbe3e4ae2e58cbe73d4492ee5cf465fd4c3e5df2c8ca7e282b627df9e637267af1e3816386b1dc6db2398b31936925ce0e432219fec3a9b3398f01e3e65
2019-02-22Style cleanup.Jim Posen
2019-02-22util: Move CheckDiskSpace to util.Jim Posen
2019-02-21Merge #15278: Improve PID file error handlingWladimir J. van der Laan
3782075a5fd4ad0c15a6119e8cdaf136898f679e Move all PID file stuff to init.cpp (Hennadii Stepanov) 561e375c73a37934fe77a519762d81edf7a3325c Make PID file creating errors fatal (Hennadii Stepanov) 745a2ace18ce857bc712d7e66c8bad7c082c07e2 Improve PID file removing errors logging (Hennadii Stepanov) Pull request description: Digging into #15240 the lack of the proper logging has been discovered. Fixed by this PR. UPDATE (inspired by @laanwj's [comment](https://github.com/bitcoin/bitcoin/pull/15278#discussion_r252641810)): Not being able to create the PID file is fatal now. Output of `bitcoind`: ``` $ src/bitcoind -pid=/run/bitcoind/bitcoind.pid 2019-02-01T23:20:10Z Bitcoin Core version v0.17.99.0-561e375c7 (release build) 2019-02-01T23:20:10Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures. 2019-02-01T23:20:10Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463 2019-02-01T23:20:10Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation 2019-02-01T23:20:10Z Using RdRand as an additional entropy source 2019-02-01T23:20:11Z Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory Error: Unable to create the PID file '/run/bitcoind/bitcoind.pid': No such file or directory 2019-02-01T23:20:11Z Shutdown: In progress... 2019-02-01T23:20:11Z Shutdown: Unable to remove PID file: File does not exist 2019-02-01T23:20:11Z Shutdown: done ``` Output of `bitcoin-qt`: ![screenshot from 2019-02-02 01-19-05](https://user-images.githubusercontent.com/32963518/52154886-9349b600-2688-11e9-8128-470f16790305.png) **Notes for reviewers** 1. `CreatePidFile()` has been moved from `util/system.cpp` to `init.cpp` for the following reasons: - to get the ability to use `InitError()` - now `init.cpp` contains code of both creating PID file and removing it 2. Regarding 0.18 release process: this PR modifies 1 string and introduces 2 new ones. Tree-SHA512: ac07d0f800e61ec759e427d0afc0ca43d67f232e977662253963afdd0a220d34b871050f58149fc9fabd427bfc8e0d3f6a6032f2a38f30ad366fc0d074b0f2b3
2019-02-19Fix lack of warning of unrecognized section namesAkio Nakamura
1. Fix lack of warning by collecting all section names by moving m_config_sections.clear() to ArgsManager::ReadConfigFiles(). 2. Add info(file name, line number) to warning message. 3. Add a test code to confirm this situation. 3. Do clear() in ReadConfigString().
2019-02-15Merge #15391: Add compile time verification of assumptions we're currently ↵Wladimir J. van der Laan
making implicitly/tacitly 7cee85807c4db679003c6659d247a2fe74c2464a Add compile time verification of assumptions we're currently making implicitly/tacitly (practicalswift) Pull request description: Add compile time verification of assumptions we're currently making implicitly/tacitly. As suggested by @sipa in https://github.com/bitcoin/bitcoin/pull/14239#issuecomment-462508012 and @MarcoFalke in https://github.com/bitcoin/bitcoin/pull/14479#issuecomment-462534878. Tree-SHA512: e68fe51164dbd3eeb76aa8a7e83dfcd3b4d5a66037c0f1822bbbd189bbe3c280e03b3b10af870880ecc09b612e62fb3d9bcd6cf1e16cb7ba818c257db0712ce4
2019-02-14Move all PID file stuff to init.cppHennadii Stepanov
It is only used from init.cpp. Move-only refactoring.
2019-02-14Add WriteHDKeypath function and move *HDKeypath to util/bip32.{h,cpp}Andrew Chow
Creates new files util/bip32.h and util/bip32.cpp for containing BIP 32 stuff. Moves FormatKeyPath from descriptor.cpp to util/bip32. Adds a wrapper around it to prepent the 'm' for when just the BIP 32 style keypath is needed.
2019-02-14Add compile time verification of assumptions we're currently making ↵practicalswift
implicitly/tacitly
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 #15358: util: Add SetupHelpOptions()Wladimir J. van der Laan
a99999cc04c2e7d79bb841fd954c84e985ed3b88 util: Add SetupHelpOptions() (MarcoFalke) Pull request description: Every binary we have sets up the help option in their own way and wording. Solve that by having one function take care of it for all of them. Tree-SHA512: 6e947fa8bc2a46fa6ca9f45777020aa269a5df0dd916ebc863224f9a1e0f79e8e7754a1478567307edd9461e8babd77d26bc2710bbd56e8f8da9020aa85a8c9c