Skip to content

Commit 87b6d1c

Browse files
Merge pull request #4830 from kittywhiskers/auxiliary_ports
backport: bitcoin#15141, bitcoin#15437, bitcoin#16240, bitcoin#18923, bitcoin#19219, bitcoin#19277, bitcoin#20016, bitcoin#20671 (auxiliary backports)
2 parents ef8cf4b + af2984b commit 87b6d1c

38 files changed

+353
-341
lines changed

src/Makefile.test.include

Lines changed: 238 additions & 239 deletions
Large diffs are not rendered by default.

src/coinjoin/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int CTransactionBuilder::GetSizeOfCompactSizeDiff(size_t nAdd) const
252252

253253
bool CTransactionBuilder::IsDust(CAmount nAmount) const
254254
{
255-
return ::IsDust(CTxOut(nAmount, ::GetScriptForDestination(tallyItem.txdest)), coinControl.m_discard_feerate.get());
255+
return ::IsDust(CTxOut(nAmount, ::GetScriptForDestination(tallyItem.txdest)), coinControl.m_discard_feerate.value());
256256
}
257257

258258
bool CTransactionBuilder::Commit(bilingual_str& strResult)

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,9 +1781,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
17811781
node.mempool = &::mempool;
17821782
assert(!node.chainman);
17831783
node.chainman = &g_chainman;
1784-
ChainstateManager& chainman = EnsureChainman(node);
1784+
ChainstateManager& chainman = *Assert(node.chainman);
17851785

1786-
node.peer_logic.reset(new PeerLogicValidation(node.connman.get(), node.banman.get(), *node.scheduler, *node.chainman, *node.mempool, args.GetBoolArg("-enablebip61", DEFAULT_ENABLE_BIP61)));
1786+
node.peer_logic.reset(new PeerLogicValidation(node.connman.get(), node.banman.get(), *node.scheduler, chainman, *node.mempool, args.GetBoolArg("-enablebip61", DEFAULT_ENABLE_BIP61)));
17871787
RegisterValidationInterface(node.peer_logic.get());
17881788

17891789
// sanitize comments per BIP-0014, format user agent and check total size

src/interfaces/chain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <string>
1616
#include <vector>
1717

18+
class ArgsManager;
1819
class CBlock;
1920
class CConnman;
2021
class CFeeRate;

src/interfaces/wallet.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ WalletTx MakeWalletTx(CWallet& wallet, const CWalletTx& wtx)
7878
WalletTxStatus MakeWalletTxStatus(CWallet& wallet, const CWalletTx& wtx)
7979
{
8080
WalletTxStatus result;
81-
result.block_height = wallet.chain().getBlockHeight(wtx.m_confirm.hashBlock).get_value_or(std::numeric_limits<int>::max());
81+
result.block_height = wallet.chain().getBlockHeight(wtx.m_confirm.hashBlock).value_or(std::numeric_limits<int>::max());
8282
result.blocks_to_maturity = wtx.GetBlocksToMaturity();
8383
result.depth_in_main_chain = wtx.GetDepthInMainChain();
8484
result.time_received = wtx.nTimeReceived;
@@ -395,7 +395,7 @@ class WalletImpl : public Wallet
395395
return false;
396396
}
397397
balances = getBalances();
398-
num_blocks = m_wallet->chain().getHeight().get_value_or(-1);
398+
num_blocks = m_wallet->chain().getHeight().value_or(-1);
399399
return true;
400400
}
401401
CAmount getBalance() override
@@ -558,10 +558,11 @@ class WalletImpl : public Wallet
558558
class WalletClientImpl : public WalletClient
559559
{
560560
public:
561-
WalletClientImpl(Chain& chain, std::vector<std::string> wallet_filenames)
561+
WalletClientImpl(Chain& chain, ArgsManager& args, std::vector<std::string> wallet_filenames)
562562
: m_wallet_filenames(std::move(wallet_filenames))
563563
{
564564
m_context.chain = &chain;
565+
m_context.args = &args;
565566
}
566567
~WalletClientImpl() override { UnloadWallets(); }
567568

@@ -577,7 +578,7 @@ class WalletClientImpl : public WalletClient
577578
}
578579
bool verify() override { return VerifyWallets(*m_context.chain, m_wallet_filenames); }
579580
bool load() override { return LoadWallets(*m_context.chain, m_wallet_filenames); }
580-
void start(CScheduler& scheduler) override { return StartWallets(scheduler); }
581+
void start(CScheduler& scheduler) override { return StartWallets(scheduler, *Assert(m_context.args)); }
581582
void flush() override { return FlushWallets(); }
582583
void stop() override { return StopWallets(); }
583584
void setMockTime(int64_t time) override { return SetMockTime(time); }
@@ -619,7 +620,7 @@ class WalletClientImpl : public WalletClient
619620
}
620621

