mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +01:00
Merge #20480: Replace boost::variant with std::variant
faa8f68943Replace 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 ACKfaa8f68943fanquake: ACKfaa8f68943Tree-SHA512: 6e3aecd33b00c2e31a763f999247944d5b2ce5e3018f1965c516c1000cd08ff6703a8d50fb0be64883153da2925ae72986b8a6b96586db74057bd05d6f4986e6
This commit is contained in:
@@ -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 */:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,9 +261,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
|
||||
@@ -300,7 +299,7 @@ public:
|
||||
|
||||
CScript GetScriptForDestination(const CTxDestination& dest)
|
||||
{
|
||||
return boost::apply_visitor(CScriptVisitor(), dest);
|
||||
return std::visit(CScriptVisitor(), dest);
|
||||
}
|
||||
|
||||
CScript GetScriptForRawPubKey(const CPubKey& pubKey)
|
||||
@@ -320,5 +319,5 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
|
||||
}
|
||||
|
||||
bool IsValidDestination(const CTxDestination& dest) {
|
||||
return dest.which() != 0;
|
||||
return dest.index() != 0;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
#include <script/interpreter.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <variant>
|
||||
|
||||
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)
|
||||
* 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. */
|
||||
bool IsValidDestination(const CTxDestination& dest);
|
||||
|
||||
Reference in New Issue
Block a user