Merge bd6af53e1f into merged_master (Bitcoin PR #20480)

what a trainwreck of a programming language..
This commit is contained in:
Andrew Poelstra 2021-06-17 14:43:32 +00:00
commit acf709b3ab
20 changed files with 119 additions and 129 deletions

View file

@ -10,16 +10,12 @@
#include <chainparams.h>
#include <util/strencodings.h>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <algorithm>
#include <assert.h>
#include <string.h>
#include <algorithm>
namespace
{
class DestinationEncoder : public boost::static_visitor<std::string>
namespace {
class DestinationEncoder
{
private:
const CChainParams& m_params;
@ -338,7 +334,7 @@ std::string EncodeExtKey(const CExtKey& key)
std::string EncodeDestination(const CTxDestination& dest)
{
return boost::apply_visitor(DestinationEncoder(Params(), false), dest);
return std::visit(DestinationEncoder(Params(), false), dest);
}
CTxDestination DecodeDestination(const std::string& str)
@ -361,7 +357,7 @@ bool IsValidDestinationString(const std::string& str)
std::string EncodeParentDestination(const CTxDestination& dest)
{
return boost::apply_visitor(DestinationEncoder(Params(), true), dest);
return std::visit(DestinationEncoder(Params(), true), dest);
}
CTxDestination DecodeParentDestination(const std::string& str)

View file

@ -159,8 +159,8 @@ void PSBTInput::Merge(const PSBTInput& input)
if (asset.IsNull() && !input.asset.IsNull()) asset = input.asset;
if (asset_blinding_factor.IsNull() && !input.asset_blinding_factor.IsNull()) asset_blinding_factor = input.asset_blinding_factor;
if (peg_in_tx.which() == 0 && peg_in_tx.which() > 0) peg_in_tx = input.peg_in_tx;
if (txout_proof.which() == 0 && peg_in_tx.which() > 0) txout_proof = input.txout_proof;
if (peg_in_tx.index() == 0 && peg_in_tx.index() > 0) peg_in_tx = input.peg_in_tx;
if (txout_proof.index() == 0 && peg_in_tx.index() > 0) txout_proof = input.txout_proof;
if (claim_script.empty() && !input.claim_script.empty()) claim_script = input.claim_script;
if (genesis_hash.IsNull() && !input.genesis_hash.IsNull()) genesis_hash = input.genesis_hash;
}
@ -346,16 +346,16 @@ bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransacti
result.witness.vtxinwit[i].scriptWitness = psbtx.inputs[i].final_script_witness;
PSBTInput& input = psbtx.inputs[i];
if (input.value && input.peg_in_tx.which() != 0 && input.txout_proof.which() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
if (input.value && input.peg_in_tx.index() != 0 && input.txout_proof.index() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
CScriptWitness pegin_witness;
if (Params().GetConsensus().ParentChainHasPow()) {
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, btc_peg_in_tx, btc_txout_proof);
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&input.peg_in_tx);
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *btc_peg_in_tx, *btc_txout_proof);
} else {
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, elem_peg_in_tx, elem_txout_proof);
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&input.peg_in_tx);
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *elem_peg_in_tx, *elem_txout_proof);
}
result.vin[i].m_is_pegin = true;
result.witness.vtxinwit[i].m_pegin_witness = pegin_witness;

View file

