Skip to content

Commit acf709b

Browse files
committed
Merge bd6af53 into merged_master (Bitcoin PR #20480)
what a trainwreck of a programming language..
2 parents 4daefd2 + bd6af53 commit acf709b

20 files changed

+119
-129
lines changed

src/key_io.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,12 @@
1010
#include <chainparams.h>
1111
#include <util/strencodings.h>
1212

13-
#include <boost/variant/apply_visitor.hpp>
14-
#include <boost/variant/static_visitor.hpp>
15-
13+
#include <algorithm>
1614
#include <assert.h>
1715
#include <string.h>
18-
#include <algorithm>
1916

20-
namespace
21-
{
22-
class DestinationEncoder : public boost::static_visitor<std::string>
17+
namespace {
18+
class DestinationEncoder
2319
{
2420
private:
2521
const CChainParams& m_params;
@@ -338,7 +334,7 @@ std::string EncodeExtKey(const CExtKey& key)
338334

339335
std::string EncodeDestination(const CTxDestination& dest)
340336
{
341-
return boost::apply_visitor(DestinationEncoder(Params(), false), dest);
337+
return std::visit(DestinationEncoder(Params(), false), dest);
342338
}
343339

344340
CTxDestination DecodeDestination(const std::string& str)
@@ -361,7 +357,7 @@ bool IsValidDestinationString(const std::string& str)
361357

362358
std::string EncodeParentDestination(const CTxDestination& dest)
363359
{
364-
return boost::apply_visitor(DestinationEncoder(Params(), true), dest);
360+
return std::visit(DestinationEncoder(Params(), true), dest);
365361
}
366362

367363
CTxDestination DecodeParentDestination(const std::string& str)

src/psbt.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ void PSBTInput::Merge(const PSBTInput& input)
159159
if (asset.IsNull() && !input.asset.IsNull()) asset = input.asset;
160160
if (asset_blinding_factor.IsNull() && !input.asset_blinding_factor.IsNull()) asset_blinding_factor = input.asset_blinding_factor;
161161

162-
if (peg_in_tx.which() == 0 && peg_in_tx.which() > 0) peg_in_tx = input.peg_in_tx;
163-
if (txout_proof.which() == 0 && peg_in_tx.which() > 0) txout_proof = input.txout_proof;
162+
if (peg_in_tx.index() == 0 && peg_in_tx.index() > 0) peg_in_tx = input.peg_in_tx;
163+
if (txout_proof.index() == 0 && peg_in_tx.index() > 0) txout_proof = input.txout_proof;
164164
if (claim_script.empty() && !input.claim_script.empty()) claim_script = input.claim_script;
165165
if (genesis_hash.IsNull() && !input.genesis_hash.IsNull()) genesis_hash = input.genesis_hash;
166166
}
@@ -346,16 +346,16 @@ bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransacti
346346
result.witness.vtxinwit[i].scriptWitness = psbtx.inputs[i].final_script_witness;
347347
PSBTInput& input = psbtx.inputs[i];
348348

349-
if (input.value && input.peg_in_tx.which() != 0 && input.txout_proof.which() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
349+
if (input.value && input.peg_in_tx.index() != 0 && input.txout_proof.index() != 0 && !input.claim_script.empty() && !input.genesis_hash.IsNull()) {
350350
CScriptWitness pegin_witness;
351351
if (Params().GetConsensus().ParentChainHasPow()) {
352-
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
353-
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
354-
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, btc_peg_in_tx, btc_txout_proof);
352+
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&input.peg_in_tx);
353+
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&input.txout_proof);
354+
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *btc_peg_in_tx, *btc_txout_proof);
355355
} else {
356-
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
357-
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
358-
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, elem_peg_in_tx, elem_txout_proof);
356+
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&input.peg_in_tx);
357+
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&input.txout_proof);
358+
pegin_witness = CreatePeginWitness(*input.value, input.asset, input.genesis_hash, input.claim_script, *elem_peg_in_tx, *elem_txout_proof);
359359
}
360360
result.vin[i].m_is_pegin = true;
361361
result.witness.vtxinwit[i].m_pegin_witness = pegin_witness;

src/psbt.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <script/sign.h>
1919
#include <script/signingprovider.h>
2020

21-
#include <boost/variant.hpp>
21+
#include <variant>
2222

2323
// Magic bytes
2424
static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
@@ -95,8 +95,8 @@ struct PSBTInput
9595
CAsset asset;
9696
uint256 asset_blinding_factor;
9797

