From 57e980d13ca488031bde6ef197cf34d493d36796 Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 15 Mar 2021 10:41:30 +0800 Subject: [PATCH] scripted-diff: remove Optional & nullopt -BEGIN VERIFY SCRIPT- git rm src/optional.h sed -i -e 's/Optional/d' src/test/fuzz/autofile.cpp src/test/fuzz/buffered_file.cpp src/test/fuzz/node_eviction.cpp sed -i -e 's/#include /#include /g' $(git grep -l '#include ' src) -END VERIFY SCRIPT- --- src/Makefile.am | 1 - src/bench/wallet_balance.cpp | 4 +-- src/bitcoin-cli.cpp | 10 ++++---- src/interfaces/chain.h | 8 +++--- src/miner.cpp | 4 +-- src/miner.h | 6 ++--- src/net.cpp | 22 ++++++++--------- src/net.h | 10 ++++---- src/net_processing.cpp | 2 +- src/node/interfaces.cpp | 10 ++++---- src/node/psbt.h | 12 ++++----- src/optional.h | 20 --------------- src/psbt.h | 4 +-- src/qt/test/addressbooktests.cpp | 2 +- src/qt/test/wallettests.cpp | 2 +- src/rpc/rawtransaction.cpp | 6 ++--- src/script/descriptor.cpp | 18 +++++++------- src/script/descriptor.h | 4 +-- src/signet.cpp | 12 ++++----- src/signet.h | 4 +-- src/test/descriptor_tests.cpp | 26 ++++++++++---------- src/test/fuzz/autofile.cpp | 1 - src/test/fuzz/buffered_file.cpp | 1 - src/test/fuzz/deserialize.cpp | 4 +-- src/test/fuzz/net.cpp | 2 +- src/test/fuzz/node_eviction.cpp | 3 +-- src/test/fuzz/p2p_transport_deserializer.cpp | 2 +- src/test/fuzz/psbt.cpp | 4 +-- src/test/fuzz/script_descriptor_cache.cpp | 2 +- src/test/fuzz/system.cpp | 4 +-- src/test/net_tests.cpp | 4 +-- src/test/util_tests.cpp | 8 +++--- src/txmempool.cpp | 8 +++--- src/txmempool.h | 6 ++--- src/util/system.cpp | 12 ++++----- src/util/system.h | 4 +-- src/validation.cpp | 4 +-- src/validation.h | 6 ++--- src/wallet/coincontrol.h | 10 ++++---- src/wallet/coinselection.cpp | 4 +-- src/wallet/db.h | 4 +-- src/wallet/load.cpp | 2 +- src/wallet/rpcdump.cpp | 2 +- src/wallet/rpcwallet.cpp | 16 ++++++------ src/wallet/scriptpubkeyman.cpp | 4 +-- src/wallet/test/wallet_tests.cpp | 6 ++--- src/wallet/wallet.cpp | 26 ++++++++++---------- src/wallet/wallet.h | 16 ++++++------ src/wallet/walletdb.cpp | 2 +- 49 files changed, 165 insertions(+), 189 deletions(-) delete mode 100644 src/optional.h diff --git a/src/Makefile.am b/src/Makefile.am index 8f37e055fff..07d046c32d1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -182,7 +182,6 @@ BITCOIN_CORE_H = \ node/ui_interface.h \ node/utxo_snapshot.h \ noui.h \ - optional.h \ outputtype.h \ policy/feerate.h \ policy/fees.h \ diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index c96ef209e36..867be7296b4 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -26,7 +26,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b } auto handler = test_setup->m_node.chain->handleNotifications({&wallet, [](CWallet*) {}}); - const Optional address_mine{add_mine ? Optional{getnewaddress(wallet)} : nullopt}; + const std::optional address_mine{add_mine ? std::optional{getnewaddress(wallet)} : std::nullopt}; if (add_watchonly) importaddress(wallet, ADDRESS_WATCHONLY); for (int i = 0; i < 100; ++i) { diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index dc4b142f835..de3c73c78a4 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -611,7 +611,7 @@ public: } }; -static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, const std::vector& args, const Optional& rpcwallet = {}) +static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, const std::vector& args, const std::optional& rpcwallet = {}) { std::string host; // In preference order, we choose the following for the port: @@ -733,7 +733,7 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co * @returns the RPC response as a UniValue object. * @throws a CConnectionFailed std::runtime_error if connection failed or RPC server still in warmup. */ -static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& strMethod, const std::vector& args, const Optional& rpcwallet = {}) +static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& strMethod, const std::vector& args, const std::optional& rpcwallet = {}) { UniValue response(UniValue::VOBJ); // Execute and handle connection failures with -rpcwait. @@ -817,7 +817,7 @@ static void GetWalletBalances(UniValue& result) */ static UniValue GetNewAddress() { - Optional wallet_name{}; + std::optional wallet_name{}; if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", ""); DefaultRequestHandler rh; return ConnectAndCallRPC(&rh, "getnewaddress", /* args=*/{}, wallet_name); @@ -922,7 +922,7 @@ static int CommandLineRPC(int argc, char *argv[]) } if (nRet == 0) { // Perform RPC call - Optional wallet_name{}; + std::optional wallet_name{}; if (gArgs.IsArgSet("-rpcwallet")) wallet_name = gArgs.GetArg("-rpcwallet", ""); const UniValue reply = ConnectAndCallRPC(rh.get(), method, args, wallet_name); diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index ebc54661737..50294ee375b 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_INTERFACES_CHAIN_H #define BITCOIN_INTERFACES_CHAIN_H -#include // For Optional and nullopt +#include // For Optional and nullopt #include // For CTransactionRef #include // For util::SettingsValue @@ -94,7 +94,7 @@ 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 getHeight() = 0; + virtual std::optional getHeight() = 0; //! Get block hash. Height must be valid or this function will abort. virtual uint256 getBlockHash(int height) = 0; @@ -109,7 +109,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 findLocatorFork(const CBlockLocator& locator) = 0; + virtual std::optional findLocatorFork(const CBlockLocator& locator) = 0; //! Check if transaction will be final given chain height current time. virtual bool checkFinalTx(const CTransaction& tx) = 0; @@ -154,7 +154,7 @@ public: //! Return true if data is available for all blocks in the specified range //! of blocks. This checks all blocks that are ancestors of block_hash in //! the height range from min_height to max_height, inclusive. - virtual bool hasBlocks(const uint256& block_hash, int min_height = 0, Optional max_height = {}) = 0; + virtual bool hasBlocks(const uint256& block_hash, int min_height = 0, std::optional max_height = {}) = 0; //! Check if transaction is RBF opt in. virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0; diff --git a/src/miner.cpp b/src/miner.cpp index fbaef0f2245..53404e2b9d6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -96,8 +96,8 @@ void BlockAssembler::resetBlock() nFees = 0; } -Optional BlockAssembler::m_last_block_num_txs{nullopt}; -Optional BlockAssembler::m_last_block_weight{nullopt}; +std::optional BlockAssembler::m_last_block_num_txs{std::nullopt}; +std::optional BlockAssembler::m_last_block_weight{std::nullopt}; std::unique_ptr BlockAssembler::CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn) { diff --git a/src/miner.h b/src/miner.h index a67fec6dd89..236d792f1e8 100644 --- a/src/miner.h +++ b/src/miner.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_MINER_H #define BITCOIN_MINER_H -#include +#include #include #include #include @@ -160,8 +160,8 @@ public: /** Construct a new block template with coinbase to scriptPubKeyIn */ std::unique_ptr CreateNewBlock(CChainState& chainstate, const CScript& scriptPubKeyIn); - static Optional m_last_block_num_txs; - static Optional m_last_block_weight; + static std::optional m_last_block_num_txs; + static std::optional m_last_block_weight; private: // utility functions diff --git a/src/net.cpp b/src/net.cpp index 1e4a6a9aa78..fb8e06d14ba 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -193,7 +193,7 @@ bool IsPeerAddrLocalGood(CNode *pnode) IsReachable(addrLocal.GetNetwork()); } -Optional GetLocalAddrForPeer(CNode *pnode) +std::optional GetLocalAddrForPeer(CNode *pnode) { CAddress addrLocal = GetLocalAddress(&pnode->addr, pnode->GetLocalServices()); if (gArgs.GetBoolArg("-addrmantest", false)) { @@ -215,7 +215,7 @@ Optional GetLocalAddrForPeer(CNode *pnode) return addrLocal; } // Address is unroutable. Don't advertise. - return nullopt; + return std::nullopt; } // learn a new local address @@ -632,7 +632,7 @@ bool CNode::ReceiveMsgBytes(Span msg_bytes, bool& complete) if (m_deserializer->Complete()) { // decompose a transport agnostic CNetMessage from the deserializer uint32_t out_err_raw_size{0}; - Optional result{m_deserializer->GetMessage(time, out_err_raw_size)}; + std::optional result{m_deserializer->GetMessage(time, 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 @@ -723,10 +723,10 @@ const uint256& V1TransportDeserializer::GetMessageHash() const return data_hash; } -Optional V1TransportDeserializer::GetMessage(const std::chrono::microseconds time, uint32_t& out_err_raw_size) +std::optional V1TransportDeserializer::GetMessage(const std::chrono::microseconds time, uint32_t& out_err_raw_size) { // decompose a single CNetMessage from the TransportDeserializer - Optional msg(std::move(vRecv)); + std::optional msg(std::move(vRecv)); // store command string, time, and sizes msg->m_command = hdr.GetCommand(); @@ -747,12 +747,12 @@ Optional V1TransportDeserializer::GetMessage(const std::chrono::mic HexStr(hdr.pchChecksum), m_node_id); out_err_raw_size = msg->m_raw_message_size; - msg = nullopt; + msg = std::nullopt; } 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 = std::nullopt; } // Always reset the network deserializer (prepare for the next message) @@ -879,7 +879,7 @@ static void EraseLastKElements(std::vector &elements, Comparator comparator, elements.erase(elements.end() - eraseSize, elements.end()); } -[[nodiscard]] Optional SelectNodeToEvict(std::vector&& vEvictionCandidates) +[[nodiscard]] std::optional SelectNodeToEvict(std::vector&& vEvictionCandidates) { // Protect connections with certain characteristics @@ -918,7 +918,7 @@ static void EraseLastKElements(std::vector &elements, Comparator comparator, total_protect_size -= initial_size - vEvictionCandidates.size(); EraseLastKElements(vEvictionCandidates, ReverseCompareNodeTimeConnected, total_protect_size); - if (vEvictionCandidates.empty()) return nullopt; + if (vEvictionCandidates.empty()) return std::nullopt; // If any remaining peers are preferred for eviction consider only them. // This happens after the other preferences since if a peer is really the best by other criteria (esp relaying blocks) @@ -989,7 +989,7 @@ bool CConnman::AttemptToEvictConnection() vEvictionCandidates.push_back(candidate); } } - const Optional node_id_to_evict = SelectNodeToEvict(std::move(vEvictionCandidates)); + const std::optional node_id_to_evict = SelectNodeToEvict(std::move(vEvictionCandidates)); if (!node_id_to_evict) { return false; } diff --git a/src/net.h b/src/net.h index beef47f045b..2eab20f243a 100644 --- a/src/net.h +++ b/src/net.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -200,7 +200,7 @@ enum bool IsPeerAddrLocalGood(CNode *pnode); /** Returns a local address that we should advertise to this peer */ -Optional GetLocalAddrForPeer(CNode *pnode); +std::optional GetLocalAddrForPeer(CNode *pnode); /** * Mark a network as reachable or unreachable (no automatic connects to it) @@ -311,7 +311,7 @@ public: /** read and deserialize data, advances msg_bytes data pointer */ virtual int Read(Span& msg_bytes) = 0; // decomposes a message from the context - virtual Optional GetMessage(std::chrono::microseconds time, uint32_t& out_err) = 0; + virtual std::optional GetMessage(std::chrono::microseconds time, uint32_t& out_err) = 0; virtual ~TransportDeserializer() {} }; @@ -375,7 +375,7 @@ public: } return ret; } - Optional GetMessage(std::chrono::microseconds time, uint32_t& out_err_raw_size) override; + std::optional GetMessage(std::chrono::microseconds time, uint32_t& out_err_raw_size) override; }; /** The TransportSerializer prepares messages for the network transport @@ -1283,6 +1283,6 @@ struct NodeEvictionCandidate bool m_is_local; }; -[[nodiscard]] Optional SelectNodeToEvict(std::vector&& vEvictionCandidates); +[[nodiscard]] std::optional SelectNodeToEvict(std::vector&& vEvictionCandidates); #endif // BITCOIN_NET_H diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c569acd3cb6..4d9dc2204d4 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4222,7 +4222,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) if (pto->m_next_local_addr_send != 0us) { pto->m_addr_known->reset(); } - if (Optional local_addr = GetLocalAddrForPeer(pto)) { + if (std::optional local_addr = GetLocalAddrForPeer(pto)) { FastRandomContext insecure_rand; pto->PushAddress(*local_addr, insecure_rand); } diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 9406ef07c5a..7a4fa0a613d 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -415,7 +415,7 @@ class ChainImpl : public Chain { public: explicit ChainImpl(NodeContext& node) : m_node(node) {} - Optional getHeight() override + std::optional getHeight() override { LOCK(::cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); @@ -423,7 +423,7 @@ public: if (height >= 0) { return height; } - return nullopt; + return std::nullopt; } uint256 getBlockHash(int height) override { @@ -452,7 +452,7 @@ public: assert(std::addressof(::ChainActive()) == std::addressof(m_node.chainman->ActiveChain())); return CheckFinalTx(m_node.chainman->ActiveChain().Tip(), tx); } - Optional findLocatorFork(const CBlockLocator& locator) override + std::optional findLocatorFork(const CBlockLocator& locator) override { LOCK(cs_main); const CChain& active = Assert(m_node.chainman)->ActiveChain(); @@ -460,7 +460,7 @@ public: if (CBlockIndex* fork = m_node.chainman->m_blockman.FindForkInGlobalIndex(active, locator)) { return fork->nHeight; } - return nullopt; + return std::nullopt; } bool findBlock(const uint256& hash, const FoundBlock& block) override { @@ -518,7 +518,7 @@ public: assert(std::addressof(g_chainman) == std::addressof(*m_node.chainman)); return GuessVerificationProgress(Params().TxData(), m_node.chainman->m_blockman.LookupBlockIndex(block_hash)); } - bool hasBlocks(const uint256& block_hash, int min_height, Optional max_height) override + bool hasBlocks(const uint256& block_hash, int min_height, std::optional max_height) override { // hasBlocks returns true if all ancestors of block_hash in specified // range have block data (are not pruned), false if any ancestors in diff --git a/src/node/psbt.h b/src/node/psbt.h index 7384dc415cc..009e0941e1a 100644 --- a/src/node/psbt.h +++ b/src/node/psbt.h @@ -25,18 +25,18 @@ struct PSBTInputAnalysis { * Holds the results of AnalyzePSBT (miscellaneous information about a PSBT) */ struct PSBTAnalysis { - Optional estimated_vsize; //!< Estimated weight of the transaction - Optional estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction - Optional fee; //!< Amount of fee being paid by the transaction + std::optional estimated_vsize; //!< Estimated weight of the transaction + std::optional estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction + std::optional fee; //!< Amount of fee being paid by the transaction std::vector inputs; //!< More information about the individual inputs of the transaction PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next std::string error; //!< Error message void SetInvalid(std::string err_msg) { - estimated_vsize = nullopt; - estimated_feerate = nullopt; - fee = nullopt; + estimated_vsize = std::nullopt; + estimated_feerate = std::nullopt; + fee = std::nullopt; inputs.clear(); next = PSBTRole::CREATOR; error = err_msg; diff --git a/src/optional.h b/src/optional.h deleted file mode 100644 index 583c56eabda..00000000000 --- a/src/optional.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2017-2020 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 -#include - -//! Substitute for C++17 std::optional -//! DEPRECATED use std::optional in new code. -template -using Optional = std::optional; - -//! Substitute for C++17 std::nullopt -//! DEPRECATED use std::nullopt in new code. -static auto& nullopt = std::nullopt; - -#endif // BITCOIN_OPTIONAL_H diff --git a/src/psbt.h b/src/psbt.h index b566726ee38..319eb48cb02 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -389,7 +389,7 @@ struct PSBTOutput /** A version of CTransaction with the PSBT format*/ struct PartiallySignedTransaction { - Optional tx; + std::optional tx; std::vector inputs; std::vector outputs; std::map, std::vector> unknown; diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp index 35fcb2b0ca6..a0260692325 100644 --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -112,7 +112,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node) ClientModel clientModel(node, &optionsModel); AddWallet(wallet); WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get()); - RemoveWallet(wallet, nullopt); + RemoveWallet(wallet, std::nullopt); EditAddressDialog editAddressDialog(EditAddressDialog::NewSendingAddress); editAddressDialog.setModel(walletModel.getAddressTableModel()); diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index d6d2d0e3dfd..1107c44dc9f 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -167,7 +167,7 @@ void TestGUI(interfaces::Node& node) ClientModel clientModel(node, &optionsModel); AddWallet(wallet); WalletModel walletModel(interfaces::MakeWallet(wallet), clientModel, platformStyle.get()); - RemoveWallet(wallet, nullopt); + RemoveWallet(wallet, std::nullopt); sendCoinsDialog.setModel(&walletModel); transactionView.setModel(&walletModel); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 47c776bbd1d..2f92a321f8e 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1828,13 +1828,13 @@ static RPCHelpMan analyzepsbt() } if (!inputs_result.empty()) result.pushKV("inputs", inputs_result); - if (psbta.estimated_vsize != nullopt) { + if (psbta.estimated_vsize != std::nullopt) { result.pushKV("estimated_vsize", (int)*psbta.estimated_vsize); } - if (psbta.estimated_feerate != nullopt) { + if (psbta.estimated_feerate != std::nullopt) { result.pushKV("estimated_feerate", ValueFromAmount(psbta.estimated_feerate->GetFeePerK())); } - if (psbta.fee != nullopt) { + if (psbta.fee != std::nullopt) { result.pushKV("fee", ValueFromAmount(*psbta.fee)); } result.pushKV("next", PSBTRoleName(psbta.next)); diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 889cb4f06e9..cfe1da12e84 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -632,7 +632,7 @@ public: } } - Optional GetOutputType() const override { return nullopt; } + std::optional GetOutputType() const override { return std::nullopt; } }; /** A parsed addr(A) descriptor. */ @@ -646,7 +646,7 @@ public: AddressDescriptor(CTxDestination destination) : DescriptorImpl({}, {}, "addr"), m_destination(std::move(destination)) {} bool IsSolvable() const final { return false; } - Optional GetOutputType() const override + std::optional GetOutputType() const override { switch (m_destination.index()) { case 1 /* PKHash */: @@ -655,7 +655,7 @@ public: case 4 /* WitnessV0KeyHash */: case 5 /* WitnessUnknown */: return OutputType::BECH32; case 0 /* CNoDestination */: - default: return nullopt; + default: return std::nullopt; } } bool IsSingleType() const final { return true; } @@ -672,7 +672,7 @@ public: RawDescriptor(CScript script) : DescriptorImpl({}, {}, "raw"), m_script(std::move(script)) {} bool IsSolvable() const final { return false; } - Optional GetOutputType() const override + std::optional GetOutputType() const override { CTxDestination dest; ExtractDestination(m_script, dest); @@ -683,7 +683,7 @@ public: case 4 /* WitnessV0KeyHash */: case 5 /* WitnessUnknown */: return OutputType::BECH32; case 0 /* CNoDestination */: - default: return nullopt; + default: return std::nullopt; } } bool IsSingleType() const final { return true; } @@ -711,7 +711,7 @@ protected: } public: PKHDescriptor(std::unique_ptr prov) : DescriptorImpl(Vector(std::move(prov)), {}, "pkh") {} - Optional GetOutputType() const override { return OutputType::LEGACY; } + std::optional GetOutputType() const override { return OutputType::LEGACY; } bool IsSingleType() const final { return true; } }; @@ -727,7 +727,7 @@ protected: } public: WPKHDescriptor(std::unique_ptr prov) : DescriptorImpl(Vector(std::move(prov)), {}, "wpkh") {} - Optional GetOutputType() const override { return OutputType::BECH32; } + std::optional GetOutputType() const override { return OutputType::BECH32; } bool IsSingleType() const final { return true; } }; @@ -783,7 +783,7 @@ protected: public: SHDescriptor(std::unique_ptr desc) : DescriptorImpl({}, std::move(desc), "sh") {} - Optional GetOutputType() const override + std::optional GetOutputType() const override { assert(m_subdescriptor_arg); if (m_subdescriptor_arg->GetOutputType() == OutputType::BECH32) return OutputType::P2SH_SEGWIT; @@ -799,7 +799,7 @@ protected: std::vector MakeScripts(const std::vector&, const CScript* script, FlatSigningProvider&) const override { return Vector(GetScriptForDestination(WitnessV0ScriptHash(*script))); } public: WSHDescriptor(std::unique_ptr desc) : DescriptorImpl({}, std::move(desc), "wsh") {} - Optional GetOutputType() const override { return OutputType::BECH32; } + std::optional GetOutputType() const override { return OutputType::BECH32; } bool IsSingleType() const final { return true; } }; diff --git a/src/script/descriptor.h b/src/script/descriptor.h index 46d51fa587c..c8d9efb11fb 100644 --- a/src/script/descriptor.h +++ b/src/script/descriptor.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_SCRIPT_DESCRIPTOR_H #define BITCOIN_SCRIPT_DESCRIPTOR_H -#include +#include #include #include