@ -18,7 +18,7 @@
#include <script/sign.h>
#include <script/signingprovider.h>
#include <boost/variant.hpp>
#include <variant>
// Magic bytes
static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
@ -95,8 +95,8 @@ struct PSBTInput
CAsset asset;
uint256 asset_blinding_factor;
boost::variant<boost::blank, CTransactionRef, Sidechain::Bitcoin::CTransactionRef> peg_in_tx;
boost::variant<boost::blank, CMerkleBlock, Sidechain::Bitcoin::CMerkleBlock> txout_proof;
std::variant<std::monostate, CTransactionRef, Sidechain::Bitcoin::CTransactionRef> peg_in_tx;
std::variant<std::monostate, CMerkleBlock, Sidechain::Bitcoin::CMerkleBlock> txout_proof;
CScript claim_script;
uint256 genesis_hash;
@ -182,35 +182,35 @@ struct PSBTInput
// Write peg-in data
if (Params().GetConsensus().ParentChainHasPow()) {
if (peg_in_tx.which() > 0) {
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(peg_in_tx);
if (peg_in_tx.index() > 0) {
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&peg_in_tx);
if (btc_peg_in_tx) {
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_PEG_IN_TX);
OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
SerializeToVector(os, btc_peg_in_tx);
SerializeToVector(os, *btc_peg_in_tx);
}
}
if (txout_proof.which() > 0) {
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(txout_proof);
if (!btc_txout_proof.header.IsNull()) {
if (txout_proof.index() > 0) {
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&txout_proof);
if (btc_txout_proof) {
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_TXOUT_PROOF);
SerializeToVector(s, btc_txout_proof);
SerializeToVector(s, *btc_txout_proof);
}
}
} else {
if (peg_in_tx.which() > 0) {
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(peg_in_tx);
if (peg_in_tx.index() > 0) {
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&peg_in_tx);
if (elem_peg_in_tx) {
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_PEG_IN_TX);
OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
SerializeToVector(os, elem_peg_in_tx);
SerializeToVector(os, *elem_peg_in_tx);
}
}
if (txout_proof.which() > 0) {
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(txout_proof);
if (!elem_txout_proof.header.IsNull()) {
if (txout_proof.index() > 0) {
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&txout_proof);
if (elem_txout_proof) {
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_TXOUT_PROOF);
SerializeToVector(s, elem_txout_proof);
SerializeToVector(s, *elem_txout_proof);
}
}
}
@ -412,7 +412,7 @@ struct PSBTInput
}
case PSBT_IN_PEG_IN_TX:
{
if (peg_in_tx.which() != 0) {
if (peg_in_tx.index() != 0) {
throw std::ios_base::failure("Duplicate Key, peg-in tx already provided");
} else if (subkey_len != 1) {
throw std::ios_base::failure("Peg-in tx key is more than one byte type");
@ -432,7 +432,7 @@ struct PSBTInput
}
case PSBT_IN_TXOUT_PROOF:
{
if (txout_proof.which() != 0) {
if (txout_proof.index() != 0) {
throw std::ios_base::failure("Duplicate Key, peg-in txout proof already provided");
} else if (subkey_len != 1) {
throw std::ios_base::failure("Peg-in txout proof key is more than one byte type");

View file

@ -11,7 +11,6 @@
#include <wallet/wallet.h>
#include <algorithm>
#include <typeinfo>
#include <QFont>
#include <QDebug>
@ -82,8 +81,9 @@ public:
{
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;
}
AddressTableEntry::Type addressType = translateTransactionType(
QString::fromStdString(address.purpose), address.is_mine);
cachedAddressTable.append(AddressTableEntry(addressType,
@ -261,7 +261,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
} else if(index.column() == Address) {
CTxDestination newAddress = DecodeDestination(value.toString().toStdString());
// 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;
return false;

View file

@ -455,7 +455,7 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
else if(ExtractDestination(out.txout.scriptPubKey, address))
{
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))
{
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."));
return;
}
const PKHash* pkhash = boost::get<PKHash>(&destination);
const PKHash* pkhash = std::get_if<PKHash>(&destination);
if (!pkhash) {
ui->addressIn_SM->setValid(false);
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");

View file

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

View file

@ -874,7 +874,7 @@ static RPCHelpMan dumpassetlabels()
};
}
class BlindingPubkeyAdderVisitor : public boost::static_visitor<>
class BlindingPubkeyAdderVisitor
{
public:
CPubKey blind_key;
@ -950,7 +950,7 @@ static RPCHelpMan createblindedaddress()
key.Set(keydata.begin(), keydata.end());
// Append blinding key and return
boost::apply_visitor(BlindingPubkeyAdderVisitor(key), address);
std::visit(BlindingPubkeyAdderVisitor(key), address);
return EncodeDestination(address);
},
};

View file

@ -1433,36 +1433,36 @@ static RPCHelpMan decodepsbt()
// Peg-in stuff
if (Params().GetConsensus().ParentChainHasPow()) {
if (input.peg_in_tx.which() > 0) {
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
if (input.peg_in_tx.index() > 0) {
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&input.peg_in_tx);
if (btc_peg_in_tx) {
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
ss_tx << btc_peg_in_tx;
ss_tx << *btc_peg_in_tx;
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx));
}
}
if (input.txout_proof.which() > 0) {
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
if (!btc_txout_proof.header.IsNull()) {
if (input.txout_proof.index() > 0) {
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&input.txout_proof);
if (btc_txout_proof) {
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
ss_mb << btc_txout_proof;
ss_mb << *btc_txout_proof;
in.pushKV("pegin_txout_proof", HexStr(ss_mb));
}
}
} else {
if (input.peg_in_tx.which() > 0) {
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
if (input.peg_in_tx.index() > 0) {
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&input.peg_in_tx);
if (elem_peg_in_tx) {
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
ss_tx << elem_peg_in_tx;
ss_tx << *elem_peg_in_tx;
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx));
}
}
if (input.txout_proof.which() > 0) {
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
if (!elem_txout_proof.header.IsNull()) {
if (input.txout_proof.index() > 0) {
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&input.txout_proof);
if (elem_txout_proof) {
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
ss_mb << elem_txout_proof;
ss_mb << *elem_txout_proof;
in.pushKV("pegin_txout_proof", HexStr(ss_mb));
}
}
@ -2552,7 +2552,7 @@ static RPCHelpMan rawissueasset()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing corresponding asset_address");
}
asset_dest = DecodeDestination(asset_address_uni.get_str());
if (boost::get<CNoDestination>(&asset_dest)) {
if (std::get_if<CNoDestination>(&asset_dest)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid asset address provided: %s", asset_address_uni.get_str()));
}
}
@ -2569,7 +2569,7 @@ static RPCHelpMan rawissueasset()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing corresponding token_address");
}
token_dest = DecodeDestination(token_address_uni.get_str());
if (boost::get<CNoDestination>(&token_dest)) {
if (std::get_if<CNoDestination>(&token_dest)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid token address provided: %s", token_address_uni.get_str()));
}
}
@ -2684,7 +2684,7 @@ static RPCHelpMan rawreissueasset()
throw JSONRPCError(RPC_INVALID_PARAMETER, "Reissuance missing asset_address");
}
CTxDestination asset_dest = DecodeDestination(asset_address_uni.get_str());
if (boost::get<CNoDestination>(&asset_dest)) {
if (std::get_if<CNoDestination>(&asset_dest)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid asset address provided: %s", asset_address_uni.get_str()));
}

View file

@ -212,7 +212,7 @@ CTxDestination AddAndGetMultisigDestination(const int required, const std::vecto
return dest;
}
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
class DescribeAddressVisitor
{
public:
explicit DescribeAddressVisitor() {}
@ -278,7 +278,7 @@ public:
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)
@ -889,7 +889,7 @@ UniValue GetServicesNames(ServiceFlags services)
//
// ELEMENTS
class BlindingPubkeyVisitor : public boost::static_visitor<CPubKey>
class BlindingPubkeyVisitor
{
public:
explicit BlindingPubkeyVisitor() {}
@ -931,14 +931,14 @@ public:
};
CPubKey GetDestinationBlindingKey(const CTxDestination& dest) {
return boost::apply_visitor(BlindingPubkeyVisitor(), dest);
return std::visit(BlindingPubkeyVisitor(), dest);
}
bool IsBlindDestination(const CTxDestination& dest) {
return GetDestinationBlindingKey(dest).IsFullyValid();
}
class DescribeBlindAddressVisitor : public boost::static_visitor<UniValue>
class DescribeBlindAddressVisitor
{
public:
@ -1019,7 +1019,7 @@ public:
UniValue DescribeBlindAddress(const CTxDestination& dest)
{
UniValue ret(UniValue::VOBJ);
ret.pushKVs(boost::apply_visitor(DescribeBlindAddressVisitor(), dest));
ret.pushKVs(std::visit(DescribeBlindAddressVisitor(), dest));
return ret;
}

View file

@ -565,7 +565,7 @@ public:
Optional<OutputType> GetOutputType() const override
{
switch (m_destination.which()) {
switch (m_destination.index()) {
case 1 /* PKHash */:
case 2 /* ScriptHash */: return OutputType::LEGACY;
case 3 /* WitnessV0ScriptHash */:
@ -593,7 +593,7 @@ public:
{
CTxDestination dest;
ExtractDestination(m_script, dest);
switch (dest.which()) {
switch (dest.index()) {
case 1 /* PKHash */:
case 2 /* ScriptHash */: return OutputType::LEGACY;
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,
// P2WPKH, and P2SH-P2WPKH.
if (auto id = boost::get<PKHash>(&dest)) {
if (auto id = std::get_if<PKHash>(&dest)) {
return ToKeyID(*id);
}
if (auto witness_id = boost::get<WitnessV0KeyHash>(&dest)) {
if (auto witness_id = std::get_if<WitnessV0KeyHash>(&dest)) {
return ToKeyID(*witness_id);
}
if (auto script_hash = boost::get<ScriptHash>(&dest)) {
if (auto script_hash = std::get_if<ScriptHash>(&dest)) {
CScript script;
CScriptID script_id(*script_hash);
CTxDestination 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);
}
}

View file

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

View file

@ -9,10 +9,8 @@
#include <script/interpreter.h>
#include <uint256.h>
#include <boost/variant.hpp>
#include <string>
#include <variant>
#include <pubkey.h> // blinding_pubkey
@ -245,7 +243,7 @@ public:
};
// ELEMENTS
class SetBlindingPubKeyVisitor : public boost::static_visitor<>
class SetBlindingPubKeyVisitor
{
public:
const CPubKey& blinding_pubkey;
@ -272,7 +270,7 @@ public:
* * NullData: TxoutType::NULL_DATA destination (OP_RETURN)
* A CTxDestination is the internal data type encoded in a bitcoin address
*/
typedef boost::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown, NullData> CTxDestination;
using CTxDestination = std::variant<CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown, NullData>;
/** Check whether a CTxDestination is a CNoDestination. */
bool IsValidDestination(const CTxDestination& dest);

View file

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

View file

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

View file

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

View file

@ -554,7 +554,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins();
}
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);
// Check initial balance from one mature coinbase transaction.
@ -570,7 +570,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins();
}
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);
// Lock both coins. Confirm number of available coins drops to 0.
@ -599,7 +599,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
list = wallet->ListCoins();
}
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);
}

View file

@ -2850,16 +2850,16 @@ TransactionError CWallet::SignPSBT(PartiallySignedTransaction& psbtx, bool& comp
// Stuff in the peg-in data
for (unsigned int i = 0; i < tx.vin.size(); ++i) {
PSBTInput& input = psbtx.inputs[i];
if (input.value && input.peg_in_tx.which() != 0 && input.txout_proof.which() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
if (input.value && input.peg_in_tx.index() != 0 && input.txout_proof.index() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
CScriptWitness pegin_witness;
if (Params().GetConsensus().ParentChainHasPow()) {
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, btc_peg_in_tx, btc_txout_proof);
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&input.peg_in_tx);
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *btc_peg_in_tx, *btc_txout_proof);
} else {
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, elem_peg_in_tx, elem_txout_proof);
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&input.peg_in_tx);
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&input.txout_proof);
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *elem_peg_in_tx, *elem_txout_proof);
}
tx.vin[i].m_is_pegin = true;
tx.witness.vtxinwit[i].m_pegin_witness = pegin_witness;
@ -4254,7 +4254,7 @@ bool CWallet::GetNewDestination(const OutputType type, const std::string label,
result = spk_man->GetNewDestination(type, dest, error);
if (add_blinding_key) {
CPubKey blinding_pubkey = GetBlindingPubKey(GetScriptForDestination(dest));
boost::apply_visitor(SetBlindingPubKeyVisitor(blinding_pubkey), dest);
std::visit(SetBlindingPubKeyVisitor(blinding_pubkey), dest);
}
} else {
error = strprintf("Error: No %s addresses available.", FormatOutputType(type));
@ -4482,7 +4482,7 @@ bool ReserveDestination::GetReservedDestination(CTxDestination& dest, bool inter
void ReserveDestination::SetBlindingPubKey(const CPubKey& blinding_pubkey, CTxDestination& dest)
{
boost::apply_visitor(SetBlindingPubKeyVisitor(blinding_pubkey), address);
std::visit(SetBlindingPubKeyVisitor(blinding_pubkey), address);
dest = address;
}
@ -4660,7 +4660,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)
{
if (boost::get<CNoDestination>(&dest))
if (std::get_if<CNoDestination>(&dest))
return false;
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/shared_mutex.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