Merge #20480: Replace boost::variant with std::variant

faa8f68943 Replace boost::variant with std::variant (MarcoFalke)

Pull request description:

  Now that we can use std::variant from the vanilla standard library, drop the third-party boost variant dependency

ACKs for top commit:
  fjahr:
    Code review ACK faa8f68943
  fanquake:
    ACK faa8f68943

Tree-SHA512: 6e3aecd33b00c2e31a763f999247944d5b2ce5e3018f1965c516c1000cd08ff6703a8d50fb0be64883153da2925ae72986b8a6b96586db74057bd05d6f4986e6
This commit is contained in:
fanquake 2021-01-11 10:19:43 +08:00
commit bd6af53e1f
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1
16 changed files with 56 additions and 66 deletions

View File

@ -8,16 +8,12 @@
#include <bech32.h> #include <bech32.h>
#include <util/strencodings.h> #include <util/strencodings.h>
#include <boost/variant/apply_visitor.hpp> #include <algorithm>
#include <boost/variant/static_visitor.hpp>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <algorithm>
namespace namespace {
{ class DestinationEncoder
class DestinationEncoder : public boost::static_visitor<std::string>
{ {
private: private:
const CChainParams& m_params; const CChainParams& m_params;
@ -209,7 +205,7 @@ std::string EncodeExtKey(const CExtKey& key)
std::string EncodeDestination(const CTxDestination& dest) std::string EncodeDestination(const CTxDestination& dest)
{ {
return boost::apply_visitor(DestinationEncoder(Params()), dest); return std::visit(DestinationEncoder(Params()), dest);
} }
CTxDestination DecodeDestination(const std::string& str) CTxDestination DecodeDestination(const std::string& str)

View File

@ -11,7 +11,6 @@
#include <wallet/wallet.h> #include <wallet/wallet.h>
#include <algorithm> #include <algorithm>
#include <typeinfo>
#include <QFont> #include <QFont>
#include <QDebug> #include <QDebug>
@ -82,8 +81,9 @@ public:
{ {
for (const auto& address : wallet.getAddresses()) for (const auto& address : wallet.getAddresses())
{ {
if (pk_hash_only && address.dest.type() != typeid(PKHash)) if (pk_hash_only && !std::holds_alternative<PKHash>(address.dest)) {
continue; continue;
}
AddressTableEntry::Type addressType = translateTransactionType( AddressTableEntry::Type addressType = translateTransactionType(
QString::fromStdString(address.purpose), address.is_mine); QString::fromStdString(address.purpose), address.is_mine);
cachedAddressTable.append(AddressTableEntry(addressType, cachedAddressTable.append(AddressTableEntry(addressType,
@ -261,7 +261,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
} else if(index.column() == Address) { } else if(index.column() == Address) {
CTxDestination newAddress = DecodeDestination(value.toString().toStdString()); CTxDestination newAddress = DecodeDestination(value.toString().toStdString());
// Refuse to set invalid address, set error status and return false // Refuse to set invalid address, set error status and return false
if(boost::get<CNoDestination>(&newAddress)) if(std::get_if<CNoDestination>(&newAddress))
{ {
editStatus = INVALID_ADDRESS; editStatus = INVALID_ADDRESS;
return false; return false;

View File

@ -455,7 +455,7 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
else if(ExtractDestination(out.txout.scriptPubKey, address)) else if(ExtractDestination(out.txout.scriptPubKey, address))
{ {
CPubKey pubkey; CPubKey pubkey;
PKHash *pkhash = boost::get<PKHash>(&address); PKHash* pkhash = std::get_if<PKHash>(&address);
if (pkhash && model->wallet().getPubKey(out.txout.scriptPubKey, ToKeyID(*pkhash), pubkey)) if (pkhash && model->wallet().getPubKey(out.txout.scriptPubKey, ToKeyID(*pkhash), pubkey))
{ {
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);

View File

@ -120,7 +120,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
return; return;
} }
const PKHash* pkhash = boost::get<PKHash>(&destination); const PKHash* pkhash = std::get_if<PKHash>(&destination);
if (!pkhash) { if (!pkhash) {
ui->addressIn_SM->setValid(false); ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");

View File

@ -123,7 +123,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
continue; continue;
} }
if (!boost::get<CNoDestination>(&wtx.txout_address[nOut])) if (!std::get_if<CNoDestination>(&wtx.txout_address[nOut]))
{ {
// Sent to Bitcoin Address // Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress; sub.type = TransactionRecord::SendToAddress;

View File

@ -209,7 +209,7 @@ CTxDestination AddAndGetMultisigDestination(const int required, const std::vecto
return dest; return dest;
} }
class DescribeAddressVisitor : public boost::static_visitor<UniValue> class DescribeAddressVisitor
{ {
public: public:
explicit DescribeAddressVisitor() {} explicit DescribeAddressVisitor() {}
@ -267,7 +267,7 @@ public:
UniValue DescribeAddress(const CTxDestination& dest) UniValue DescribeAddress(const CTxDestination& dest)
{ {
return boost::apply_visitor(DescribeAddressVisitor(), dest); return std::visit(DescribeAddressVisitor(), dest);
} }
unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target) unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target)

View File

@ -565,7 +565,7 @@ public:
Optional<OutputType> GetOutputType() const override Optional<OutputType> GetOutputType() const override
{ {
switch (m_destination.which()) { switch (m_destination.index()) {
case 1 /* PKHash */: case 1 /* PKHash */:
case 2 /* ScriptHash */: return OutputType::LEGACY; case 2 /* ScriptHash */: return OutputType::LEGACY;
case 3 /* WitnessV0ScriptHash */: case 3 /* WitnessV0ScriptHash */:
@ -593,7 +593,7 @@ public:
{ {
CTxDestination dest; CTxDestination dest;
ExtractDestination(m_script, dest); ExtractDestination(m_script, dest);
switch (dest.which()) { switch (dest.index()) {
case 1 /* PKHash */: case 1 /* PKHash */:
case 2 /* ScriptHash */: return OutputType::LEGACY; case 2 /* ScriptHash */: return OutputType::LEGACY;
case 3 /* WitnessV0ScriptHash */: case 3 /* WitnessV0ScriptHash */:

View File

@ -179,18 +179,18 @@ CKeyID GetKeyForDestination(const SigningProvider& store, const CTxDestination&
{ {
// Only supports destinations which map to single public keys, i.e. P2PKH, // Only supports destinations which map to single public keys, i.e. P2PKH,
// P2WPKH, and P2SH-P2WPKH. // P2WPKH, and P2SH-P2WPKH.
if (auto id = boost::get<PKHash>(&dest)) { if (auto id = std::get_if<PKHash>(&dest)) {
return ToKeyID(*id); return ToKeyID(*id);
} }
if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) { if (auto witness_id = std::get_if<WitnessV0KeyHash>(&dest)) {
return ToKeyID(*witness_id); return ToKeyID(*witness_id);
} }
if (auto script_hash = boost::get<ScriptHash>(&dest)) { if (auto script_hash = std::get_if<ScriptHash>(&dest)) {
CScript script; CScript script;
CScriptID script_id(*script_hash); CScriptID script_id(*script_hash);
CTxDestination inner_dest; CTxDestination inner_dest;
if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) { if (store.GetCScript(script_id, script) && ExtractDestination(script, inner_dest)) {
if (auto inner_witness_id = boost::get<WitnessV0KeyHash>(&inner_dest)) { if (auto inner_witness_id = std::get_if<WitnessV0KeyHash>(&inner_dest)) {
return ToKeyID(*inner_witness_id); return ToKeyID(*inner_witness_id);
} }
} }

View File

@ -261,9 +261,8 @@ bool ExtractDestinations(const CScript& scriptPubKey, TxoutType& typeRet, std::v
return true; return true;
} }
namespace namespace {
{ class CScriptVisitor
class CScriptVisitor : public boost::static_visitor<CScript>
{ {
public: public:
CScript operator()(const CNoDestination& dest) const CScript operator()(const CNoDestination& dest) const
@ -300,7 +299,7 @@ public:
CScript GetScriptForDestination(const CTxDestination& dest) CScript GetScriptForDestination(const CTxDestination& dest)
{ {
return boost::apply_visitor(CScriptVisitor(), dest); return std::visit(CScriptVisitor(), dest);
} }
CScript GetScriptForRawPubKey(const CPubKey& pubKey) CScript GetScriptForRawPubKey(const CPubKey& pubKey)
@ -320,5 +319,5 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
} }
bool IsValidDestination(const CTxDestination& dest) { bool IsValidDestination(const CTxDestination& dest) {
return dest.which() != 0; return dest.index() != 0;
} }

View File

@ -9,10 +9,8 @@
#include <script/interpreter.h> #include <script/interpreter.h>
#include <uint256.h> #include <uint256.h>
#include <boost/variant.hpp>
#include <string> #include <string>
#include <variant>
static const bool DEFAULT_ACCEPT_DATACARRIER = true; static const bool DEFAULT_ACCEPT_DATACARRIER = true;
@ -211,7 +209,7 @@ struct WitnessUnknown
* (taproot outputs do not require their own type as long as no wallet support exists) * (taproot outputs do not require their own type as long as no wallet support exists)
* A CTxDestination is the internal data type encoded in a bitcoin address * A CTxDestination is the internal data type encoded in a bitcoin address
*/ */
typedef boost::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown> CTxDestination; using CTxDestination = std::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown>;
/** Check whether a CTxDestination is a CNoDestination. */ /** Check whether a CTxDestination is a CNoDestination. */
bool IsValidDestination(const CTxDestination& dest); bool IsValidDestination(const CTxDestination& dest);

View File

@ -183,23 +183,23 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
s.clear(); s.clear();
s << ToByteVector(pubkey) << OP_CHECKSIG; s << ToByteVector(pubkey) << OP_CHECKSIG;
BOOST_CHECK(ExtractDestination(s, address)); BOOST_CHECK(ExtractDestination(s, address));
BOOST_CHECK(boost::get<PKHash>(&address) && BOOST_CHECK(std::get_if<PKHash>(&address) &&
*boost::get<PKHash>(&address) == PKHash(pubkey)); *std::get_if<PKHash>(&address) == PKHash(pubkey));
// TxoutType::PUBKEYHASH // TxoutType::PUBKEYHASH
s.clear(); s.clear();
s << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG; s << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
BOOST_CHECK(ExtractDestination(s, address)); BOOST_CHECK(ExtractDestination(s, address));
BOOST_CHECK(boost::get<PKHash>(&address) && BOOST_CHECK(std::get_if<PKHash>(&address) &&
*boost::get<PKHash>(&address) == PKHash(pubkey)); *std::get_if<PKHash>(&address) == PKHash(pubkey));
// TxoutType::SCRIPTHASH // TxoutType::SCRIPTHASH
CScript redeemScript(s); // initialize with leftover P2PKH script CScript redeemScript(s); // initialize with leftover P2PKH script
s.clear(); s.clear();
s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL; s << OP_HASH160 << ToByteVector(CScriptID(redeemScript)) << OP_EQUAL;
BOOST_CHECK(ExtractDestination(s, address)); BOOST_CHECK(ExtractDestination(s, address));
BOOST_CHECK(boost::get<ScriptHash>(&address) && BOOST_CHECK(std::get_if<ScriptHash>(&address) &&
*boost::get<ScriptHash>(&address) == ScriptHash(redeemScript)); *std::get_if<ScriptHash>(&address) == ScriptHash(redeemScript));
// TxoutType::MULTISIG // TxoutType::MULTISIG
s.clear(); s.clear();
@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
BOOST_CHECK(ExtractDestination(s, address)); BOOST_CHECK(ExtractDestination(s, address));
WitnessV0KeyHash keyhash; WitnessV0KeyHash keyhash;
CHash160().Write(pubkey).Finalize(keyhash); CHash160().Write(pubkey).Finalize(keyhash);
BOOST_CHECK(boost::get<WitnessV0KeyHash>(&address) && *boost::get<WitnessV0KeyHash>(&address) == keyhash); BOOST_CHECK(std::get_if<WitnessV0KeyHash>(&address) && *std::get_if<WitnessV0KeyHash>(&address) == keyhash);
// TxoutType::WITNESS_V0_SCRIPTHASH // TxoutType::WITNESS_V0_SCRIPTHASH
s.clear(); s.clear();
@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
CSHA256().Write(redeemScript.data(), redeemScript.size()).Finalize(scripthash.begin()); CSHA256().Write(redeemScript.data(), redeemScript.size()).Finalize(scripthash.begin());
s << OP_0 << ToByteVector(scripthash); s << OP_0 << ToByteVector(scripthash);
BOOST_CHECK(ExtractDestination(s, address)); BOOST_CHECK(ExtractDestination(s, address));
BOOST_CHECK(boost::get<WitnessV0ScriptHash>(&address) && *boost::get<WitnessV0ScriptHash>(&address) == scripthash); BOOST_CHECK(std::get_if<WitnessV0ScriptHash>(&address) && *std::get_if<WitnessV0ScriptHash>(&address) == scripthash);
// TxoutType::WITNESS_UNKNOWN with unknown version // TxoutType::WITNESS_UNKNOWN with unknown version
s.clear(); s.clear();
@ -235,7 +235,7 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
unk.length = 33; unk.length = 33;
unk.version = 1; unk.version = 1;
std::copy(pubkey.begin(), pubkey.end(), unk.program); std::copy(pubkey.begin(), pubkey.end(), unk.program);
BOOST_CHECK(boost::get<WitnessUnknown>(&address) && *boost::get<WitnessUnknown>(&address) == unk); BOOST_CHECK(std::get_if<WitnessUnknown>(&address) && *std::get_if<WitnessUnknown>(&address) == unk);
} }
BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations) BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
@ -259,8 +259,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEY); BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEY);
BOOST_CHECK_EQUAL(addresses.size(), 1U); BOOST_CHECK_EQUAL(addresses.size(), 1U);
BOOST_CHECK_EQUAL(nRequired, 1); BOOST_CHECK_EQUAL(nRequired, 1);
BOOST_CHECK(boost::get<PKHash>(&addresses[0]) && BOOST_CHECK(std::get_if<PKHash>(&addresses[0]) &&
*boost::get<PKHash>(&addresses[0]) == PKHash(pubkeys[0])); *std::get_if<PKHash>(&addresses[0]) == PKHash(pubkeys[0]));
// TxoutType::PUBKEYHASH // TxoutType::PUBKEYHASH
s.clear(); s.clear();
@ -269,8 +269,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEYHASH); BOOST_CHECK_EQUAL(whichType, TxoutType::PUBKEYHASH);
BOOST_CHECK_EQUAL(addresses.size(), 1U); BOOST_CHECK_EQUAL(addresses.size(), 1U);
BOOST_CHECK_EQUAL(nRequired, 1); BOOST_CHECK_EQUAL(nRequired, 1);
BOOST_CHECK(boost::get<PKHash>(&addresses[0]) && BOOST_CHECK(std::get_if<PKHash>(&addresses[0]) &&
*boost::get<PKHash>(&addresses[0]) == PKHash(pubkeys[0])); *std::get_if<PKHash>(&addresses[0]) == PKHash(pubkeys[0]));
// TxoutType::SCRIPTHASH // TxoutType::SCRIPTHASH
CScript redeemScript(s); // initialize with leftover P2PKH script CScript redeemScript(s); // initialize with leftover P2PKH script
@ -280,8 +280,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
BOOST_CHECK_EQUAL(whichType, TxoutType::SCRIPTHASH); BOOST_CHECK_EQUAL(whichType, TxoutType::SCRIPTHASH);
BOOST_CHECK_EQUAL(addresses.size(), 1U); BOOST_CHECK_EQUAL(addresses.size(), 1U);
BOOST_CHECK_EQUAL(nRequired, 1); BOOST_CHECK_EQUAL(nRequired, 1);
BOOST_CHECK(boost::get<ScriptHash>(&addresses[0]) && BOOST_CHECK(std::get_if<ScriptHash>(&addresses[0]) &&
*boost::get<ScriptHash>(&addresses[0]) == ScriptHash(redeemScript)); *std::get_if<ScriptHash>(&addresses[0]) == ScriptHash(redeemScript));
// TxoutType::MULTISIG // TxoutType::MULTISIG
s.clear(); s.clear();
@ -293,10 +293,10 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
BOOST_CHECK_EQUAL(whichType, TxoutType::MULTISIG); BOOST_CHECK_EQUAL(whichType, TxoutType::MULTISIG);
BOOST_CHECK_EQUAL(addresses.size(), 2U); BOOST_CHECK_EQUAL(addresses.size(), 2U);
BOOST_CHECK_EQUAL(nRequired, 2); BOOST_CHECK_EQUAL(nRequired, 2);
BOOST_CHECK(boost::get<PKHash>(&addresses[0]) && BOOST_CHECK(std::get_if<PKHash>(&addresses[0]) &&
*boost::get<PKHash>(&addresses[0]) == PKHash(pubkeys[0])); *std::get_if<PKHash>(&addresses[0]) == PKHash(pubkeys[0]));
BOOST_CHECK(boost::get<PKHash>(&addresses[1]) && BOOST_CHECK(std::get_if<PKHash>(&addresses[1]) &&
*boost::get<PKHash>(&addresses[1]) == PKHash(pubkeys[1])); *std::get_if<PKHash>(&addresses[1]) == PKHash(pubkeys[1]));
// TxoutType::NULL_DATA // TxoutType::NULL_DATA
s.clear(); s.clear();

View File

@ -31,7 +31,7 @@ MessageVerificationResult MessageVerify(
return MessageVerificationResult::ERR_INVALID_ADDRESS; return MessageVerificationResult::ERR_INVALID_ADDRESS;
} }
if (boost::get<PKHash>(&destination) == nullptr) { if (std::get_if<PKHash>(&destination) == nullptr) {
return MessageVerificationResult::ERR_ADDRESS_NO_KEY; return MessageVerificationResult::ERR_ADDRESS_NO_KEY;
} }

View File

@ -627,7 +627,7 @@ static RPCHelpMan signmessage()
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
} }
const PKHash *pkhash = boost::get<PKHash>(&dest); const PKHash* pkhash = std::get_if<PKHash>(&dest);
if (!pkhash) { if (!pkhash) {
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
} }
@ -3002,7 +3002,7 @@ static RPCHelpMan listunspent()
std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey); std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
if (provider) { if (provider) {
if (scriptPubKey.IsPayToScriptHash()) { if (scriptPubKey.IsPayToScriptHash()) {
const CScriptID& hash = CScriptID(boost::get<ScriptHash>(address)); const CScriptID& hash = CScriptID(std::get<ScriptHash>(address));
CScript redeemScript; CScript redeemScript;
if (provider->GetCScript(hash, redeemScript)) { if (provider->GetCScript(hash, redeemScript)) {
entry.pushKV("redeemScript", HexStr(redeemScript)); entry.pushKV("redeemScript", HexStr(redeemScript));
@ -3012,7 +3012,7 @@ static RPCHelpMan listunspent()
bool extracted = ExtractDestination(redeemScript, witness_destination); bool extracted = ExtractDestination(redeemScript, witness_destination);
CHECK_NONFATAL(extracted); CHECK_NONFATAL(extracted);
// Also return the witness script // Also return the witness script
const WitnessV0ScriptHash& whash = boost::get<WitnessV0ScriptHash>(witness_destination); const WitnessV0ScriptHash& whash = std::get<WitnessV0ScriptHash>(witness_destination);
CScriptID id; CScriptID id;
CRIPEMD160().Write(whash.begin(), whash.size()).Finalize(id.begin()); CRIPEMD160().Write(whash.begin(), whash.size()).Finalize(id.begin());
CScript witnessScript; CScript witnessScript;
@ -3022,7 +3022,7 @@ static RPCHelpMan listunspent()
} }
} }
} else if (scriptPubKey.IsPayToWitnessScriptHash()) { } else if (scriptPubKey.IsPayToWitnessScriptHash()) {
const WitnessV0ScriptHash& whash = boost::get<WitnessV0ScriptHash>(address); const WitnessV0ScriptHash& whash = std::get<WitnessV0ScriptHash>(address);
CScriptID id; CScriptID id;
CRIPEMD160().Write(whash.begin(), whash.size()).Finalize(id.begin()); CRIPEMD160().Write(whash.begin(), whash.size()).Finalize(id.begin());
CScript witnessScript; CScript witnessScript;
@ -3645,7 +3645,7 @@ static RPCHelpMan rescanblockchain()
}; };
} }
class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue> class DescribeWalletAddressVisitor
{ {
public: public:
const SigningProvider * const provider; const SigningProvider * const provider;
@ -3664,7 +3664,7 @@ public:
UniValue subobj(UniValue::VOBJ); UniValue subobj(UniValue::VOBJ);
UniValue detail = DescribeAddress(embedded); UniValue detail = DescribeAddress(embedded);
subobj.pushKVs(detail); subobj.pushKVs(detail);
UniValue wallet_detail = boost::apply_visitor(*this, embedded); UniValue wallet_detail = std::visit(*this, embedded);
subobj.pushKVs(wallet_detail); subobj.pushKVs(wallet_detail);
subobj.pushKV("address", EncodeDestination(embedded)); subobj.pushKV("address", EncodeDestination(embedded));
subobj.pushKV("scriptPubKey", HexStr(subscript)); subobj.pushKV("scriptPubKey", HexStr(subscript));
@ -3747,7 +3747,7 @@ static UniValue DescribeWalletAddress(const CWallet* const pwallet, const CTxDes
provider = pwallet->GetSolvingProvider(script); provider = pwallet->GetSolvingProvider(script);
} }
ret.pushKVs(detail); ret.pushKVs(detail);
ret.pushKVs(boost::apply_visitor(DescribeWalletAddressVisitor(provider.get()), dest)); ret.pushKVs(std::visit(DescribeWalletAddressVisitor(provider.get()), dest));
return ret; return ret;
} }

View File

@ -550,7 +550,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins(); list = wallet->ListCoins();
} }
BOOST_CHECK_EQUAL(list.size(), 1U); BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress); BOOST_CHECK_EQUAL(std::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 1U); BOOST_CHECK_EQUAL(list.begin()->second.size(), 1U);
// Check initial balance from one mature coinbase transaction. // Check initial balance from one mature coinbase transaction.
@ -566,7 +566,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins(); list = wallet->ListCoins();
} }
BOOST_CHECK_EQUAL(list.size(), 1U); BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress); BOOST_CHECK_EQUAL(std::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U); BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
// Lock both coins. Confirm number of available coins drops to 0. // Lock both coins. Confirm number of available coins drops to 0.
@ -595,7 +595,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins(); list = wallet->ListCoins();
} }
BOOST_CHECK_EQUAL(list.size(), 1U); BOOST_CHECK_EQUAL(list.size(), 1U);
BOOST_CHECK_EQUAL(boost::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress); BOOST_CHECK_EQUAL(std::get<PKHash>(list.begin()->first).ToString(), coinbaseAddress);
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U); BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U);
} }

View File

@ -2789,7 +2789,7 @@ bool CWallet::CreateTransactionInternal(
CScript scriptChange; CScript scriptChange;
// coin control: send change to custom address // coin control: send change to custom address
if (!boost::get<CNoDestination>(&coin_control.destChange)) { if (!std::get_if<CNoDestination>(&coin_control.destChange)) {
scriptChange = GetScriptForDestination(coin_control.destChange); scriptChange = GetScriptForDestination(coin_control.destChange);
} else { // no coin control: send change to newly generated address } else { // no coin control: send change to newly generated address
// Note: We use a new key here to keep it from being obvious which side is the change. // Note: We use a new key here to keep it from being obvious which side is the change.
@ -3724,7 +3724,7 @@ unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
bool CWallet::AddDestData(WalletBatch& batch, const CTxDestination &dest, const std::string &key, const std::string &value) bool CWallet::AddDestData(WalletBatch& batch, const CTxDestination &dest, const std::string &key, const std::string &value)
{ {
if (boost::get<CNoDestination>(&dest)) if (std::get_if<CNoDestination>(&dest))
return false; return false;
m_address_book[dest].destdata.insert(std::make_pair(key, value)); m_address_book[dest].destdata.insert(std::make_pair(key, value));

View File

@ -71,9 +71,6 @@ EXPECTED_BOOST_INCLUDES=(
boost/thread/mutex.hpp boost/thread/mutex.hpp
boost/thread/shared_mutex.hpp boost/thread/shared_mutex.hpp
boost/thread/thread.hpp boost/thread/thread.hpp
boost/variant.hpp
boost/variant/apply_visitor.hpp
boost/variant/static_visitor.hpp
) )
for BOOST_INCLUDE in $(git grep '^#include <boost/' -- "*.cpp" "*.h" | cut -f2 -d: | cut -f2 -d'<' | cut -f1 -d'>' | sort -u); do for BOOST_INCLUDE in $(git grep '^#include <boost/' -- "*.cpp" "*.h" | cut -f2 -d: | cut -f2 -d'<' | cut -f1 -d'>' | sort -u); do