mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-29 18:05:58 +02:00
refactor: Hand-replace some ParseHex -> ""_hex
The following scripted-diff commit will replace ParseHex("...") with "..."_hex_u8, but this replacement will not work in cases where vectors are needed instead of arrays, and is not ideal in cases where std::byte is accepted.
For example, it is currently necessary to use _hex_v_u8 when calling CScript operator<< because that operator does not currently support std::array or std::byte.
Conversely, it is incorrect to use _hex_v instead of _hex in net_processing.cpp for the MakeAndPushMessage argument, because if the argument is a std::vector it is considered variable-length and serialized with a size prefix, but if the argument is a std::array or Span is it considered fixed length and serialized without a prefix.
By the same logic, it is also safe to change the NUMS_H constant in pubkey.cpp from a std::vector to std::array because it is never serialized.
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
using namespace util::hex_literals;
|
||||
|
||||
namespace {
|
||||
|
||||
struct Secp256k1SelfTester
|
||||
@@ -190,8 +192,7 @@ int ecdsa_signature_parse_der_lax(secp256k1_ecdsa_signature* sig, const unsigned
|
||||
* For an example script for calculating H, refer to the unit tests in
|
||||
* ./test/functional/test_framework/crypto/secp256k1.py
|
||||
*/
|
||||
static const std::vector<unsigned char> NUMS_H_DATA{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
|
||||
const XOnlyPubKey XOnlyPubKey::NUMS_H{NUMS_H_DATA};
|
||||
constexpr XOnlyPubKey XOnlyPubKey::NUMS_H{"50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"_hex_u8};
|
||||
|
||||
std::vector<CKeyID> XOnlyPubKey::GetKeyIDs() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user