aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.test.include2
-rw-r--r--src/i2p.cpp4
-rw-r--r--src/script/descriptor.cpp10
-rw-r--r--src/script/miniscript.h4
-rw-r--r--src/script/parsing.cpp (renamed from src/util/spanparsing.cpp)6
-rw-r--r--src/script/parsing.h (renamed from src/util/spanparsing.h)18
-rw-r--r--src/test/fuzz/script_parsing.cpp (renamed from src/test/fuzz/spanparsing.cpp)13
-rw-r--r--src/test/util_tests.cpp6
9 files changed, 27 insertions, 40 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a2df160bdd..64490161cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -268,6 +268,7 @@ BITCOIN_CORE_H = \
script/descriptor.h \
script/keyorigin.h \
script/miniscript.h \
+ script/parsing.h \
script/sigcache.h \
script/sign.h \
script/signingprovider.h \
@@ -318,7 +319,6 @@ BITCOIN_CORE_H = \
util/serfloat.h \
util/signalinterrupt.h \
util/sock.h \
- util/spanparsing.h \
util/strencodings.h \
util/string.h \
util/subprocess.h \
@@ -711,6 +711,7 @@ libbitcoin_common_a_SOURCES = \
scheduler.cpp \
script/descriptor.cpp \
script/miniscript.cpp \
+ script/parsing.cpp \
script/sign.cpp \
script/signingprovider.cpp \
script/solver.cpp \
@@ -752,7 +753,6 @@ libbitcoin_util_a_SOURCES = \
util/threadinterrupt.cpp \
util/threadnames.cpp \
util/serfloat.cpp \
- util/spanparsing.cpp \
util/strencodings.cpp \
util/string.cpp \
util/time.cpp \
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index cfd28b0a4d..e3a77c6524 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -371,6 +371,7 @@ test_fuzz_fuzz_SOURCES = \
test/fuzz/script_format.cpp \
test/fuzz/script_interpreter.cpp \
test/fuzz/script_ops.cpp \
+ test/fuzz/script_parsing.cpp \
test/fuzz/script_sigcache.cpp \
test/fuzz/script_sign.cpp \
test/fuzz/scriptnum_ops.cpp \
@@ -380,7 +381,6 @@ test_fuzz_fuzz_SOURCES = \
test/fuzz/signet.cpp \
test/fuzz/socks5.cpp \
test/fuzz/span.cpp \
- test/fuzz/spanparsing.cpp \
test/fuzz/string.cpp \
test/fuzz/strprintf.cpp \
test/fuzz/system.cpp \
diff --git a/src/i2p.cpp b/src/i2p.cpp
index 962adb124d..cb24a93db9 100644
--- a/src/i2p.cpp
+++ b/src/i2p.cpp
@@ -12,12 +12,12 @@
#include <netaddress.h>
#include <netbase.h>
#include <random.h>
+#include <script/parsing.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/fs.h>
#include <util/readwritefile.h>
#include <util/sock.h>
-#include <util/spanparsing.h>
#include <util/strencodings.h>
#include <util/threadinterrupt.h>
@@ -308,7 +308,7 @@ Session::Reply Session::SendRequestAndGetReply(const Sock& sock,
reply.full = sock.RecvUntilTerminator('\n', recv_timeout, *m_interrupt, MAX_MSG_SIZE);
- for (const auto& kv : spanparsing::Split(reply.full, ' ')) {
+ for (const auto& kv : Split(reply.full, ' ')) {
const auto& pos = std::find(kv.begin(), kv.end(), '=');
if (pos != kv.end()) {
reply.keys.emplace(std::string{kv.begin(), pos}, std::string{pos + 1, kv.end()});
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp
index a11d4dcbd5..3bc0730c73 100644
--- a/src/script/descriptor.cpp
+++ b/src/script/descriptor.cpp
@@ -8,6 +8,7 @@
#include <key_io.h>
#include <pubkey.h>
#include <script/miniscript.h>
+#include <script/parsing.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <script/solver.h>
@@ -17,7 +18,6 @@
#include <span.h>
#include <util/bip32.h>
#include <util/check.h>
-#include <util/spanparsing.h>
#include <util/strencodings.h>
#include <util/vector.h>
@@ -1350,8 +1350,6 @@ enum class ParseScriptContext {
/** Parse a public key that excludes origin information. */
std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, bool& apostrophe, std::string& error)
{
- using namespace spanparsing;
-
bool permit_uncompressed = ctx == ParseScriptContext::TOP || ctx == ParseScriptContext::P2SH;
auto split = Split(sp, '/');
std::string str(split[0].begin(), split[0].end());
@@ -1424,8 +1422,6 @@ std::unique_ptr<PubkeyProvider> ParsePubkeyInner(uint32_t key_exp_index, const S
/** Parse a public key including origin information (if enabled). */
std::unique_ptr<PubkeyProvider> ParsePubkey(uint32_t key_exp_index, const Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, std::string& error)
{
- using namespace spanparsing;
-
auto origin_split = Split(sp, ']');
if (origin_split.size() > 2) {
error = "Multiple ']' characters found for a single pubkey";
@@ -1589,7 +1585,7 @@ struct KeyParser {
// NOLINTNEXTLINE(misc-no-recursion)
std::unique_ptr<DescriptorImpl> ParseScript(uint32_t& key_exp_index, Span<const char>& sp, ParseScriptContext ctx, FlatSigningProvider& out, std::string& error)
{
- using namespace spanparsing;
+ using namespace script;
auto expr = Expr(sp);
if (Func("pk", expr)) {
@@ -2038,8 +2034,6 @@ std::unique_ptr<DescriptorImpl> InferScript(const CScript& script, ParseScriptCo
/** Check a descriptor checksum, and update desc to be the checksum-less part. */
bool CheckChecksum(Span<const char>& sp, bool require_checksum, std::string& error, std::string* out_checksum = nullptr)
{
- using namespace spanparsing;
-
auto check_split = Split(sp, '#');
if (check_split.size() > 2) {
error = "Multiple '#' symbols";
diff --git a/src/script/miniscript.h b/src/script/miniscript.h
index 4880f32410..17e0cf5c8d 100644
--- a/src/script/miniscript.h
+++ b/src/script/miniscript.h
@@ -18,10 +18,10 @@
#include <policy/policy.h>
#include <primitives/transaction.h>
+#include <script/parsing.h>
#include <script/script.h>
#include <span.h>
#include <util/check.h>
-#include <util/spanparsing.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/vector.h>
@@ -1764,7 +1764,7 @@ void BuildBack(const MiniscriptContext script_ctx, Fragment nt, std::vector<Node
template<typename Key, typename Ctx>
inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
{
- using namespace spanparsing;
+ using namespace script;
// Account for the minimum script size for all parsed fragments so far. It "borrows" 1
// script byte from all leaf nodes, counting it instead whenever a space for a recursive
diff --git a/src/util/spanparsing.cpp b/src/script/parsing.cpp
index c464fc2b87..3528ac9bfa 100644
--- a/src/util/spanparsing.cpp
+++ b/src/script/parsing.cpp
@@ -2,7 +2,7 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <util/spanparsing.h>
+#include <script/parsing.h>
#include <span.h>
@@ -10,7 +10,7 @@
#include <cstddef>
#include <string>
-namespace spanparsing {
+namespace script {
bool Const(const std::string& str, Span<const char>& sp)
{
@@ -49,4 +49,4 @@ Span<const char> Expr(Span<const char>& sp)
return ret;
}
-} // namespace spanparsing
+} // namespace script
diff --git a/src/util/spanparsing.h b/src/script/parsing.h
index 71006ae151..850faea041 100644
--- a/src/util/spanparsing.h
+++ b/src/script/parsing.h
@@ -2,15 +2,14 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_UTIL_SPANPARSING_H
-#define BITCOIN_UTIL_SPANPARSING_H
+#ifndef BITCOIN_SCRIPT_PARSING_H
+#define BITCOIN_SCRIPT_PARSING_H
#include <span.h>
-#include <util/string.h>
#include <string>
-namespace spanparsing {
+namespace script {
/** Parse a constant.
*
@@ -36,13 +35,6 @@ bool Func(const std::string& str, Span<const char>& sp);
*/
Span<const char> Expr(Span<const char>& sp);
-/** Split alias for backwards compatibility */
-template <typename... Args>
-auto Split(Args&&... args)
-{
- return ::Split(std::forward<Args>(args)...);
-}
+} // namespace script
-} // namespace spanparsing
-
-#endif // BITCOIN_UTIL_SPANPARSING_H
+#endif // BITCOIN_SCRIPT_PARSING_H
diff --git a/src/test/fuzz/spanparsing.cpp b/src/test/fuzz/script_parsing.cpp
index b8996632bc..77f4503d47 100644
--- a/src/test/fuzz/spanparsing.cpp
+++ b/src/test/fuzz/script_parsing.cpp
@@ -2,11 +2,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include <script/parsing.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
-#include <util/spanparsing.h>
+#include <util/string.h>
-FUZZ_TARGET(spanparsing)
+FUZZ_TARGET(script_parsing)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
const size_t query_size = fuzzed_data_provider.ConsumeIntegral<size_t>();
@@ -15,16 +16,16 @@ FUZZ_TARGET(spanparsing)
const Span<const char> const_span{span_str};
Span<const char> mut_span = const_span;
- (void)spanparsing::Const(query, mut_span);
+ (void)script::Const(query, mut_span);
mut_span = const_span;
- (void)spanparsing::Func(query, mut_span);
+ (void)script::Func(query, mut_span);
mut_span = const_span;
- (void)spanparsing::Expr(mut_span);
+ (void)script::Expr(mut_span);
if (!query.empty()) {
mut_span = const_span;
- (void)spanparsing::Split(mut_span, query.front());
+ (void)Split(mut_span, query.front());
}
}
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index dcf1b7ace7..f59ce26058 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -6,6 +6,7 @@
#include <common/signmessage.h> // For MessageSign(), MessageVerify(), MESSAGE_MAGIC
#include <hash.h> // For Hash()
#include <key.h> // For CKey
+#include <script/parsing.h>
#include <sync.h>
#include <test/util/random.h>
#include <test/util/setup_common.h>
@@ -16,7 +17,6 @@
#include <util/moneystr.h>
#include <util/overflow.h>
#include <util/readwritefile.h>
-#include <util/spanparsing.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/time.h>
@@ -1292,9 +1292,9 @@ static std::string SpanToStr(const Span<const char>& span)
return std::string(span.begin(), span.end());
}
-BOOST_AUTO_TEST_CASE(test_spanparsing)
+BOOST_AUTO_TEST_CASE(test_script_parsing)
{
- using namespace spanparsing;
+ using namespace script;
std::string input;
Span<const char> sp;
bool success;