mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 03:22:47 +01:00
merge bitcoin#21415: remove Optional & nullopt
This commit is contained in:
parent
898fef5c01
commit
41eba6beef
@ -240,7 +240,6 @@ BITCOIN_CORE_H = \
|
||||
node/transaction.h \
|
||||
node/utxo_snapshot.h \
|
||||
noui.h \
|
||||
optional.h \
|
||||
policy/feerate.h \
|
||||
policy/fees.h \
|
||||
policy/policy.h \
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdio.h>
|
||||
#include <tuple>
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <stacktraces.h>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <stdio.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
@ -229,7 +229,7 @@ bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPre
|
||||
int64_t nTime1 = GetTimeMicros();
|
||||
|
||||
auto retVal = CachedGetQcHashesQcIndexedHashes(pindexPrev, quorum_block_processor);
|
||||
if (retVal == std::nullopt) {
|
||||
if (!retVal) {
|
||||
return state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "commitment-not-found");
|
||||
}
|
||||
// The returned quorums are in reversed order, so the most recent one is at index 0
|
||||
|
@ -139,23 +139,23 @@ class ChainImpl : public Chain
|
||||
{
|
||||
public:
|
||||
explicit ChainImpl(NodeContext& node) : m_node(node) {}
|
||||
Optional<int> getHeight() override
|
||||
std::optional<int> getHeight() override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
int height = ::ChainActive().Height();
|
||||
if (height >= 0) {
|
||||
return height;
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
Optional<int> getBlockHeight(const uint256& hash) override
|
||||
std::optional<int> getBlockHeight(const uint256& hash) override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
CBlockIndex* block = LookupBlockIndex(hash);
|
||||
if (block && ::ChainActive().Contains(block)) {
|
||||
return block->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
uint256 getBlockHash(int height) override
|
||||
{
|
||||
@ -184,7 +184,7 @@ public:
|
||||
CBlockIndex* block = ::ChainActive()[height];
|
||||
return block && ((block->nStatus & BLOCK_HAVE_DATA) != 0) && block->nTx > 0;
|
||||
}
|
||||
Optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override
|
||||
std::optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
CBlockIndex* block = ::ChainActive().FindEarliestAtLeast(time, height);
|
||||
@ -192,9 +192,9 @@ public:
|
||||
if (hash) *hash = block->GetBlockHash();
|
||||
return block->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
Optional<int> findPruned(int start_height, Optional<int> stop_height) override
|
||||
std::optional<int> findPruned(int start_height, std::optional<int> stop_height) override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (::fPruneMode) {
|
||||
@ -206,9 +206,9 @@ public:
|
||||
block = block->pprev;
|
||||
}
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
Optional<int> findFork(const uint256& hash, Optional<int>* height) override
|
||||
std::optional<int> findFork(const uint256& hash, std::optional<int>* height) override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
const CBlockIndex* block = LookupBlockIndex(hash);
|
||||
@ -223,20 +223,20 @@ public:
|
||||
if (fork) {
|
||||
return fork->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
CBlockLocator getTipLocator() override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
return ::ChainActive().GetLocator();
|
||||
}
|
||||
Optional<int> findLocatorFork(const CBlockLocator& locator) override
|
||||
std::optional<int> findLocatorFork(const CBlockLocator& locator) override
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if (CBlockIndex* fork = FindForkInGlobalIndex(::ChainActive(), locator)) {
|
||||
return fork->nHeight;
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
bool checkFinalTx(const CTransaction& tx) override
|
||||
{
|
||||
|
@ -5,11 +5,11 @@
|
||||
#ifndef BITCOIN_INTERFACES_CHAIN_H
|
||||
#define BITCOIN_INTERFACES_CHAIN_H
|
||||
|
||||
#include <optional.h> // For Optional and nullopt
|
||||
#include <primitives/transaction.h> // For CTransactionRef
|
||||
#include <util/settings.h> // For util::SettingsValue
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@ -76,12 +76,12 @@ public:
|
||||
//! Get current chain height, not including genesis block (returns 0 if
|
||||
//! chain only contains genesis block, nullopt if chain does not contain
|
||||
//! any blocks)
|
||||
virtual Optional<int> getHeight() = 0;
|
||||
virtual std::optional<int> getHeight() = 0;
|
||||
|
||||
//! Get block height above genesis block. Returns 0 for genesis block,
|
||||
//! 1 for following block, and so on. Returns nullopt for a block not
|
||||
//! included in the current chain.
|
||||
virtual Optional<int> getBlockHeight(const uint256& hash) = 0;
|
||||
virtual std::optional<int> getBlockHeight(const uint256& hash) = 0;
|
||||
|
||||
//! Get block hash. Height must be valid or this function will abort.
|
||||
virtual uint256 getBlockHash(int height) = 0;
|
||||
@ -102,11 +102,11 @@ public:
|
||||
//! given height, or nullopt if there is no block with a high enough
|
||||
//! timestamp and height. Also return the block hash as an optional output parameter
|
||||
//! (to avoid the cost of a second lookup in case this information is needed.)
|
||||
virtual Optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) = 0;
|
||||
virtual std::optional<int> findFirstBlockWithTimeAndHeight(int64_t time, int height, uint256* hash) = 0;
|
||||
|
||||
//! Return height of last block in the specified range which is pruned, or
|
||||
//! nullopt if no block in the range is pruned. Range is inclusive.
|
||||
virtual Optional<int> findPruned(int start_height = 0, Optional<int> stop_height = nullopt) = 0;
|
||||
virtual std::optional<int> findPruned(int start_height = 0, std::optional<int> stop_height = std::nullopt) = 0;
|
||||
|
||||
//! Return height of the specified block if it is on the chain, otherwise
|
||||
//! return the height of the highest block on chain that's an ancestor
|
||||
@ -114,7 +114,7 @@ public:
|
||||
//! Also return the height of the specified block as an optional output
|
||||
//! parameter (to avoid the cost of a second hash lookup in case this
|
||||
//! information is desired).
|
||||
virtual Optional<int> findFork(const uint256& hash, Optional<int>* height) = 0;
|
||||
virtual std::optional<int> findFork(const uint256& hash, std::optional<int>* height) = 0;
|
||||
|
||||
//! Get locator for the current chain tip.
|
||||
virtual CBlockLocator getTipLocator() = 0;
|
||||
@ -122,7 +122,7 @@ public:
|
||||
//! Return height of the highest block on chain in common with the locator,
|
||||
//! which will either be the original block used to create the locator,
|
||||
//! or one of its ancestors.
|
||||
virtual Optional<int> findLocatorFork(const CBlockLocator& locator) = 0;
|
||||
virtual std::optional<int> findLocatorFork(const CBlockLocator& locator) = 0;
|
||||
|
||||
//! Check if transaction will be final given chain height current time.
|
||||
virtual bool checkFinalTx(const CTransaction& tx) = 0;
|
||||
|
@ -369,7 +369,7 @@ public:
|
||||
if (mi == m_wallet->mapWallet.end()) {
|
||||
return false;
|
||||
}
|
||||
if (Optional<int> height = m_wallet->chain().getHeight()) {
|
||||
if (std::optional<int> height = m_wallet->chain().getHeight()) {
|
||||
block_time = m_wallet->chain().getBlockTime(*height);
|
||||
} else {
|
||||
block_time = -1;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <saltedhasher.h>
|
||||
#include <streams.h>
|
||||
#include <sync.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
class CNode;
|
||||
|
@ -291,8 +291,8 @@ bool BuildQuorumRotationInfo(const CGetQuorumRotationInfo& request, CQuorumRotat
|
||||
response.mnListDiffAtHMinus4C = std::move(mn4c);
|
||||
} else {
|
||||
response.extraShare = false;
|
||||
response.quorumSnapshotAtHMinus4C = std::nullopt;
|
||||
response.mnListDiffAtHMinus4C = std::nullopt;
|
||||
response.quorumSnapshotAtHMinus4C.reset();
|
||||
response.mnListDiffAtHMinus4C.reset();
|
||||
}
|
||||
|
||||
std::set<int> snapshotHeightsNeeded;
|
||||
|
@ -11,9 +11,10 @@
|
||||
#include <random.h>
|
||||
#include <set>
|
||||
#include <sync.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
#include <versionbits.h>
|
||||
|
||||
class CConnman;
|
||||
class CBlockIndex;
|
||||
|
@ -107,9 +107,6 @@ void BlockAssembler::resetBlock()
|
||||
nFees = 0;
|
||||
}
|
||||
|
||||
Optional<int64_t> BlockAssembler::m_last_block_num_txs{nullopt};
|
||||
Optional<int64_t> BlockAssembler::m_last_block_size{nullopt};
|
||||
|
||||
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
{
|
||||
int64_t nTimeStart = GetTimeMicros();
|
||||
|
@ -6,12 +6,12 @@
|
||||
#ifndef BITCOIN_MINER_H
|
||||
#define BITCOIN_MINER_H
|
||||
|
||||
#include <optional.h>
|
||||
#include <primitives/block.h>
|
||||
#include <txmempool.h>
|
||||
#include <validation.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
@ -178,8 +178,8 @@ public:
|
||||
/** Construct a new block template with coinbase to scriptPubKeyIn */
|
||||
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
|
||||
|
||||
static Optional<int64_t> m_last_block_num_txs;
|
||||
static Optional<int64_t> m_last_block_size;
|
||||
inline static std::optional<int64_t> m_last_block_num_txs{};
|
||||
inline static std::optional<int64_t> m_last_block_size{};
|
||||
|
||||
private:
|
||||
// utility functions
|
||||
|
10
src/net.cpp
10
src/net.cpp
@ -662,7 +662,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
|
||||
if (m_deserializer->Complete()) {
|
||||
// decompose a transport agnostic CNetMessage from the deserializer
|
||||
uint32_t out_err_raw_size{0};
|
||||
Optional<CNetMessage> result{m_deserializer->GetMessage(nTimeMicros, out_err_raw_size)};
|
||||
std::optional<CNetMessage> result{m_deserializer->GetMessage(nTimeMicros, out_err_raw_size)};
|
||||
if (!result) {
|
||||
// Message deserialization failed. Drop the message but don't disconnect the peer.
|
||||
// store the size of the corrupt message
|
||||
@ -780,10 +780,10 @@ const uint256& V1TransportDeserializer::GetMessageHash() const
|
||||
return data_hash;
|
||||
}
|
||||
|
||||
Optional<CNetMessage> V1TransportDeserializer::GetMessage(int64_t time, uint32_t& out_err_raw_size)
|
||||
std::optional<CNetMessage> V1TransportDeserializer::GetMessage(int64_t time, uint32_t& out_err_raw_size)
|
||||
{
|
||||
// decompose a single CNetMessage from the TransportDeserializer
|
||||
Optional<CNetMessage> msg(std::move(vRecv));
|
||||
std::optional<CNetMessage> msg(std::move(vRecv));
|
||||
|
||||
// store command string, time, and sizes
|
||||
msg->m_command = hdr.GetCommand();
|
||||
@ -804,12 +804,12 @@ Optional<CNetMessage> V1TransportDeserializer::GetMessage(int64_t time, uint32_t
|
||||
HexStr(Span<uint8_t>(hdr.pchChecksum, hdr.pchChecksum+CMessageHeader::CHECKSUM_SIZE)),
|
||||
m_node_id);
|
||||
out_err_raw_size = msg->m_raw_message_size;
|
||||
msg = nullopt;
|
||||
msg.reset();
|
||||
} else if (!hdr.IsCommandValid()) {
|
||||
LogPrint(BCLog::NET, "HEADER ERROR - COMMAND (%s, %u bytes), peer=%d\n",
|
||||
hdr.GetCommand(), msg->m_message_size, m_node_id);
|
||||
out_err_raw_size = msg->m_raw_message_size;
|
||||
msg = nullopt;
|
||||
msg.reset();
|
||||
}
|
||||
|
||||
// Always reset the network deserializer (prepare for the next message)
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <limitedmap.h>
|
||||
#include <net_permissions.h>
|
||||
#include <netaddress.h>
|
||||
#include <optional.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
@ -36,6 +35,7 @@
|
||||
#include <memory>
|
||||
#include <condition_variable>
|
||||
#include <unordered_set>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
|
||||
#ifndef WIN32
|
||||
@ -854,7 +854,7 @@ public:
|
||||
// read and deserialize data
|
||||
virtual int Read(const char *data, unsigned int bytes) = 0;
|
||||
// decomposes a message from the context
|
||||
virtual Optional<CNetMessage> GetMessage(int64_t time, uint32_t& out_err) = 0;
|
||||
virtual std::optional<CNetMessage> GetMessage(int64_t time, uint32_t& out_err) = 0;
|
||||
virtual ~TransportDeserializer() {}
|
||||
};
|
||||
|
||||
@ -913,7 +913,7 @@ public:
|
||||
if (ret < 0) Reset();
|
||||
return ret;
|
||||
}
|
||||
Optional<CNetMessage> GetMessage(int64_t time, uint32_t& out_err_raw_size) override;
|
||||
std::optional<CNetMessage> GetMessage(int64_t time, uint32_t& out_err_raw_size) override;
|
||||
};
|
||||
|
||||
/** The TransportSerializer prepares messages for the network transport
|
||||
|
@ -1,20 +0,0 @@
|
||||
// Copyright (c) 2017 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_OPTIONAL_H
|
||||
#define BITCOIN_OPTIONAL_H
|
||||
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
//! Substitute for C++17 std::optional
|
||||
//! DEPRECATED use std::optional in new code.
|
||||
template <typename T>
|
||||
using Optional = std::optional<T>;
|
||||
|
||||
//! Substitute for C++17 std::nullopt
|
||||
//! DEPRECATED use std::nullopt in new code.
|
||||
static auto& nullopt = std::nullopt;
|
||||
|
||||
#endif // BITCOIN_OPTIONAL_H
|
11
src/psbt.h
11
src/psbt.h
@ -7,13 +7,14 @@
|
||||
|
||||
#include <attributes.h>
|
||||
#include <node/transaction.h>
|
||||
#include <optional.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/sign.h>
|
||||
#include <script/signingprovider.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
// Magic bytes
|
||||
static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
|
||||
|
||||
@ -315,7 +316,7 @@ struct PSBTOutput
|
||||
/** A version of CTransaction with the PSBT format*/
|
||||
struct PartiallySignedTransaction
|
||||
{
|
||||
Optional<CMutableTransaction> tx;
|
||||
std::optional<CMutableTransaction> tx;
|
||||
std::vector<PSBTInput> inputs;
|
||||
std::vector<PSBTOutput> outputs;
|
||||
std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
|
||||
@ -509,9 +510,9 @@ struct PSBTInputAnalysis {
|
||||
* Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
|
||||
*/
|
||||
struct PSBTAnalysis {
|
||||
Optional<size_t> estimated_vsize; //!< Estimated weight of the transaction
|
||||
Optional<CFeeRate> estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction
|
||||
Optional<CAmount> fee; //!< Amount of fee being paid by the transaction
|
||||
std::optional<size_t> estimated_vsize; //!< Estimated weight of the transaction
|
||||
std::optional<CFeeRate> estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction
|
||||
std::optional<CAmount> fee; //!< Amount of fee being paid by the transaction
|
||||
std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction
|
||||
PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next
|
||||
};
|
||||
|
@ -106,7 +106,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
|
||||
OptionsModel optionsModel(node);
|
||||
AddWallet(wallet);
|
||||
WalletModel walletModel(interfaces::MakeWallet(wallet), node, &optionsModel);
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
EditAddressDialog editAddressDialog(EditAddressDialog::NewSendingAddress);
|
||||
editAddressDialog.setModel(walletModel.getAddressTableModel());
|
||||
|
||||
|
@ -211,7 +211,7 @@ void TestGUI(interfaces::Node& node)
|
||||
QPushButton* removeRequestButton = receiveCoinsDialog.findChild<QPushButton*>("removeRequestButton");
|
||||
removeRequestButton->click();
|
||||
QCOMPARE(requestTableModel->rowCount({}), currentRowCount-1);
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -1664,13 +1664,13 @@ UniValue analyzepsbt(const JSONRPCRequest& request)
|
||||
}
|
||||
result.pushKV("inputs", inputs_result);
|
||||
|
||||
if (psbta.estimated_vsize != nullopt) {
|
||||
if (psbta.estimated_vsize) {
|
||||
result.pushKV("estimated_vsize", (int)*psbta.estimated_vsize);
|
||||
}
|
||||
if (psbta.estimated_feerate != nullopt) {
|
||||
if (psbta.estimated_feerate) {
|
||||
result.pushKV("estimated_feerate", ValueFromAmount(psbta.estimated_feerate->GetFeePerK()));
|
||||
}
|
||||
if (psbta.fee != nullopt) {
|
||||
if (psbta.fee) {
|
||||
result.pushKV("fee", ValueFromAmount(*psbta.fee));
|
||||
}
|
||||
result.pushKV("next", PSBTRoleName(psbta.next));
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <util/system.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <optional.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <optional.h>
|
||||
#include <streams.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <net.h>
|
||||
#include <net_permissions.h>
|
||||
#include <netaddress.h>
|
||||
#include <optional.h>
|
||||
#include <protocol.h>
|
||||
#include <random.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
@ -16,6 +15,7 @@
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
void initialize_p2p_transport_deserializer()
|
||||
@ -33,7 +34,7 @@ FUZZ_TARGET_INIT(p2p_transport_deserializer, initialize_p2p_transport_deserializ
|
||||
if (deserializer.Complete()) {
|
||||
const int64_t m_time = std::numeric_limits<int64_t>::max();
|
||||
uint32_t out_err_raw_size{0};
|
||||
Optional<CNetMessage> result{deserializer.GetMessage(m_time, out_err_raw_size)};
|
||||
std::optional<CNetMessage> result{deserializer.GetMessage(m_time, out_err_raw_size)};
|
||||
if (result) {
|
||||
assert(result->m_command.size() <= CMessageHeader::COMMAND_SIZE);
|
||||
assert(result->m_raw_message_size <= buffer.size());
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <test/fuzz/fuzz.h>
|
||||
|
||||
#include <psbt.h>
|
||||
#include <optional.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/script.h>
|
||||
#include <streams.h>
|
||||
@ -13,6 +12,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
void initialize_psbt()
|
||||
@ -39,7 +39,7 @@ FUZZ_TARGET_INIT(psbt, initialize_psbt)
|
||||
(void)psbt.IsNull();
|
||||
(void)psbt.IsSane();
|
||||
|
||||
Optional<CMutableTransaction> tx = psbt.tx;
|
||||
std::optional<CMutableTransaction> tx = psbt.tx;
|
||||
if (tx) {
|
||||
const CMutableTransaction& mtx = *tx;
|
||||
const PartiallySignedTransaction psbt_from_tx{mtx};
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <optional.h>
|
||||
#include <pubkey.h>
|
||||
#include <script/descriptor.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
@ -10,6 +9,7 @@
|
||||
#include <test/fuzz/util.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -54,7 +54,7 @@ FUZZ_TARGET(system)
|
||||
// Avoid hitting:
|
||||
// util/system.cpp:425: void ArgsManager::AddArg(const std::string &, const std::string &, unsigned int, const OptionsCategory &): Assertion `ret.second' failed.
|
||||
const std::string argument_name = GetArgumentName(fuzzed_data_provider.ConsumeRandomLengthString(16));
|
||||
if (args_manager.GetArgFlags(argument_name) != nullopt) {
|
||||
if (args_manager.GetArgFlags(argument_name)) {
|
||||
break;
|
||||
}
|
||||
args_manager.AddArg(argument_name, fuzzed_data_provider.ConsumeRandomLengthString(16), fuzzed_data_provider.ConsumeIntegral<unsigned int>(), options_category);
|
||||
@ -67,7 +67,7 @@ FUZZ_TARGET(system)
|
||||
std::vector<std::string> hidden_arguments;
|
||||
for (const std::string& name : names) {
|
||||
const std::string hidden_argument = GetArgumentName(name);
|
||||
if (args_manager.GetArgFlags(hidden_argument) != nullopt) {
|
||||
if (args_manager.GetArgFlags(hidden_argument)) {
|
||||
continue;
|
||||
}
|
||||
if (std::find(hidden_arguments.begin(), hidden_arguments.end(), hidden_argument) != hidden_arguments.end()) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <consensus/consensus.h>
|
||||
#include <consensus/tx_verify.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <optional.h>
|
||||
#include <validation.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/fees.h>
|
||||
@ -25,6 +24,8 @@
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <llmq/instantsend.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFee,
|
||||
int64_t _nTime, unsigned int _entryHeight,
|
||||
bool _spendsCoinbase, unsigned int _sigOps, LockPoints lp)
|
||||
@ -165,7 +166,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntr
|
||||
// GetMemPoolParents() is only valid for entries in the mempool, so we
|
||||
// iterate mapTx to find parents.
|
||||
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
||||
Optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
|
||||
std::optional<txiter> piter = GetIter(tx.vin[i].prevout.hash);
|
||||
if (piter) {
|
||||
parentHashes.insert(*piter);
|
||||
if (parentHashes.size() + 1 > limitAncestorCount) {
|
||||
@ -1376,11 +1377,11 @@ const CTransaction* CTxMemPool::GetConflictTx(const COutPoint& prevout) const
|
||||
return it == mapNextTx.end() ? nullptr : it->second;
|
||||
}
|
||||
|
||||
Optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
|
||||
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
|
||||
{
|
||||
auto it = mapTx.find(txid);
|
||||
if (it != mapTx.end()) return it;
|
||||
return Optional<txiter>{};
|
||||
return {};
|
||||
}
|
||||
|
||||
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -19,7 +20,6 @@
|
||||
#include <coins.h>
|
||||
#include <crypto/siphash.h>
|
||||
#include <indirectmap.h>
|
||||
#include <optional.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <sync.h>
|
||||
@ -645,7 +645,7 @@ public:
|
||||
const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Returns an iterator to the given hash, if found */
|
||||
Optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Translate a set of hashes into a set of pool iterators to avoid repeated lookups */
|
||||
setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
@ -356,7 +356,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
key.erase(0, 1);
|
||||
std::string section;
|
||||
util::SettingsValue value = InterpretOption(section, key, val);
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
|
||||
// Unknown command line options and command line options with dot
|
||||
// characters (which are returned from InterpretOption with nonempty
|
||||
@ -382,7 +382,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||
return success;
|
||||
}
|
||||
|
||||
Optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
std::optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
{
|
||||
LOCK(cs_args);
|
||||
for (const auto& arg_map : m_available_args) {
|
||||
@ -391,7 +391,7 @@ Optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
return search->second.m_flags;
|
||||
}
|
||||
}
|
||||
return nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<std::string> ArgsManager::GetArgs(const std::string& strArg) const
|
||||
@ -875,7 +875,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
|
||||
std::string section;
|
||||
std::string key = option.first;
|
||||
util::SettingsValue value = InterpretOption(section, key, option.second);
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + key);
|
||||
if (flags) {
|
||||
if (!CheckValid(key, value, *flags, error)) {
|
||||
return false;
|
||||
@ -1028,7 +1028,7 @@ void ArgsManager::logArgsPrefix(
|
||||
std::string section_str = section.empty() ? "" : "[" + section + "] ";
|
||||
for (const auto& arg : args) {
|
||||
for (const auto& value : arg.second) {
|
||||
Optional<unsigned int> flags = GetArgFlags('-' + arg.first);
|
||||
std::optional<unsigned int> flags = GetArgFlags('-' + arg.first);
|
||||
if (flags) {
|
||||
std::string value_str = (*flags & SENSITIVE) ? "****" : value.write();
|
||||
LogPrintf("%s %s%s=%s\n", prefix, section_str, arg.first, value_str);
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <compat/assumptions.h>
|
||||
#include <fs.h>
|
||||
#include <logging.h>
|
||||
#include <optional.h>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/settings.h>
|
||||
@ -30,6 +29,7 @@
|
||||
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
@ -344,7 +344,7 @@ public:
|
||||
* Return Flags for known arg.
|
||||
* Return nullopt for unknown arg.
|
||||
*/
|
||||
Optional<unsigned int> GetArgFlags(const std::string& name) const;
|
||||
std::optional<unsigned int> GetArgFlags(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Read and update settings file with saved settings. This needs to be
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <index/txindex.h>
|
||||
#include <logging.h>
|
||||
#include <logging/timer.h>
|
||||
#include <optional.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/settings.h>
|
||||
@ -62,6 +61,7 @@
|
||||
|
||||
#include <statsd_client.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
@ -5527,7 +5527,7 @@ public:
|
||||
};
|
||||
static CMainCleanup instance_of_cmaincleanup;
|
||||
|
||||
Optional<uint256> ChainstateManager::SnapshotBlockhash() const {
|
||||
std::optional<uint256> ChainstateManager::SnapshotBlockhash() const {
|
||||
if (m_active_chainstate != nullptr) {
|
||||
// If a snapshot chainstate exists, it will always be our active.
|
||||
return m_active_chainstate->m_from_snapshot_blockhash;
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <coins.h>
|
||||
#include <crypto/common.h> // for ReadLE64
|
||||
#include <fs.h>
|
||||
#include <optional.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <protocol.h> // For CMessageHeader::MessageStartChars
|
||||
#include <script/script_error.h>
|
||||
@ -29,6 +28,7 @@
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <utility>
|
||||
@ -884,7 +884,7 @@ public:
|
||||
|
||||
bool IsSnapshotActive() const;
|
||||
|
||||
Optional<uint256> SnapshotBlockhash() const;
|
||||
std::optional<uint256> SnapshotBlockhash() const;
|
||||
|
||||
//! Is there a snapshot in use and has it been fully validated?
|
||||
bool IsSnapshotValidated() const { return m_snapshot_validated; }
|
||||
|
@ -6,12 +6,13 @@
|
||||
#define BITCOIN_WALLET_COINCONTROL_H
|
||||
|
||||
#include <key.h>
|
||||
#include <optional.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/fees.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <script/standard.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
enum class CoinType
|
||||
{
|
||||
ALL_COINS,
|
||||
@ -39,11 +40,11 @@ public:
|
||||
//! Override automatic min/max checks on fee, m_feerate must be set if true
|
||||
bool fOverrideFeeRate;
|
||||
//! Override the wallet's m_pay_tx_fee if set
|
||||
Optional<CFeeRate> m_feerate;
|
||||
std::optional<CFeeRate> m_feerate;
|
||||
//! Override the discard feerate estimation with m_discard_feerate in CreateTransaction if set
|
||||
Optional<CFeeRate> m_discard_feerate;
|
||||
std::optional<CFeeRate> m_discard_feerate;
|
||||
//! Override the default confirmation target if set
|
||||
Optional<unsigned int> m_confirm_target;
|
||||
std::optional<unsigned int> m_confirm_target;
|
||||
//! Avoid partial use of funds sent to a given address
|
||||
bool m_avoid_partial_spends;
|
||||
//! Forbids inclusion of dirty (previously used) addresses
|
||||
|
@ -4,13 +4,14 @@
|
||||
|
||||
#include <wallet/coinselection.h>
|
||||
|
||||
#include <optional.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
|
||||
#include <llmq/instantsend.h>
|
||||
#include <coinjoin/coinjoin.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
// Descending order comparator
|
||||
struct {
|
||||
bool operator()(const OutputGroup& a, const OutputGroup& b) const
|
||||
@ -251,7 +252,7 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
|
||||
nValueRet = 0;
|
||||
|
||||
// List of values less than target
|
||||
Optional<OutputGroup> lowest_larger;
|
||||
std::optional<OutputGroup> lowest_larger;
|
||||
std::vector<OutputGroup> applicable_groups;
|
||||
CAmount nTotalLower = 0;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
struct bilingual_str;
|
||||
|
@ -159,7 +159,7 @@ void UnloadWallets()
|
||||
auto wallet = wallets.back();
|
||||
wallets.pop_back();
|
||||
std::vector<bilingual_str> warnings;
|
||||
RemoveWallet(wallet, nullopt, warnings);
|
||||
RemoveWallet(wallet, std::nullopt, warnings);
|
||||
UnloadWallet(std::move(wallet));
|
||||
}
|
||||
}
|
||||
|
@ -323,8 +323,8 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Something wrong with merkleblock");
|
||||
}
|
||||
|
||||
Optional<int> height = pwallet->chain().getBlockHeight(merkleBlock.header.GetHash());
|
||||
if (height == nullopt) {
|
||||
std::optional<int> height = pwallet->chain().getBlockHeight(merkleBlock.header.GetHash());
|
||||
if (!height) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
||||
if (!file.is_open()) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||
}
|
||||
Optional<int> tip_height = pwallet->chain().getHeight();
|
||||
std::optional<int> tip_height = pwallet->chain().getHeight();
|
||||
nTimeBegin = tip_height ? pwallet->chain().getBlockTime(*tip_height) : 0;
|
||||
|
||||
int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
|
||||
@ -940,7 +940,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
||||
// produce output
|
||||
file << strprintf("# Wallet dump created by Dash Core %s\n", CLIENT_BUILD);
|
||||
file << strprintf("# * Created on %s\n", FormatISO8601DateTime(GetTime()));
|
||||
const Optional<int> tip_height = pwallet->chain().getHeight();
|
||||
const std::optional<int> tip_height = pwallet->chain().getHeight();
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", tip_height.value_or(-1), tip_height ? pwallet->chain().getBlockHash(*tip_height).ToString() : "(missing block hash)");
|
||||
file << strprintf("# mined on %s\n", tip_height ? FormatISO8601DateTime(pwallet->chain().getBlockTime(*tip_height)) : "(missing block time)");
|
||||
file << "\n";
|
||||
@ -1519,7 +1519,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
|
||||
// Verify all timestamps are present before importing any keys.
|
||||
const Optional<int> tip_height = pwallet->chain().getHeight();
|
||||
const std::optional<int> tip_height = pwallet->chain().getHeight();
|
||||
now = tip_height ? pwallet->chain().getBlockMedianTimePast(*tip_height) : 0;
|
||||
for (const UniValue& data : requests.getValues()) {
|
||||
GetImportTimestamp(data, now);
|
||||
|
@ -1581,8 +1581,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
|
||||
LOCK(pwallet->cs_wallet);
|
||||
|
||||
Optional<int> height; // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
|
||||
Optional<int> altheight; // Height of the specified block, even if it's in a deactivated chain.
|
||||
std::optional<int> height; // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain.
|
||||
std::optional<int> altheight; // Height of the specified block, even if it's in a deactivated chain.
|
||||
int target_confirms = 1;
|
||||
isminefilter filter = ISMINE_SPENDABLE;
|
||||
|
||||
@ -1610,7 +1610,7 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
||||
|
||||
bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
|
||||
|
||||
const Optional<int> tip_height = pwallet->chain().getHeight();
|
||||
const std::optional<int> tip_height = pwallet->chain().getHeight();
|
||||
int depth = tip_height && height ? (1 + *tip_height - *height) : -1;
|
||||
|
||||
UniValue transactions(UniValue::VARR);
|
||||
@ -2766,7 +2766,7 @@ static UniValue loadwallet(const JSONRPCRequest& request)
|
||||
options.require_existing = true;
|
||||
bilingual_str error;
|
||||
std::vector<bilingual_str> warnings;
|
||||
Optional<bool> load_on_start = request.params[1].isNull() ? nullopt : Optional<bool>(request.params[1].get_bool());
|
||||
std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
|
||||
std::shared_ptr<CWallet> const wallet = LoadWallet(*context.chain, name, load_on_start, options, status, error, warnings);
|
||||
if (!wallet) {
|
||||
// Map bad format to not found, since bad format is returned when the
|
||||
@ -2904,7 +2904,7 @@ static UniValue createwallet(const JSONRPCRequest& request)
|
||||
options.create_flags = flags;
|
||||
options.create_passphrase = passphrase;
|
||||
bilingual_str error;
|
||||
Optional<bool> load_on_start = request.params[5].isNull() ? nullopt : Optional<bool>(request.params[5].get_bool());
|
||||
std::optional<bool> load_on_start = request.params[5].isNull() ? std::nullopt : std::optional<bool>(request.params[5].get_bool());
|
||||
std::shared_ptr<CWallet> wallet = CreateWallet(*context.chain, request.params[0].get_str(), load_on_start, options, status, error, warnings);
|
||||
if (!wallet) {
|
||||
RPCErrorCode code = status == DatabaseStatus::FAILED_ENCRYPT ? RPC_WALLET_ENCRYPTION_FAILED : RPC_WALLET_ERROR;
|
||||
@ -2954,7 +2954,7 @@ static UniValue unloadwallet(const JSONRPCRequest& request)
|
||||
// Note that any attempt to load the same wallet would fail until the wallet
|
||||
// is destroyed (see CheckUniqueFileid).
|
||||
std::vector<bilingual_str> warnings;
|
||||
Optional<bool> load_on_start = request.params[1].isNull() ? nullopt : Optional<bool>(request.params[1].get_bool());
|
||||
std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
|
||||
if (!RemoveWallet(wallet, load_on_start, warnings)) {
|
||||
throw JSONRPCError(RPC_MISC_ERROR, "Requested wallet already unloaded");
|
||||
}
|
||||
@ -3483,7 +3483,7 @@ static UniValue rescanblockchain(const JSONRPCRequest& request)
|
||||
int start_height = 0;
|
||||
uint256 start_block, stop_block;
|
||||
{
|
||||
Optional<int> tip_height = pwallet->chain().getHeight();
|
||||
std::optional<int> tip_height = pwallet->chain().getHeight();
|
||||
|
||||
if (!request.params[0].isNull()) {
|
||||
start_height = request.params[0].get_int();
|
||||
@ -3492,7 +3492,7 @@ static UniValue rescanblockchain(const JSONRPCRequest& request)
|
||||
}
|
||||
}
|
||||
|
||||
Optional<int> stop_height;
|
||||
std::optional<int> stop_height;
|
||||
if (!request.params[1].isNull()) {
|
||||
stop_height = request.params[1].get_int();
|
||||
if (*stop_height < 0 || !tip_height || *stop_height > *tip_height) {
|
||||
|
@ -148,7 +148,7 @@ public:
|
||||
|
||||
~CTransactionBuilderTestSetup()
|
||||
{
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
}
|
||||
|
||||
std::shared_ptr<interfaces::Chain> chain;
|
||||
|
@ -51,7 +51,7 @@ static void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
|
||||
std::vector<bilingual_str> warnings;
|
||||
SyncWithValidationInterfaceQueue();
|
||||
wallet->m_chain_notifications_handler.reset();
|
||||
RemoveWallet(wallet, nullopt, warnings);
|
||||
RemoveWallet(wallet, std::nullopt, warnings);
|
||||
UnloadWallet(std::move(wallet));
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
|
||||
"downloading and rescanning the relevant blocks (see -reindex and -rescan "
|
||||
"options).\"}},{\"success\":true}]",
|
||||
0, oldTip->GetBlockTimeMax(), TIMESTAMP_WINDOW));
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
||||
request.params.push_back(backup_file);
|
||||
AddWallet(wallet);
|
||||
::dumpwallet(request);
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
}
|
||||
|
||||
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
|
||||
@ -289,7 +289,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
|
||||
request.params.push_back(backup_file);
|
||||
AddWallet(wallet);
|
||||
::importwallet(request);
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
|
||||
LOCK(wallet->cs_wallet);
|
||||
BOOST_CHECK_EQUAL(wallet->mapWallet.size(), 3U);
|
||||
@ -578,7 +578,7 @@ public:
|
||||
|
||||
~CreateTransactionTestSetup()
|
||||
{
|
||||
RemoveWallet(wallet, nullopt);
|
||||
RemoveWallet(wallet, std::nullopt);
|
||||
}
|
||||
|
||||
std::shared_ptr<CWallet> wallet;
|
||||
|
@ -94,10 +94,10 @@ bool RemoveWalletSetting(interfaces::Chain& chain, const std::string& wallet_nam
|
||||
|
||||
static void UpdateWalletSetting(interfaces::Chain& chain,
|
||||
const std::string& wallet_name,
|
||||
Optional<bool> load_on_startup,
|
||||
std::optional<bool> load_on_startup,
|
||||
std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
if (load_on_startup == nullopt) return;
|
||||
if (load_on_startup == std::nullopt) return;
|
||||
if (load_on_startup.value() && !AddWalletSetting(chain, wallet_name)) {
|
||||
warnings.emplace_back(Untranslated("Wallet load on startup setting could not be updated, so wallet may not be loaded next node startup."));
|
||||
} else if (!load_on_startup.value() && !RemoveWalletSetting(chain, wallet_name)) {
|
||||
@ -117,7 +117,7 @@ bool AddWallet(const std::shared_ptr<CWallet>& wallet)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, Optional<bool> load_on_start, std::vector<bilingual_str>& warnings)
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
assert(wallet);
|
||||
|
||||
@ -140,7 +140,7 @@ bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, Optional<bool> load_on
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, Optional<bool> load_on_start)
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start)
|
||||
{
|
||||
std::vector<bilingual_str> warnings;
|
||||
return RemoveWallet(wallet, load_on_start, warnings);
|
||||
@ -217,7 +217,7 @@ void UnloadWallet(std::shared_ptr<CWallet>&& wallet)
|
||||
}
|
||||
|
||||
namespace {
|
||||
std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std::string& name, Optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
try {
|
||||
std::unique_ptr<WalletDatabase> database = MakeWalletDatabase(name, options, status, error);
|
||||
@ -245,7 +245,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std:
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, Optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
auto result = WITH_LOCK(g_loading_wallet_mutex, return g_loading_wallet_set.insert(name));
|
||||
if (!result.second) {
|
||||
@ -257,7 +257,7 @@ std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string&
|
||||
return wallet;
|
||||
}
|
||||
|
||||
std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, Optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings)
|
||||
{
|
||||
uint64_t wallet_creation_flags = options.create_flags;
|
||||
const SecureString& passphrase = options.create_passphrase;
|
||||
@ -929,7 +929,7 @@ void CWallet::LoadToWallet(CWalletTx& wtxIn)
|
||||
{
|
||||
// If wallet doesn't have a chain (e.g dash-wallet), don't bother to update txn.
|
||||
if (HaveChain()) {
|
||||
Optional<int> block_height = chain().getBlockHeight(wtxIn.m_confirm.hashBlock);
|
||||
std::optional<int> block_height = chain().getBlockHeight(wtxIn.m_confirm.hashBlock);
|
||||
if (block_height) {
|
||||
// Update cached block height variable since it not stored in the
|
||||
// serialized transaction.
|
||||
@ -1814,8 +1814,8 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
|
||||
// to be scanned.
|
||||
uint256 start_block;
|
||||
{
|
||||
const Optional<int> start_height = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, &start_block);
|
||||
const Optional<int> tip_height = chain().getHeight();
|
||||
const std::optional<int> start_height = chain().findFirstBlockWithTimeAndHeight(startTime - TIMESTAMP_WINDOW, 0, &start_block);
|
||||
const std::optional<int> tip_height = chain().getHeight();
|
||||
WalletLogPrintf("%s: Rescanning last %i blocks\n", __func__, tip_height && start_height ? *tip_height - *start_height + 1 : 0);
|
||||
}
|
||||
|
||||
@ -1870,11 +1870,11 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||
ShowProgress(strprintf("%s " + _("Rescanning...").translated, GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup
|
||||
uint256 tip_hash;
|
||||
// The way the 'block_height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
|
||||
Optional<int> block_height;
|
||||
std::optional<int> block_height;
|
||||
double progress_begin;
|
||||
double progress_end;
|
||||
{
|
||||
if (Optional<int> tip_height = chain().getHeight()) {
|
||||
if (std::optional<int> tip_height = chain().getHeight()) {
|
||||
tip_hash = chain().getBlockHash(*tip_height);
|
||||
}
|
||||
block_height = chain().getBlockHeight(block_hash);
|
||||
@ -1920,7 +1920,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||
break;
|
||||
}
|
||||
{
|
||||
Optional<int> tip_height = chain().getHeight();
|
||||
std::optional<int> tip_height = chain().getHeight();
|
||||
if (!tip_height || *tip_height <= block_height || !chain().getBlockHeight(block_hash)) {
|
||||
// break successfully when rescan has reached the tip, or
|
||||
// previous block is no longer on the chain due to a reorg
|
||||
@ -3603,7 +3603,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
||||
}
|
||||
|
||||
if (HaveChain()) {
|
||||
const Optional<int> tip_height = chain().getHeight();
|
||||
const std::optional<int> tip_height = chain().getHeight();
|
||||
if (tip_height) {
|
||||
SetLastBlockProcessed(*tip_height, chain().getBlockHash(*tip_height));
|
||||
for (auto& pair : mapWallet) {
|
||||
@ -4080,7 +4080,7 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t>& mapKeyBirth) c
|
||||
}
|
||||
|
||||
// map in which we'll infer heights of other keys
|
||||
const Optional<int> tip_height = chain().getHeight();
|
||||
const std::optional<int> tip_height = chain().getHeight();
|
||||
const int max_height = tip_height && *tip_height > 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin
|
||||
std::map<CKeyID, int> mapKeyFirstBlock;
|
||||
for (const CKeyID &keyid : spk_man->GetKeys()) {
|
||||
@ -4096,7 +4096,7 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t>& mapKeyBirth) c
|
||||
for (const auto& entry : mapWallet) {
|
||||
// iterate over all wallet transactions...
|
||||
const CWalletTx &wtx = entry.second;
|
||||
if (Optional<int> height = chain().getBlockHeight(wtx.m_confirm.hashBlock)) {
|
||||
if (std::optional<int> height = chain().getBlockHeight(wtx.m_confirm.hashBlock)) {
|
||||
// ... which are already in a block
|
||||
for (const CTxOut &txout : wtx.tx->vout) {
|
||||
// iterate over all their outputs
|
||||
@ -4266,7 +4266,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
|
||||
}
|
||||
AddWallet(walletInstance);
|
||||
auto unload_wallet = [&](const bilingual_str& strError) {
|
||||
RemoveWallet(walletInstance, nullopt);
|
||||
RemoveWallet(walletInstance, std::nullopt);
|
||||
error = strError;
|
||||
return nullptr;
|
||||
};
|
||||
@ -4274,7 +4274,7 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
|
||||
try {
|
||||
nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
|
||||
} catch (const std::exception& e) {
|
||||
RemoveWallet(walletInstance, nullopt);
|
||||
RemoveWallet(walletInstance, std::nullopt);
|
||||
throw;
|
||||
}
|
||||
if (nLoadWalletRet != DBErrors::LOAD_OK)
|
||||
@ -4505,13 +4505,13 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
|
||||
WalletBatch batch(*walletInstance->database);
|
||||
CBlockLocator locator;
|
||||
if (batch.ReadBestBlock(locator)) {
|
||||
if (const Optional<int> fork_height = chain.findLocatorFork(locator)) {
|
||||
if (const std::optional<int> fork_height = chain.findLocatorFork(locator)) {
|
||||
rescan_height = *fork_height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Optional<int> tip_height = chain.getHeight();
|
||||
const std::optional<int> tip_height = chain.getHeight();
|
||||
if (tip_height) {
|
||||
walletInstance->m_last_block_processed = chain.getBlockHash(*tip_height);
|
||||
walletInstance->m_last_block_processed_height = *tip_height;
|
||||
@ -4546,14 +4546,14 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
|
||||
// our wallet birthday (as adjusted for block time variability)
|
||||
// unless a full rescan was requested
|
||||
if (gArgs.GetArg("-rescan", 0) != 2) {
|
||||
Optional<int64_t> time_first_key;
|
||||
std::optional<int64_t> time_first_key;
|
||||
if (auto spk_man = walletInstance->m_spk_man.get()) {
|
||||
LOCK(spk_man->cs_wallet);
|
||||
int64_t time = spk_man->GetTimeFirstKey();
|
||||
if (!time_first_key || time < *time_first_key) time_first_key = time;
|
||||
}
|
||||
if (time_first_key) {
|
||||
if (Optional<int> first_block = chain.findFirstBlockWithTimeAndHeight(*time_first_key - TIMESTAMP_WINDOW, rescan_height, nullptr)) {
|
||||
if (std::optional<int> first_block = chain.findFirstBlockWithTimeAndHeight(*time_first_key - TIMESTAMP_WINDOW, rescan_height, nullptr)) {
|
||||
rescan_height = *first_block;
|
||||
}
|
||||
}
|
||||
@ -4843,7 +4843,7 @@ bool CWalletTx::IsChainLocked() const
|
||||
if (!fIsChainlocked) {
|
||||
assert(pwallet != nullptr);
|
||||
AssertLockHeld(pwallet->cs_wallet);
|
||||
if (Optional<int> height = pwallet->chain().getBlockHeight(m_confirm.hashBlock)) {
|
||||
if (std::optional<int> height = pwallet->chain().getBlockHeight(m_confirm.hashBlock)) {
|
||||
fIsChainlocked = llmq::chainLocksHandler->HasChainLock(*height, m_confirm.hashBlock);
|
||||
}
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ using LoadWalletFn = std::function<void(std::unique_ptr<interfaces::Wallet> wall
|
||||
void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
|
||||
|
||||
bool AddWallet(const std::shared_ptr<CWallet>& wallet);
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, Optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, Optional<bool> load_on_start);
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start, std::vector<bilingual_str>& warnings);
|
||||
bool RemoveWallet(const std::shared_ptr<CWallet>& wallet, std::optional<bool> load_on_start);
|
||||
std::vector<std::shared_ptr<CWallet>> GetWallets();
|
||||
std::shared_ptr<CWallet> GetWallet(const std::string& name);
|
||||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, Optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, Optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::shared_ptr<CWallet> LoadWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::unique_ptr<interfaces::Handler> HandleLoadWallet(LoadWalletFn load_wallet);
|
||||
std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
|
||||
|
||||
@ -978,7 +978,7 @@ public:
|
||||
//! Unset if no blocks were scanned due to read errors or the chain
|
||||
//! being empty.
|
||||
uint256 last_scanned_block;
|
||||
Optional<int> last_scanned_height;
|
||||
std::optional<int> last_scanned_height;
|
||||
|
||||
//! Height of the most recent block that could not be scanned due to
|
||||
//! read errors or pruning. Will be set if status is FAILURE, unset if
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <validation.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace DBKeys {
|
||||
@ -822,7 +823,7 @@ std::unique_ptr<WalletDatabase> MakeDatabase(const fs::path& path, const Databas
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Optional<DatabaseFormat> format;
|
||||
std::optional<DatabaseFormat> format;
|
||||
if (exists) {
|
||||
if (ExistsBerkeleyDatabase(path)) {
|
||||
format = DatabaseFormat::BERKELEY;
|
||||
|
Loading…
Reference in New Issue
Block a user