aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core_read.cpp2
-rw-r--r--src/index/base.cpp2
-rw-r--r--src/kernel/chainparams.cpp2
-rw-r--r--src/net.cpp2
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/rpc/mining.cpp19
-rw-r--r--src/rpc/node.cpp7
-rw-r--r--src/script/sign.cpp2
-rw-r--r--src/test/script_tests.cpp24
9 files changed, 50 insertions, 14 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index dfabf3a0c2..ffc4bb4965 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -257,6 +257,6 @@ util::Result<int> SighashFromStr(const std::string& sighash)
if (it != map_sighash_values.end()) {
return it->second;
} else {
- return util::Error{Untranslated(sighash + " is not a valid sighash parameter.")};
+ return util::Error{Untranslated("'" + sighash + "' is not a valid sighash parameter.")};
}
}
diff --git a/src/index/base.cpp b/src/index/base.cpp
index 8474d01c41..298755038c 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -165,9 +165,9 @@ void BaseIndex::ThreadSync()
const CBlockIndex* pindex_next = NextSyncBlock(pindex, m_chainstate->m_chain);
if (!pindex_next) {
SetBestBlockIndex(pindex);
- m_synced = true;
// No need to handle errors in Commit. See rationale above.
Commit();
+ m_synced = true;
break;
}
if (pindex_next->pprev != pindex && !Rewind(pindex, pindex_next->pprev)) {
diff --git a/src/kernel/chainparams.cpp b/src/kernel/chainparams.cpp
index 73ba330ff0..96656de572 100644
--- a/src/kernel/chainparams.cpp
+++ b/src/kernel/chainparams.cpp
@@ -133,7 +133,7 @@ public:
// release ASAP to avoid it where possible.
vSeeds.emplace_back("seed.bitcoin.sipa.be."); // Pieter Wuille, only supports x1, x5, x9, and xd
vSeeds.emplace_back("dnsseed.bluematt.me."); // Matt Corallo, only supports x9
- vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org."); // Luke Dashjr
+ vSeeds.emplace_back("dnsseed.bitcoin.dashjr-list-of-p2p-nodes.us."); // Luke Dashjr
vSeeds.emplace_back("seed.bitcoinstats.com."); // Christian Decker, supports x1 - xf
vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch."); // Jonas Schnelli, only supports x1, x5, x9, and xd
vSeeds.emplace_back("seed.btc.petertodd.org."); // Peter Todd, only supports x1, x5, x9, and xd
diff --git a/src/net.cpp b/src/net.cpp
index 5305e1148a..36a8964bb6 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2794,7 +2794,7 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo() const
}
for (const auto& addr : lAddresses) {
- CService service(LookupNumeric(addr.m_added_node, GetDefaultPort(addr.m_added_node)));
+ CService service{MaybeFlipIPv6toCJDNS(LookupNumeric(addr.m_added_node, GetDefaultPort(addr.m_added_node)))};
AddedNodeInfo addedNode{addr, CService(), false, false};
if (service.IsValid()) {
// strAddNode is an IP:port
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 7b84747a3f..1ed1ed50c2 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -190,12 +190,12 @@ UniValue blockToJSON(BlockManager& blockman, const CBlock& block, const CBlockIn
const CTxUndo* txundo = (have_undo && i > 0) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
UniValue objTx(UniValue::VOBJ);
TxToUniv(*tx, /*block_hash=*/uint256(), /*entry=*/objTx, /*include_hex=*/true, RPCSerializationFlags(), txundo, verbosity);
- txs.push_back(objTx);
+ txs.push_back(std::move(objTx));
}
break;
}
- result.pushKV("tx", txs);
+ result.pushKV("tx", std::move(txs));
return result;
}
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 76170c3201..a1894a3030 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -49,13 +49,22 @@ using node::UpdateTime;
/**
* Return average network hashes per second based on the last 'lookup' blocks,
- * or from the last difficulty change if 'lookup' is nonpositive.
- * If 'height' is nonnegative, compute the estimate at the time when a given block was found.
+ * or from the last difficulty change if 'lookup' is -1.
+ * If 'height' is -1, compute the estimate from current chain tip.
+ * If 'height' is a valid block height, compute the estimate at the time when a given block was found.
*/
static UniValue GetNetworkHashPS(int lookup, int height, const CChain& active_chain) {
+ if (lookup < -1 || lookup == 0) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid nblocks. Must be a positive number or -1.");
+ }
+
+ if (height < -1 || height > active_chain.Height()) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Block does not exist at specified height");
+ }
+
const CBlockIndex* pb = active_chain.Tip();
- if (height >= 0 && height < active_chain.Height()) {
+ if (height >= 0) {
pb = active_chain[height];
}
@@ -63,7 +72,7 @@ static UniValue GetNetworkHashPS(int lookup, int height, const CChain& active_ch
return 0;
// If lookup is -1, then use blocks since last difficulty change.
- if (lookup <= 0)
+ if (lookup == -1)
lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() + 1;
// If lookup is larger than chain, then set it to chain length.
@@ -97,7 +106,7 @@ static RPCHelpMan getnetworkhashps()
"Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
"Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
{
- {"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of blocks, or -1 for blocks since last difficulty change."},
+ {"nblocks", RPCArg::Type::NUM, RPCArg::Default{120}, "The number of previous blocks to calculate estimate from, or -1 for blocks since last difficulty change."},
{"height", RPCArg::Type::NUM, RPCArg::Default{-1}, "To estimate at the time of the given height."},
},
RPCResult{
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp
index 6b3662996c..020e87f19c 100644
--- a/src/rpc/node.cpp
+++ b/src/rpc/node.cpp
@@ -22,6 +22,7 @@
#include <univalue.h>
#include <util/any.h>
#include <util/check.h>
+#include <util/time.h>
#include <stdint.h>
#ifdef HAVE_MALLOC_INFO
@@ -54,9 +55,11 @@ static RPCHelpMan setmocktime()
LOCK(cs_main);
const int64_t time{request.params[0].getInt<int64_t>()};
- if (time < 0) {
- throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime cannot be negative: %s.", time));
+ constexpr int64_t max_time{Ticks<std::chrono::seconds>(std::chrono::nanoseconds::max())};
+ if (time < 0 || time > max_time) {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Mocktime must be in the range [0, %s], not %s.", max_time, time));
}
+
SetMockTime(time);
const NodeContext& node_context{EnsureAnyNodeContext(request.context)};
for (const auto& chain_client : node_context.chain_clients) {
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 251a8420f7..d91a246d03 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -295,7 +295,7 @@ struct TapSatisfier: Satisfier<XOnlyPubKey> {
//! Conversion from a raw xonly public key.
template <typename I>
std::optional<XOnlyPubKey> FromPKBytes(I first, I last) const {
- CHECK_NONFATAL(last - first == 32);
+ if (last - first != 32) return {};
XOnlyPubKey pubkey;
std::copy(first, last, pubkey.begin());
return pubkey;
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 624d0b2c12..50715e9a04 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1276,6 +1276,30 @@ BOOST_AUTO_TEST_CASE(script_combineSigs)
BOOST_CHECK(combined.scriptSig == partial3c);
}
+/**
+ * Reproduction of an exception incorrectly raised when parsing a public key inside a TapMiniscript.
+ */
+BOOST_AUTO_TEST_CASE(sign_invalid_miniscript)
+{
+ FillableSigningProvider keystore;
+ SignatureData sig_data;
+ CMutableTransaction prev, curr;
+
+ // Create a Taproot output which contains a leaf in which a non-32 bytes push is used where a public key is expected
+ // by the Miniscript parser. This offending Script was found by the RPC fuzzer.
+ const auto invalid_pubkey{ParseHex("173d36c8c9c9c9ffffffffffff0200000000021e1e37373721361818181818181e1e1e1e19000000000000000000b19292929292926b006c9b9b9292")};
+ TaprootBuilder builder;
+ builder.Add(0, {invalid_pubkey}, 0xc0);
+ XOnlyPubKey nums{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
+ builder.Finalize(nums);
+ prev.vout.emplace_back(0, GetScriptForDestination(builder.GetOutput()));
+ curr.vin.emplace_back(COutPoint{prev.GetHash(), 0});
+ sig_data.tr_spenddata = builder.GetSpendData();
+
+ // SignSignature can fail but it shouldn't raise an exception (nor crash).
+ BOOST_CHECK(!SignSignature(keystore, CTransaction(prev), curr, 0, SIGHASH_ALL, sig_data));
+}
+
BOOST_AUTO_TEST_CASE(script_standard_push)
{
ScriptError err;