aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.cpp
diff options
context:
space:
mode:
authorHodlinator <172445034+hodlinator@users.noreply.github.com>2024-08-27 21:21:30 +0200
committerHodlinator <172445034+hodlinator@users.noreply.github.com>2024-08-28 19:11:59 +0200
commit50bc017040ae300c795e3709233b80619db24518 (patch)
tree167e39a98d9c91f06e1c6624e2c40b9e213e7b7a /src/pubkey.cpp
parent5b74a849cf5c54543280ba6488ae7f87361b1e2f (diff)
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.
Diffstat (limited to 'src/pubkey.cpp')
-rw-r--r--src/pubkey.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pubkey.cpp b/src/pubkey.cpp
index 148b268e2e..0849d2a266 100644
--- a/src/pubkey.cpp
+++ b/src/pubkey.cpp
@@ -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
{