aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2024-05-24 11:16:33 +0100
committerglozow <gloriajzhao@gmail.com>2024-05-24 11:22:00 +0100
commit6d7a1e3670675fe4bcdd9b2df9bce7979ecd90fc (patch)
tree56a41f19fe50e8c056e96ea9a3c1b13ddfe978d7 /src
parent0b4aa31c34b239ec7da36760a2670792184c3ba8 (diff)
parentaa7e876953c460e8ff97a719fdb18f4f3ac4896f (diff)
Merge bitcoin/bitcoin#29899: [26.x] archive 26.1 release notes + backports
aa7e876953c460e8ff97a719fdb18f4f3ac4896f [doc] add draft release notes for 26.2rc1 (glozow) 21d9aaae3226d76094d323c1de8e1470c5384622 p2p, bugfix: detect addnode cjdns peers in GetAddedNodeInfo() (Jon Atack) ec5ce2fb2b34cdf9691557121faa69298daa97f2 windeploy: Renew certificate (Ava Chow) 96d0e818c5801d4af5570241cd9949cddbacba5e rpc: Reword SighashFromStr error message (MarcoFalke) 6685affe92ce61a586d257b3ccdf0d97f8b9ef85 rpc: move UniValue in blockToJSON (willcl-ark) 7f45e0017417d1a100c60ff02cc72eb788b6f9c6 depends: Fix build of Qt for 32-bit platforms (laanwj) f9b76bae57a79f55b3a6eff0a029b5dc21b1730c ci: Pull in qtbase5-dev instead of seperate low-level libraries (laanwj) c587753f484d2ccb5b93a7cd37c7a8d491e03818 doc: Suggest installing dev packages for debian/ubuntu qt5 build (laanwj) 7ecdb0846dd7d5ff66aec961515c552a531d25f8 ci: Bump s390x to ubuntu:24.04 (MarcoFalke) d9ef6cf934cbd8e9b2f8256de001ca44f74ad6e9 sign: don't assume we are parsing a sane Miniscript (Antoine Poinsot) e4859c82c7b848554b4e9d27c2f8b8615422528e depends: fix mingw-w64 Qt DEBUG=1 build (fanquake) bb46b90b2ec7c8a4955ed8c5711bbc128d803b76 Fix #29767, set m_synced = true after Commit() (nanlour) bf5b6fc8a7c7e6c13520671bb7b2d4d1d110c2bb Throw error if invalid parameters passed to getnetworkhashps RPC endpoint (Jameson Lopp) a81a9228fbaaa10d6308299f11d6093485d645e5 [rpc, bugfix] Enforce maximum value for setmocktime (dergoegge) d39ea519c71ea9e0f2ed0ee79cc66ecaf35e86ee Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us (Luke Dashjr) c21bbcc898d9c1fbc77ca93e46fc84ae22b68afa [doc] archive 26.1 release notes (glozow) Pull request description: Archives 26.1 release notes and adds draft release notes for 26.2rc1 Also backports: - #29691 - #29869 - #28554 - #29747 - #29853 - #29856 - #29764 - #29776 - #29985 - #30094 - #29870 - #30149 - #30085 ACKs for top commit: stickies-v: re-ACK aa7e876953c460e8ff97a719fdb18f4f3ac4896f, only changes are fixing commit msg and transifex reference willcl-ark: ACK aa7e876953c460e8ff97a719fdb18f4f3ac4896f Tree-SHA512: b81ba6092640de696d782114cdf43e7ed1d63ea0a3231cade30653c2743d87700e0f852a1b1fcc42ae313b2d4f004e6026ddbad87d58c2fde0a660e90026ed98
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;