98-
boost::variant<boost::blank, CTransactionRef, Sidechain::Bitcoin::CTransactionRef> peg_in_tx;
99-
boost::variant<boost::blank, CMerkleBlock, Sidechain::Bitcoin::CMerkleBlock> txout_proof;
98+
std::variant<std::monostate, CTransactionRef, Sidechain::Bitcoin::CTransactionRef> peg_in_tx;
99+
std::variant<std::monostate, CMerkleBlock, Sidechain::Bitcoin::CMerkleBlock> txout_proof;
100100
CScript claim_script;
101101
uint256 genesis_hash;
102102

@@ -182,35 +182,35 @@ struct PSBTInput
182182

183183
// Write peg-in data
184184
if (Params().GetConsensus().ParentChainHasPow()) {
185-
if (peg_in_tx.which() > 0) {
186-
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(peg_in_tx);
185+
if (peg_in_tx.index() > 0) {
186+
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&peg_in_tx);
187187
if (btc_peg_in_tx) {
188188
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_PEG_IN_TX);
189189
OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
190-
SerializeToVector(os, btc_peg_in_tx);
190+
SerializeToVector(os, *btc_peg_in_tx);
191191
}
192192
}
193-
if (txout_proof.which() > 0) {
194-
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(txout_proof);
195-
if (!btc_txout_proof.header.IsNull()) {
193+
if (txout_proof.index() > 0) {
194+
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&txout_proof);
195+
if (btc_txout_proof) {
196196
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_TXOUT_PROOF);
197-
SerializeToVector(s, btc_txout_proof);
197+
SerializeToVector(s, *btc_txout_proof);
198198
}
199199
}
200200
} else {
201-
if (peg_in_tx.which() > 0) {
202-
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(peg_in_tx);
201+
if (peg_in_tx.index() > 0) {
202+
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&peg_in_tx);
203203
if (elem_peg_in_tx) {
204204
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_PEG_IN_TX);
205205
OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
206-
SerializeToVector(os, elem_peg_in_tx);
206+
SerializeToVector(os, *elem_peg_in_tx);
207207
}
208208
}
209-
if (txout_proof.which() > 0) {
210-
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(txout_proof);
211-
if (!elem_txout_proof.header.IsNull()) {
209+
if (txout_proof.index() > 0) {
210+
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&txout_proof);
211+
if (elem_txout_proof) {
212212
SerializeToVector(s, PSBT_IN_PROPRIETARY, PSBT_ELEMENTS_ID, PSBT_IN_TXOUT_PROOF);
213-
SerializeToVector(s, elem_txout_proof);
213+
SerializeToVector(s, *elem_txout_proof);
214214
}
215215
}
216216
}
@@ -412,7 +412,7 @@ struct PSBTInput
412412
}
413413
case PSBT_IN_PEG_IN_TX:
414414
{
415-
if (peg_in_tx.which() != 0) {
415+
if (peg_in_tx.index() != 0) {
416416
throw std::ios_base::failure("Duplicate Key, peg-in tx already provided");
417417
} else if (subkey_len != 1) {
418418
throw std::ios_base::failure("Peg-in tx key is more than one byte type");
@@ -432,7 +432,7 @@ struct PSBTInput
432432
}
433433
case PSBT_IN_TXOUT_PROOF:
434434
{
435-
if (txout_proof.which() != 0) {
435+
if (txout_proof.index() != 0) {
436436
throw std::ios_base::failure("Duplicate Key, peg-in txout proof already provided");
437437
} else if (subkey_len != 1) {
438438
throw std::ios_base::failure("Peg-in txout proof key is more than one byte type");

src/qt/addresstablemodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <wallet/wallet.h>
1212

1313
#include <algorithm>
14-
#include <typeinfo>
1514

1615
#include <QFont>
1716
#include <QDebug>
@@ -82,8 +81,9 @@ class AddressTablePriv
8281
{
8382
for (const auto& address : wallet.getAddresses())
8483
{
85-
if (pk_hash_only && address.dest.type() != typeid(PKHash))
84+
if (pk_hash_only && !std::holds_alternative<PKHash>(address.dest)) {
8685
continue;
86+
}
8787
AddressTableEntry::Type addressType = translateTransactionType(
8888
QString::fromStdString(address.purpose), address.is_mine);
8989
cachedAddressTable.append(AddressTableEntry(addressType,
@@ -261,7 +261,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
261261
} else if(index.column() == Address) {
262262
CTxDestination newAddress = DecodeDestination(value.toString().toStdString());
263263
// Refuse to set invalid address, set error status and return false
264-
if(boost::get<CNoDestination>(&newAddress))
264+
if(std::get_if<CNoDestination>(&newAddress))
265265
{
266266
editStatus = INVALID_ADDRESS;
267267
return false;

src/qt/coincontroldialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
455455
else if(ExtractDestination(out.txout.scriptPubKey, address))
456456
{
457457
CPubKey pubkey;
458-
PKHash *pkhash = boost::get<PKHash>(&address);
458+
PKHash* pkhash = std::get_if<PKHash>(&address);
459459
if (pkhash && model->wallet().getPubKey(out.txout.scriptPubKey, ToKeyID(*pkhash), pubkey))
460460
{
461461
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);

src/qt/signverifymessagedialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
120120
ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
121121
return;
122122
}
123-
const PKHash* pkhash = boost::get<PKHash>(&destination);
123+
const PKHash* pkhash = std::get_if<PKHash>(&destination);
124124
if (!pkhash) {
125125
ui->addressIn_SM->setValid(false);
126126
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");

src/qt/transactionrecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
125125
sub.amount = -wtx.txout_amounts[i];
126126
sub.asset = asset;
127127

128-
if (!boost::get<CNoDestination>(&wtx.txout_address[i]))
128+
if (!std::get_if<CNoDestination>(&wtx.txout_address[i]))
129129
{
130130
// Sent to Bitcoin Address
131131
sub.type = TransactionRecord::SendToAddress;

src/rpc/misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ static RPCHelpMan dumpassetlabels()
874874
};
875875
}
876876

877-
class BlindingPubkeyAdderVisitor : public boost::static_visitor<>
877+
class BlindingPubkeyAdderVisitor
878878
{
879879
public:
880880
CPubKey blind_key;
@@ -950,7 +950,7 @@ static RPCHelpMan createblindedaddress()
950950
key.Set(keydata.begin(), keydata.end());
951951

952952
// Append blinding key and return
953-
boost::apply_visitor(BlindingPubkeyAdderVisitor(key), address);
953+
std::visit(BlindingPubkeyAdderVisitor(key), address);
954954
return EncodeDestination(address);
955955
},
956956
};

src/rpc/rawtransaction.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,36 +1433,36 @@ static RPCHelpMan decodepsbt()
14331433

14341434
// Peg-in stuff
14351435
if (Params().GetConsensus().ParentChainHasPow()) {
1436-
if (input.peg_in_tx.which() > 0) {
1437-
const Sidechain::Bitcoin::CTransactionRef& btc_peg_in_tx = boost::get<Sidechain::Bitcoin::CTransactionRef>(input.peg_in_tx);
1436+
if (input.peg_in_tx.index() > 0) {
1437+
const auto btc_peg_in_tx = std::get_if<Sidechain::Bitcoin::CTransactionRef>(&input.peg_in_tx);
14381438
if (btc_peg_in_tx) {
14391439
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1440-
ss_tx << btc_peg_in_tx;
1440+
ss_tx << *btc_peg_in_tx;
14411441
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx));
14421442
}
14431443
}
1444-
if (input.txout_proof.which() > 0) {
1445-
const Sidechain::Bitcoin::CMerkleBlock& btc_txout_proof = boost::get<Sidechain::Bitcoin::CMerkleBlock>(input.txout_proof);
1446-
if (!btc_txout_proof.header.IsNull()) {
1444+
if (input.txout_proof.index() > 0) {
1445+
const auto btc_txout_proof = std::get_if<Sidechain::Bitcoin::CMerkleBlock>(&input.txout_proof);
1446+
if (btc_txout_proof) {
14471447
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1448-
ss_mb << btc_txout_proof;
1448+
ss_mb << *btc_txout_proof;
14491449
in.pushKV("pegin_txout_proof", HexStr(ss_mb));
14501450
}
14511451
}
14521452
} else {
1453-
if (input.peg_in_tx.which() > 0) {
1454-
const CTransactionRef& elem_peg_in_tx = boost::get<CTransactionRef>(input.peg_in_tx);
1453+
if (input.peg_in_tx.index() > 0) {
1454+
const auto elem_peg_in_tx = std::get_if<CTransactionRef>(&input.peg_in_tx);
14551455
if (elem_peg_in_tx) {
14561456
CDataStream ss_tx(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1457-
ss_tx << elem_peg_in_tx;
1457+
ss_tx << *elem_peg_in_tx;
14581458
in.pushKV("pegin_bitcoin_tx", HexStr(ss_tx));
14591459
}
14601460
}
1461-
if (input.txout_proof.which() > 0) {
1462-
const CMerkleBlock& elem_txout_proof = boost::get<CMerkleBlock>(input.txout_proof);
1463-
if (!elem_txout_proof.header.IsNull()) {
1461+
if (input.txout_proof.index() > 0) {
1462+
const auto elem_txout_proof = std::get_if<CMerkleBlock>(&input.txout_proof);
1463+
if (elem_txout_proof) {
14641464
CDataStream ss_mb(SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS);
1465-
ss_mb << elem_txout_proof;
1465+
ss_mb << *elem_txout_proof;
14661466
in.pushKV("pegin_txout_proof", HexStr(ss_mb));
14671467
}
14681468
}
@@ -2552,7 +2552,7 @@ static RPCHelpMan rawissueasset()
25522552
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing corresponding asset_address");
25532553
}
25542554
asset_dest = DecodeDestination(asset_address_uni.get_str());
2555-
if (boost::get<CNoDestination>(&asset_dest)) {
2555+
if (std::get_if<CNoDestination>(&asset_dest)) {
25562556
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid asset address provided: %s", asset_address_uni.get_str()));
25572557
}
25582558
}
@@ -2569,7 +2569,7 @@ static RPCHelpMan rawissueasset()
25692569
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing corresponding token_address");
25702570
}
25712571
token_dest = DecodeDestination(token_address_uni.get_str());
2572-
if (boost::get<CNoDestination>(&token_dest)) {
2572+
if (std::get_if<CNoDestination>(&token_dest)) {
25732573
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid token address provided: %s", token_address_uni.get_str()));
25742574
}
25752575
}
@@ -2684,7 +2684,7 @@ static RPCHelpMan rawreissueasset()
26842684
throw JSONRPCError(RPC_INVALID_PARAMETER, "Reissuance missing asset_address");
26852685
}
26862686
CTxDestination asset_dest = DecodeDestination(asset_address_uni.get_str());
2687-
if (boost::get<CNoDestination>(&asset_dest)) {
2687+
if (std::get_if<CNoDestination>(&asset_dest)) {
26882688
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid asset address provided: %s", asset_address_uni.get_str()));
26892689
}
26902690

src/rpc/util.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ CTxDestination AddAndGetMultisigDestination(const int required, const std::vecto
212212
return dest;
213213
}
214214

215-
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
215+
class DescribeAddressVisitor
216216
{
217217
public:
218218
explicit DescribeAddressVisitor() {}
@@ -278,7 +278,7 @@ class DescribeAddressVisitor : public boost::static_visitor<UniValue>
278278

279279
UniValue DescribeAddress(const CTxDestination& dest)
280280
{
281-
return boost::apply_visitor(DescribeAddressVisitor(), dest);
281+
return std::visit(DescribeAddressVisitor(), dest);
282282
}
283283

284284
unsigned int ParseConfirmTarget(const UniValue& value, unsigned int max_target)
@@ -889,7 +889,7 @@ UniValue GetServicesNames(ServiceFlags services)
889889
//
890890
// ELEMENTS
891891

892-
class BlindingPubkeyVisitor : public boost::static_visitor<CPubKey>
892+
class BlindingPubkeyVisitor
893893
{
894894
public:
895895
explicit BlindingPubkeyVisitor() {}
@@ -931,14 +931,14 @@ class BlindingPubkeyVisitor : public boost::static_visitor<CPubKey>
931931
};
932932

933933
CPubKey GetDestinationBlindingKey(const CTxDestination& dest) {
934-
return boost::apply_visitor(BlindingPubkeyVisitor(), dest);
934+
return std::visit(BlindingPubkeyVisitor(), dest);
935935
}
936936

937937
bool IsBlindDestination(const CTxDestination& dest) {
938938
return GetDestinationBlindingKey(dest).IsFullyValid();
939939
}
940940

941-
class DescribeBlindAddressVisitor : public boost::static_visitor<UniValue>
941+
class DescribeBlindAddressVisitor
942942
{
943943
public:
944944

@@ -1019,7 +1019,7 @@ class DescribeBlindAddressVisitor : public boost::static_visitor<UniValue>
10191019
UniValue DescribeBlindAddress(const CTxDestination& dest)
10201020
{
10211021
UniValue ret(UniValue::VOBJ);
1022-
ret.pushKVs(boost::apply_visitor(DescribeBlindAddressVisitor(), dest));
1022+
ret.pushKVs(std::visit(DescribeBlindAddressVisitor(), dest));
10231023
return ret;
10241024
}
10251025

0 commit comments

Comments
 (0)