621622
WalletContext m_context;
622-
std::vector<std::string> m_wallet_filenames;
623+
const std::vector<std::string> m_wallet_filenames;
623624
std::vector<std::unique_ptr<Handler>> m_rpc_handlers;
624625
std::list<CRPCCommand> m_rpc_commands;
625626
};
@@ -628,9 +629,9 @@ class WalletClientImpl : public WalletClient
628629

629630
std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet) { return wallet ? MakeUnique<WalletImpl>(wallet) : nullptr; }
630631

631-
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames)
632+
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args, std::vector<std::string> wallet_filenames)
632633
{
633-
return MakeUnique<WalletClientImpl>(chain, std::move(wallet_filenames));
634+
return MakeUnique<WalletClientImpl>(chain, args, std::move(wallet_filenames));
634635
}
635636

636637
} // namespace interfaces

src/interfaces/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ std::unique_ptr<Wallet> MakeWallet(const std::shared_ptr<CWallet>& wallet);
450450

451451
//! Return implementation of ChainClient interface for a wallet client. This
452452
//! function will be undefined in builds where ENABLE_WALLET is false.
453-
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, std::vector<std::string> wallet_filenames);
453+
std::unique_ptr<WalletClient> MakeWalletClient(Chain& chain, ArgsManager& args, std::vector<std::string> wallet_filenames);
454454

455455
} // namespace interfaces
456456

src/llmq/snapshot.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ class CQuorumRotationInfo
178178

179179
size_t cnt = ReadCompactSize(s);
180180
for ([[maybe_unused]] const auto _ : irange::range(cnt)) {
181-
uint256 hash;
182181
CFinalCommitment qc;
183182
::Unserialize(s, qc);
184183
lastCommitmentPerIndex.push_back(std::move(qc));

src/node/context.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,4 @@ struct NodeContext {
5656
~NodeContext();
5757
};
5858

59-
inline ChainstateManager& EnsureChainman(const NodeContext& node)
60-
{
61-
assert(node.chainman);
62-
return *node.chainman;
63-
}
64-
6559
#endif // BITCOIN_NODE_CONTEXT_H

src/optional.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55
#ifndef BITCOIN_OPTIONAL_H
66
#define BITCOIN_OPTIONAL_H
77

8+
#include <optional>
89
#include <utility>
910

10-
#include <boost/optional.hpp>
11-
1211
//! Substitute for C++17 std::optional
12+
//! DEPRECATED use std::optional in new code.
1313
template <typename T>
14-
using Optional = boost::optional<T>;
15-
16-
//! Substitute for C++17 std::make_optional
17-
template <typename T>
18-
Optional<T> MakeOptional(bool condition, T&& value)
19-
{
20-
return boost::make_optional(condition, std::forward<T>(value));
21-
}
14+
using Optional = std::optional<T>;
2215

2316
//! Substitute for C++17 std::nullopt
24-
static auto& nullopt = boost::none;
17+
//! DEPRECATED use std::nullopt in new code.
18+
static auto& nullopt = std::nullopt;
2519

2620
#endif // BITCOIN_OPTIONAL_H

src/psbt.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <psbt.h>
6+
#include <util/check.h>
67
#include <util/strencodings.h>
78

89
bool PartiallySignedTransaction::IsNull() const
@@ -165,7 +166,8 @@ void PSBTOutput::Merge(const PSBTOutput& output)
165166

166167
void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index)
167168
{
168-
const CTxOut& out = psbt.tx->vout.at(index);
169+
CMutableTransaction& tx = *Assert(psbt.tx);
170+
const CTxOut& out = tx.vout.at(index);
169171
PSBTOutput& psbt_out = psbt.outputs.at(index);
170172

171173
// Fill a SignatureData with output info
@@ -175,7 +177,7 @@ void UpdatePSBTOutput(const SigningProvider& provider, PartiallySignedTransactio
175177
// Construct a would-be spend of this output, to update sigdata with.
176178
// Note that ProduceSignature is used to fill in metadata (not actual signatures),
177179
// so provider does not need to provide any private keys (it can be a HidingSigningProvider).
178-
MutableTransactionSignatureCreator creator(psbt.tx.get_ptr(), /* index */ 0, out.nValue, SIGHASH_ALL);
180+
MutableTransactionSignatureCreator creator(&tx, /* index */ 0, out.nValue, SIGHASH_ALL);
179181
ProduceSignature(provider, creator, out.scriptPubKey, sigdata);
180182

181183
// Put redeem_script, key paths, into PSBTOutput.

0 commit comments

Comments
 (0)