string_view
and optional
fa7078d84fc2858a466bc1a85404f821df682538 scripted-diff: Rename ValidAsCString to ContainsNoNUL (MacroFake)
e7d2fbda63c346ae88767c3f8d4db3edeae2dc0b Use std::string_view throughout util strencodings/string (Pieter Wuille)
8ffbd1412d887535ce5eb613884858c319bd12be Make DecodeBase{32,64} take string_view arguments (Pieter Wuille)
1a72d62152bfdd7c5c2b2704b679f894e7d35e37 Generalize ConvertBits to permit transforming the input (Pieter Wuille)
78f3ac51b7d073d12da6a3b9b7d80d91e04ce3a7 Make DecodeBase{32,64} return optional instead of taking bool* (Pieter Wuille)
a65931e3ce66d87b8f83d67ecdbb46f137e6a670 Make DecodeBase{32,64} always return vector, not string (Pieter Wuille)
a4377a0843636eae0aaf698510fc6518582545db Reject incorrect base64 in HTTP auth (Pieter Wuille)
d648b5120b2fefa9e599898bd26f05ecf4428fac Make SanitizeString use string_view (Pieter Wuille)
963bc9b576f0a62caffede2ce32830aef3473995 Make IsHexNumber use string_view (Pieter Wuille)
40062997f223d88d4f92aaae4622a31476686163 Make IsHex use string_view (Pieter Wuille)
c1d165a8c2678c31aced5e1d46231d9996b0774a Make ParseHex use string_view (Pieter Wuille)
Pull request description:
Make use of `std::string_view` and `std::optional` in the util/{strencodings, string} files.
This avoids many temporary string/vector objects being created, while making the interface easier to read. Changes include:
* Make all input arguments in functions in util/strencodings and util/string take `std::string_view` instead of `std::string`.
* Add `RemovePrefixView` and `TrimStringView` which also *return* `std::string_view` objects (the corresponding `RemovePrefix` and `TrimString` keep returning an `std::string`, as that's needed in many call sites still).
* Stop returning `std::string` from `DecodeBase32` and `DecodeBase64`, but return vectors. Base32/64 are fundamentally algorithms for encoding bytes as strings; returning `std::string` from those (especially doing it conditionally based on the input arguments/types) is just bizarre.
* Stop taking a `bool* pf_invalid` output argument pointer in `DecodeBase32` and `DecodeBase64`; return an `std::optional` instead.
* Make `DecodeBase32` and `DecodeBase64` more efficient by doing the conversion from characters to integer symbols on-the-fly rather than through a temporary vector.
ACKs for top commit:
MarcoFalke:
re-ACK fa7078d84fc2858a466bc1a85404f821df682538 only change is rebase and adding a scripted-diff 🍲
martinus:
Code review ACK fa7078d84fc2858a466bc1a85404f821df682538, found no issue
laanwj:
Code review ACK fa7078d84fc2858a466bc1a85404f821df682538
sipa:
utACK fa7078d84fc2858a466bc1a85404f821df682538 (as far as the commit that isn't mine goes)
Tree-SHA512: 5cf02e541caef0bcd100466747664bdb828a68a05dae568cbcd0632a53dd3a4c4e85cd8c48ebbd168d4247d5c9666689c16005f1c8ad75b0f057d8683931f664
Bitcoin Core integration/staging tree
For an immediately usable, binary version of the Bitcoin Core software, see https://bitcoincore.org/en/download/.
Further information about Bitcoin Core is available in the doc folder.
What is Bitcoin?
Bitcoin is an experimental digital currency that enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate with no central authority: managing transactions and issuing money are carried out collectively by the network. Bitcoin Core is the name of open source software which enables the use of this currency.
For more information read the original Bitcoin whitepaper.
License
Bitcoin Core is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.
Development Process
The master
branch is regularly built (see doc/build-*.md
for instructions) and tested, but it is not guaranteed to be
completely stable. Tags are created
regularly from release branches to indicate new official, stable release versions of Bitcoin Core.
The https://github.com/bitcoin-core/gui repository is used exclusively for the development of the GUI. Its master branch is identical in all monotree repositories. Release branches and tags do not exist, so please do not fork that repository unless it is for development reasons.
The contribution workflow is described in CONTRIBUTING.md and useful hints for developers can be found in doc/developer-notes.md.
Testing
Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people lots of money.
Automated Testing
Developers are strongly encouraged to write unit tests for new code, and to
submit new unit tests for old code. Unit tests can be compiled and run
(assuming they weren't disabled in configure) with: make check
. Further details on running
and extending unit tests can be found in /src/test/README.md.
There are also regression and integration tests, written
in Python.
These tests can be run (if the test dependencies are installed) with: test/functional/test_runner.py
The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS, and that unit/sanity tests are run automatically.
Manual Quality Assurance (QA) Testing
Changes should be tested by somebody other than the developer who wrote the code. This is especially important for large or high-risk changes. It is useful to add a test plan to the pull request description if testing the changes is not straightforward.
Translations
Changes to translations as well as new translations can be submitted to Bitcoin Core's Transifex page.
Translations are periodically pulled from Transifex and merged into the git repository. See the translation process for details on how this works.
Important: We do not accept translation changes as GitHub pull requests because the next pull from Transifex would automatically overwrite them again.