Auto merge of #4892 - str4d:boosted, r=str4d
Replace boost::variant and boost::optional with standard library Includes a commit cherry-picked from https://github.com/bitcoin/bitcoin/pull/20419. Closes #4821. Closes #4822.
This commit is contained in:
commit
dea50714f9
|
@ -27,7 +27,7 @@ files:
|
|||
- "Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz"
|
||||
script: |
|
||||
WRAP_DIR=$HOME/wrapped
|
||||
HOSTS="x86_64-apple-darwin16"
|
||||
HOSTS="x86_64-apple-darwin18"
|
||||
CONFIGFLAGS="--enable-reduce-exports --disable-bench GENISOIMAGE=$WRAP_DIR/genisoimage"
|
||||
FAKETIME_HOST_PROGS=""
|
||||
FAKETIME_PROGS="ar ranlib date dmg genisoimage"
|
||||
|
|
|
@ -22,7 +22,7 @@ Common `host-platform-triplets` for cross compilation are:
|
|||
|
||||
- `i686-w64-mingw32` for Win32
|
||||
- `x86_64-w64-mingw32` for Win64
|
||||
- `x86_64-apple-darwin16` for macOS
|
||||
- `x86_64-apple-darwin18` for macOS
|
||||
- `arm-linux-gnueabihf` for Linux ARM 32 bit
|
||||
- `aarch64-linux-gnu` for Linux ARM 64 bit
|
||||
- `riscv32-linux-gnu` for Linux RISC-V 32 bit
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
OSX_MIN_VERSION=10.12
|
||||
OSX_SDK_VERSION=10.15.1
|
||||
OSX_MIN_VERSION=10.14
|
||||
XCODE_VERSION=11.3.1
|
||||
XCODE_BUILD_ID=11C505
|
||||
LD64_VERSION=530
|
||||
|
|
27
src/chain.h
27
src/chain.h
|
@ -12,6 +12,7 @@
|
|||
#include "tinyformat.h"
|
||||
#include "uint256.h"
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
static const int SPROUT_VALUE_VERSION = 1001400;
|
||||
|
@ -228,7 +229,7 @@ public:
|
|||
//! Branch ID corresponding to the consensus rules used to validate this block.
|
||||
//! Only cached if block validity is BLOCK_VALID_CONSENSUS.
|
||||
//! Persisted at each activation height, memory-only for intervening blocks.
|
||||
boost::optional<uint32_t> nCachedBranchId;
|
||||
std::optional<uint32_t> nCachedBranchId;
|
||||
|
||||
//! The anchor for the tree state up to the start of this block
|
||||
uint256 hashSproutAnchor;
|
||||
|
@ -237,22 +238,22 @@ public:
|
|||
uint256 hashFinalSproutRoot;
|
||||
|
||||
//! Change in value held by the Sprout circuit over this block.
|
||||
//! Will be boost::none for older blocks on old nodes until a reindex has taken place.
|
||||
boost::optional<CAmount> nSproutValue;
|
||||
//! Will be std::nullopt for older blocks on old nodes until a reindex has taken place.
|
||||
std::optional<CAmount> nSproutValue;
|
||||
|
||||
//! (memory only) Total value held by the Sprout circuit up to and including this block.
|
||||
//! Will be boost::none for on old nodes until a reindex has taken place.
|
||||
//! Will be boost::none if nChainTx is zero.
|
||||
boost::optional<CAmount> nChainSproutValue;
|
||||
//! Will be std::nullopt for on old nodes until a reindex has taken place.
|
||||
//! Will be std::nullopt if nChainTx is zero.
|
||||
std::optional<CAmount> nChainSproutValue;
|
||||
|
||||
//! Change in value held by the Sapling circuit over this block.
|
||||
//! Not a boost::optional because this was added before Sapling activated, so we can
|
||||
//! Not a std::optional because this was added before Sapling activated, so we can
|
||||
//! rely on the invariant that every block before this was added had nSaplingValue = 0.
|
||||
CAmount nSaplingValue;
|
||||
|
||||
//! (memory only) Total value held by the Sapling circuit up to and including this block.
|
||||
//! Will be boost::none if nChainTx is zero.
|
||||
boost::optional<CAmount> nChainSaplingValue;
|
||||
//! Will be std::nullopt if nChainTx is zero.
|
||||
std::optional<CAmount> nChainSaplingValue;
|
||||
|
||||
//! Root of the Sapling commitment tree as of the end of this block.
|
||||
//!
|
||||
|
@ -295,14 +296,14 @@ public:
|
|||
nTx = 0;
|
||||
nChainTx = 0;
|
||||
nStatus = 0;
|
||||
nCachedBranchId = boost::none;
|
||||
nCachedBranchId = std::nullopt;
|
||||
hashSproutAnchor = uint256();
|
||||
hashFinalSproutRoot = uint256();
|
||||
nSequenceId = 0;
|
||||
nSproutValue = boost::none;
|
||||
nChainSproutValue = boost::none;
|
||||
nSproutValue = std::nullopt;
|
||||
nChainSproutValue = std::nullopt;
|
||||
nSaplingValue = 0;
|
||||
nChainSaplingValue = boost::none;
|
||||
nChainSaplingValue = std::nullopt;
|
||||
|
||||
nVersion = 0;
|
||||
hashMerkleRoot = uint256();
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "utilstrencodings.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
|
@ -103,7 +105,7 @@ public:
|
|||
consensus.nPowMaxAdjustUp = 16; // 16% adjustment up
|
||||
consensus.nPreBlossomPowTargetSpacing = Consensus::PRE_BLOSSOM_POW_TARGET_SPACING;
|
||||
consensus.nPostBlossomPowTargetSpacing = Consensus::POST_BLOSSOM_POW_TARGET_SPACING;
|
||||
consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none;
|
||||
consensus.nPowAllowMinDifficultyBlocksAfterHeight = std::nullopt;
|
||||
consensus.fPowNoRetargeting = false;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002;
|
||||
consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight =
|
||||
|
@ -812,7 +814,7 @@ CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const {
|
|||
CTxDestination address = keyIO.DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str());
|
||||
assert(IsValidDestination(address));
|
||||
assert(IsScriptDestination(address));
|
||||
CScriptID scriptID = boost::get<CScriptID>(address); // address is a boost variant
|
||||
CScriptID scriptID = std::get<CScriptID>(address); // address is a variant
|
||||
CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
|
||||
return script;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ std::set<FundingStreamElement> GetActiveFundingStreamElements(
|
|||
// in the definition of vFundingStreams.
|
||||
auto fs = params.vFundingStreams[idx];
|
||||
// Funding period is [startHeight, endHeight)
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) {
|
||||
requiredElements.insert(std::make_pair(
|
||||
fs.get().RecipientAddress(params, nHeight),
|
||||
fs.value().RecipientAddress(params, nHeight),
|
||||
FundingStreamInfo[idx].Value(blockSubsidy)));
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ std::vector<FSInfo> GetActiveFundingStreams(
|
|||
if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) {
|
||||
for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
|
||||
auto fs = params.vFundingStreams[idx];
|
||||
if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) {
|
||||
if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) {
|
||||
activeStreams.push_back(FundingStreamInfo[idx]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <amount.h>
|
||||
#include <consensus/params.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
namespace Consensus
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace Consensus {
|
|||
return (nHeight - fundingStreamStartHeight + startPeriodOffset) / nFundingPeriodLength;
|
||||
}
|
||||
|
||||
boost::variant<FundingStream, FundingStreamError> FundingStream::ValidateFundingStream(
|
||||
std::variant<FundingStream, FundingStreamError> FundingStream::ValidateFundingStream(
|
||||
const Consensus::Params& params,
|
||||
const int startHeight,
|
||||
const int endHeight,
|
||||
|
@ -123,7 +123,7 @@ namespace Consensus {
|
|||
return FundingStream(startHeight, endHeight, addresses);
|
||||
};
|
||||
|
||||
class GetFundingStreamOrThrow: public boost::static_visitor<FundingStream> {
|
||||
class GetFundingStreamOrThrow {
|
||||
public:
|
||||
FundingStream operator()(const FundingStream& fs) const {
|
||||
return fs;
|
||||
|
@ -163,12 +163,12 @@ namespace Consensus {
|
|||
// If the string is not a valid transparent or Sapling address, we will
|
||||
// throw here.
|
||||
|
||||
addresses.push_back(boost::get<libzcash::SaplingPaymentAddress>(zaddr));
|
||||
addresses.push_back(std::get<libzcash::SaplingPaymentAddress>(zaddr));
|
||||
}
|
||||
}
|
||||
|
||||
auto validationResult = FundingStream::ValidateFundingStream(params, startHeight, endHeight, addresses);
|
||||
return boost::apply_visitor(GetFundingStreamOrThrow(), validationResult);
|
||||
return std::visit(GetFundingStreamOrThrow(), validationResult);
|
||||
};
|
||||
|
||||
void Params::AddZIP207FundingStream(
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#include "key_constants.h"
|
||||
#include <zcash/address/sapling.hpp>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
|
||||
namespace Consensus {
|
||||
|
||||
|
@ -79,10 +80,10 @@ struct NetworkUpgrade {
|
|||
* scrutiny than regular releases. nMinimumChainWork MUST be set to at least the chain
|
||||
* work of this block, otherwise this detection will have false positives.
|
||||
*/
|
||||
boost::optional<uint256> hashActivationBlock;
|
||||
std::optional<uint256> hashActivationBlock;
|
||||
};
|
||||
|
||||
typedef boost::variant<libzcash::SaplingPaymentAddress, CScript> FundingStreamAddress;
|
||||
typedef std::variant<libzcash::SaplingPaymentAddress, CScript> FundingStreamAddress;
|
||||
|
||||
/**
|
||||
* Index into Params.vFundingStreams.
|
||||
|
@ -116,7 +117,7 @@ public:
|
|||
FundingStream(const FundingStream& fs):
|
||||
startHeight(fs.startHeight), endHeight(fs.endHeight), addresses(fs.addresses) { }
|
||||
|
||||
static boost::variant<FundingStream, FundingStreamError> ValidateFundingStream(
|
||||
static std::variant<FundingStream, FundingStreamError> ValidateFundingStream(
|
||||
const Consensus::Params& params,
|
||||
const int startHeight,
|
||||
const int endHeight,
|
||||
|
@ -210,7 +211,7 @@ struct Params {
|
|||
NetworkUpgrade vUpgrades[MAX_NETWORK_UPGRADES];
|
||||
|
||||
int nFundingPeriodLength;
|
||||
boost::optional<FundingStream> vFundingStreams[MAX_FUNDING_STREAMS];
|
||||
std::optional<FundingStream> vFundingStreams[MAX_FUNDING_STREAMS];
|
||||
void AddZIP207FundingStream(
|
||||
const KeyConstants& keyConstants,
|
||||
FundingStreamIndex idx,
|
||||
|
@ -262,7 +263,7 @@ struct Params {
|
|||
unsigned int nEquihashN = 0;
|
||||
unsigned int nEquihashK = 0;
|
||||
uint256 powLimit;
|
||||
boost::optional<uint32_t> nPowAllowMinDifficultyBlocksAfterHeight;
|
||||
std::optional<uint32_t> nPowAllowMinDifficultyBlocksAfterHeight;
|
||||
bool fPowNoRetargeting;
|
||||
int64_t nPowAveragingWindow;
|
||||
int64_t nPowMaxAdjustDown;
|
||||
|
|
|
@ -140,9 +140,9 @@ bool IsActivationHeightForAnyUpgrade(
|
|||
return false;
|
||||
}
|
||||
|
||||
boost::optional<int> NextEpoch(int nHeight, const Consensus::Params& params) {
|
||||
std::optional<int> NextEpoch(int nHeight, const Consensus::Params& params) {
|
||||
if (nHeight < 0) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Sprout is never pending
|
||||
|
@ -152,16 +152,16 @@ boost::optional<int> NextEpoch(int nHeight, const Consensus::Params& params) {
|
|||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<int> NextActivationHeight(
|
||||
std::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params)
|
||||
{
|
||||
auto idx = NextEpoch(nHeight, params);
|
||||
if (idx) {
|
||||
return params.vUpgrades[idx.get()].nActivationHeight;
|
||||
return params.vUpgrades[idx.value()].nActivationHeight;
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "consensus/params.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
enum UpgradeState {
|
||||
UPGRADE_DISABLED,
|
||||
|
@ -83,15 +83,15 @@ bool IsActivationHeightForAnyUpgrade(
|
|||
|
||||
/**
|
||||
* Returns the index of the next upgrade after the given block height, or
|
||||
* boost::none if there are no more known upgrades.
|
||||
* std::nullopt if there are no more known upgrades.
|
||||
*/
|
||||
boost::optional<int> NextEpoch(int nHeight, const Consensus::Params& params);
|
||||
std::optional<int> NextEpoch(int nHeight, const Consensus::Params& params);
|
||||
|
||||
/**
|
||||
* Returns the activation height for the next upgrade after the given block height,
|
||||
* or boost::none if there are no more known upgrades.
|
||||
* or std::nullopt if there are no more known upgrades.
|
||||
*/
|
||||
boost::optional<int> NextActivationHeight(
|
||||
std::optional<int> NextActivationHeight(
|
||||
int nHeight,
|
||||
const Consensus::Params& params);
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "crypto/equihash.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
void eh_HashState::Update(const unsigned char *input, size_t inputLen)
|
||||
{
|
||||
|
@ -149,7 +151,6 @@ std::vector<unsigned char> GetMinimalFromIndices(std::vector<eh_index> indices,
|
|||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
static EhSolverCancelledException solver_cancelled;
|
||||
|
||||
|
@ -646,7 +647,7 @@ bool Equihash<N,K>::OptimisedSolve(const eh_HashState& base_state,
|
|||
size_t hashLen;
|
||||
size_t lenIndices;
|
||||
unsigned char tmpHash[HashOutput];
|
||||
std::vector<boost::optional<std::vector<FullStepRow<FinalFullWidth>>>> X;
|
||||
std::vector<std::optional<std::vector<FullStepRow<FinalFullWidth>>>> X;
|
||||
X.reserve(K+1);
|
||||
|
||||
// 3) Repeat steps 1 and 2 for each partial index
|
||||
|
@ -664,7 +665,7 @@ bool Equihash<N,K>::OptimisedSolve(const eh_HashState& base_state,
|
|||
N/8, HashLength, CollisionBitLength, newIndex);
|
||||
if (cancelled(PartialGeneration)) throw solver_cancelled;
|
||||
}
|
||||
boost::optional<std::vector<FullStepRow<FinalFullWidth>>> ic = icv;
|
||||
std::optional<std::vector<FullStepRow<FinalFullWidth>>> ic = icv;
|
||||
|
||||
// 2a) For each pair of lists:
|
||||
hashLen = HashLength;
|
||||
|
@ -689,7 +690,7 @@ bool Equihash<N,K>::OptimisedSolve(const eh_HashState& base_state,
|
|||
if (ic->size() == 0)
|
||||
goto invalidsolution;
|
||||
|
||||
X[r] = boost::none;
|
||||
X[r] = std::nullopt;
|
||||
hashLen -= CollisionByteLength;
|
||||
lenIndices *= 2;
|
||||
rti = lti;
|
||||
|
|
|
@ -12,7 +12,7 @@ bool fExperimentalPaymentDisclosure = false;
|
|||
bool fExperimentalInsightExplorer = false;
|
||||
bool fExperimentalLightWalletd = false;
|
||||
|
||||
boost::optional<std::string> InitExperimentalMode()
|
||||
std::optional<std::string> InitExperimentalMode()
|
||||
{
|
||||
auto fExperimentalMode = GetBoolArg("-experimentalfeatures", false);
|
||||
fExperimentalDeveloperEncryptWallet = GetBoolArg("-developerencryptwallet", false);
|
||||
|
@ -35,7 +35,7 @@ boost::optional<std::string> InitExperimentalMode()
|
|||
return _("Light Walletd requires -experimentalfeatures.");
|
||||
}
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetExperimentalFeatures()
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
#ifndef ZCASH_EXPERIMENTAL_FEATURES_H
|
||||
#define ZCASH_EXPERIMENTAL_FEATURES_H
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
extern bool fExperimentalDeveloperEncryptWallet;
|
||||
extern bool fExperimentalDeveloperSetPoolSizeZero;
|
||||
|
@ -15,7 +15,7 @@ extern bool fExperimentalPaymentDisclosure;
|
|||
extern bool fExperimentalInsightExplorer;
|
||||
extern bool fExperimentalLightWalletd;
|
||||
|
||||
boost::optional<std::string> InitExperimentalMode();
|
||||
std::optional<std::string> InitExperimentalMode();
|
||||
std::vector<std::string> GetExperimentalFeatures();
|
||||
|
||||
#endif // ZCASH_EXPERIMENTAL_FEATURES_H
|
||||
|
|
|
@ -1134,7 +1134,7 @@ TEST(ChecktransactionTests, HeartwoodAcceptsShieldedCoinbase) {
|
|||
auto output = OutputDescriptionInfo(ovk, note, {{0xF6}});
|
||||
|
||||
auto ctx = librustzcash_sapling_proving_ctx_init();
|
||||
auto odesc = output.Build(ctx).get();
|
||||
auto odesc = output.Build(ctx).value();
|
||||
librustzcash_sapling_proving_ctx_free(ctx);
|
||||
|
||||
CMutableTransaction mtx = GetValidTransaction();
|
||||
|
@ -1240,7 +1240,7 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
|
|||
|
||||
// Add a Sapling output.
|
||||
auto ctx = librustzcash_sapling_proving_ctx_init();
|
||||
auto odesc = output.Build(ctx).get();
|
||||
auto odesc = output.Build(ctx).value();
|
||||
librustzcash_sapling_proving_ctx_free(ctx);
|
||||
mtx.vShieldedOutput.push_back(odesc);
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ void checkNumberOfUniqueAddresses(int nUnique) {
|
|||
int GetMaxFundingStreamHeight(const Consensus::Params& params) {
|
||||
int result = 0;
|
||||
for (auto fs : params.vFundingStreams) {
|
||||
if (fs && result < fs.get().GetEndHeight() - 1) {
|
||||
result = fs.get().GetEndHeight() - 1;
|
||||
if (fs && result < fs.value().GetEndHeight() - 1) {
|
||||
result = fs.value().GetEndHeight() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/variant/get.hpp>
|
||||
|
||||
#include "zcash/prf.h"
|
||||
#include "util.h"
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "utiltest.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Keys, EncodeAndDecodeSapling)
|
||||
|
@ -24,8 +26,8 @@ TEST(Keys, EncodeAndDecodeSapling)
|
|||
auto spendingkey2 = keyIO.DecodeSpendingKey(sk_string);
|
||||
EXPECT_TRUE(IsValidSpendingKey(spendingkey2));
|
||||
|
||||
ASSERT_TRUE(boost::get<libzcash::SaplingExtendedSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = boost::get<libzcash::SaplingExtendedSpendingKey>(spendingkey2);
|
||||
ASSERT_TRUE(std::get_if<libzcash::SaplingExtendedSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = std::get<libzcash::SaplingExtendedSpendingKey>(spendingkey2);
|
||||
EXPECT_EQ(sk, sk2);
|
||||
}
|
||||
{
|
||||
|
@ -38,8 +40,8 @@ TEST(Keys, EncodeAndDecodeSapling)
|
|||
auto viewingkey2 = keyIO.DecodeViewingKey(vk_string);
|
||||
EXPECT_TRUE(IsValidViewingKey(viewingkey2));
|
||||
|
||||
ASSERT_TRUE(boost::get<libzcash::SaplingExtendedFullViewingKey>(&viewingkey2) != nullptr);
|
||||
auto extfvk2 = boost::get<libzcash::SaplingExtendedFullViewingKey>(viewingkey2);
|
||||
ASSERT_TRUE(std::get_if<libzcash::SaplingExtendedFullViewingKey>(&viewingkey2) != nullptr);
|
||||
auto extfvk2 = std::get<libzcash::SaplingExtendedFullViewingKey>(viewingkey2);
|
||||
EXPECT_EQ(extfvk, extfvk2);
|
||||
}
|
||||
{
|
||||
|
@ -53,8 +55,8 @@ TEST(Keys, EncodeAndDecodeSapling)
|
|||
auto paymentaddr2 = keyIO.DecodePaymentAddress(addr_string);
|
||||
EXPECT_TRUE(IsValidPaymentAddress(paymentaddr2));
|
||||
|
||||
ASSERT_TRUE(boost::get<libzcash::SaplingPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = boost::get<libzcash::SaplingPaymentAddress>(paymentaddr2);
|
||||
ASSERT_TRUE(std::get_if<libzcash::SaplingPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = std::get<libzcash::SaplingPaymentAddress>(paymentaddr2);
|
||||
EXPECT_EQ(addr, addr2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,13 +94,13 @@ TEST(MempoolLimitTests, WeightedTxTreeCheckSizeAfterDropping)
|
|||
tree.add(WeightedTxInfo(TX_ID2, TxWeight(MIN_TX_COST, MIN_TX_COST)));
|
||||
EXPECT_EQ(8000, tree.getTotalWeight().cost);
|
||||
EXPECT_EQ(8000, tree.getTotalWeight().evictionWeight);
|
||||
EXPECT_FALSE(tree.maybeDropRandom().is_initialized());
|
||||
EXPECT_FALSE(tree.maybeDropRandom().has_value());
|
||||
tree.add(WeightedTxInfo(TX_ID3, TxWeight(MIN_TX_COST, MIN_TX_COST + LOW_FEE_PENALTY)));
|
||||
EXPECT_EQ(12000, tree.getTotalWeight().cost);
|
||||
EXPECT_EQ(12000 + LOW_FEE_PENALTY, tree.getTotalWeight().evictionWeight);
|
||||
boost::optional<uint256> drop = tree.maybeDropRandom();
|
||||
ASSERT_TRUE(drop.is_initialized());
|
||||
uint256 txid = drop.get();
|
||||
std::optional<uint256> drop = tree.maybeDropRandom();
|
||||
ASSERT_TRUE(drop.has_value());
|
||||
uint256 txid = drop.value();
|
||||
testedDropping.insert(txid);
|
||||
// Do not continue to test if a particular trial fails
|
||||
ASSERT_EQ(8000, tree.getTotalWeight().cost);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "miner.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
|
||||
TEST(Miner, GetMinerAddress) {
|
||||
SelectParams(CBaseChainParams::MAIN);
|
||||
|
@ -52,8 +54,8 @@ TEST(Miner, GetMinerAddress) {
|
|||
MinerAddress minerAddress;
|
||||
GetMinerAddress(minerAddress);
|
||||
EXPECT_TRUE(IsValidMinerAddress(minerAddress));
|
||||
EXPECT_TRUE(boost::get<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = boost::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_TRUE(std::get_if<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = std::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript);
|
||||
}
|
||||
|
||||
|
@ -63,8 +65,8 @@ TEST(Miner, GetMinerAddress) {
|
|||
MinerAddress minerAddress;
|
||||
GetMinerAddress(minerAddress);
|
||||
EXPECT_TRUE(IsValidMinerAddress(minerAddress));
|
||||
EXPECT_TRUE(boost::get<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = boost::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_TRUE(std::get_if<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = std::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript);
|
||||
}
|
||||
|
||||
|
@ -74,8 +76,8 @@ TEST(Miner, GetMinerAddress) {
|
|||
MinerAddress minerAddress;
|
||||
GetMinerAddress(minerAddress);
|
||||
EXPECT_TRUE(IsValidMinerAddress(minerAddress));
|
||||
EXPECT_TRUE(boost::get<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = boost::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_TRUE(std::get_if<boost::shared_ptr<CReserveScript>>(&minerAddress) != nullptr);
|
||||
auto coinbaseScript = std::get<boost::shared_ptr<CReserveScript>>(minerAddress);
|
||||
EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript);
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ TEST(Miner, GetMinerAddress) {
|
|||
MinerAddress minerAddress;
|
||||
GetMinerAddress(minerAddress);
|
||||
EXPECT_TRUE(IsValidMinerAddress(minerAddress));
|
||||
EXPECT_TRUE(boost::get<libzcash::SaplingPaymentAddress>(&minerAddress) != nullptr);
|
||||
EXPECT_TRUE(std::get_if<libzcash::SaplingPaymentAddress>(&minerAddress) != nullptr);
|
||||
}
|
||||
|
||||
// Valid Sapling address with leading whitespace
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "sodium.h"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "zcash/Note.hpp"
|
||||
|
@ -50,7 +51,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -58,7 +59,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -88,7 +89,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto bar = foo.get();
|
||||
auto bar = foo.value();
|
||||
|
||||
ASSERT_TRUE(bar.value() == pt.value());
|
||||
ASSERT_TRUE(bar.memo() == pt.memo());
|
||||
|
@ -101,7 +102,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto new_note = foobar.get();
|
||||
auto new_note = foobar.value();
|
||||
|
||||
ASSERT_TRUE(note.value() == new_note.value());
|
||||
ASSERT_TRUE(note.d == new_note.d);
|
||||
|
@ -136,7 +137,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto decrypted_out_ct_unwrapped = decrypted_out_ct.get();
|
||||
auto decrypted_out_ct_unwrapped = decrypted_out_ct.value();
|
||||
|
||||
ASSERT_TRUE(decrypted_out_ct_unwrapped.pk_d == out_pt.pk_d);
|
||||
ASSERT_TRUE(decrypted_out_ct_unwrapped.esk == out_pt.esk);
|
||||
|
@ -169,7 +170,7 @@ TEST(NoteEncryption, NotePlaintext)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
bar = foo.get();
|
||||
bar = foo.value();
|
||||
|
||||
ASSERT_TRUE(bar.value() == pt.value());
|
||||
ASSERT_TRUE(bar.memo() == pt.memo());
|
||||
|
@ -210,7 +211,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -218,7 +219,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -241,7 +242,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -249,7 +250,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -301,7 +302,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -309,7 +310,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -343,7 +344,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -351,7 +352,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -380,7 +381,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
if (!cmu_opt) {
|
||||
FAIL();
|
||||
}
|
||||
uint256 cmu = cmu_opt.get();
|
||||
uint256 cmu = cmu_opt.value();
|
||||
SaplingNotePlaintext pt(note, memo);
|
||||
|
||||
auto res = pt.encrypt(addr.pk_d);
|
||||
|
@ -388,7 +389,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled)
|
|||
FAIL();
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
|
||||
auto ct = enc.first;
|
||||
auto encryptor = enc.second;
|
||||
|
@ -442,7 +443,7 @@ TEST(NoteEncryption, SaplingApi)
|
|||
librustzcash_sapling_generate_r(esk.begin());
|
||||
|
||||
// Invalid diversifier
|
||||
ASSERT_EQ(boost::none, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, esk));
|
||||
ASSERT_EQ(std::nullopt, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, esk));
|
||||
|
||||
// Encrypt to pk_1
|
||||
auto enc = *SaplingNoteEncryption::FromDiversifier(pk_1.d, esk);
|
||||
|
|
|
@ -93,7 +93,7 @@ TEST(PoW, MinDifficultyRules) {
|
|||
std::vector<CBlockIndex> blocks(lastBlk+1);
|
||||
for (int i = 0; i <= lastBlk; i++) {
|
||||
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
|
||||
blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.get() + i;
|
||||
blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.value() + i;
|
||||
blocks[i].nTime = i ? blocks[i - 1].nTime + params.PoWTargetSpacing(i) : 1269211443;
|
||||
blocks[i].nBits = 0x1e7fffff; /* target 0x007fffff000... */
|
||||
blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0);
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST(SaplingNote, TestVectors)
|
|||
|
||||
// Test commitment
|
||||
SaplingNote note = SaplingNote(diversifier, pk_d, v, r, Zip212Enabled::BeforeZip212);
|
||||
ASSERT_EQ(note.cmu().get(), cm);
|
||||
ASSERT_EQ(note.cmu().value(), cm);
|
||||
|
||||
// Test nullifier
|
||||
SaplingSpendingKey spendingKey(sk);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "chainparams.h"
|
||||
#include "consensus/upgrades.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
class UpgradesTest : public ::testing::Test {
|
||||
protected:
|
||||
|
@ -148,28 +148,28 @@ TEST_F(UpgradesTest, NextEpoch) {
|
|||
const Consensus::Params& params = Params().GetConsensus();
|
||||
|
||||
// Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT
|
||||
EXPECT_EQ(NextEpoch(-1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(0, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(0, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), std::nullopt);
|
||||
|
||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
||||
|
||||
EXPECT_EQ(NextEpoch(-1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(0, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(0, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), std::nullopt);
|
||||
|
||||
int nActivationHeight = 100;
|
||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight);
|
||||
|
||||
EXPECT_EQ(NextEpoch(-1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(0, params), static_cast<int>(Consensus::UPGRADE_TESTDUMMY));
|
||||
EXPECT_EQ(NextEpoch(1, params), static_cast<int>(Consensus::UPGRADE_TESTDUMMY));
|
||||
EXPECT_EQ(NextEpoch(nActivationHeight - 1, params), static_cast<int>(Consensus::UPGRADE_TESTDUMMY));
|
||||
EXPECT_EQ(NextEpoch(nActivationHeight, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextEpoch(nActivationHeight, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), std::nullopt);
|
||||
EXPECT_EQ(NextEpoch(1000000, params), std::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(UpgradesTest, NextActivationHeight) {
|
||||
|
@ -177,26 +177,26 @@ TEST_F(UpgradesTest, NextActivationHeight) {
|
|||
const Consensus::Params& params = Params().GetConsensus();
|
||||
|
||||
// Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(0, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(0, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt);
|
||||
|
||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
||||
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(0, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(0, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt);
|
||||
|
||||
int nActivationHeight = 100;
|
||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight);
|
||||
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(0, params), nActivationHeight);
|
||||
EXPECT_EQ(NextActivationHeight(1, params), nActivationHeight);
|
||||
EXPECT_EQ(NextActivationHeight(nActivationHeight - 1, params), nActivationHeight);
|
||||
EXPECT_EQ(NextActivationHeight(nActivationHeight, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), boost::none);
|
||||
EXPECT_EQ(NextActivationHeight(nActivationHeight, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), std::nullopt);
|
||||
EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "transaction_builder.h"
|
||||
#include "utiltest.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
extern bool ReceivedBlockTransactions(
|
||||
const CBlock &block,
|
||||
CValidationState& state,
|
||||
|
@ -14,7 +16,7 @@ extern bool ReceivedBlockTransactions(
|
|||
CBlockIndex *pindexNew,
|
||||
const CDiskBlockPos& pos);
|
||||
|
||||
void ExpectOptionalAmount(CAmount expected, boost::optional<CAmount> actual) {
|
||||
void ExpectOptionalAmount(CAmount expected, std::optional<CAmount> actual) {
|
||||
EXPECT_TRUE((bool)actual);
|
||||
if (actual) {
|
||||
EXPECT_EQ(expected, *actual);
|
||||
|
@ -24,7 +26,7 @@ void ExpectOptionalAmount(CAmount expected, boost::optional<CAmount> actual) {
|
|||
// Fake a view that optionally contains a single coin.
|
||||
class ValidationFakeCoinsViewDB : public CCoinsView {
|
||||
public:
|
||||
boost::optional<std::pair<std::pair<uint256, uint256>, std::pair<CTxOut, int>>> coin;
|
||||
std::optional<std::pair<std::pair<uint256, uint256>, std::pair<CTxOut, int>>> coin;
|
||||
|
||||
ValidationFakeCoinsViewDB() {}
|
||||
ValidationFakeCoinsViewDB(uint256 blockHash, uint256 txid, CTxOut txOut, int nHeight) :
|
||||
|
@ -43,11 +45,11 @@ public:
|
|||
}
|
||||
|
||||
bool GetCoins(const uint256 &txid, CCoins &coins) const {
|
||||
if (coin && txid == coin.get().first.second) {
|
||||
if (coin && txid == coin.value().first.second) {
|
||||
CCoins newCoins;
|
||||
newCoins.vout.resize(2);
|
||||
newCoins.vout[0] = coin.get().second.first;
|
||||
newCoins.nHeight = coin.get().second.second;
|
||||
newCoins.vout[0] = coin.value().second.first;
|
||||
newCoins.nHeight = coin.value().second.second;
|
||||
coins.swap(newCoins);
|
||||
return true;
|
||||
} else {
|
||||
|
@ -56,7 +58,7 @@ public:
|
|||
}
|
||||
|
||||
bool HaveCoins(const uint256 &txid) const {
|
||||
if (coin && txid == coin.get().first.second) {
|
||||
if (coin && txid == coin.value().first.second) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -65,7 +67,7 @@ public:
|
|||
|
||||
uint256 GetBestBlock() const {
|
||||
if (coin) {
|
||||
return coin.get().first.first;
|
||||
return coin.value().first.first;
|
||||
} else {
|
||||
uint256 a;
|
||||
return a;
|
||||
|
|
|
@ -109,7 +109,7 @@ TEST(ZIP32, TestVectors) {
|
|||
auto maybe_m_1_2hv_3 = m_1_2hv.Derive(3);
|
||||
EXPECT_TRUE(maybe_m_1_2hv_3);
|
||||
|
||||
auto m_1_2hv_3 = maybe_m_1_2hv_3.get();
|
||||
auto m_1_2hv_3 = maybe_m_1_2hv_3.value();
|
||||
EXPECT_EQ(m_1_2hv_3.depth, 3);
|
||||
EXPECT_EQ(m_1_2hv_3.parentFVKTag, 0x7583c148);
|
||||
EXPECT_EQ(m_1_2hv_3.childIndex, 3);
|
||||
|
|
|
@ -899,7 +899,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
// Set this early so that experimental features are correctly enabled/disabled
|
||||
auto err = InitExperimentalMode();
|
||||
if (err) {
|
||||
return InitError(err.get());
|
||||
return InitError(err.value());
|
||||
}
|
||||
|
||||
// Make sure enough file descriptors are available
|
||||
|
@ -1053,7 +1053,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
// Try a Sapling address
|
||||
auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]);
|
||||
if (!IsValidPaymentAddress(zaddr) ||
|
||||
boost::get<libzcash::SaplingPaymentAddress>(&zaddr) == nullptr)
|
||||
std::get_if<libzcash::SaplingPaymentAddress>(&zaddr) == nullptr)
|
||||
{
|
||||
return InitError(strprintf(
|
||||
_("Invalid address for -mineraddress=<addr>: '%s' (must be a Sapling or transparent address)"),
|
||||
|
@ -1574,11 +1574,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
if (pwalletMain) {
|
||||
CTxDestination addr = keyIO.DecodeDestination(mapArgs["-mineraddress"]);
|
||||
if (IsValidDestination(addr)) {
|
||||
CKeyID keyID = boost::get<CKeyID>(addr);
|
||||
CKeyID keyID = std::get<CKeyID>(addr);
|
||||
minerAddressInLocalWallet = pwalletMain->HaveKey(keyID);
|
||||
} else {
|
||||
auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]);
|
||||
minerAddressInLocalWallet = boost::apply_visitor(
|
||||
minerAddressInLocalWallet = std::visit(
|
||||
HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,15 @@
|
|||
#include <script/script.h>
|
||||
#include <utilstrencodings.h>
|
||||
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <variant>
|
||||
|
||||
namespace
|
||||
{
|
||||
class DestinationEncoder : public boost::static_visitor<std::string>
|
||||
class DestinationEncoder
|
||||
{
|
||||
private:
|
||||
const KeyConstants& keyConstants;
|
||||
|
@ -44,7 +43,7 @@ public:
|
|||
std::string operator()(const CNoDestination& no) const { return {}; }
|
||||
};
|
||||
|
||||
class PaymentAddressEncoder : public boost::static_visitor<std::string>
|
||||
class PaymentAddressEncoder
|
||||
{
|
||||
private:
|
||||
const KeyConstants& keyConstants;
|
||||
|
@ -77,7 +76,7 @@ public:
|
|||
std::string operator()(const libzcash::InvalidEncoding& no) const { return {}; }
|
||||
};
|
||||
|
||||
class ViewingKeyEncoder : public boost::static_visitor<std::string>
|
||||
class ViewingKeyEncoder
|
||||
{
|
||||
private:
|
||||
const KeyConstants& keyConstants;
|
||||
|
@ -115,7 +114,7 @@ public:
|
|||
std::string operator()(const libzcash::InvalidEncoding& no) const { return {}; }
|
||||
};
|
||||
|
||||
class SpendingKeyEncoder : public boost::static_visitor<std::string>
|
||||
class SpendingKeyEncoder
|
||||
{
|
||||
private:
|
||||
const KeyConstants& keyConstants;
|
||||
|
@ -264,7 +263,7 @@ std::string KeyIO::EncodeExtKey(const CExtKey& key)
|
|||
|
||||
std::string KeyIO::EncodeDestination(const CTxDestination& dest)
|
||||
{
|
||||
return boost::apply_visitor(DestinationEncoder(keyConstants), dest);
|
||||
return std::visit(DestinationEncoder(keyConstants), dest);
|
||||
}
|
||||
|
||||
bool KeyIO::IsValidDestinationString(const std::string& str)
|
||||
|
@ -274,7 +273,7 @@ bool KeyIO::IsValidDestinationString(const std::string& str)
|
|||
|
||||
std::string KeyIO::EncodePaymentAddress(const libzcash::PaymentAddress& zaddr)
|
||||
{
|
||||
return boost::apply_visitor(PaymentAddressEncoder(keyConstants), zaddr);
|
||||
return std::visit(PaymentAddressEncoder(keyConstants), zaddr);
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
|
@ -336,7 +335,7 @@ bool KeyIO::IsValidPaymentAddressString(const std::string& str) {
|
|||
|
||||
std::string KeyIO::EncodeViewingKey(const libzcash::ViewingKey& vk)
|
||||
{
|
||||
return boost::apply_visitor(ViewingKeyEncoder(keyConstants), vk);
|
||||
return std::visit(ViewingKeyEncoder(keyConstants), vk);
|
||||
}
|
||||
|
||||
libzcash::ViewingKey KeyIO::DecodeViewingKey(const std::string& str)
|
||||
|
@ -353,7 +352,7 @@ libzcash::ViewingKey KeyIO::DecodeViewingKey(const std::string& str)
|
|||
|
||||
std::string KeyIO::EncodeSpendingKey(const libzcash::SpendingKey& zkey)
|
||||
{
|
||||
return boost::apply_visitor(SpendingKeyEncoder(keyConstants), zkey);
|
||||
return std::visit(SpendingKeyEncoder(keyConstants), zkey);
|
||||
}
|
||||
|
||||
libzcash::SpendingKey KeyIO::DecodeSpendingKey(const std::string& str)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "zcash/NoteEncryption.hpp"
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
/** A virtual base class for key stores */
|
||||
class CKeyStore
|
||||
|
|
37
src/main.cpp
37
src/main.cpp
|
@ -39,6 +39,7 @@
|
|||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <sstream>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
|
@ -85,7 +86,7 @@ uint64_t nPruneTarget = 0;
|
|||
bool fAlerts = DEFAULT_ALERTS;
|
||||
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
|
||||
|
||||
boost::optional<unsigned int> expiryDeltaArg = boost::none;
|
||||
std::optional<unsigned int> expiryDeltaArg = std::nullopt;
|
||||
|
||||
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
|
||||
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
|
||||
|
@ -962,7 +963,7 @@ bool ContextualCheckTransaction(
|
|||
if (canopyActive) {
|
||||
libzcash::SaplingPaymentAddress zaddr(encPlaintext->d, outPlaintext->pk_d);
|
||||
for (auto it = fundingStreamElements.begin(); it != fundingStreamElements.end(); ++it) {
|
||||
const libzcash::SaplingPaymentAddress* streamAddr = boost::get<libzcash::SaplingPaymentAddress>(&(it->first));
|
||||
const libzcash::SaplingPaymentAddress* streamAddr = std::get_if<libzcash::SaplingPaymentAddress>(&(it->first));
|
||||
if (streamAddr && zaddr == *streamAddr && encPlaintext->value() == it->second) {
|
||||
fundingStreamElements.erase(it);
|
||||
break;
|
||||
|
@ -1012,7 +1013,7 @@ bool ContextualCheckTransaction(
|
|||
// Detect transparent funding streams.
|
||||
for (const CTxOut& output : tx.vout) {
|
||||
for (auto it = fundingStreamElements.begin(); it != fundingStreamElements.end(); ++it) {
|
||||
const CScript* taddr = boost::get<CScript>(&(it->first));
|
||||
const CScript* taddr = std::get_if<CScript>(&(it->first));
|
||||
if (taddr && output.scriptPubKey == *taddr && output.nValue == it->second) {
|
||||
fundingStreamElements.erase(it);
|
||||
break;
|
||||
|
@ -1967,7 +1968,7 @@ bool IsInitialBlockDownload(const Consensus::Params& params)
|
|||
// If an upgrade is active, we must be past its activation height.
|
||||
assert(chainActive[upgrade.nActivationHeight]);
|
||||
|
||||
if (chainActive[upgrade.nActivationHeight]->GetBlockHash() != upgrade.hashActivationBlock.get()) {
|
||||
if (chainActive[upgrade.nActivationHeight]->GetBlockHash() != upgrade.hashActivationBlock.value()) {
|
||||
AbortNode(
|
||||
strprintf(
|
||||
"%s: We are on a chain with sufficient work, but the activation block hash for the %s network upgrade is not as expected.\n"
|
||||
|
@ -1979,7 +1980,7 @@ bool IsInitialBlockDownload(const Consensus::Params& params)
|
|||
params.nMinimumChainWork.GetHex(),
|
||||
chainActive.Height(),
|
||||
upgrade.nActivationHeight,
|
||||
upgrade.hashActivationBlock.get().GetHex(),
|
||||
upgrade.hashActivationBlock.value().GetHex(),
|
||||
chainActive[upgrade.nActivationHeight]->GetBlockHash().GetHex()),
|
||||
_("We are on a chain with sufficient work, but the network upgrade checkpoints do not match. Your node may be under attack! Shutting down for safety."));
|
||||
return true;
|
||||
|
@ -2576,7 +2577,7 @@ static DisconnectResult DisconnectBlock(const CBlock& block, CValidationState& s
|
|||
|
||||
// This is guaranteed to be filled by LoadBlockIndex.
|
||||
assert(pindex->nCachedBranchId);
|
||||
auto consensusBranchId = pindex->nCachedBranchId.get();
|
||||
auto consensusBranchId = pindex->nCachedBranchId.value();
|
||||
|
||||
if (chainparams.GetConsensus().NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
view.PopHistoryNode(consensusBranchId);
|
||||
|
@ -2795,7 +2796,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
// Sapling
|
||||
//
|
||||
// If we've reached ConnectBlock, we have all transactions of
|
||||
// parents and can expect nChainSaplingValue not to be boost::none.
|
||||
// parents and can expect nChainSaplingValue not to be std::nullopt.
|
||||
// However, the miner and mining RPCs may not have populated this
|
||||
// value and will call `TestBlockValidity`. So, we act
|
||||
// conditionally.
|
||||
|
@ -3857,7 +3858,7 @@ void FallbackSproutValuePoolBalance(
|
|||
assert(*pindex->nChainSproutValue == chainparams.SproutValuePoolCheckpointBalance());
|
||||
// And we should expect non-none for the delta stored in the block index here,
|
||||
// or the checkpoint is too early.
|
||||
assert(pindex->nSproutValue != boost::none);
|
||||
assert(pindex->nSproutValue != std::nullopt);
|
||||
}
|
||||
} else {
|
||||
LogPrintf(
|
||||
|
@ -3893,9 +3894,9 @@ bool ReceivedBlockTransactions(
|
|||
}
|
||||
}
|
||||
pindexNew->nSproutValue = sproutValue;
|
||||
pindexNew->nChainSproutValue = boost::none;
|
||||
pindexNew->nChainSproutValue = std::nullopt;
|
||||
pindexNew->nSaplingValue = saplingValue;
|
||||
pindexNew->nChainSaplingValue = boost::none;
|
||||
pindexNew->nChainSaplingValue = std::nullopt;
|
||||
pindexNew->nFile = pos.nFile;
|
||||
pindexNew->nDataPos = pos.nPos;
|
||||
pindexNew->nUndoPos = 0;
|
||||
|
@ -3917,12 +3918,12 @@ bool ReceivedBlockTransactions(
|
|||
if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) {
|
||||
pindex->nChainSproutValue = *pindex->pprev->nChainSproutValue + *pindex->nSproutValue;
|
||||
} else {
|
||||
pindex->nChainSproutValue = boost::none;
|
||||
pindex->nChainSproutValue = std::nullopt;
|
||||
}
|
||||
if (pindex->pprev->nChainSaplingValue) {
|
||||
pindex->nChainSaplingValue = *pindex->pprev->nChainSaplingValue + pindex->nSaplingValue;
|
||||
} else {
|
||||
pindex->nChainSaplingValue = boost::none;
|
||||
pindex->nChainSaplingValue = std::nullopt;
|
||||
}
|
||||
} else {
|
||||
pindex->nChainSproutValue = pindex->nSproutValue;
|
||||
|
@ -4662,17 +4663,17 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
|||
if (pindex->pprev->nChainSproutValue && pindex->nSproutValue) {
|
||||
pindex->nChainSproutValue = *pindex->pprev->nChainSproutValue + *pindex->nSproutValue;
|
||||
} else {
|
||||
pindex->nChainSproutValue = boost::none;
|
||||
pindex->nChainSproutValue = std::nullopt;
|
||||
}
|
||||
if (pindex->pprev->nChainSaplingValue) {
|
||||
pindex->nChainSaplingValue = *pindex->pprev->nChainSaplingValue + pindex->nSaplingValue;
|
||||
} else {
|
||||
pindex->nChainSaplingValue = boost::none;
|
||||
pindex->nChainSaplingValue = std::nullopt;
|
||||
}
|
||||
} else {
|
||||
pindex->nChainTx = 0;
|
||||
pindex->nChainSproutValue = boost::none;
|
||||
pindex->nChainSaplingValue = boost::none;
|
||||
pindex->nChainSproutValue = std::nullopt;
|
||||
pindex->nChainSaplingValue = std::nullopt;
|
||||
mapBlocksUnlinked.insert(std::make_pair(pindex->pprev, pindex));
|
||||
}
|
||||
} else {
|
||||
|
@ -6981,7 +6982,7 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
|
|||
|
||||
bool blossomActive = consensusParams.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_BLOSSOM);
|
||||
unsigned int defaultExpiryDelta = blossomActive ? DEFAULT_POST_BLOSSOM_TX_EXPIRY_DELTA : DEFAULT_PRE_BLOSSOM_TX_EXPIRY_DELTA;
|
||||
mtx.nExpiryHeight = nHeight + (expiryDeltaArg ? expiryDeltaArg.get() : defaultExpiryDelta);
|
||||
mtx.nExpiryHeight = nHeight + (expiryDeltaArg ? expiryDeltaArg.value() : defaultExpiryDelta);
|
||||
|
||||
// mtx.nExpiryHeight == 0 is valid for coinbase transactions
|
||||
if (mtx.nExpiryHeight <= 0 || mtx.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD) {
|
||||
|
@ -6993,7 +6994,7 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
|
|||
// TX_EXPIRING_SOON_THRESHOLD (3) blocks (for DoS mitigation) based on the current height.
|
||||
auto nextActivationHeight = NextActivationHeight(nHeight, consensusParams);
|
||||
if (nextActivationHeight) {
|
||||
mtx.nExpiryHeight = std::min(mtx.nExpiryHeight, static_cast<uint32_t>(nextActivationHeight.get()) - 1);
|
||||
mtx.nExpiryHeight = std::min(mtx.nExpiryHeight, static_cast<uint32_t>(nextActivationHeight.value()) - 1);
|
||||
}
|
||||
}
|
||||
return mtx;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
@ -133,7 +134,7 @@ struct BlockHasher
|
|||
size_t operator()(const uint256& hash) const { return hash.GetCheapHash(); }
|
||||
};
|
||||
|
||||
extern boost::optional<unsigned int> expiryDeltaArg;
|
||||
extern std::optional<unsigned int> expiryDeltaArg;
|
||||
extern CScript COINBASE_FLAGS;
|
||||
extern CCriticalSection cs_main;
|
||||
extern CTxMemPool mempool;
|
||||
|
|
|
@ -118,11 +118,11 @@ void WeightedTxTree::remove(const uint256& txId)
|
|||
childWeights.pop_back();
|
||||
}
|
||||
|
||||
boost::optional<uint256> WeightedTxTree::maybeDropRandom()
|
||||
std::optional<uint256> WeightedTxTree::maybeDropRandom()
|
||||
{
|
||||
TxWeight totalTxWeight = getTotalWeight();
|
||||
if (totalTxWeight.cost <= capacity) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
LogPrint("mempool", "Mempool cost limit exceeded (cost=%d, limit=%d)\n", totalTxWeight.cost, capacity);
|
||||
int randomWeight = GetRand(totalTxWeight.evictionWeight);
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#define ZCASH_MEMPOOL_LIMIT_H
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "boost/optional.hpp"
|
||||
#include "primitives/transaction.h"
|
||||
#include "uint256.h"
|
||||
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
|
||||
// If the total cost limit is exceeded, pick a random number based on the total cost
|
||||
// of the collection and remove the associated transaction.
|
||||
boost::optional<uint256> maybeDropRandom();
|
||||
std::optional<uint256> maybeDropRandom();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
#include "utilmoneystr.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/range/irange.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/synchronized_value.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
|
@ -275,13 +276,13 @@ std::string DisplayHashRate(double value)
|
|||
return strprintf(_("%.3f TSol/s"), value / coef);
|
||||
}
|
||||
|
||||
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight)
|
||||
std::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight)
|
||||
{
|
||||
auto nextHeight = NextActivationHeight(currentHeight, params);
|
||||
if (nextHeight) {
|
||||
return (nextHeight.get() - currentHeight) * params.PoWTargetSpacing(nextHeight.get() - 1);
|
||||
return (nextHeight.value() - currentHeight) * params.PoWTargetSpacing(nextHeight.value() - 1);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -641,7 +642,7 @@ void ThreadShowMetricsScreen()
|
|||
}
|
||||
|
||||
// Lock and fetch stats before erasing the screen, in case we block.
|
||||
boost::optional<MetricsStats> metricsStats;
|
||||
std::optional<MetricsStats> metricsStats;
|
||||
if (loaded) {
|
||||
metricsStats = loadStats();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
struct AtomicCounter {
|
||||
|
@ -75,7 +76,7 @@ void TrackMinedBlock(uint256 hash);
|
|||
void MarkStartTime();
|
||||
double GetLocalSolPS();
|
||||
int EstimateNetHeight(const Consensus::Params& params, int currentBlockHeight, int64_t currentBlockTime);
|
||||
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight);
|
||||
std::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight);
|
||||
std::string DisplayDuration(int64_t time, DurationFormat format);
|
||||
std::string DisplaySize(size_t value);
|
||||
std::string DisplayHashRate(double value);
|
||||
|
|
|
@ -111,18 +111,18 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||
pblock->nTime = nTime;
|
||||
|
||||
// Updating time can change work required on testnet:
|
||||
if (consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none) {
|
||||
if (consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != std::nullopt) {
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsShieldedMinerAddress(const MinerAddress& minerAddr) {
|
||||
return !(
|
||||
minerAddr.type() == typeid(InvalidMinerAddress) ||
|
||||
minerAddr.type() == typeid(boost::shared_ptr<CReserveScript>));
|
||||
std::holds_alternative<InvalidMinerAddress>(minerAddr) ||
|
||||
std::holds_alternative<boost::shared_ptr<CReserveScript>>(minerAddr));
|
||||
}
|
||||
|
||||
class AddFundingStreamValueToTx : public boost::static_visitor<bool>
|
||||
class AddFundingStreamValueToTx
|
||||
{
|
||||
private:
|
||||
CMutableTransaction &mtx;
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
|
||||
auto odesc = output.Build(ctx);
|
||||
if (odesc) {
|
||||
mtx.vShieldedOutput.push_back(odesc.get());
|
||||
mtx.vShieldedOutput.push_back(odesc.value());
|
||||
mtx.valueBalance -= fundingStreamValue;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class AddOutputsToCoinbaseTxAndSign : public boost::static_visitor<>
|
||||
class AddOutputsToCoinbaseTxAndSign
|
||||
{
|
||||
private:
|
||||
CMutableTransaction &mtx;
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
|
||||
for (Consensus::FundingStreamElement fselem : fundingStreamElements) {
|
||||
miner_reward -= fselem.second;
|
||||
bool added = boost::apply_visitor(AddFundingStreamValueToTx(mtx, ctx, fselem.second, GetZip212Flag()), fselem.first);
|
||||
bool added = std::visit(AddFundingStreamValueToTx(mtx, ctx, fselem.second, GetZip212Flag()), fselem.first);
|
||||
if (!added) {
|
||||
librustzcash_sapling_proving_ctx_free(ctx);
|
||||
throw new std::runtime_error("Failed to add funding stream output.");
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
librustzcash_sapling_proving_ctx_free(ctx);
|
||||
throw new std::runtime_error("Failed to create shielded output for miner");
|
||||
}
|
||||
mtx.vShieldedOutput.push_back(odesc.get());
|
||||
mtx.vShieldedOutput.push_back(odesc.value());
|
||||
|
||||
ComputeBindingSig(ctx);
|
||||
|
||||
|
@ -297,7 +297,7 @@ CMutableTransaction CreateCoinbaseTransaction(const CChainParams& chainparams, C
|
|||
mtx.nExpiryHeight = 0;
|
||||
|
||||
// Add outputs and sign
|
||||
boost::apply_visitor(
|
||||
std::visit(
|
||||
AddOutputsToCoinbaseTxAndSign(mtx, chainparams, nHeight, nFees),
|
||||
minerAddress);
|
||||
|
||||
|
@ -667,7 +667,7 @@ void GetMinerAddress(MinerAddress &minerAddress)
|
|||
CTxDestination addr = keyIO.DecodeDestination(mAddrArg);
|
||||
if (IsValidDestination(addr)) {
|
||||
boost::shared_ptr<MinerAddressScript> mAddr(new MinerAddressScript());
|
||||
CKeyID keyID = boost::get<CKeyID>(addr);
|
||||
CKeyID keyID = std::get<CKeyID>(addr);
|
||||
|
||||
mAddr->reserveScript = CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
minerAddress = mAddr;
|
||||
|
@ -675,8 +675,8 @@ void GetMinerAddress(MinerAddress &minerAddress)
|
|||
// Try a Sapling address
|
||||
auto zaddr = keyIO.DecodePaymentAddress(mAddrArg);
|
||||
if (IsValidPaymentAddress(zaddr)) {
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
minerAddress = boost::get<libzcash::SaplingPaymentAddress>(zaddr);
|
||||
if (std::get_if<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
minerAddress = std::get<libzcash::SaplingPaymentAddress>(zaddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
|
|||
|
||||
try {
|
||||
// Throw an error if no address valid for mining was provided.
|
||||
if (!boost::apply_visitor(IsValidMinerAddress(), minerAddress)) {
|
||||
if (!std::visit(IsValidMinerAddress(), minerAddress)) {
|
||||
throw std::runtime_error("No miner address available (mining requires a wallet or -mineraddress)");
|
||||
}
|
||||
|
||||
|
@ -852,7 +852,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
|
|||
cancelSolver = false;
|
||||
}
|
||||
SetThreadPriority(THREAD_PRIORITY_LOWEST);
|
||||
boost::apply_visitor(KeepMinerAddress(), minerAddress);
|
||||
std::visit(KeepMinerAddress(), minerAddress);
|
||||
|
||||
// In regression test mode, stop mining after a block is found.
|
||||
if (chainparams.MineBlocksOnDemand()) {
|
||||
|
@ -931,7 +931,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
|
|||
// Update nNonce and nTime
|
||||
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
if (chainparams.GetConsensus().nPowAllowMinDifficultyBlocksAfterHeight != boost::none)
|
||||
if (chainparams.GetConsensus().nPowAllowMinDifficultyBlocksAfterHeight != std::nullopt)
|
||||
{
|
||||
// Changing pblock->nTime can change work required on testnet:
|
||||
hashTarget.SetCompact(pblock->nBits);
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include "primitives/block.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
class CBlockIndex;
|
||||
class CChainParams;
|
||||
|
@ -28,9 +28,9 @@ public:
|
|||
friend bool operator<(const InvalidMinerAddress &a, const InvalidMinerAddress &b) { return true; }
|
||||
};
|
||||
|
||||
typedef boost::variant<InvalidMinerAddress, libzcash::SaplingPaymentAddress, boost::shared_ptr<CReserveScript>> MinerAddress;
|
||||
typedef std::variant<InvalidMinerAddress, libzcash::SaplingPaymentAddress, boost::shared_ptr<CReserveScript>> MinerAddress;
|
||||
|
||||
class KeepMinerAddress : public boost::static_visitor<>
|
||||
class KeepMinerAddress
|
||||
{
|
||||
public:
|
||||
KeepMinerAddress() {}
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
bool IsShieldedMinerAddress(const MinerAddress& minerAddr);
|
||||
|
||||
class IsValidMinerAddress : public boost::static_visitor<bool>
|
||||
class IsValidMinerAddress
|
||||
{
|
||||
public:
|
||||
IsValidMinerAddress() {}
|
||||
|
|
|
@ -823,7 +823,7 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
|
|||
const Consensus::Params& params = Params().GetConsensus();
|
||||
auto nextEpoch = NextEpoch(height, params);
|
||||
if (nextEpoch) {
|
||||
auto idx = nextEpoch.get();
|
||||
auto idx = nextEpoch.value();
|
||||
int nActivationHeight = params.vUpgrades[idx].nActivationHeight;
|
||||
|
||||
if (nActivationHeight > 0 &&
|
||||
|
|
|
@ -30,8 +30,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
|||
{
|
||||
// Comparing to pindexLast->nHeight with >= because this function
|
||||
// returns the work required for the block after pindexLast.
|
||||
if (params.nPowAllowMinDifficultyBlocksAfterHeight != boost::none &&
|
||||
pindexLast->nHeight >= params.nPowAllowMinDifficultyBlocksAfterHeight.get())
|
||||
if (params.nPowAllowMinDifficultyBlocksAfterHeight != std::nullopt &&
|
||||
pindexLast->nHeight >= params.nPowAllowMinDifficultyBlocksAfterHeight.value())
|
||||
{
|
||||
// Special difficulty rule for testnet:
|
||||
// If the new block's timestamp is more than 6 * block interval minutes
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "consensus/consensus.h"
|
||||
|
||||
#include <array>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
#include "zcash/Zcash.h"
|
||||
|
@ -140,7 +140,7 @@ public:
|
|||
};
|
||||
|
||||
template <typename Stream>
|
||||
class SproutProofSerializer : public boost::static_visitor<>
|
||||
class SproutProofSerializer
|
||||
{
|
||||
Stream& s;
|
||||
bool useGroth;
|
||||
|
@ -169,7 +169,7 @@ template<typename Stream, typename T>
|
|||
inline void SerReadWriteSproutProof(Stream& s, const T& proof, bool useGroth, CSerActionSerialize ser_action)
|
||||
{
|
||||
auto ps = SproutProofSerializer<Stream>(s, useGroth);
|
||||
boost::apply_visitor(ps, proof);
|
||||
std::visit(ps, proof);
|
||||
}
|
||||
|
||||
template<typename Stream, typename T>
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
#include <zcash/JoinSplit.hpp>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <variant>
|
||||
|
||||
#include <librustzcash.h>
|
||||
|
||||
class SproutProofVerifier : public boost::static_visitor<bool>
|
||||
class SproutProofVerifier
|
||||
{
|
||||
ProofVerifier& verifier;
|
||||
const Ed25519VerificationKey& joinSplitPubKey;
|
||||
|
@ -66,5 +67,5 @@ bool ProofVerifier::VerifySprout(
|
|||
}
|
||||
|
||||
auto pv = SproutProofVerifier(*this, joinSplitPubKey, jsdesc);
|
||||
return boost::apply_visitor(pv, jsdesc.proof);
|
||||
return std::visit(pv, jsdesc.proof);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <univalue.h>
|
||||
|
||||
#include <optional>
|
||||
#include <regex>
|
||||
|
||||
using namespace std;
|
||||
|
@ -83,8 +84,8 @@ double GetNetworkDifficulty(const CBlockIndex* blockindex)
|
|||
|
||||
static UniValue ValuePoolDesc(
|
||||
const std::string &name,
|
||||
const boost::optional<CAmount> chainValue,
|
||||
const boost::optional<CAmount> valueDelta)
|
||||
const std::optional<CAmount> chainValue,
|
||||
const std::optional<CAmount> valueDelta)
|
||||
{
|
||||
UniValue rv(UniValue::VOBJ);
|
||||
rv.pushKV("id", name);
|
||||
|
@ -1059,8 +1060,8 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
|||
|
||||
CBlockIndex* tip = chainActive.Tip();
|
||||
UniValue valuePools(UniValue::VARR);
|
||||
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none));
|
||||
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
|
||||
valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, std::nullopt));
|
||||
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, std::nullopt));
|
||||
obj.pushKV("valuePools", valuePools);
|
||||
|
||||
const CChainParams& chainparams = Params();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
@ -189,13 +190,13 @@ UniValue generate(const UniValue& params, bool fHelp)
|
|||
GetMainSignals().AddressForMining(minerAddress);
|
||||
|
||||
// If the keypool is exhausted, no script is returned at all. Catch this.
|
||||
auto resv = boost::get<boost::shared_ptr<CReserveScript>>(&minerAddress);
|
||||
auto resv = std::get_if<boost::shared_ptr<CReserveScript>>(&minerAddress);
|
||||
if (resv && !resv->get()) {
|
||||
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
|
||||
}
|
||||
|
||||
// Throw an error if no address valid for mining was provided.
|
||||
if (!boost::apply_visitor(IsValidMinerAddress(), minerAddress)) {
|
||||
if (!std::visit(IsValidMinerAddress(), minerAddress)) {
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No miner address available (mining requires a wallet or -mineraddress)");
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ endloop:
|
|||
blockHashes.push_back(pblock->GetHash().GetHex());
|
||||
|
||||
//mark miner address as important because it was used at least for one coinbase output
|
||||
boost::apply_visitor(KeepMinerAddress(), minerAddress);
|
||||
std::visit(KeepMinerAddress(), minerAddress);
|
||||
}
|
||||
return blockHashes;
|
||||
}
|
||||
|
@ -670,7 +671,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Throw an error if no address valid for mining was provided.
|
||||
if (!boost::apply_visitor(IsValidMinerAddress(), minerAddress)) {
|
||||
if (!std::visit(IsValidMinerAddress(), minerAddress)) {
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "No miner address available (mining requires a wallet or -mineraddress)");
|
||||
}
|
||||
|
||||
|
@ -679,7 +680,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
|
||||
|
||||
// Mark script as important because it was used at least for one coinbase output
|
||||
boost::apply_visitor(KeepMinerAddress(), minerAddress);
|
||||
std::visit(KeepMinerAddress(), minerAddress);
|
||||
|
||||
// Need to update only after we know CreateNewBlock succeeded
|
||||
pindexPrev = pindexPrevNew;
|
||||
|
@ -980,9 +981,9 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp)
|
|||
fsobj.pushKV("valueZat", nStreamAmount);
|
||||
|
||||
auto fs = consensus.vFundingStreams[idx];
|
||||
auto address = fs.get().RecipientAddress(consensus, nHeight);
|
||||
auto address = fs.value().RecipientAddress(consensus, nHeight);
|
||||
|
||||
CScript* outpoint = boost::get<CScript>(&address);
|
||||
CScript* outpoint = std::get_if<CScript>(&address);
|
||||
std::string addressStr;
|
||||
|
||||
if (outpoint != nullptr) {
|
||||
|
@ -992,7 +993,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp)
|
|||
addressStr = find_value(pubkey, "addresses").get_array()[0].get_str();
|
||||
|
||||
} else {
|
||||
libzcash::SaplingPaymentAddress* zaddr = boost::get<libzcash::SaplingPaymentAddress>(&address);
|
||||
libzcash::SaplingPaymentAddress* zaddr = std::get_if<libzcash::SaplingPaymentAddress>(&address);
|
||||
if (zaddr != nullptr) {
|
||||
// For shielded funding stream addresses
|
||||
addressStr = keyIO.EncodePaymentAddress(*zaddr);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
|
@ -114,7 +115,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
class DescribeAddressVisitor : public boost::static_visitor<UniValue>
|
||||
class DescribeAddressVisitor
|
||||
{
|
||||
public:
|
||||
UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); }
|
||||
|
@ -203,7 +204,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
|
|||
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
||||
ret.pushKV("ismine", (mine & ISMINE_SPENDABLE) ? true : false);
|
||||
ret.pushKV("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false);
|
||||
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(), dest);
|
||||
UniValue detail = std::visit(DescribeAddressVisitor(), dest);
|
||||
ret.pushKVs(detail);
|
||||
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
|
||||
ret.pushKV("account", pwalletMain->mapAddressBook[dest].name);
|
||||
|
@ -213,7 +214,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
|
||||
class DescribePaymentAddressVisitor : public boost::static_visitor<UniValue>
|
||||
class DescribePaymentAddressVisitor
|
||||
{
|
||||
public:
|
||||
UniValue operator()(const libzcash::InvalidEncoding &zaddr) const { return UniValue(UniValue::VOBJ); }
|
||||
|
@ -287,7 +288,7 @@ UniValue z_validateaddress(const UniValue& params, bool fHelp)
|
|||
if (isValid)
|
||||
{
|
||||
ret.pushKV("address", strAddress);
|
||||
UniValue detail = boost::apply_visitor(DescribePaymentAddressVisitor(), address);
|
||||
UniValue detail = std::visit(DescribePaymentAddressVisitor(), address);
|
||||
ret.pushKVs(detail);
|
||||
}
|
||||
return ret;
|
||||
|
@ -323,7 +324,7 @@ CScript _createmultisig_redeemScript(const UniValue& params)
|
|||
// Case 1: Bitcoin address and we have full public key:
|
||||
CTxDestination dest = keyIO.DecodeDestination(ks);
|
||||
if (pwalletMain && IsValidDestination(dest)) {
|
||||
const CKeyID *keyID = boost::get<CKeyID>(&dest);
|
||||
const CKeyID *keyID = std::get_if<CKeyID>(&dest);
|
||||
if (!keyID) {
|
||||
throw std::runtime_error(strprintf("%s does not refer to a key", ks));
|
||||
}
|
||||
|
@ -438,7 +439,7 @@ UniValue verifymessage(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
|
||||
}
|
||||
|
||||
const CKeyID *keyID = boost::get<CKeyID>(&destination);
|
||||
const CKeyID *keyID = std::get_if<CKeyID>(&destination);
|
||||
if (!keyID) {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
|
||||
}
|
||||
|
@ -538,13 +539,13 @@ static bool getIndexKey(
|
|||
return false;
|
||||
}
|
||||
if (IsKeyDestination(dest)) {
|
||||
auto x = boost::get<CKeyID>(&dest);
|
||||
auto x = std::get_if<CKeyID>(&dest);
|
||||
memcpy(&hashBytes, x->begin(), 20);
|
||||
type = CScript::P2PKH;
|
||||
return true;
|
||||
}
|
||||
if (IsScriptDestination(dest)) {
|
||||
auto x = boost::get<CScriptID>(&dest);
|
||||
auto x = std::get_if<CScriptID>(&dest);
|
||||
memcpy(&hashBytes, x->begin(), 20);
|
||||
type = CScript::P2SH;
|
||||
return true;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/assign/list_of.hpp>
|
||||
|
||||
|
@ -103,7 +104,7 @@ UniValue TxJoinSplitToJSON(const CTransaction& tx) {
|
|||
|
||||
CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION);
|
||||
auto ps = SproutProofSerializer<CDataStream>(ssProof, useGroth);
|
||||
boost::apply_visitor(ps, jsdescription.proof);
|
||||
std::visit(ps, jsdescription.proof);
|
||||
joinsplit.pushKV("proof", HexStr(ssProof.begin(), ssProof.end()));
|
||||
|
||||
{
|
||||
|
|
|
@ -225,7 +225,7 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto
|
|||
|
||||
namespace
|
||||
{
|
||||
class CScriptVisitor : public boost::static_visitor<bool>
|
||||
class CScriptVisitor
|
||||
{
|
||||
private:
|
||||
CScript *script;
|
||||
|
@ -255,7 +255,7 @@ CScript GetScriptForDestination(const CTxDestination& dest)
|
|||
{
|
||||
CScript script;
|
||||
|
||||
boost::apply_visitor(CScriptVisitor(&script), dest);
|
||||
std::visit(CScriptVisitor(&script), dest);
|
||||
return script;
|
||||
}
|
||||
|
||||
|
@ -276,15 +276,15 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
|
|||
}
|
||||
|
||||
bool IsValidDestination(const CTxDestination& dest) {
|
||||
return dest.which() != 0;
|
||||
return !std::holds_alternative<CNoDestination>(dest);
|
||||
}
|
||||
|
||||
bool IsKeyDestination(const CTxDestination& dest) {
|
||||
return dest.which() == 1;
|
||||
return std::holds_alternative<CKeyID>(dest);
|
||||
}
|
||||
|
||||
bool IsScriptDestination(const CTxDestination& dest) {
|
||||
return dest.which() == 2;
|
||||
return std::holds_alternative<CScriptID>(dest);
|
||||
}
|
||||
|
||||
// insightexplorer
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include "script/interpreter.h"
|
||||
#include "uint256.h"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
static const bool DEFAULT_ACCEPT_DATACARRIER = true;
|
||||
|
||||
|
@ -66,6 +66,7 @@ enum txnouttype
|
|||
class CNoDestination {
|
||||
public:
|
||||
friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
|
||||
friend bool operator!=(const CNoDestination &a, const CNoDestination &b) { return false; }
|
||||
friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
|
||||
};
|
||||
|
||||
|
@ -76,7 +77,7 @@ public:
|
|||
* * CScriptID: TX_SCRIPTHASH destination
|
||||
* A CTxDestination is the internal data type encoded in a bitcoin address
|
||||
*/
|
||||
typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
|
||||
typedef std::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
|
||||
|
||||
/** Check whether a CTxDestination is a CNoDestination. */
|
||||
bool IsValidDestination(const CTxDestination& dest);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
@ -23,7 +24,6 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <rust/ed25519/types.h>
|
||||
|
||||
|
@ -538,8 +538,8 @@ template<typename Stream, typename T, typename A> inline void Unserialize(Stream
|
|||
/**
|
||||
* optional
|
||||
*/
|
||||
template<typename Stream, typename T> void Serialize(Stream& os, const boost::optional<T>& item);
|
||||
template<typename Stream, typename T> void Unserialize(Stream& is, boost::optional<T>& item);
|
||||
template<typename Stream, typename T> void Serialize(Stream& os, const std::optional<T>& item);
|
||||
template<typename Stream, typename T> void Unserialize(Stream& is, std::optional<T>& item);
|
||||
|
||||
/**
|
||||
* array
|
||||
|
@ -784,7 +784,7 @@ inline void Unserialize(Stream& is, std::vector<T, A>& v)
|
|||
* optional
|
||||
*/
|
||||
template<typename Stream, typename T>
|
||||
void Serialize(Stream& os, const boost::optional<T>& item)
|
||||
void Serialize(Stream& os, const std::optional<T>& item)
|
||||
{
|
||||
// If the value is there, put 0x01 and then serialize the value.
|
||||
// If it's not, put 0x00.
|
||||
|
@ -799,13 +799,13 @@ void Serialize(Stream& os, const boost::optional<T>& item)
|
|||
}
|
||||
|
||||
template<typename Stream, typename T>
|
||||
void Unserialize(Stream& is, boost::optional<T>& item)
|
||||
void Unserialize(Stream& is, std::optional<T>& item)
|
||||
{
|
||||
unsigned char discriminant = 0x00;
|
||||
Unserialize(is, discriminant);
|
||||
|
||||
if (discriminant == 0x00) {
|
||||
item = boost::none;
|
||||
item = std::nullopt;
|
||||
} else if (discriminant == 0x01) {
|
||||
T object;
|
||||
Unserialize(is, object);
|
||||
|
|
|
@ -644,7 +644,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits)
|
|||
CMutableTransaction mtx;
|
||||
mtx.vJoinSplit.push_back(js2);
|
||||
|
||||
BOOST_CHECK(cache.HaveShieldedRequirements(mtx) == std::optional(UnsatisfiedShieldedReq::SproutUnknownAnchor));
|
||||
BOOST_CHECK(cache.HaveShieldedRequirements(mtx) == std::optional<UnsatisfiedShieldedReq>(UnsatisfiedShieldedReq::SproutUnknownAnchor));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -654,7 +654,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits)
|
|||
mtx.vJoinSplit.push_back(js2);
|
||||
mtx.vJoinSplit.push_back(js1);
|
||||
|
||||
BOOST_CHECK(cache.HaveShieldedRequirements(mtx) == std::optional(UnsatisfiedShieldedReq::SproutUnknownAnchor));
|
||||
BOOST_CHECK(cache.HaveShieldedRequirements(mtx) == std::optional<UnsatisfiedShieldedReq>(UnsatisfiedShieldedReq::SproutUnknownAnchor));
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "zcash/Address.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
@ -202,8 +203,8 @@ BOOST_AUTO_TEST_CASE(zc_address_test)
|
|||
|
||||
auto spendingkey2 = keyIO.DecodeSpendingKey(sk_string);
|
||||
BOOST_CHECK(IsValidSpendingKey(spendingkey2));
|
||||
BOOST_ASSERT(boost::get<SproutSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = boost::get<SproutSpendingKey>(spendingkey2);
|
||||
BOOST_ASSERT(std::get_if<SproutSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = std::get<SproutSpendingKey>(spendingkey2);
|
||||
BOOST_CHECK(sk.inner() == sk2.inner());
|
||||
}
|
||||
{
|
||||
|
@ -217,8 +218,8 @@ BOOST_AUTO_TEST_CASE(zc_address_test)
|
|||
auto paymentaddr2 = keyIO.DecodePaymentAddress(addr_string);
|
||||
BOOST_ASSERT(IsValidPaymentAddress(paymentaddr2));
|
||||
|
||||
BOOST_ASSERT(boost::get<SproutPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = boost::get<SproutPaymentAddress>(paymentaddr2);
|
||||
BOOST_ASSERT(std::get_if<SproutPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = std::get<SproutPaymentAddress>(paymentaddr2);
|
||||
BOOST_CHECK(addr.a_pk == addr2.a_pk);
|
||||
BOOST_CHECK(addr.pk_enc == addr2.pk_enc);
|
||||
}
|
||||
|
@ -241,8 +242,8 @@ BOOST_AUTO_TEST_CASE(zs_address_test)
|
|||
auto spendingkey2 = keyIO.DecodeSpendingKey(sk_string);
|
||||
BOOST_CHECK(IsValidSpendingKey(spendingkey2));
|
||||
|
||||
BOOST_ASSERT(boost::get<SaplingExtendedSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = boost::get<SaplingExtendedSpendingKey>(spendingkey2);
|
||||
BOOST_ASSERT(std::get_if<SaplingExtendedSpendingKey>(&spendingkey2) != nullptr);
|
||||
auto sk2 = std::get<SaplingExtendedSpendingKey>(spendingkey2);
|
||||
BOOST_CHECK(sk == sk2);
|
||||
}
|
||||
{
|
||||
|
@ -254,8 +255,8 @@ BOOST_AUTO_TEST_CASE(zs_address_test)
|
|||
auto paymentaddr2 = keyIO.DecodePaymentAddress(addr_string);
|
||||
BOOST_CHECK(IsValidPaymentAddress(paymentaddr2));
|
||||
|
||||
BOOST_ASSERT(boost::get<SaplingPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = boost::get<SaplingPaymentAddress>(paymentaddr2);
|
||||
BOOST_ASSERT(std::get_if<SaplingPaymentAddress>(&paymentaddr2) != nullptr);
|
||||
auto addr2 = std::get<SaplingPaymentAddress>(paymentaddr2);
|
||||
BOOST_CHECK(addr == addr2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "script/standard.h"
|
||||
#include "test/test_bitcoin.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
|
@ -175,23 +177,23 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
|
|||
s.clear();
|
||||
s << ToByteVector(pubkey) << OP_CHECKSIG;
|
||||
BOOST_CHECK(ExtractDestination(s, address));
|
||||
BOOST_CHECK(boost::get<CKeyID>(&address) &&
|
||||
*boost::get<CKeyID>(&address) == pubkey.GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&address) &&
|
||||
std::get<CKeyID>(address) == pubkey.GetID());
|
||||
|
||||
// TX_PUBKEYHASH
|
||||
s.clear();
|
||||
s << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
BOOST_CHECK(ExtractDestination(s, address));
|
||||
BOOST_CHECK(boost::get<CKeyID>(&address) &&
|
||||
*boost::get<CKeyID>(&address) == pubkey.GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&address) &&
|
||||
std::get<CKeyID>(address) == pubkey.GetID());
|
||||
|
||||
// TX_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<CScriptID>(&address) &&
|
||||
*boost::get<CScriptID>(&address) == CScriptID(redeemScript));
|
||||
BOOST_CHECK(std::get_if<CScriptID>(&address) &&
|
||||
std::get<CScriptID>(address) == CScriptID(redeemScript));
|
||||
|
||||
// TX_MULTISIG
|
||||
s.clear();
|
||||
|
@ -235,8 +237,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
|
|||
BOOST_CHECK_EQUAL(whichType, TX_PUBKEY);
|
||||
BOOST_CHECK_EQUAL(addresses.size(), 1);
|
||||
BOOST_CHECK_EQUAL(nRequired, 1);
|
||||
BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
|
||||
*boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&addresses[0]) &&
|
||||
std::get<CKeyID>(addresses[0]) == pubkeys[0].GetID());
|
||||
|
||||
// TX_PUBKEYHASH
|
||||
s.clear();
|
||||
|
@ -245,8 +247,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
|
|||
BOOST_CHECK_EQUAL(whichType, TX_PUBKEYHASH);
|
||||
BOOST_CHECK_EQUAL(addresses.size(), 1);
|
||||
BOOST_CHECK_EQUAL(nRequired, 1);
|
||||
BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
|
||||
*boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&addresses[0]) &&
|
||||
std::get<CKeyID>(addresses[0]) == pubkeys[0].GetID());
|
||||
|
||||
// TX_SCRIPTHASH
|
||||
CScript redeemScript(s); // initialize with leftover P2PKH script
|
||||
|
@ -256,8 +258,8 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
|
|||
BOOST_CHECK_EQUAL(whichType, TX_SCRIPTHASH);
|
||||
BOOST_CHECK_EQUAL(addresses.size(), 1);
|
||||
BOOST_CHECK_EQUAL(nRequired, 1);
|
||||
BOOST_CHECK(boost::get<CScriptID>(&addresses[0]) &&
|
||||
*boost::get<CScriptID>(&addresses[0]) == CScriptID(redeemScript));
|
||||
BOOST_CHECK(std::get_if<CScriptID>(&addresses[0]) &&
|
||||
std::get<CScriptID>(addresses[0]) == CScriptID(redeemScript));
|
||||
|
||||
// TX_MULTISIG
|
||||
s.clear();
|
||||
|
@ -269,10 +271,10 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
|
|||
BOOST_CHECK_EQUAL(whichType, TX_MULTISIG);
|
||||
BOOST_CHECK_EQUAL(addresses.size(), 2);
|
||||
BOOST_CHECK_EQUAL(nRequired, 2);
|
||||
BOOST_CHECK(boost::get<CKeyID>(&addresses[0]) &&
|
||||
*boost::get<CKeyID>(&addresses[0]) == pubkeys[0].GetID());
|
||||
BOOST_CHECK(boost::get<CKeyID>(&addresses[1]) &&
|
||||
*boost::get<CKeyID>(&addresses[1]) == pubkeys[1].GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&addresses[0]) &&
|
||||
std::get<CKeyID>(addresses[0]) == pubkeys[0].GetID());
|
||||
BOOST_CHECK(std::get_if<CKeyID>(&addresses[1]) &&
|
||||
std::get<CKeyID>(addresses[1]) == pubkeys[1].GetID());
|
||||
|
||||
// TX_NULL_DATA
|
||||
s.clear();
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#include "utilstrencodings.h"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -83,15 +83,15 @@ public:
|
|||
|
||||
BOOST_AUTO_TEST_CASE(boost_optional)
|
||||
{
|
||||
check_ser_rep<boost::optional<unsigned char>>(0xff, {0x01, 0xff});
|
||||
check_ser_rep<boost::optional<unsigned char>>(boost::none, {0x00});
|
||||
check_ser_rep<boost::optional<std::string>>(std::string("Test"), {0x01, 0x04, 'T', 'e', 's', 't'});
|
||||
check_ser_rep<std::optional<unsigned char>>(0xff, {0x01, 0xff});
|
||||
check_ser_rep<std::optional<unsigned char>>(std::nullopt, {0x00});
|
||||
check_ser_rep<std::optional<std::string>>(std::string("Test"), {0x01, 0x04, 'T', 'e', 's', 't'});
|
||||
|
||||
{
|
||||
// Ensure that canonical optional discriminant is used
|
||||
CDataStream ss(SER_DISK, 0);
|
||||
ss.write("\x02\x04Test", 6);
|
||||
boost::optional<std::string> into;
|
||||
std::optional<std::string> into;
|
||||
|
||||
BOOST_CHECK_THROW(ss >> into, std::ios_base::failure);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "utilmoneystr.h"
|
||||
#include "zcash/Note.hpp"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <librustzcash.h>
|
||||
#include <rust/ed25519.h>
|
||||
|
||||
|
@ -25,19 +24,19 @@ SpendDescriptionInfo::SpendDescriptionInfo(
|
|||
librustzcash_sapling_generate_r(alpha.begin());
|
||||
}
|
||||
|
||||
boost::optional<OutputDescription> OutputDescriptionInfo::Build(void* ctx) {
|
||||
std::optional<OutputDescription> OutputDescriptionInfo::Build(void* ctx) {
|
||||
auto cmu = this->note.cmu();
|
||||
if (!cmu) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
libzcash::SaplingNotePlaintext notePlaintext(this->note, this->memo);
|
||||
|
||||
auto res = notePlaintext.encrypt(this->note.pk_d);
|
||||
if (!res) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
auto encryptor = enc.second;
|
||||
|
||||
libzcash::SaplingPaymentAddress address(this->note.d, this->note.pk_d);
|
||||
|
@ -55,7 +54,7 @@ boost::optional<OutputDescription> OutputDescriptionInfo::Build(void* ctx) {
|
|||
this->note.value(),
|
||||
odesc.cv.begin(),
|
||||
odesc.zkproof.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
odesc.cmu = *cmu;
|
||||
|
@ -76,13 +75,13 @@ TransactionBuilderResult::TransactionBuilderResult(const CTransaction& tx) : may
|
|||
|
||||
TransactionBuilderResult::TransactionBuilderResult(const std::string& error) : maybeError(error) {}
|
||||
|
||||
bool TransactionBuilderResult::IsTx() { return maybeTx != boost::none; }
|
||||
bool TransactionBuilderResult::IsTx() { return maybeTx != std::nullopt; }
|
||||
|
||||
bool TransactionBuilderResult::IsError() { return maybeError != boost::none; }
|
||||
bool TransactionBuilderResult::IsError() { return maybeError != std::nullopt; }
|
||||
|
||||
CTransaction TransactionBuilderResult::GetTxOrThrow() {
|
||||
if (maybeTx) {
|
||||
return maybeTx.get();
|
||||
return maybeTx.value();
|
||||
} else {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Failed to build transaction: " + GetError());
|
||||
}
|
||||
|
@ -90,7 +89,7 @@ CTransaction TransactionBuilderResult::GetTxOrThrow() {
|
|||
|
||||
std::string TransactionBuilderResult::GetError() {
|
||||
if (maybeError) {
|
||||
return maybeError.get();
|
||||
return maybeError.value();
|
||||
} else {
|
||||
// This can only happen if isTx() is true in which case we should not call getError()
|
||||
throw std::runtime_error("getError() was called in TransactionBuilderResult, but the result was not initialized as an error.");
|
||||
|
@ -228,15 +227,15 @@ void TransactionBuilder::SetFee(CAmount fee)
|
|||
void TransactionBuilder::SendChangeTo(libzcash::SaplingPaymentAddress changeAddr, uint256 ovk)
|
||||
{
|
||||
saplingChangeAddr = std::make_pair(ovk, changeAddr);
|
||||
sproutChangeAddr = boost::none;
|
||||
tChangeAddr = boost::none;
|
||||
sproutChangeAddr = std::nullopt;
|
||||
tChangeAddr = std::nullopt;
|
||||
}
|
||||
|
||||
void TransactionBuilder::SendChangeTo(libzcash::SproutPaymentAddress changeAddr)
|
||||
{
|
||||
sproutChangeAddr = changeAddr;
|
||||
saplingChangeAddr = boost::none;
|
||||
tChangeAddr = boost::none;
|
||||
saplingChangeAddr = std::nullopt;
|
||||
tChangeAddr = std::nullopt;
|
||||
}
|
||||
|
||||
void TransactionBuilder::SendChangeTo(CTxDestination& changeAddr)
|
||||
|
@ -246,8 +245,8 @@ void TransactionBuilder::SendChangeTo(CTxDestination& changeAddr)
|
|||
}
|
||||
|
||||
tChangeAddr = changeAddr;
|
||||
saplingChangeAddr = boost::none;
|
||||
sproutChangeAddr = boost::none;
|
||||
saplingChangeAddr = std::nullopt;
|
||||
sproutChangeAddr = std::nullopt;
|
||||
}
|
||||
|
||||
TransactionBuilderResult TransactionBuilder::Build()
|
||||
|
@ -286,7 +285,7 @@ TransactionBuilderResult TransactionBuilder::Build()
|
|||
if (saplingChangeAddr) {
|
||||
AddSaplingOutput(saplingChangeAddr->first, saplingChangeAddr->second, change);
|
||||
} else if (sproutChangeAddr) {
|
||||
AddSproutOutput(sproutChangeAddr.get(), change);
|
||||
AddSproutOutput(sproutChangeAddr.value(), change);
|
||||
} else if (tChangeAddr) {
|
||||
// tChangeAddr has already been validated.
|
||||
AddTransparentOutput(tChangeAddr.value(), change);
|
||||
|
@ -361,7 +360,7 @@ TransactionBuilderResult TransactionBuilder::Build()
|
|||
return TransactionBuilderResult("Failed to create output description");
|
||||
}
|
||||
|
||||
mtx.vShieldedOutput.push_back(odesc.get());
|
||||
mtx.vShieldedOutput.push_back(odesc.value());
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -567,7 +566,7 @@ void TransactionBuilder::CreateJSDescriptions()
|
|||
|
||||
assert(changeOutputIndex != -1);
|
||||
assert(changeOutputIndex < prevJoinSplit.commitments.size());
|
||||
boost::optional<SproutWitness> changeWitness;
|
||||
std::optional<SproutWitness> changeWitness;
|
||||
int n = 0;
|
||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||
tree.append(commitment);
|
||||
|
@ -575,7 +574,7 @@ void TransactionBuilder::CreateJSDescriptions()
|
|||
if (!changeWitness && changeOutputIndex == n++) {
|
||||
changeWitness = tree.witness();
|
||||
} else if (changeWitness) {
|
||||
changeWitness.get().append(commitment);
|
||||
changeWitness.value().append(commitment);
|
||||
}
|
||||
}
|
||||
assert(changeWitness.has_value());
|
||||
|
@ -594,7 +593,7 @@ void TransactionBuilder::CreateJSDescriptions()
|
|||
(unsigned char)changeOutputIndex);
|
||||
|
||||
auto note = plaintext.note(changeAddress);
|
||||
vjsin[0] = libzcash::JSInput(changeWitness.get(), note, changeKey);
|
||||
vjsin[0] = libzcash::JSInput(changeWitness.value(), note, changeKey);
|
||||
|
||||
jsInputValue += plaintext.value();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "zcash/Note.hpp"
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
#define NO_MEMO {{0xF6}}
|
||||
|
||||
|
@ -46,7 +46,7 @@ struct OutputDescriptionInfo {
|
|||
libzcash::SaplingNote note,
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo) : ovk(ovk), note(note), memo(memo) {}
|
||||
|
||||
boost::optional<OutputDescription> Build(void* ctx);
|
||||
std::optional<OutputDescription> Build(void* ctx);
|
||||
};
|
||||
|
||||
struct TransparentInputInfo {
|
||||
|
@ -60,8 +60,8 @@ struct TransparentInputInfo {
|
|||
|
||||
class TransactionBuilderResult {
|
||||
private:
|
||||
boost::optional<CTransaction> maybeTx;
|
||||
boost::optional<std::string> maybeError;
|
||||
std::optional<CTransaction> maybeTx;
|
||||
std::optional<std::string> maybeError;
|
||||
public:
|
||||
TransactionBuilderResult() = delete;
|
||||
TransactionBuilderResult(const CTransaction& tx);
|
||||
|
@ -89,9 +89,9 @@ private:
|
|||
std::vector<libzcash::JSOutput> jsOutputs;
|
||||
std::vector<TransparentInputInfo> tIns;
|
||||
|
||||
boost::optional<std::pair<uint256, libzcash::SaplingPaymentAddress>> saplingChangeAddr;
|
||||
boost::optional<libzcash::SproutPaymentAddress> sproutChangeAddr;
|
||||
boost::optional<CTxDestination> tChangeAddr;
|
||||
std::optional<std::pair<uint256, libzcash::SaplingPaymentAddress>> saplingChangeAddr;
|
||||
std::optional<libzcash::SproutPaymentAddress> sproutChangeAddr;
|
||||
std::optional<CTxDestination> tChangeAddr;
|
||||
|
||||
public:
|
||||
TransactionBuilder() {}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include "validationinterface.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
CTxMemPoolEntry::CTxMemPoolEntry():
|
||||
|
@ -839,9 +841,9 @@ bool CTxMemPool::IsRecentlyEvicted(const uint256& txId) {
|
|||
|
||||
void CTxMemPool::EnsureSizeLimit() {
|
||||
AssertLockHeld(cs);
|
||||
boost::optional<uint256> maybeDropTxId;
|
||||
while ((maybeDropTxId = weightedTxTree->maybeDropRandom()).is_initialized()) {
|
||||
uint256 txId = maybeDropTxId.get();
|
||||
std::optional<uint256> maybeDropTxId;
|
||||
while ((maybeDropTxId = weightedTxTree->maybeDropRandom()).has_value()) {
|
||||
uint256 txId = maybeDropTxId.value();
|
||||
recentlyEvicted->add(txId);
|
||||
std::list<CTransaction> removed;
|
||||
remove(mapTx.find(txId)->GetTx(), removed, true);
|
||||
|
|
|
@ -290,7 +290,7 @@ CKey AddTestCKeyToKeyStore(CBasicKeyStore& keyStore) {
|
|||
TestSaplingNote GetTestSaplingNote(const libzcash::SaplingPaymentAddress& pa, CAmount value) {
|
||||
// Generate dummy Sapling note
|
||||
libzcash::SaplingNote note(pa, value, libzcash::Zip212Enabled::BeforeZip212);
|
||||
uint256 cm = note.cmu().get();
|
||||
uint256 cm = note.cmu().value();
|
||||
SaplingMerkleTree tree;
|
||||
tree.append(cm);
|
||||
return { note, tree };
|
||||
|
|
|
@ -189,7 +189,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
|
|||
SyncWithWallets(tx, NULL, pindexLastTip->nHeight);
|
||||
}
|
||||
// Update cached incremental witnesses
|
||||
GetMainSignals().ChainTip(pindexLastTip, &block, boost::none);
|
||||
GetMainSignals().ChainTip(pindexLastTip, &block, std::nullopt);
|
||||
|
||||
// On to the next block!
|
||||
pindexLastTip = pindexLastTip->pprev;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#ifndef BITCOIN_VALIDATIONINTERFACE_H
|
||||
#define BITCOIN_VALIDATIONINTERFACE_H
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
|
@ -35,7 +37,7 @@ protected:
|
|||
virtual void UpdatedBlockTip(const CBlockIndex *pindex) {}
|
||||
virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock, const int nHeight) {}
|
||||
virtual void EraseFromWallet(const uint256 &hash) {}
|
||||
virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, boost::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added) {}
|
||||
virtual void ChainTip(const CBlockIndex *pindex, const CBlock *pblock, std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added) {}
|
||||
virtual void UpdatedTransaction(const uint256 &hash) {}
|
||||
virtual void Inventory(const uint256 &hash) {}
|
||||
virtual void ResendWalletTransactions(int64_t nBestBlockTime) {}
|
||||
|
@ -57,7 +59,7 @@ struct CMainSignals {
|
|||
/** Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). */
|
||||
boost::signals2::signal<void (const uint256 &)> UpdatedTransaction;
|
||||
/** Notifies listeners of a change to the tip of the active block chain. */
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlock *, boost::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>>)> ChainTip;
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlock *, std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>>)> ChainTip;
|
||||
/** Notifies listeners about an inventory item being seen on the network. */
|
||||
boost::signals2::signal<void (const uint256 &)> Inventory;
|
||||
/** Tells listeners to broadcast their data. */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||
|
||||
UniValue SendTransaction(CTransaction& tx, boost::optional<CReserveKey&> reservekey, bool testmode) {
|
||||
UniValue SendTransaction(CTransaction& tx, std::optional<std::reference_wrapper<CReserveKey>> reservekey, bool testmode) {
|
||||
UniValue o(UniValue::VOBJ);
|
||||
// Send the transaction
|
||||
if (!testmode) {
|
||||
|
@ -25,7 +25,7 @@ UniValue SendTransaction(CTransaction& tx, boost::optional<CReserveKey&> reserve
|
|||
return o;
|
||||
}
|
||||
|
||||
std::pair<CTransaction, UniValue> SignSendRawTransaction(UniValue obj, boost::optional<CReserveKey&> reservekey, bool testmode) {
|
||||
std::pair<CTransaction, UniValue> SignSendRawTransaction(UniValue obj, std::optional<std::reference_wrapper<CReserveKey>> reservekey, bool testmode) {
|
||||
// Sign the raw transaction
|
||||
UniValue rawtxnValue = find_value(obj, "rawtxn");
|
||||
if (rawtxnValue.isNull()) {
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "univalue.h"
|
||||
#include "wallet.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
* Sends a given transaction.
|
||||
*
|
||||
|
@ -18,7 +20,7 @@
|
|||
* If testmode is true, do not commit the transaction,
|
||||
* return {"test": 1, "txid": tx.GetHash().ToString(), "hex": EncodeHexTx(tx)}
|
||||
*/
|
||||
UniValue SendTransaction(CTransaction& tx, boost::optional<CReserveKey&> reservekey, bool testmode);
|
||||
UniValue SendTransaction(CTransaction& tx, std::optional<std::reference_wrapper<CReserveKey>> reservekey, bool testmode);
|
||||
|
||||
/**
|
||||
* Sign and send a raw transaction.
|
||||
|
@ -26,6 +28,6 @@ UniValue SendTransaction(CTransaction& tx, boost::optional<CReserveKey&> reserve
|
|||
*
|
||||
* Returns a pair of (the parsed transaction, and the result of sending)
|
||||
*/
|
||||
std::pair<CTransaction, UniValue> SignSendRawTransaction(UniValue obj, boost::optional<CReserveKey&> reservekey, bool testmode);
|
||||
std::pair<CTransaction, UniValue> SignSendRawTransaction(UniValue obj, std::optional<std::reference_wrapper<CReserveKey>> reservekey, bool testmode);
|
||||
|
||||
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_COMMON_H
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <variant>
|
||||
|
||||
#include <rust/ed25519.h>
|
||||
|
||||
|
@ -56,7 +57,7 @@ int mta_find_output(UniValue obj, int n)
|
|||
}
|
||||
|
||||
AsyncRPCOperation_mergetoaddress::AsyncRPCOperation_mergetoaddress(
|
||||
boost::optional<TransactionBuilder> builder,
|
||||
std::optional<TransactionBuilder> builder,
|
||||
CMutableTransaction contextualTx,
|
||||
std::vector<MergeToAddressInputUTXO> utxoInputs,
|
||||
std::vector<MergeToAddressInputSproutNote> sproutNoteInputs,
|
||||
|
@ -90,7 +91,7 @@ AsyncRPCOperation_mergetoaddress::AsyncRPCOperation_mergetoaddress(
|
|||
isUsingBuilder_ = false;
|
||||
if (builder) {
|
||||
isUsingBuilder_ = true;
|
||||
builder_ = builder.get();
|
||||
builder_ = builder.value();
|
||||
}
|
||||
|
||||
KeyIO keyIO(Params());
|
||||
|
@ -295,7 +296,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
builder_.AddTransparentInput(outPoint, scriptPubKey, amount);
|
||||
}
|
||||
|
||||
boost::optional<uint256> ovk;
|
||||
std::optional<uint256> ovk;
|
||||
// Select Sapling notes
|
||||
std::vector<SaplingOutPoint> saplingOPs;
|
||||
std::vector<SaplingNote> saplingNotes;
|
||||
|
@ -312,7 +313,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
|
||||
// Fetch Sapling anchor and witnesses
|
||||
uint256 anchor;
|
||||
std::vector<boost::optional<SaplingWitness>> witnesses;
|
||||
std::vector<std::optional<SaplingWitness>> witnesses;
|
||||
{
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
pwalletMain->GetSaplingNoteWitnesses(saplingOPs, witnesses, anchor);
|
||||
|
@ -323,7 +324,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
if (!witnesses[i]) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Missing witness for Sapling note");
|
||||
}
|
||||
builder_.AddSaplingSpend(expsks[i], saplingNotes[i], anchor, witnesses[i].get());
|
||||
builder_.AddSaplingSpend(expsks[i], saplingNotes[i], anchor, witnesses[i].value());
|
||||
}
|
||||
|
||||
if (isToTaddr_) {
|
||||
|
@ -332,7 +333,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
std::string zaddr = std::get<0>(recipient_);
|
||||
std::string memo = std::get<1>(recipient_);
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> hexMemo = get_memo_from_hex_string(memo);
|
||||
auto saplingPaymentAddress = boost::get<libzcash::SaplingPaymentAddress>(&toPaymentAddress_);
|
||||
auto saplingPaymentAddress = std::get_if<libzcash::SaplingPaymentAddress>(&toPaymentAddress_);
|
||||
if (saplingPaymentAddress == nullptr) {
|
||||
// This should never happen as we have already determined that the payment is to sapling
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Could not get Sapling payment address.");
|
||||
|
@ -348,13 +349,13 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
if (!ovk) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Sending to a Sapling address requires an ovk.");
|
||||
}
|
||||
builder_.AddSaplingOutput(ovk.get(), *saplingPaymentAddress, sendAmount, hexMemo);
|
||||
builder_.AddSaplingOutput(ovk.value(), *saplingPaymentAddress, sendAmount, hexMemo);
|
||||
}
|
||||
|
||||
// Build the transaction
|
||||
tx_ = builder_.Build().GetTxOrThrow();
|
||||
|
||||
UniValue sendResult = SendTransaction(tx_, boost::none, testmode);
|
||||
UniValue sendResult = SendTransaction(tx_, std::nullopt, testmode);
|
||||
set_result(sendResult);
|
||||
|
||||
return true;
|
||||
|
@ -374,7 +375,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
if (isPureTaddrOnlyTx) {
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("rawtxn", EncodeHexTx(tx_));
|
||||
auto txAndResult = SignSendRawTransaction(obj, boost::none, testmode);
|
||||
auto txAndResult = SignSendRawTransaction(obj, std::nullopt, testmode);
|
||||
tx_ = txAndResult.first;
|
||||
set_result(txAndResult.second);
|
||||
return true;
|
||||
|
@ -405,14 +406,14 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
info.vpub_old = sendAmount;
|
||||
info.vpub_new = 0;
|
||||
|
||||
JSOutput jso = JSOutput(boost::get<libzcash::SproutPaymentAddress>(toPaymentAddress_), sendAmount);
|
||||
JSOutput jso = JSOutput(std::get<libzcash::SproutPaymentAddress>(toPaymentAddress_), sendAmount);
|
||||
if (hexMemo.size() > 0) {
|
||||
jso.memo = get_memo_from_hex_string(hexMemo);
|
||||
}
|
||||
info.vjsout.push_back(jso);
|
||||
|
||||
UniValue obj = perform_joinsplit(info);
|
||||
auto txAndResult = SignSendRawTransaction(obj, boost::none, testmode);
|
||||
auto txAndResult = SignSendRawTransaction(obj, std::nullopt, testmode);
|
||||
tx_ = txAndResult.first;
|
||||
set_result(txAndResult.second);
|
||||
return true;
|
||||
|
@ -437,7 +438,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
JSOutPoint jso = std::get<0>(t);
|
||||
std::vector<JSOutPoint> vOutPoints = {jso};
|
||||
uint256 inputAnchor;
|
||||
std::vector<boost::optional<SproutWitness>> vInputWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> vInputWitnesses;
|
||||
pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
|
||||
jsopWitnessAnchorMap[jso.ToString()] = MergeToAddressWitnessAnchorData{vInputWitnesses[0], inputAnchor};
|
||||
}
|
||||
|
@ -501,7 +502,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
|
||||
CAmount jsInputValue = 0;
|
||||
uint256 jsAnchor;
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
|
||||
JSDescription prevJoinSplit;
|
||||
|
||||
|
@ -532,7 +533,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
}
|
||||
|
||||
assert(changeOutputIndex != -1);
|
||||
boost::optional<SproutWitness> changeWitness;
|
||||
std::optional<SproutWitness> changeWitness;
|
||||
int n = 0;
|
||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||
tree.append(commitment);
|
||||
|
@ -540,7 +541,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
if (!changeWitness && changeOutputIndex == n++) {
|
||||
changeWitness = tree.witness();
|
||||
} else if (changeWitness) {
|
||||
changeWitness.get().append(commitment);
|
||||
changeWitness.value().append(commitment);
|
||||
}
|
||||
}
|
||||
if (changeWitness) {
|
||||
|
@ -582,7 +583,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
std::vector<SproutNote> vInputNotes;
|
||||
std::vector<SproutSpendingKey> vInputZKeys;
|
||||
std::vector<JSOutPoint> vOutPoints;
|
||||
std::vector<boost::optional<SproutWitness>> vInputWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> vInputWitnesses;
|
||||
uint256 inputAnchor;
|
||||
int numInputsNeeded = (jsChange > 0) ? 1 : 0;
|
||||
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
||||
|
@ -639,7 +640,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
if (!optionalWitness) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null");
|
||||
}
|
||||
SproutWitness w = *optionalWitness; // could use .get();
|
||||
SproutWitness w = *optionalWitness; // could use .value();
|
||||
if (jsChange > 0) {
|
||||
for (const uint256& commitment : previousCommitments) {
|
||||
w.append(commitment);
|
||||
|
@ -689,7 +690,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
// If this is the final output, set the target and memo
|
||||
if (isToZaddr_ && vpubNewProcessed) {
|
||||
outputType = "target";
|
||||
jso.addr = boost::get<libzcash::SproutPaymentAddress>(toPaymentAddress_);
|
||||
jso.addr = std::get<libzcash::SproutPaymentAddress>(toPaymentAddress_);
|
||||
if (!hexMemo.empty()) {
|
||||
jso.memo = get_memo_from_hex_string(hexMemo);
|
||||
}
|
||||
|
@ -713,7 +714,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
assert(zInputsDeque.size() == 0);
|
||||
assert(vpubNewProcessed);
|
||||
|
||||
auto txAndResult = SignSendRawTransaction(obj, boost::none, testmode);
|
||||
auto txAndResult = SignSendRawTransaction(obj, std::nullopt, testmode);
|
||||
tx_ = txAndResult.first;
|
||||
set_result(txAndResult.second);
|
||||
return true;
|
||||
|
@ -722,7 +723,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
|
||||
UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info)
|
||||
{
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
@ -734,7 +735,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf
|
|||
|
||||
UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info, std::vector<JSOutPoint>& outPoints)
|
||||
{
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
@ -745,7 +746,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf
|
|||
|
||||
UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(
|
||||
MergeToAddressJSInfo& info,
|
||||
std::vector<boost::optional<SproutWitness>> witnesses,
|
||||
std::vector<std::optional<SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
if (anchor.IsNull()) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "zcash/JoinSplit.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -50,7 +51,7 @@ struct MergeToAddressJSInfo {
|
|||
|
||||
// A struct to help us track the witness and anchor for a given JSOutPoint
|
||||
struct MergeToAddressWitnessAnchorData {
|
||||
boost::optional<SproutWitness> witness;
|
||||
std::optional<SproutWitness> witness;
|
||||
uint256 anchor;
|
||||
};
|
||||
|
||||
|
@ -58,7 +59,7 @@ class AsyncRPCOperation_mergetoaddress : public AsyncRPCOperation
|
|||
{
|
||||
public:
|
||||
AsyncRPCOperation_mergetoaddress(
|
||||
boost::optional<TransactionBuilder> builder,
|
||||
std::optional<TransactionBuilder> builder,
|
||||
CMutableTransaction contextualTx,
|
||||
std::vector<MergeToAddressInputUTXO> utxoInputs,
|
||||
std::vector<MergeToAddressInputSproutNote> sproutNoteInputs,
|
||||
|
@ -122,7 +123,7 @@ private:
|
|||
// JoinSplit where you have the witnesses and anchor
|
||||
UniValue perform_joinsplit(
|
||||
MergeToAddressJSInfo& info,
|
||||
std::vector<boost::optional<SproutWitness>> witnesses,
|
||||
std::vector<std::optional<SproutWitness>> witnesses,
|
||||
uint256 anchor);
|
||||
|
||||
void lock_utxos();
|
||||
|
@ -180,7 +181,7 @@ public:
|
|||
|
||||
UniValue perform_joinsplit(
|
||||
MergeToAddressJSInfo& info,
|
||||
std::vector<boost::optional<SproutWitness>> witnesses,
|
||||
std::vector<std::optional<SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
return delegate->perform_joinsplit(info, witnesses, anchor);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "assert.h"
|
||||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "asyncrpcoperation_saplingmigration.h"
|
||||
#include "init.h"
|
||||
#include "key_io.h"
|
||||
|
@ -12,6 +11,9 @@
|
|||
#include "utilmoneystr.h"
|
||||
#include "wallet.h"
|
||||
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
const CAmount FEE = 10000;
|
||||
const int MIGRATION_EXPIRY_DELTA = 450;
|
||||
|
||||
|
@ -71,7 +73,7 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
|||
LogPrint("zrpcunsafe", "%s: Beginning AsyncRPCOperation_saplingmigration.\n", getId());
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams);
|
||||
if (nextActivationHeight && targetHeight_ + MIGRATION_EXPIRY_DELTA >= nextActivationHeight.get()) {
|
||||
if (nextActivationHeight && targetHeight_ + MIGRATION_EXPIRY_DELTA >= nextActivationHeight.value()) {
|
||||
LogPrint("zrpcunsafe", "%s: Migration txs would be created before a NU activation but may expire after. Skipping this round.\n", getId());
|
||||
setMigrationResult(0, 0, std::vector<std::string>());
|
||||
return true;
|
||||
|
@ -138,9 +140,9 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
|||
// for each Sprout JoinSplit description
|
||||
// TODO: the above functionality (in comment) is not implemented in zcashd
|
||||
uint256 inputAnchor;
|
||||
std::vector<boost::optional<SproutWitness>> vInputWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> vInputWitnesses;
|
||||
pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
|
||||
builder.AddSproutInput(sproutSk, sproutEntry.note, vInputWitnesses[0].get());
|
||||
builder.AddSproutInput(sproutSk, sproutEntry.note, vInputWitnesses[0].value());
|
||||
}
|
||||
// The amount chosen *includes* the 0.0001 ZEC fee for this transaction, i.e.
|
||||
// the value of the Sapling output will be 0.0001 ZEC less.
|
||||
|
@ -196,7 +198,7 @@ libzcash::SaplingPaymentAddress AsyncRPCOperation_saplingmigration::getMigration
|
|||
if (mapArgs.count("-migrationdestaddress")) {
|
||||
std::string migrationDestAddress = mapArgs["-migrationdestaddress"];
|
||||
auto address = keyIO.DecodePaymentAddress(migrationDestAddress);
|
||||
auto saplingAddress = boost::get<libzcash::SaplingPaymentAddress>(&address);
|
||||
auto saplingAddress = std::get_if<libzcash::SaplingPaymentAddress>(&address);
|
||||
assert(saplingAddress != nullptr); // This is checked in init.cpp
|
||||
return *saplingAddress;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include <rust/ed25519.h>
|
||||
|
||||
|
@ -57,7 +58,7 @@ int find_output(UniValue obj, int n) {
|
|||
}
|
||||
|
||||
AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
||||
boost::optional<TransactionBuilder> builder,
|
||||
std::optional<TransactionBuilder> builder,
|
||||
CMutableTransaction contextualTx,
|
||||
std::string fromAddress,
|
||||
std::vector<SendManyRecipient> tOutputs,
|
||||
|
@ -84,7 +85,7 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
|||
isUsingBuilder_ = false;
|
||||
if (builder) {
|
||||
isUsingBuilder_ = true;
|
||||
builder_ = builder.get();
|
||||
builder_ = builder.value();
|
||||
}
|
||||
|
||||
KeyIO keyIO(Params());
|
||||
|
@ -98,13 +99,13 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
|||
auto address = keyIO.DecodePaymentAddress(fromAddress);
|
||||
if (IsValidPaymentAddress(address)) {
|
||||
// We don't need to lock on the wallet as spending key related methods are thread-safe
|
||||
if (!boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), address)) {
|
||||
if (!std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), address)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, no spending key found for zaddr");
|
||||
}
|
||||
|
||||
isfromzaddr_ = true;
|
||||
frompaymentaddress_ = address;
|
||||
spendingkey_ = boost::apply_visitor(GetSpendingKeyForPaymentAddress(pwalletMain), address).get();
|
||||
spendingkey_ = std::visit(GetSpendingKeyForPaymentAddress(pwalletMain), address).value();
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address");
|
||||
}
|
||||
|
@ -305,7 +306,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
SaplingExpandedSpendingKey expsk;
|
||||
uint256 ovk;
|
||||
if (isfromzaddr_) {
|
||||
auto sk = boost::get<libzcash::SaplingExtendedSpendingKey>(spendingkey_);
|
||||
auto sk = std::get<libzcash::SaplingExtendedSpendingKey>(spendingkey_);
|
||||
expsk = sk.expsk;
|
||||
ovk = expsk.full_viewing_key().ovk;
|
||||
} else {
|
||||
|
@ -352,7 +353,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
|
||||
// Fetch Sapling anchor and witnesses
|
||||
uint256 anchor;
|
||||
std::vector<boost::optional<SaplingWitness>> witnesses;
|
||||
std::vector<std::optional<SaplingWitness>> witnesses;
|
||||
{
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
pwalletMain->GetSaplingNoteWitnesses(ops, witnesses, anchor);
|
||||
|
@ -363,7 +364,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
if (!witnesses[i]) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Missing witness for Sapling note");
|
||||
}
|
||||
builder_.AddSaplingSpend(expsk, notes[i], anchor, witnesses[i].get());
|
||||
builder_.AddSaplingSpend(expsk, notes[i], anchor, witnesses[i].value());
|
||||
}
|
||||
|
||||
// Add Sapling outputs
|
||||
|
@ -373,8 +374,8 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
auto hexMemo = r.memo;
|
||||
|
||||
auto addr = keyIO.DecodePaymentAddress(address);
|
||||
assert(boost::get<libzcash::SaplingPaymentAddress>(&addr) != nullptr);
|
||||
auto to = boost::get<libzcash::SaplingPaymentAddress>(addr);
|
||||
assert(std::get_if<libzcash::SaplingPaymentAddress>(&addr) != nullptr);
|
||||
auto to = std::get<libzcash::SaplingPaymentAddress>(addr);
|
||||
|
||||
auto memo = get_memo_from_hex_string(hexMemo);
|
||||
|
||||
|
@ -475,7 +476,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
JSOutPoint jso = t.point;
|
||||
std::vector<JSOutPoint> vOutPoints = { jso };
|
||||
uint256 inputAnchor;
|
||||
std::vector<boost::optional<SproutWitness>> vInputWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> vInputWitnesses;
|
||||
pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor);
|
||||
jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses[0], inputAnchor };
|
||||
}
|
||||
|
@ -532,7 +533,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
zOutputsDeque.pop_front();
|
||||
|
||||
PaymentAddress pa = keyIO.DecodePaymentAddress(address);
|
||||
JSOutput jso = JSOutput(boost::get<libzcash::SproutPaymentAddress>(pa), value);
|
||||
JSOutput jso = JSOutput(std::get<libzcash::SproutPaymentAddress>(pa), value);
|
||||
if (hexMemo.size() > 0) {
|
||||
jso.memo = get_memo_from_hex_string(hexMemo);
|
||||
}
|
||||
|
@ -586,7 +587,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
|
||||
CAmount jsInputValue = 0;
|
||||
uint256 jsAnchor;
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
|
||||
JSDescription prevJoinSplit;
|
||||
|
||||
|
@ -617,7 +618,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
}
|
||||
|
||||
assert(changeOutputIndex != -1);
|
||||
boost::optional<SproutWitness> changeWitness;
|
||||
std::optional<SproutWitness> changeWitness;
|
||||
int n = 0;
|
||||
for (const uint256& commitment : prevJoinSplit.commitments) {
|
||||
tree.append(commitment);
|
||||
|
@ -625,7 +626,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
if (!changeWitness && changeOutputIndex == n++) {
|
||||
changeWitness = tree.witness();
|
||||
} else if (changeWitness) {
|
||||
changeWitness.get().append(commitment);
|
||||
changeWitness.value().append(commitment);
|
||||
}
|
||||
}
|
||||
if (changeWitness) {
|
||||
|
@ -635,7 +636,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
intermediates.insert(std::make_pair(tree.root(), tree)); // chained js are interstitial (found in between block boundaries)
|
||||
|
||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||
ZCNoteDecryption decryptor(boost::get<libzcash::SproutSpendingKey>(spendingkey_).receiving_key());
|
||||
ZCNoteDecryption decryptor(std::get<libzcash::SproutSpendingKey>(spendingkey_).receiving_key());
|
||||
auto hSig = prevJoinSplit.h_sig(tx_.joinSplitPubKey);
|
||||
try {
|
||||
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
|
||||
|
@ -645,7 +646,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
hSig,
|
||||
(unsigned char) changeOutputIndex);
|
||||
|
||||
SproutNote note = plaintext.note(boost::get<libzcash::SproutPaymentAddress>(frompaymentaddress_));
|
||||
SproutNote note = plaintext.note(std::get<libzcash::SproutPaymentAddress>(frompaymentaddress_));
|
||||
info.notes.push_back(note);
|
||||
|
||||
jsInputValue += plaintext.value();
|
||||
|
@ -666,7 +667,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
//
|
||||
std::vector<SproutNote> vInputNotes;
|
||||
std::vector<JSOutPoint> vOutPoints;
|
||||
std::vector<boost::optional<SproutWitness>> vInputWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> vInputWitnesses;
|
||||
uint256 inputAnchor;
|
||||
int numInputsNeeded = (jsChange>0) ? 1 : 0;
|
||||
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
||||
|
@ -723,7 +724,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
if (!optionalWitness) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null");
|
||||
}
|
||||
SproutWitness w = *optionalWitness; // could use .get();
|
||||
SproutWitness w = *optionalWitness; // could use .value();
|
||||
if (jsChange > 0) {
|
||||
for (const uint256& commitment : previousCommitments) {
|
||||
w.append(commitment);
|
||||
|
@ -795,7 +796,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
} else {
|
||||
PaymentAddress pa = keyIO.DecodePaymentAddress(address);
|
||||
// If we are here, we know we have no Sapling outputs.
|
||||
JSOutput jso = JSOutput(boost::get<libzcash::SproutPaymentAddress>(pa), value);
|
||||
JSOutput jso = JSOutput(std::get<libzcash::SproutPaymentAddress>(pa), value);
|
||||
if (hexMemo.size() > 0) {
|
||||
jso.memo = get_memo_from_hex_string(hexMemo);
|
||||
}
|
||||
|
@ -804,7 +805,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
|
||||
// create output for any change
|
||||
if (jsChange>0) {
|
||||
info.vjsout.push_back(JSOutput(boost::get<libzcash::SproutPaymentAddress>(frompaymentaddress_), jsChange));
|
||||
info.vjsout.push_back(JSOutput(std::get<libzcash::SproutPaymentAddress>(frompaymentaddress_), jsChange));
|
||||
|
||||
LogPrint("zrpcunsafe", "%s: generating note for change (amount=%s)\n",
|
||||
getId(),
|
||||
|
@ -824,7 +825,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
assert(zOutputsDeque.size() == 0);
|
||||
assert(vpubNewProcessed);
|
||||
|
||||
auto txAndResult = SignSendRawTransaction(obj, boost::none, testmode);
|
||||
auto txAndResult = SignSendRawTransaction(obj, std::nullopt, testmode);
|
||||
tx_ = txAndResult.first;
|
||||
set_result(txAndResult.second);
|
||||
return true;
|
||||
|
@ -973,7 +974,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() {
|
|||
}
|
||||
|
||||
UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info) {
|
||||
std::vector<boost::optional < SproutWitness>> witnesses;
|
||||
std::vector<std::optional < SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
@ -984,7 +985,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info
|
|||
|
||||
|
||||
UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info, std::vector<JSOutPoint> & outPoints) {
|
||||
std::vector<boost::optional < SproutWitness>> witnesses;
|
||||
std::vector<std::optional < SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
@ -995,7 +996,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info
|
|||
|
||||
UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
|
||||
AsyncJoinSplitInfo & info,
|
||||
std::vector<boost::optional < SproutWitness>> witnesses,
|
||||
std::vector<std::optional < SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
if (anchor.IsNull()) {
|
||||
|
@ -1010,7 +1011,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
|
|||
if (!witnesses[i]) {
|
||||
throw runtime_error("joinsplit input could not be found in tree");
|
||||
}
|
||||
info.vjsin.push_back(JSInput(*witnesses[i], info.notes[i], boost::get<libzcash::SproutSpendingKey>(spendingkey_)));
|
||||
info.vjsin.push_back(JSInput(*witnesses[i], info.notes[i], std::get<libzcash::SproutSpendingKey>(spendingkey_)));
|
||||
}
|
||||
|
||||
// Make sure there are two inputs and two outputs
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "wallet/paymentdisclosure.h"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <tuple>
|
||||
|
||||
|
@ -60,14 +61,14 @@ struct AsyncJoinSplitInfo
|
|||
|
||||
// A struct to help us track the witness and anchor for a given JSOutPoint
|
||||
struct WitnessAnchorData {
|
||||
boost::optional<SproutWitness> witness;
|
||||
std::optional<SproutWitness> witness;
|
||||
uint256 anchor;
|
||||
};
|
||||
|
||||
class AsyncRPCOperation_sendmany : public AsyncRPCOperation {
|
||||
public:
|
||||
AsyncRPCOperation_sendmany(
|
||||
boost::optional<TransactionBuilder> builder,
|
||||
std::optional<TransactionBuilder> builder,
|
||||
CMutableTransaction contextualTx,
|
||||
std::string fromAddress,
|
||||
std::vector<SendManyRecipient> tOutputs,
|
||||
|
@ -141,7 +142,7 @@ private:
|
|||
// JoinSplit where you have the witnesses and anchor
|
||||
UniValue perform_joinsplit(
|
||||
AsyncJoinSplitInfo & info,
|
||||
std::vector<boost::optional < SproutWitness>> witnesses,
|
||||
std::vector<std::optional < SproutWitness>> witnesses,
|
||||
uint256 anchor);
|
||||
|
||||
// payment disclosure!
|
||||
|
@ -196,7 +197,7 @@ public:
|
|||
|
||||
UniValue perform_joinsplit(
|
||||
AsyncJoinSplitInfo & info,
|
||||
std::vector<boost::optional < SproutWitness>> witnesses,
|
||||
std::vector<std::optional < SproutWitness>> witnesses,
|
||||
uint256 anchor)
|
||||
{
|
||||
return delegate->perform_joinsplit(info, witnesses, anchor);
|
||||
|
|
|
@ -32,8 +32,10 @@
|
|||
#include <array>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include <rust/ed25519.h>
|
||||
|
||||
|
@ -196,7 +198,7 @@ bool AsyncRPCOperation_shieldcoinbase::main_impl() {
|
|||
LogPrint("zrpc", "%s: spending %s to shield %s with fee %s\n",
|
||||
getId(), FormatMoney(targetAmount), FormatMoney(sendAmount), FormatMoney(minersFee));
|
||||
|
||||
return boost::apply_visitor(ShieldToAddress(this, sendAmount), tozaddr_);
|
||||
return std::visit(ShieldToAddress(this, sendAmount), tozaddr_);
|
||||
}
|
||||
|
||||
bool ShieldToAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) const {
|
||||
|
@ -222,7 +224,7 @@ bool ShieldToAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) co
|
|||
info.vjsout.push_back(jso);
|
||||
UniValue obj = m_op->perform_joinsplit(info);
|
||||
|
||||
auto txAndResult = SignSendRawTransaction(obj, boost::none, m_op->testmode);
|
||||
auto txAndResult = SignSendRawTransaction(obj, std::nullopt, m_op->testmode);
|
||||
m_op->tx_ = txAndResult.first;
|
||||
m_op->set_result(txAndResult.second);
|
||||
return true;
|
||||
|
@ -250,7 +252,7 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
|||
// Build the transaction
|
||||
m_op->tx_ = m_op->builder_.Build().GetTxOrThrow();
|
||||
|
||||
UniValue sendResult = SendTransaction(m_op->tx_, boost::none, m_op->testmode);
|
||||
UniValue sendResult = SendTransaction(m_op->tx_, std::nullopt, m_op->testmode);
|
||||
m_op->set_result(sendResult);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -97,7 +97,7 @@ private:
|
|||
std::vector<PaymentDisclosureKeyInfo> paymentDisclosureData_;
|
||||
};
|
||||
|
||||
class ShieldToAddress : public boost::static_visitor<bool>
|
||||
class ShieldToAddress
|
||||
{
|
||||
private:
|
||||
AsyncRPCOperation_shieldcoinbase *m_op;
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "zcash/Note.hpp"
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
using ::testing::Return;
|
||||
|
||||
ACTION(ThrowLogicError) {
|
||||
|
@ -103,8 +105,8 @@ std::pair<JSOutPoint, SaplingOutPoint> CreateValidBlock(TestWallet& wallet,
|
|||
std::pair<uint256, uint256> GetWitnessesAndAnchors(TestWallet& wallet,
|
||||
std::vector<JSOutPoint>& sproutNotes,
|
||||
std::vector<SaplingOutPoint>& saplingNotes,
|
||||
std::vector<boost::optional<SproutWitness>>& sproutWitnesses,
|
||||
std::vector<boost::optional<SaplingWitness>>& saplingWitnesses) {
|
||||
std::vector<std::optional<SproutWitness>>& sproutWitnesses,
|
||||
std::vector<std::optional<SaplingWitness>>& saplingWitnesses) {
|
||||
sproutWitnesses.clear();
|
||||
saplingWitnesses.clear();
|
||||
uint256 sproutAnchor;
|
||||
|
@ -360,7 +362,7 @@ TEST(WalletTests, SetSaplingNoteAddrsInCWalletTx) {
|
|||
auto pk = sk.DefaultAddress();
|
||||
|
||||
libzcash::SaplingNote note(pk, 50000, zip_212_enabled[ver]);
|
||||
auto cm = note.cmu().get();
|
||||
auto cm = note.cmu().value();
|
||||
SaplingMerkleTree tree;
|
||||
tree.append(cm);
|
||||
auto anchor = tree.root();
|
||||
|
@ -368,7 +370,7 @@ TEST(WalletTests, SetSaplingNoteAddrsInCWalletTx) {
|
|||
|
||||
auto nf = note.nullifier(fvk, witness.position());
|
||||
ASSERT_TRUE(nf);
|
||||
uint256 nullifier = nf.get();
|
||||
uint256 nullifier = nf.value();
|
||||
|
||||
auto builder = TransactionBuilder(consensusParams, 1);
|
||||
builder.AddSaplingSpend(expsk, note, anchor, witness);
|
||||
|
@ -634,7 +636,7 @@ TEST(WalletTests, GetConflictedSaplingNotes) {
|
|||
|
||||
// Generate note A
|
||||
libzcash::SaplingNote note(pk, 50000, zip_212_enabled[ver]);
|
||||
auto cm = note.cmu().get();
|
||||
auto cm = note.cmu().value();
|
||||
SaplingMerkleTree saplingTree;
|
||||
saplingTree.append(cm);
|
||||
auto anchor = saplingTree.root();
|
||||
|
@ -684,15 +686,15 @@ TEST(WalletTests, GetConflictedSaplingNotes) {
|
|||
wtx.vShieldedOutput[0].ephemeralKey,
|
||||
wtx.vShieldedOutput[0].cmu);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_pt), true);
|
||||
auto maybe_note = maybe_pt.get().note(ivk);
|
||||
auto maybe_note = maybe_pt.value().note(ivk);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_note), true);
|
||||
auto note2 = maybe_note.get();
|
||||
auto note2 = maybe_note.value();
|
||||
|
||||
SaplingOutPoint sop0(wtx.GetHash(), 0);
|
||||
auto spend_note_witness = wtx.mapSaplingNoteData[sop0].witnesses.front();
|
||||
auto maybe_nf = note2.nullifier(extfvk.fvk, spend_note_witness.position());
|
||||
ASSERT_EQ(static_cast<bool>(maybe_nf), true);
|
||||
auto nullifier2 = maybe_nf.get();
|
||||
auto nullifier2 = maybe_nf.value();
|
||||
|
||||
anchor = saplingTree.root();
|
||||
|
||||
|
@ -804,7 +806,7 @@ TEST(WalletTests, SaplingNullifierIsSpent) {
|
|||
// Manually compute the nullifier based on the known position
|
||||
auto nf = testNote.note.nullifier(extfvk.fvk, testNote.tree.witness().position());
|
||||
ASSERT_TRUE(nf);
|
||||
uint256 nullifier = nf.get();
|
||||
uint256 nullifier = nf.value();
|
||||
|
||||
// Verify note has not been spent
|
||||
EXPECT_FALSE(wallet.IsSaplingSpent(nullifier));
|
||||
|
@ -889,7 +891,7 @@ TEST(WalletTests, NavigateFromSaplingNullifierToNote) {
|
|||
// Manually compute the nullifier based on the expected position
|
||||
auto nf = testNote.note.nullifier(extfvk.fvk, testNote.tree.witness().position());
|
||||
ASSERT_TRUE(nf);
|
||||
uint256 nullifier = nf.get();
|
||||
uint256 nullifier = nf.value();
|
||||
|
||||
// Verify dummy note is unspent
|
||||
EXPECT_FALSE(wallet.IsSaplingSpent(nullifier));
|
||||
|
@ -941,7 +943,7 @@ TEST(WalletTests, NavigateFromSaplingNullifierToNote) {
|
|||
EXPECT_EQ(hash, op.hash);
|
||||
EXPECT_EQ(1, nd.witnesses.size());
|
||||
ASSERT_TRUE(nd.nullifier);
|
||||
auto nf = nd.nullifier.get();
|
||||
auto nf = nd.nullifier.value();
|
||||
EXPECT_EQ(1, wallet.mapSaplingNullifiersToNotes.count(nf));
|
||||
EXPECT_EQ(op.hash, wallet.mapSaplingNullifiersToNotes[nf].hash);
|
||||
EXPECT_EQ(op.n, wallet.mapSaplingNullifiersToNotes[nf].n);
|
||||
|
@ -1007,7 +1009,7 @@ TEST(WalletTests, SpentSaplingNoteIsFromMe) {
|
|||
|
||||
// Generate Sapling note A
|
||||
libzcash::SaplingNote note(pk, 50000, zip_212_enabled[ver]);
|
||||
auto cm = note.cmu().get();
|
||||
auto cm = note.cmu().value();
|
||||
SaplingMerkleTree saplingTree;
|
||||
saplingTree.append(cm);
|
||||
auto anchor = saplingTree.root();
|
||||
|
@ -1059,7 +1061,7 @@ TEST(WalletTests, SpentSaplingNoteIsFromMe) {
|
|||
// Manually compute the nullifier and check map entry does not exist
|
||||
auto nf = note.nullifier(extfvk.fvk, witness.position());
|
||||
ASSERT_TRUE(nf);
|
||||
ASSERT_FALSE(wallet.mapSaplingNullifiersToNotes.count(nf.get()));
|
||||
ASSERT_FALSE(wallet.mapSaplingNullifiersToNotes.count(nf.value()));
|
||||
|
||||
// Decrypt note B
|
||||
auto maybe_pt = libzcash::SaplingNotePlaintext::decrypt(
|
||||
|
@ -1070,16 +1072,16 @@ TEST(WalletTests, SpentSaplingNoteIsFromMe) {
|
|||
wtx.vShieldedOutput[0].ephemeralKey,
|
||||
wtx.vShieldedOutput[0].cmu);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_pt), true);
|
||||
auto maybe_note = maybe_pt.get().note(ivk);
|
||||
auto maybe_note = maybe_pt.value().note(ivk);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_note), true);
|
||||
auto note2 = maybe_note.get();
|
||||
auto note2 = maybe_note.value();
|
||||
|
||||
// Get witness to retrieve position of note B we want to spend
|
||||
SaplingOutPoint sop0(wtx.GetHash(), 0);
|
||||
auto spend_note_witness = wtx.mapSaplingNoteData[sop0].witnesses.front();
|
||||
auto maybe_nf = note2.nullifier(extfvk.fvk, spend_note_witness.position());
|
||||
ASSERT_EQ(static_cast<bool>(maybe_nf), true);
|
||||
auto nullifier2 = maybe_nf.get();
|
||||
auto nullifier2 = maybe_nf.value();
|
||||
|
||||
// NOTE: Not updating the anchor results in a core dump. Shouldn't builder just return error?
|
||||
// *** Error in `./zcash-gtest': double free or corruption (out): 0x00007ffd8755d990 ***
|
||||
|
@ -1159,8 +1161,8 @@ TEST(WalletTests, CachedWitnessesEmptyChain) {
|
|||
std::vector<JSOutPoint> sproutNotes {jsoutpt, jsoutpt2};
|
||||
std::vector<SaplingOutPoint> saplingNotes = SetSaplingNoteData(wtx);
|
||||
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
::GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
|
||||
|
@ -1214,8 +1216,8 @@ TEST(WalletTests, CachedWitnessesChainTip) {
|
|||
// Called to fetch anchor
|
||||
std::vector<JSOutPoint> sproutNotes {outpts.first};
|
||||
std::vector<SaplingOutPoint> saplingNotes {outpts.second};
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
anchors1 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
EXPECT_NE(anchors1.first, anchors1.second);
|
||||
|
@ -1236,8 +1238,8 @@ TEST(WalletTests, CachedWitnessesChainTip) {
|
|||
wallet.AddToWallet(wtx, true, NULL);
|
||||
|
||||
std::vector<JSOutPoint> sproutNotes {jsoutpt};
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
|
||||
|
@ -1284,8 +1286,8 @@ TEST(WalletTests, CachedWitnessesChainTip) {
|
|||
|
||||
// Incrementing with the same block again should not change the cache
|
||||
wallet.IncrementNoteWitnesses(&index2, &block2, sproutTree, saplingTree);
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses5;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses5;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses5;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses5;
|
||||
|
||||
auto anchors5 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses5, saplingWitnesses5);
|
||||
EXPECT_NE(anchors5.first, anchors5.second);
|
||||
|
@ -1326,8 +1328,8 @@ TEST(WalletTests, CachedWitnessesDecrementFirst) {
|
|||
// Called to fetch anchor
|
||||
std::vector<JSOutPoint> sproutNotes {outpts.first};
|
||||
std::vector<SaplingOutPoint> saplingNotes {outpts.second};
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
}
|
||||
|
||||
|
@ -1346,8 +1348,8 @@ TEST(WalletTests, CachedWitnessesDecrementFirst) {
|
|||
wallet.AddToWallet(wtx, true, NULL);
|
||||
|
||||
std::vector<JSOutPoint> sproutNotes {jsoutpt};
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
auto anchors3 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
|
||||
|
@ -1391,8 +1393,8 @@ TEST(WalletTests, CachedWitnessesCleanIndex) {
|
|||
SproutMerkleTree sproutRiTree = sproutTree;
|
||||
SaplingMerkleTree saplingTree;
|
||||
SaplingMerkleTree saplingRiTree = saplingTree;
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
auto sk = libzcash::SproutSpendingKey::random();
|
||||
wallet.AddSproutSpendingKey(sk);
|
||||
|
@ -1508,8 +1510,8 @@ TEST(WalletTests, ClearNoteWitnessCache) {
|
|||
saplingNotes.emplace_back(wtx.GetHash(), 1);
|
||||
ASSERT_EQ(saplingNotes.size(), 2);
|
||||
|
||||
std::vector<boost::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<boost::optional<SaplingWitness>> saplingWitnesses;
|
||||
std::vector<std::optional<SproutWitness>> sproutWitnesses;
|
||||
std::vector<std::optional<SaplingWitness>> saplingWitnesses;
|
||||
|
||||
// Before clearing, we should have a witness for one note
|
||||
GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses);
|
||||
|
@ -1997,9 +1999,9 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) {
|
|||
// Prepare to spend the note that was just created
|
||||
auto maybe_pt = libzcash::SaplingNotePlaintext::decrypt(consensusParams, fakeIndex.nHeight, tx1.vShieldedOutput[0].encCiphertext, ivk, tx1.vShieldedOutput[0].ephemeralKey, tx1.vShieldedOutput[0].cmu);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_pt), true);
|
||||
auto maybe_note = maybe_pt.get().note(ivk);
|
||||
auto maybe_note = maybe_pt.value().note(ivk);
|
||||
ASSERT_EQ(static_cast<bool>(maybe_note), true);
|
||||
auto note = maybe_note.get();
|
||||
auto note = maybe_note.value();
|
||||
auto anchor = saplingTree.root();
|
||||
auto witness = saplingTree.witness();
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ TEST(WalletZkeysTest, StoreAndLoadSaplingZkeys) {
|
|||
// If we can't get an early diversified address, we are very unlucky
|
||||
blob88 diversifier;
|
||||
diversifier.begin()[0] = 10;
|
||||
auto dpa = sk.ToXFVK().Address(diversifier).get().second;
|
||||
auto dpa = sk.ToXFVK().Address(diversifier).value().second;
|
||||
|
||||
// verify wallet only has the default address
|
||||
EXPECT_TRUE(wallet.HaveSaplingIncomingViewingKey(sk.DefaultAddress()));
|
||||
|
@ -98,7 +98,7 @@ TEST(WalletZkeysTest, StoreAndLoadSaplingZkeys) {
|
|||
ASSERT_EQ(wallet.mapSaplingZKeyMetadata[ivk2].nCreateTime, now);
|
||||
|
||||
// Load a diversified address for the third key into the wallet
|
||||
auto dpa2 = sk2.ToXFVK().Address(diversifier).get().second;
|
||||
auto dpa2 = sk2.ToXFVK().Address(diversifier).value().second;
|
||||
EXPECT_TRUE(wallet.HaveSaplingIncomingViewingKey(sk2.DefaultAddress()));
|
||||
EXPECT_FALSE(wallet.HaveSaplingIncomingViewingKey(dpa2));
|
||||
EXPECT_TRUE(wallet.LoadSaplingPaymentAddress(dpa2, ivk2));
|
||||
|
@ -449,7 +449,7 @@ TEST(wallet_zkeys_tests, WriteCryptedSaplingZkeyDirectToDb) {
|
|||
EXPECT_TRUE(wallet.GetSaplingExtendedSpendingKey(address, extsk));
|
||||
blob88 diversifier;
|
||||
diversifier.begin()[0] = 10;
|
||||
auto dpa = extsk.ToXFVK().Address(diversifier).get().second;
|
||||
auto dpa = extsk.ToXFVK().Address(diversifier).value().second;
|
||||
|
||||
// Add diversified address to the wallet
|
||||
auto ivk = extsk.expsk.full_viewing_key().in_viewing_key();
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <future>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <leveldb/db.h>
|
||||
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
#include "wallet.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
@ -396,10 +398,10 @@ UniValue importwallet_impl(const UniValue& params, bool fImportZKeys)
|
|||
auto spendingkey = keyIO.DecodeSpendingKey(vstr[0]);
|
||||
int64_t nTime = DecodeDumpTime(vstr[1]);
|
||||
// Only include hdKeypath and seedFpStr if we have both
|
||||
boost::optional<std::string> hdKeypath = (vstr.size() > 3) ? boost::optional<std::string>(vstr[2]) : boost::none;
|
||||
boost::optional<std::string> seedFpStr = (vstr.size() > 3) ? boost::optional<std::string>(vstr[3]) : boost::none;
|
||||
std::optional<std::string> hdKeypath = (vstr.size() > 3) ? std::optional<std::string>(vstr[2]) : std::nullopt;
|
||||
std::optional<std::string> seedFpStr = (vstr.size() > 3) ? std::optional<std::string>(vstr[3]) : std::nullopt;
|
||||
if (IsValidSpendingKey(spendingkey)) {
|
||||
auto addResult = boost::apply_visitor(
|
||||
auto addResult = std::visit(
|
||||
AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus(), nTime, hdKeypath, seedFpStr, true), spendingkey);
|
||||
if (addResult == KeyAlreadyExists){
|
||||
LogPrint("zrpc", "Skipping import of zaddr (key already present)\n");
|
||||
|
@ -501,7 +503,7 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
|
|||
if (!IsValidDestination(dest)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Zcash address");
|
||||
}
|
||||
const CKeyID *keyID = boost::get<CKeyID>(&dest);
|
||||
const CKeyID *keyID = std::get_if<CKeyID>(&dest);
|
||||
if (!keyID) {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
|
||||
}
|
||||
|
@ -753,13 +755,13 @@ UniValue z_importkey(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid spending key");
|
||||
}
|
||||
|
||||
auto addrInfo = boost::apply_visitor(libzcash::AddressInfoFromSpendingKey{}, spendingkey);
|
||||
auto addrInfo = std::visit(libzcash::AddressInfoFromSpendingKey{}, spendingkey);
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.pushKV("type", addrInfo.first);
|
||||
result.pushKV("address", keyIO.EncodePaymentAddress(addrInfo.second));
|
||||
|
||||
// Sapling support
|
||||
auto addResult = boost::apply_visitor(AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus()), spendingkey);
|
||||
auto addResult = std::visit(AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus()), spendingkey);
|
||||
if (addResult == KeyAlreadyExists && fIgnoreExistingKey) {
|
||||
return result;
|
||||
}
|
||||
|
@ -848,13 +850,13 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid viewing key");
|
||||
}
|
||||
|
||||
auto addrInfo = boost::apply_visitor(libzcash::AddressInfoFromViewingKey{}, viewingkey);
|
||||
auto addrInfo = std::visit(libzcash::AddressInfoFromViewingKey{}, viewingkey);
|
||||
UniValue result(UniValue::VOBJ);
|
||||
const string strAddress = keyIO.EncodePaymentAddress(addrInfo.second);
|
||||
result.pushKV("type", addrInfo.first);
|
||||
result.pushKV("address", strAddress);
|
||||
|
||||
auto addResult = boost::apply_visitor(AddViewingKeyToWallet(pwalletMain), viewingkey);
|
||||
auto addResult = std::visit(AddViewingKeyToWallet(pwalletMain), viewingkey);
|
||||
if (addResult == SpendingKeyExists) {
|
||||
throw JSONRPCError(
|
||||
RPC_WALLET_ERROR,
|
||||
|
@ -908,11 +910,11 @@ UniValue z_exportkey(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Sapling support
|
||||
auto sk = boost::apply_visitor(GetSpendingKeyForPaymentAddress(pwalletMain), address);
|
||||
auto sk = std::visit(GetSpendingKeyForPaymentAddress(pwalletMain), address);
|
||||
if (!sk) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold private zkey for this zaddr");
|
||||
}
|
||||
return keyIO.EncodeSpendingKey(sk.get());
|
||||
return keyIO.EncodeSpendingKey(sk.value());
|
||||
}
|
||||
|
||||
UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
||||
|
@ -946,9 +948,9 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr");
|
||||
}
|
||||
|
||||
auto vk = boost::apply_visitor(GetViewingKeyForPaymentAddress(pwalletMain), address);
|
||||
auto vk = std::visit(GetViewingKeyForPaymentAddress(pwalletMain), address);
|
||||
if (vk) {
|
||||
return keyIO.EncodeViewingKey(vk.get());
|
||||
return keyIO.EncodeViewingKey(vk.value());
|
||||
} else {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold private key or viewing key for this zaddr");
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
#include <univalue.h>
|
||||
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
#include <rust/ed25519.h>
|
||||
|
||||
|
@ -589,7 +591,7 @@ UniValue signmessage(const UniValue& params, bool fHelp)
|
|||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address");
|
||||
}
|
||||
|
||||
const CKeyID *keyID = boost::get<CKeyID>(&dest);
|
||||
const CKeyID *keyID = std::get_if<CKeyID>(&dest);
|
||||
if (!keyID) {
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
|
||||
}
|
||||
|
@ -2514,7 +2516,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
|||
entry.pushKV("account", pwalletMain->mapAddressBook[address].name);
|
||||
|
||||
if (scriptPubKey.IsPayToScriptHash()) {
|
||||
const CScriptID& hash = boost::get<CScriptID>(address);
|
||||
const CScriptID& hash = std::get<CScriptID>(address);
|
||||
CScript redeemScript;
|
||||
if (pwalletMain->GetCScript(hash, redeemScript))
|
||||
entry.pushKV("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()));
|
||||
|
@ -2626,7 +2628,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp)
|
|||
if (!IsValidPaymentAddress(zaddr)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, address is not a valid zaddr: ") + address);
|
||||
}
|
||||
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||
auto hasSpendingKey = std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||
if (!fIncludeWatchonly && !hasSpendingKey) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, spending key for address does not belong to wallet: ") + address);
|
||||
}
|
||||
|
@ -2950,10 +2952,10 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp)
|
|||
if (!IsValidSpendingKey(spendingkey)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid spending key");
|
||||
}
|
||||
if (boost::get<libzcash::SproutSpendingKey>(&spendingkey) == nullptr) {
|
||||
if (std::get_if<libzcash::SproutSpendingKey>(&spendingkey) == nullptr) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Only works with Sprout spending keys");
|
||||
}
|
||||
SproutSpendingKey k = boost::get<libzcash::SproutSpendingKey>(spendingkey);
|
||||
SproutSpendingKey k = std::get<libzcash::SproutSpendingKey>(spendingkey);
|
||||
|
||||
uint256 epk;
|
||||
unsigned char nonce;
|
||||
|
@ -2987,7 +2989,7 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp)
|
|||
SproutNote decrypted_note = npt.note(payment_addr);
|
||||
|
||||
assert(pwalletMain != NULL);
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
uint256 commitment = decrypted_note.cm();
|
||||
pwalletMain->WitnessNoteCommitment(
|
||||
|
@ -3076,10 +3078,10 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
if (!IsValidSpendingKey(spendingkey)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid spending key");
|
||||
}
|
||||
if (boost::get<libzcash::SproutSpendingKey>(&spendingkey) == nullptr) {
|
||||
if (std::get_if<libzcash::SproutSpendingKey>(&spendingkey) == nullptr) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Only works with Sprout spending keys");
|
||||
}
|
||||
SproutSpendingKey k = boost::get<libzcash::SproutSpendingKey>(spendingkey);
|
||||
SproutSpendingKey k = std::get<libzcash::SproutSpendingKey>(spendingkey);
|
||||
|
||||
keys.push_back(k);
|
||||
|
||||
|
@ -3097,7 +3099,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
uint256 anchor;
|
||||
std::vector<boost::optional<SproutWitness>> witnesses;
|
||||
std::vector<std::optional<SproutWitness>> witnesses;
|
||||
pwalletMain->WitnessNoteCommitment(commitments, witnesses, anchor);
|
||||
|
||||
assert(witnesses.size() == notes.size());
|
||||
|
@ -3124,12 +3126,12 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
if (!IsValidPaymentAddress(addrTo)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid recipient address.");
|
||||
}
|
||||
if (boost::get<libzcash::SproutPaymentAddress>(&addrTo) == nullptr) {
|
||||
if (std::get_if<libzcash::SproutPaymentAddress>(&addrTo) == nullptr) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Only works with Sprout payment addresses");
|
||||
}
|
||||
CAmount nAmount = AmountFromValue(outputs[name_]);
|
||||
|
||||
vjsout.push_back(JSOutput(boost::get<libzcash::SproutPaymentAddress>(addrTo), nAmount));
|
||||
vjsout.push_back(JSOutput(std::get<libzcash::SproutPaymentAddress>(addrTo), nAmount));
|
||||
}
|
||||
|
||||
while (vjsout.size() < ZC_NUM_JS_OUTPUTS) {
|
||||
|
@ -3478,7 +3480,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Visitor to support Sprout and Sapling addrs
|
||||
if (!boost::apply_visitor(PaymentAddressBelongsToWallet(pwalletMain), zaddr)) {
|
||||
if (!std::visit(PaymentAddressBelongsToWallet(pwalletMain), zaddr)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found.");
|
||||
}
|
||||
|
||||
|
@ -3488,12 +3490,12 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, fromaddress, nMinDepth, false, false);
|
||||
|
||||
std::set<std::pair<PaymentAddress, uint256>> nullifierSet;
|
||||
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||
auto hasSpendingKey = std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr);
|
||||
if (hasSpendingKey) {
|
||||
nullifierSet = pwalletMain->GetNullifiersForAddresses({zaddr});
|
||||
}
|
||||
|
||||
if (boost::get<libzcash::SproutPaymentAddress>(&zaddr) != nullptr) {
|
||||
if (std::get_if<libzcash::SproutPaymentAddress>(&zaddr) != nullptr) {
|
||||
for (SproutNoteEntry & entry : sproutEntries) {
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("txid", entry.jsop.hash.ToString());
|
||||
|
@ -3515,7 +3517,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp)
|
|||
}
|
||||
result.push_back(obj);
|
||||
}
|
||||
} else if (boost::get<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
} else if (std::get_if<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
for (SaplingNoteEntry & entry : saplingEntries) {
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("txid", entry.op.hash.ToString());
|
||||
|
@ -3586,7 +3588,7 @@ UniValue z_getbalance(const UniValue& params, bool fHelp)
|
|||
if (!IsValidPaymentAddress(res)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or zaddr.");
|
||||
}
|
||||
if (!boost::apply_visitor(PaymentAddressBelongsToWallet(pwalletMain), res)) {
|
||||
if (!std::visit(PaymentAddressBelongsToWallet(pwalletMain), res)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, spending key or viewing key not found.");
|
||||
}
|
||||
}
|
||||
|
@ -3828,7 +3830,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp)
|
|||
// means the plaintext leadbyte was valid at the block height
|
||||
// where the note was received.
|
||||
// https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes
|
||||
auto decrypted = wtxPrev.DecryptSaplingNoteWithoutLeadByteCheck(op).get();
|
||||
auto decrypted = wtxPrev.DecryptSaplingNoteWithoutLeadByteCheck(op).value();
|
||||
auto notePt = decrypted.first;
|
||||
auto pa = decrypted.second;
|
||||
|
||||
|
@ -4072,12 +4074,12 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Check that we have the spending key
|
||||
if (!boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), res)) {
|
||||
if (!std::visit(HaveSpendingKeyForPaymentAddress(pwalletMain), res)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key not found.");
|
||||
}
|
||||
|
||||
// Remember whether this is a Sprout or Sapling address
|
||||
fromSapling = boost::get<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
fromSapling = std::get_if<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
}
|
||||
}
|
||||
// This logic will need to be updated if we add a new shielded pool
|
||||
|
@ -4121,7 +4123,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
if (IsValidPaymentAddress(res)) {
|
||||
isZaddr = true;
|
||||
|
||||
bool toSapling = boost::get<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
bool toSapling = std::get_if<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
bool toSprout = !toSapling;
|
||||
noSproutAddrs = noSproutAddrs && toSapling;
|
||||
|
||||
|
@ -4220,7 +4222,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
for (int i = 0; i < zaddrRecipients.size(); i++) {
|
||||
auto address = zaddrRecipients[i].address;
|
||||
auto res = keyIO.DecodePaymentAddress(address);
|
||||
bool toSapling = boost::get<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
bool toSapling = std::get_if<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
if (toSapling) {
|
||||
mtx.vShieldedOutput.push_back(OutputDescription());
|
||||
} else {
|
||||
|
@ -4295,7 +4297,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Builder (used if Sapling addresses are involved)
|
||||
boost::optional<TransactionBuilder> builder;
|
||||
std::optional<TransactionBuilder> builder;
|
||||
if (noSproutAddrs) {
|
||||
builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain);
|
||||
}
|
||||
|
@ -4520,7 +4522,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
|||
|
||||
if (canopyActive) {
|
||||
auto decodeAddr = keyIO.DecodePaymentAddress(destaddress);
|
||||
bool isToSproutZaddr = (boost::get<libzcash::SproutPaymentAddress>(&decodeAddr) != nullptr);
|
||||
bool isToSproutZaddr = (std::get_if<libzcash::SproutPaymentAddress>(&decodeAddr) != nullptr);
|
||||
|
||||
if (isToSproutZaddr) {
|
||||
throw JSONRPCError(RPC_VERIFY_REJECTED, "Sprout shielding is not supported after Canopy activation");
|
||||
|
@ -4600,7 +4602,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
|||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
if (!maxedOutFlag) {
|
||||
size_t increase = (boost::get<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
size_t increase = (std::get_if<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
if (estimatedTxSize + increase >= max_tx_size ||
|
||||
(mempoolLimit > 0 && utxoCounter > mempoolLimit))
|
||||
{
|
||||
|
@ -4775,7 +4777,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
auto zaddr = keyIO.DecodePaymentAddress(address);
|
||||
if (IsValidPaymentAddress(zaddr)) {
|
||||
zaddrs.insert(zaddr);
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
if (std::get_if<libzcash::SaplingPaymentAddress>(&zaddr) != nullptr) {
|
||||
isFromNonSprout = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -4809,7 +4811,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
if (!IsValidDestination(taddr)) {
|
||||
auto decodeAddr = keyIO.DecodePaymentAddress(destaddress);
|
||||
if (IsValidPaymentAddress(decodeAddr)) {
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&decodeAddr) != nullptr) {
|
||||
if (std::get_if<libzcash::SaplingPaymentAddress>(&decodeAddr) != nullptr) {
|
||||
isToSaplingZaddr = true;
|
||||
// If Sapling is not active, do not allow sending to a sapling addresses.
|
||||
if (!saplingActive) {
|
||||
|
@ -4920,7 +4922,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
if (!maxedOutUTXOsFlag) {
|
||||
size_t increase = (boost::get<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
size_t increase = (std::get_if<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
if (estimatedTxSize + increase >= max_tx_size ||
|
||||
(mempoolLimit > 0 && utxoCounter > mempoolLimit))
|
||||
{
|
||||
|
@ -5077,7 +5079,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
|||
}
|
||||
|
||||
// Builder (used if Sapling addresses are involved)
|
||||
boost::optional<TransactionBuilder> builder;
|
||||
std::optional<TransactionBuilder> builder;
|
||||
if (isToSaplingZaddr || saplingNoteInputs.size() > 0) {
|
||||
builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <variant>
|
||||
|
||||
#include <fstream>
|
||||
#include <unordered_set>
|
||||
|
@ -36,7 +38,6 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
|
@ -644,8 +645,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet)
|
|||
// check that we have the spending key for the address
|
||||
auto address = keyIO.DecodePaymentAddress(testAddr);
|
||||
BOOST_CHECK(IsValidPaymentAddress(address));
|
||||
BOOST_ASSERT(boost::get<libzcash::SproutPaymentAddress>(&address) != nullptr);
|
||||
auto addr = boost::get<libzcash::SproutPaymentAddress>(address);
|
||||
BOOST_ASSERT(std::get_if<libzcash::SproutPaymentAddress>(&address) != nullptr);
|
||||
auto addr = std::get<libzcash::SproutPaymentAddress>(address);
|
||||
BOOST_CHECK(pwalletMain->HaveSproutSpendingKey(addr));
|
||||
|
||||
// Verify the spending key is the same as the test data
|
||||
|
@ -758,7 +759,7 @@ template <typename ADDR_TYPE>
|
|||
void CheckHaveAddr(const libzcash::PaymentAddress& addr) {
|
||||
|
||||
BOOST_CHECK(IsValidPaymentAddress(addr));
|
||||
auto addr_of_type = boost::get<ADDR_TYPE>(&addr);
|
||||
auto addr_of_type = std::get_if<ADDR_TYPE>(&addr);
|
||||
BOOST_ASSERT(addr_of_type != nullptr);
|
||||
|
||||
HaveSpendingKeyForPaymentAddress test(pwalletMain);
|
||||
|
@ -1122,26 +1123,26 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
|
|||
|
||||
// Test constructor of AsyncRPCOperation_sendmany
|
||||
try {
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(boost::none, mtx, "",{}, {}, -1));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::nullopt, mtx, "",{}, {}, -1));
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Minconf cannot be negative"));
|
||||
}
|
||||
|
||||
try {
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(boost::none, mtx, "",{}, {}, 1));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::nullopt, mtx, "",{}, {}, 1));
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "From address parameter missing"));
|
||||
}
|
||||
|
||||
try {
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ", {}, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "tmRr6yJonqGK23UVhrKuyvTpF8qxQQjKigJ", {}, {}, 1) );
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "No recipients"));
|
||||
}
|
||||
|
||||
try {
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy", 1*COIN, "") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "INVALID", recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "INVALID", recipients, {}, 1) );
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Invalid from address"));
|
||||
}
|
||||
|
@ -1149,7 +1150,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
|
|||
// Testnet payment addresses begin with 'zt'. This test detects an incorrect prefix.
|
||||
try {
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy", 1*COIN, "") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "zcMuhvq8sEkHALuSU2i4NbNQxshSAYrpCExec45ZjtivYPbuiFPwk6WHy4SvsbeZ4siy1WheuRGjtaJmoD1J8bFqNXhsG6U", recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "zcMuhvq8sEkHALuSU2i4NbNQxshSAYrpCExec45ZjtivYPbuiFPwk6WHy4SvsbeZ4siy1WheuRGjtaJmoD1J8bFqNXhsG6U", recipients, {}, 1) );
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Invalid from address"));
|
||||
}
|
||||
|
@ -1158,7 +1159,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
|
|||
// invokes a method on pwalletMain, which is undefined in the google test environment.
|
||||
try {
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient("dummy", 1*COIN, "") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "ztjiDe569DPNbyTE6TSdJTaSDhoXEHLGvYoUnBU1wfVNU52TEyT6berYtySkd21njAeEoh8fFJUT42kua9r8EnhBaEKqCpP", recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, "ztjiDe569DPNbyTE6TSdJTaSDhoXEHLGvYoUnBU1wfVNU52TEyT6berYtySkd21njAeEoh8fFJUT42kua9r8EnhBaEKqCpP", recipients, {}, 1) );
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "no spending key found for zaddr"));
|
||||
}
|
||||
|
@ -1170,7 +1171,7 @@ BOOST_AUTO_TEST_CASE(asyncrpcoperation_sign_send_raw_transaction) {
|
|||
UniValue obj(UniValue::VOBJ);
|
||||
obj.pushKV("rawtxn", raw);
|
||||
// Verify test mode is returning output (since no input taddrs, signed and unsigned are the same).
|
||||
std::pair<CTransaction, UniValue> txAndResult = SignSendRawTransaction(obj, boost::none, true);
|
||||
std::pair<CTransaction, UniValue> txAndResult = SignSendRawTransaction(obj, std::nullopt, true);
|
||||
UniValue resultObj = txAndResult.second.get_obj();
|
||||
std::string hex = find_value(resultObj, "hex").get_str();
|
||||
BOOST_CHECK_EQUAL(hex, raw);
|
||||
|
@ -1205,7 +1206,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
// there are no utxos to spend
|
||||
{
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, taddr1, {}, recipients, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, taddr1, {}, recipients, 1) );
|
||||
operation->main();
|
||||
BOOST_CHECK(operation->isFailed());
|
||||
std::string msg = operation->getErrorMessage();
|
||||
|
@ -1216,7 +1217,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
{
|
||||
try {
|
||||
std::vector<SendManyRecipient> recipients = {SendManyRecipient(taddr1, 100*COIN, "DEADBEEF")};
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 0));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 0));
|
||||
BOOST_CHECK(false); // Fail test if an exception is not thrown
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK(find_error(objError, "Minconf cannot be zero when sending from zaddr"));
|
||||
|
@ -1227,7 +1228,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
// there are no unspent notes to spend
|
||||
{
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(taddr1, 100*COIN, "DEADBEEF") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) );
|
||||
operation->main();
|
||||
BOOST_CHECK(operation->isFailed());
|
||||
std::string msg = operation->getErrorMessage();
|
||||
|
@ -1237,7 +1238,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
// get_memo_from_hex_string())
|
||||
{
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation_sendmany> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_sendmany> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
|
||||
|
||||
|
@ -1288,7 +1289,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
// add_taddr_change_output_to_tx() will append a vout to a raw transaction
|
||||
{
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation_sendmany> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_sendmany> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
|
||||
|
||||
|
@ -1318,7 +1319,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
SendManyRecipient("tmUSbHz3vxnwLvRyNDXbwkZxjVyDodMJEhh", 456000000, ""),
|
||||
SendManyRecipient("tmYZAXYPCP56Xa5JQWWPZuK7o7bfUQW6kkd", 789000000, ""),
|
||||
};
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, recipients, {}, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation_sendmany> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_sendmany> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
|
||||
|
||||
|
@ -1336,7 +1337,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
// Dummy input so the operation object can be instantiated.
|
||||
std::vector<SendManyRecipient> recipients = { SendManyRecipient(zaddr1, 50000, "ABCD") };
|
||||
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, {}, recipients, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_sendmany(std::nullopt, mtx, zaddr1, {}, recipients, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation_sendmany> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_sendmany> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
|
||||
|
||||
|
@ -1344,7 +1345,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||
static_cast<AsyncRPCOperation_sendmany *>(operation.get())->testmode = true;
|
||||
|
||||
AsyncJoinSplitInfo info;
|
||||
std::vector<boost::optional < SproutWitness>> witnesses;
|
||||
std::vector<std::optional < SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
try {
|
||||
proxy.perform_joinsplit(info, witnesses, anchor);
|
||||
|
@ -1883,14 +1884,14 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
"mainnet memo");
|
||||
|
||||
try {
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(boost::none, mtx, {}, {}, {}, testnetzaddr, -1 ));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, {}, {}, {}, testnetzaddr, -1 ));
|
||||
BOOST_FAIL("Should have caused an error");
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Fee is out of range"));
|
||||
}
|
||||
|
||||
try {
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(boost::none, mtx, {}, {}, {}, testnetzaddr, 1));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, {}, {}, {}, testnetzaddr, 1));
|
||||
BOOST_FAIL("Should have caused an error");
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "No inputs"));
|
||||
|
@ -1900,7 +1901,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
|
||||
try {
|
||||
MergeToAddressRecipient badaddr("", "memo");
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, {}, {}, badaddr, 1));
|
||||
std::shared_ptr<AsyncRPCOperation> operation(new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, {}, {}, badaddr, 1));
|
||||
BOOST_FAIL("Should have caused an error");
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Recipient parameter missing"));
|
||||
|
@ -1913,7 +1914,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
|
||||
// Sprout and Sapling inputs -> throw
|
||||
try {
|
||||
auto operation = new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, sproutNoteInputs, saplingNoteInputs, testnetzaddr, 1);
|
||||
auto operation = new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, sproutNoteInputs, saplingNoteInputs, testnetzaddr, 1);
|
||||
BOOST_FAIL("Should have caused an error");
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK(find_error(objError, "Cannot send from both Sprout and Sapling addresses using z_mergetoaddress"));
|
||||
|
@ -1929,7 +1930,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
|||
// Testnet payment addresses begin with 'zt'. This test detects an incorrect prefix.
|
||||
try {
|
||||
std::vector<MergeToAddressInputUTXO> inputs = { MergeToAddressInputUTXO{ COutPoint{uint256(), 0}, 0, CScript()} };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, {}, {}, mainnetzaddr, 1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, {}, {}, mainnetzaddr, 1) );
|
||||
BOOST_FAIL("Should have caused an error");
|
||||
} catch (const UniValue& objError) {
|
||||
BOOST_CHECK( find_error(objError, "Invalid recipient address"));
|
||||
|
@ -1963,7 +1964,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
|||
// Insufficient funds
|
||||
{
|
||||
std::vector<MergeToAddressInputUTXO> inputs = { MergeToAddressInputUTXO{COutPoint{uint256(),0},0, CScript()} };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, {}, {}, zaddr1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, {}, {}, zaddr1) );
|
||||
operation->main();
|
||||
BOOST_CHECK(operation->isFailed());
|
||||
std::string msg = operation->getErrorMessage();
|
||||
|
@ -1973,7 +1974,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
|||
// get_memo_from_hex_string())
|
||||
{
|
||||
std::vector<MergeToAddressInputUTXO> inputs = { MergeToAddressInputUTXO{COutPoint{uint256(),0},100000, CScript()} };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, {}, {}, zaddr1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, {}, {}, zaddr1) );
|
||||
std::shared_ptr<AsyncRPCOperation_mergetoaddress> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_mergetoaddress> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr);
|
||||
|
||||
|
@ -2027,7 +2028,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
|||
{
|
||||
// Dummy input so the operation object can be instantiated.
|
||||
std::vector<MergeToAddressInputUTXO> inputs = { MergeToAddressInputUTXO{COutPoint{uint256(),0},100000, CScript()} };
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(boost::none, mtx, inputs, {}, {}, zaddr1) );
|
||||
std::shared_ptr<AsyncRPCOperation> operation( new AsyncRPCOperation_mergetoaddress(std::nullopt, mtx, inputs, {}, {}, zaddr1) );
|
||||
std::shared_ptr<AsyncRPCOperation_mergetoaddress> ptr = std::dynamic_pointer_cast<AsyncRPCOperation_mergetoaddress> (operation);
|
||||
TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr);
|
||||
|
||||
|
@ -2035,7 +2036,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
|||
static_cast<AsyncRPCOperation_mergetoaddress *>(operation.get())->testmode = true;
|
||||
|
||||
MergeToAddressJSInfo info;
|
||||
std::vector<boost::optional < SproutWitness>> witnesses;
|
||||
std::vector<std::optional < SproutWitness>> witnesses;
|
||||
uint256 anchor;
|
||||
try {
|
||||
proxy.perform_joinsplit(info, witnesses, anchor);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <variant>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
@ -614,7 +615,7 @@ void CWallet::ChainTipAdded(const CBlockIndex *pindex,
|
|||
|
||||
void CWallet::ChainTip(const CBlockIndex *pindex,
|
||||
const CBlock *pblock,
|
||||
boost::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added)
|
||||
std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added)
|
||||
{
|
||||
if (added) {
|
||||
ChainTipAdded(pindex, pblock, added->first, added->second);
|
||||
|
@ -665,7 +666,7 @@ void CWallet::RunSaplingMigration(int blockHeight) {
|
|||
for (const CTransaction& transaction : pendingSaplingMigrationTxs) {
|
||||
// Send the transaction
|
||||
CWalletTx wtx(this, transaction);
|
||||
CommitTransaction(wtx, boost::none);
|
||||
CommitTransaction(wtx, std::nullopt);
|
||||
}
|
||||
pendingSaplingMigrationTxs.clear();
|
||||
}
|
||||
|
@ -690,7 +691,7 @@ std::set<std::pair<libzcash::PaymentAddress, uint256>> CWallet::GetNullifiersFor
|
|||
// (There may be more than one diversified address for a given ivk.)
|
||||
std::map<libzcash::SaplingIncomingViewingKey, std::vector<libzcash::SaplingPaymentAddress>> ivkMap;
|
||||
for (const auto & addr : addresses) {
|
||||
auto saplingAddr = boost::get<libzcash::SaplingPaymentAddress>(&addr);
|
||||
auto saplingAddr = std::get_if<libzcash::SaplingPaymentAddress>(&addr);
|
||||
if (saplingAddr != nullptr) {
|
||||
libzcash::SaplingIncomingViewingKey ivk;
|
||||
this->GetSaplingIncomingViewingKey(*saplingAddr, ivk);
|
||||
|
@ -704,7 +705,7 @@ std::set<std::pair<libzcash::PaymentAddress, uint256>> CWallet::GetNullifiersFor
|
|||
auto & nullifier = noteData.nullifier;
|
||||
auto & address = noteData.address;
|
||||
if (nullifier && addresses.count(address)) {
|
||||
nullifierSet.insert(std::make_pair(address, nullifier.get()));
|
||||
nullifierSet.insert(std::make_pair(address, nullifier.value()));
|
||||
}
|
||||
}
|
||||
// Sapling
|
||||
|
@ -714,7 +715,7 @@ std::set<std::pair<libzcash::PaymentAddress, uint256>> CWallet::GetNullifiersFor
|
|||
auto & ivk = noteData.ivk;
|
||||
if (nullifier && ivkMap.count(ivk)) {
|
||||
for (const auto & addr : ivkMap[ivk]) {
|
||||
nullifierSet.insert(std::make_pair(addr, nullifier.get()));
|
||||
nullifierSet.insert(std::make_pair(addr, nullifier.value()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1522,9 +1523,9 @@ void CWallet::UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx) {
|
|||
if (nd.witnesses.empty()) {
|
||||
// If there are no witnesses, erase the nullifier and associated mapping.
|
||||
if (item.second.nullifier) {
|
||||
mapSaplingNullifiersToNotes.erase(item.second.nullifier.get());
|
||||
mapSaplingNullifiersToNotes.erase(item.second.nullifier.value());
|
||||
}
|
||||
item.second.nullifier = boost::none;
|
||||
item.second.nullifier = std::nullopt;
|
||||
}
|
||||
else {
|
||||
uint64_t position = nd.witnesses.front().position();
|
||||
|
@ -1535,21 +1536,21 @@ void CWallet::UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx) {
|
|||
|
||||
// The transaction would not have entered the wallet unless
|
||||
// its plaintext had been successfully decrypted previously.
|
||||
assert(optDeserialized != boost::none);
|
||||
assert(optDeserialized != std::nullopt);
|
||||
|
||||
auto optPlaintext = SaplingNotePlaintext::plaintext_checks_without_height(*optDeserialized, nd.ivk, output.ephemeralKey, output.cmu);
|
||||
|
||||
// An item in mapSaplingNoteData must have already been successfully decrypted,
|
||||
// otherwise the item would not exist in the first place.
|
||||
assert(optPlaintext != boost::none);
|
||||
assert(optPlaintext != std::nullopt);
|
||||
|
||||
auto optNote = optPlaintext.get().note(nd.ivk);
|
||||
assert(optNote != boost::none);
|
||||
auto optNote = optPlaintext.value().note(nd.ivk);
|
||||
assert(optNote != std::nullopt);
|
||||
|
||||
auto optNullifier = optNote.get().nullifier(extfvk.fvk, position);
|
||||
auto optNullifier = optNote.value().nullifier(extfvk.fvk, position);
|
||||
// This should not happen. If it does, maybe the position has been corrupted or miscalculated?
|
||||
assert(optNullifier != boost::none);
|
||||
uint256 nullifier = optNullifier.get();
|
||||
assert(optNullifier != std::nullopt);
|
||||
uint256 nullifier = optNullifier.value();
|
||||
mapSaplingNullifiersToNotes[nullifier] = op;
|
||||
item.second.nullifier = nullifier;
|
||||
}
|
||||
|
@ -1841,13 +1842,13 @@ void CWallet::EraseFromWallet(const uint256 &hash)
|
|||
* Returns a nullifier if the SpendingKey is available
|
||||
* Throws std::runtime_error if the decryptor doesn't match this note
|
||||
*/
|
||||
boost::optional<uint256> CWallet::GetSproutNoteNullifier(const JSDescription &jsdesc,
|
||||
std::optional<uint256> CWallet::GetSproutNoteNullifier(const JSDescription &jsdesc,
|
||||
const libzcash::SproutPaymentAddress &address,
|
||||
const ZCNoteDecryption &dec,
|
||||
const uint256 &hSig,
|
||||
uint8_t n) const
|
||||
{
|
||||
boost::optional<uint256> ret;
|
||||
std::optional<uint256> ret;
|
||||
auto note_pt = libzcash::SproutNotePlaintext::decrypt(
|
||||
dec,
|
||||
jsdesc.ciphertexts[n],
|
||||
|
@ -1945,9 +1946,9 @@ std::pair<mapSaplingNoteData_t, SaplingIncomingViewingKeyMap> CWallet::FindMySap
|
|||
if (!result) {
|
||||
continue;
|
||||
}
|
||||
auto address = ivk.address(result.get().d);
|
||||
if (address && mapSaplingIncomingViewingKeys.count(address.get()) == 0) {
|
||||
viewingKeysToAdd[address.get()] = ivk;
|
||||
auto address = ivk.address(result.value().d);
|
||||
if (address && mapSaplingIncomingViewingKeys.count(address.value()) == 0) {
|
||||
viewingKeysToAdd[address.value()] = ivk;
|
||||
}
|
||||
// We don't cache the nullifier here as computing it requires knowledge of the note position
|
||||
// in the commitment tree, which can only be determined when the transaction has been mined.
|
||||
|
@ -1987,12 +1988,12 @@ bool CWallet::IsSaplingNullifierFromMe(const uint256& nullifier) const
|
|||
}
|
||||
|
||||
void CWallet::GetSproutNoteWitnesses(std::vector<JSOutPoint> notes,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
std::vector<std::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
witnesses.resize(notes.size());
|
||||
boost::optional<uint256> rt;
|
||||
std::optional<uint256> rt;
|
||||
int i = 0;
|
||||
for (JSOutPoint note : notes) {
|
||||
if (mapWallet.count(note.hash) &&
|
||||
|
@ -2014,12 +2015,12 @@ void CWallet::GetSproutNoteWitnesses(std::vector<JSOutPoint> notes,
|
|||
}
|
||||
|
||||
void CWallet::GetSaplingNoteWitnesses(std::vector<SaplingOutPoint> notes,
|
||||
std::vector<boost::optional<SaplingWitness>>& witnesses,
|
||||
std::vector<std::optional<SaplingWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
witnesses.resize(notes.size());
|
||||
boost::optional<uint256> rt;
|
||||
std::optional<uint256> rt;
|
||||
int i = 0;
|
||||
for (SaplingOutPoint note : notes) {
|
||||
if (mapWallet.count(note.hash) &&
|
||||
|
@ -2339,13 +2340,13 @@ std::pair<SproutNotePlaintext, SproutPaymentAddress> CWalletTx::DecryptSproutNot
|
|||
}
|
||||
}
|
||||
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
SaplingNotePlaintext,
|
||||
SaplingPaymentAddress>> CWalletTx::DecryptSaplingNote(const Consensus::Params& params, int height, SaplingOutPoint op) const
|
||||
{
|
||||
// Check whether we can decrypt this SaplingOutPoint
|
||||
if (this->mapSaplingNoteData.count(op) == 0) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto output = this->vShieldedOutput[op.n];
|
||||
|
@ -2358,23 +2359,23 @@ boost::optional<std::pair<
|
|||
nd.ivk,
|
||||
output.ephemeralKey,
|
||||
output.cmu);
|
||||
assert(maybe_pt != boost::none);
|
||||
auto notePt = maybe_pt.get();
|
||||
assert(maybe_pt != std::nullopt);
|
||||
auto notePt = maybe_pt.value();
|
||||
|
||||
auto maybe_pa = nd.ivk.address(notePt.d);
|
||||
assert(maybe_pa != boost::none);
|
||||
auto pa = maybe_pa.get();
|
||||
assert(maybe_pa != std::nullopt);
|
||||
auto pa = maybe_pa.value();
|
||||
|
||||
return std::make_pair(notePt, pa);
|
||||
}
|
||||
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
SaplingNotePlaintext,
|
||||
SaplingPaymentAddress>> CWalletTx::DecryptSaplingNoteWithoutLeadByteCheck(SaplingOutPoint op) const
|
||||
{
|
||||
// Check whether we can decrypt this SaplingOutPoint
|
||||
if (this->mapSaplingNoteData.count(op) == 0) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto output = this->vShieldedOutput[op.n];
|
||||
|
@ -2384,24 +2385,24 @@ boost::optional<std::pair<
|
|||
|
||||
// The transaction would not have entered the wallet unless
|
||||
// its plaintext had been successfully decrypted previously.
|
||||
assert(optDeserialized != boost::none);
|
||||
assert(optDeserialized != std::nullopt);
|
||||
|
||||
auto maybe_pt = SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
*optDeserialized,
|
||||
nd.ivk,
|
||||
output.ephemeralKey,
|
||||
output.cmu);
|
||||
assert(maybe_pt != boost::none);
|
||||
auto notePt = maybe_pt.get();
|
||||
assert(maybe_pt != std::nullopt);
|
||||
auto notePt = maybe_pt.value();
|
||||
|
||||
auto maybe_pa = nd.ivk.address(notePt.d);
|
||||
assert(static_cast<bool>(maybe_pa));
|
||||
auto pa = maybe_pa.get();
|
||||
auto pa = maybe_pa.value();
|
||||
|
||||
return std::make_pair(notePt, pa);
|
||||
}
|
||||
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
SaplingNotePlaintext,
|
||||
SaplingPaymentAddress>> CWalletTx::RecoverSaplingNote(const Consensus::Params& params, int height, SaplingOutPoint op, std::set<uint256>& ovks) const
|
||||
{
|
||||
|
@ -2428,16 +2429,16 @@ boost::optional<std::pair<
|
|||
outPt->pk_d,
|
||||
output.cmu);
|
||||
assert(static_cast<bool>(maybe_pt));
|
||||
auto notePt = maybe_pt.get();
|
||||
auto notePt = maybe_pt.value();
|
||||
|
||||
return std::make_pair(notePt, SaplingPaymentAddress(notePt.d, outPt->pk_d));
|
||||
}
|
||||
|
||||
// Couldn't recover with any of the provided OutgoingViewingKeys
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
SaplingNotePlaintext,
|
||||
SaplingPaymentAddress>> CWalletTx::RecoverSaplingNoteWithoutLeadByteCheck(SaplingOutPoint op, std::set<uint256>& ovks) const
|
||||
{
|
||||
|
@ -2459,7 +2460,7 @@ boost::optional<std::pair<
|
|||
|
||||
// The transaction would not have entered the wallet unless
|
||||
// its plaintext had been successfully decrypted previously.
|
||||
assert(optDeserialized != boost::none);
|
||||
assert(optDeserialized != std::nullopt);
|
||||
|
||||
auto maybe_pt = SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
*optDeserialized,
|
||||
|
@ -2468,13 +2469,13 @@ boost::optional<std::pair<
|
|||
outPt->pk_d,
|
||||
output.cmu);
|
||||
assert(static_cast<bool>(maybe_pt));
|
||||
auto notePt = maybe_pt.get();
|
||||
auto notePt = maybe_pt.value();
|
||||
|
||||
return std::make_pair(notePt, SaplingPaymentAddress(notePt.d, outPt->pk_d));
|
||||
}
|
||||
|
||||
// Couldn't recover with any of the provided OutgoingViewingKeys
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int64_t CWalletTx::GetTxTime() const
|
||||
|
@ -2680,7 +2681,7 @@ bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
|
|||
}
|
||||
|
||||
void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
std::vector<std::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor)
|
||||
{
|
||||
witnesses.resize(commitments.size());
|
||||
|
@ -2700,7 +2701,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
|||
{
|
||||
tree.append(note_commitment);
|
||||
|
||||
for (boost::optional<SproutWitness>& wit : witnesses) {
|
||||
for (std::optional<SproutWitness>& wit : witnesses) {
|
||||
if (wit) {
|
||||
wit->append(note_commitment);
|
||||
}
|
||||
|
@ -2730,7 +2731,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
|||
// TODO: #93; Select a root via some heuristic.
|
||||
final_anchor = tree.root();
|
||||
|
||||
for (boost::optional<SproutWitness>& wit : witnesses) {
|
||||
for (std::optional<SproutWitness>& wit : witnesses) {
|
||||
if (wit) {
|
||||
assert(final_anchor == wit->root());
|
||||
}
|
||||
|
@ -3711,7 +3712,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||
CScript scriptChange;
|
||||
|
||||
// coin control: send change to custom address
|
||||
if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange))
|
||||
if (coinControl && !std::get_if<CNoDestination>(&coinControl->destChange))
|
||||
scriptChange = GetScriptForDestination(coinControl->destChange);
|
||||
|
||||
// no coin control: send change to newly generated address
|
||||
|
@ -3870,7 +3871,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
|||
/**
|
||||
* Call after CreateTransaction unless you want to abort
|
||||
*/
|
||||
bool CWallet::CommitTransaction(CWalletTx& wtxNew, boost::optional<CReserveKey&> reservekey)
|
||||
bool CWallet::CommitTransaction(CWalletTx& wtxNew, std::optional<std::reference_wrapper<CReserveKey>> reservekey)
|
||||
{
|
||||
{
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
|
@ -3883,7 +3884,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, boost::optional<CReserveKey&>
|
|||
|
||||
if (reservekey) {
|
||||
// Take key pair from key pool so it won't be used again
|
||||
reservekey.get().KeepKey();
|
||||
reservekey.value().get().KeepKey();
|
||||
}
|
||||
|
||||
// Add tx to wallet, because if it has change it's also ours,
|
||||
|
@ -4533,7 +4534,7 @@ std::vector<SaplingOutPoint> CWallet::ListLockedSaplingNotes()
|
|||
|
||||
/** @} */ // end of Actions
|
||||
|
||||
class CAffectedKeysVisitor : public boost::static_visitor<void> {
|
||||
class CAffectedKeysVisitor {
|
||||
private:
|
||||
const CKeyStore &keystore;
|
||||
std::vector<CKeyID> &vKeys;
|
||||
|
@ -4547,7 +4548,7 @@ public:
|
|||
int nRequired;
|
||||
if (ExtractDestinations(script, type, vDest, nRequired)) {
|
||||
for (const CTxDestination &dest : vDest)
|
||||
boost::apply_visitor(*this, dest);
|
||||
std::visit(*this, dest);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4621,7 +4622,7 @@ void CWallet::GetKeyBirthTimes(std::map<CKeyID, int64_t> &mapKeyBirth) const {
|
|||
|
||||
bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
|
||||
{
|
||||
if (boost::get<CNoDestination>(&dest))
|
||||
if (std::get_if<CNoDestination>(&dest))
|
||||
return false;
|
||||
|
||||
mapAddressBook[dest].destdata.insert(std::make_pair(key, value));
|
||||
|
@ -4912,7 +4913,7 @@ bool CWallet::ParameterInteraction()
|
|||
if (mapArgs.count("-migrationdestaddress")) {
|
||||
std::string migrationDestAddress = mapArgs["-migrationdestaddress"];
|
||||
libzcash::PaymentAddress address = keyIO.DecodePaymentAddress(migrationDestAddress);
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&address) == nullptr) {
|
||||
if (std::get_if<libzcash::SaplingPaymentAddress>(&address) == nullptr) {
|
||||
return UIError(_("-migrationdestaddress must be a valid Sapling address."));
|
||||
}
|
||||
}
|
||||
|
@ -5129,12 +5130,12 @@ void CWallet::GetFilteredNotes(
|
|||
|
||||
// The transaction would not have entered the wallet unless
|
||||
// its plaintext had been successfully decrypted previously.
|
||||
assert(optDeserialized != boost::none);
|
||||
assert(optDeserialized != std::nullopt);
|
||||
|
||||
auto notePt = optDeserialized.get();
|
||||
auto notePt = optDeserialized.value();
|
||||
auto maybe_pa = nd.ivk.address(notePt.d);
|
||||
assert(static_cast<bool>(maybe_pa));
|
||||
auto pa = maybe_pa.get();
|
||||
auto pa = maybe_pa.value();
|
||||
|
||||
// skip notes which belong to a different payment address in the wallet
|
||||
if (!(filterAddresses.empty() || filterAddresses.count(pa))) {
|
||||
|
@ -5155,7 +5156,7 @@ void CWallet::GetFilteredNotes(
|
|||
continue;
|
||||
}
|
||||
|
||||
auto note = notePt.note(nd.ivk).get();
|
||||
auto note = notePt.note(nd.ivk).value();
|
||||
saplingEntries.push_back(SaplingNoteEntry {
|
||||
op, pa, note, notePt.memo(), wtx.GetDepthInMainChain() });
|
||||
}
|
||||
|
@ -5187,21 +5188,21 @@ bool PaymentAddressBelongsToWallet::operator()(const libzcash::InvalidEncoding&
|
|||
return false;
|
||||
}
|
||||
|
||||
boost::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
const libzcash::SproutPaymentAddress &zaddr) const
|
||||
{
|
||||
libzcash::SproutViewingKey vk;
|
||||
if (!m_wallet->GetSproutViewingKey(zaddr, vk)) {
|
||||
libzcash::SproutSpendingKey k;
|
||||
if (!m_wallet->GetSproutSpendingKey(zaddr, k)) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
vk = k.viewing_key();
|
||||
}
|
||||
return libzcash::ViewingKey(vk);
|
||||
}
|
||||
|
||||
boost::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
const libzcash::SaplingPaymentAddress &zaddr) const
|
||||
{
|
||||
libzcash::SaplingIncomingViewingKey ivk;
|
||||
|
@ -5212,11 +5213,11 @@ boost::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()
|
|||
{
|
||||
return libzcash::ViewingKey(extfvk);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::ViewingKey> GetViewingKeyForPaymentAddress::operator()(
|
||||
const libzcash::InvalidEncoding& no) const
|
||||
{
|
||||
// Defaults to InvalidEncoding
|
||||
|
@ -5243,29 +5244,29 @@ bool HaveSpendingKeyForPaymentAddress::operator()(const libzcash::InvalidEncodin
|
|||
return false;
|
||||
}
|
||||
|
||||
boost::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
const libzcash::SproutPaymentAddress &zaddr) const
|
||||
{
|
||||
libzcash::SproutSpendingKey k;
|
||||
if (m_wallet->GetSproutSpendingKey(zaddr, k)) {
|
||||
return libzcash::SpendingKey(k);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
const libzcash::SaplingPaymentAddress &zaddr) const
|
||||
{
|
||||
libzcash::SaplingExtendedSpendingKey extsk;
|
||||
if (m_wallet->GetSaplingExtendedSpendingKey(zaddr, extsk)) {
|
||||
return libzcash::SpendingKey(extsk);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
std::optional<libzcash::SpendingKey> GetSpendingKeyForPaymentAddress::operator()(
|
||||
const libzcash::InvalidEncoding& no) const
|
||||
{
|
||||
// Defaults to InvalidEncoding
|
||||
|
@ -5342,11 +5343,11 @@ KeyAddResult AddSpendingKeyToWallet::operator()(const libzcash::SaplingExtendedS
|
|||
m_wallet->mapSaplingZKeyMetadata[ivk].nCreateTime = std::max((int64_t) 154051200, nTime);
|
||||
}
|
||||
if (hdKeypath) {
|
||||
m_wallet->mapSaplingZKeyMetadata[ivk].hdKeypath = hdKeypath.get();
|
||||
m_wallet->mapSaplingZKeyMetadata[ivk].hdKeypath = hdKeypath.value();
|
||||
}
|
||||
if (seedFpStr) {
|
||||
uint256 seedFp;
|
||||
seedFp.SetHex(seedFpStr.get());
|
||||
seedFp.SetHex(seedFpStr.value());
|
||||
m_wallet->mapSaplingZKeyMetadata[ivk].seedFp = seedFp;
|
||||
}
|
||||
return KeyAdded;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
|
@ -227,7 +228,7 @@ public:
|
|||
* transactions they are spent in. This is the same security semantics as
|
||||
* for transparent addresses.
|
||||
*/
|
||||
boost::optional<uint256> nullifier;
|
||||
std::optional<uint256> nullifier;
|
||||
|
||||
/**
|
||||
* Cached incremental witnesses for spendable Notes.
|
||||
|
@ -290,7 +291,7 @@ public:
|
|||
std::list<SaplingWitness> witnesses;
|
||||
int witnessHeight;
|
||||
libzcash::SaplingIncomingViewingKey ivk;
|
||||
boost::optional<uint256> nullifier;
|
||||
std::optional<uint256> nullifier;
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
|
@ -564,17 +565,17 @@ public:
|
|||
|
||||
std::pair<libzcash::SproutNotePlaintext, libzcash::SproutPaymentAddress> DecryptSproutNote(
|
||||
JSOutPoint jsop) const;
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
libzcash::SaplingNotePlaintext,
|
||||
libzcash::SaplingPaymentAddress>> DecryptSaplingNote(const Consensus::Params& params, int height, SaplingOutPoint op) const;
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
libzcash::SaplingNotePlaintext,
|
||||
libzcash::SaplingPaymentAddress>> DecryptSaplingNoteWithoutLeadByteCheck(SaplingOutPoint op) const;
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
libzcash::SaplingNotePlaintext,
|
||||
libzcash::SaplingPaymentAddress>> RecoverSaplingNote(const Consensus::Params& params, int height,
|
||||
SaplingOutPoint op, std::set<uint256>& ovks) const;
|
||||
boost::optional<std::pair<
|
||||
std::optional<std::pair<
|
||||
libzcash::SaplingNotePlaintext,
|
||||
libzcash::SaplingPaymentAddress>> RecoverSaplingNoteWithoutLeadByteCheck(SaplingOutPoint op, std::set<uint256>& ovks) const;
|
||||
|
||||
|
@ -1178,7 +1179,7 @@ public:
|
|||
void EraseFromWallet(const uint256 &hash);
|
||||
void WitnessNoteCommitment(
|
||||
std::vector<uint256> commitments,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
std::vector<std::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor);
|
||||
int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false);
|
||||
void ReacceptWalletTransactions();
|
||||
|
@ -1203,7 +1204,7 @@ public:
|
|||
*/
|
||||
bool CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosRet,
|
||||
std::string& strFailReason, const CCoinControl *coinControl = NULL, bool sign = true);
|
||||
bool CommitTransaction(CWalletTx& wtxNew, boost::optional<CReserveKey&> reservekey);
|
||||
bool CommitTransaction(CWalletTx& wtxNew, std::optional<std::reference_wrapper<CReserveKey>> reservekey);
|
||||
|
||||
static CFeeRate minTxFee;
|
||||
/**
|
||||
|
@ -1231,7 +1232,7 @@ public:
|
|||
|
||||
std::set<CTxDestination> GetAccountAddresses(const std::string& strAccount) const;
|
||||
|
||||
boost::optional<uint256> GetSproutNoteNullifier(
|
||||
std::optional<uint256> GetSproutNoteNullifier(
|
||||
const JSDescription& jsdesc,
|
||||
const libzcash::SproutPaymentAddress& address,
|
||||
const ZCNoteDecryption& dec,
|
||||
|
@ -1244,11 +1245,11 @@ public:
|
|||
|
||||
void GetSproutNoteWitnesses(
|
||||
std::vector<JSOutPoint> notes,
|
||||
std::vector<boost::optional<SproutWitness>>& witnesses,
|
||||
std::vector<std::optional<SproutWitness>>& witnesses,
|
||||
uint256 &final_anchor);
|
||||
void GetSaplingNoteWitnesses(
|
||||
std::vector<SaplingOutPoint> notes,
|
||||
std::vector<boost::optional<SaplingWitness>>& witnesses,
|
||||
std::vector<std::optional<SaplingWitness>>& witnesses,
|
||||
uint256 &final_anchor);
|
||||
|
||||
isminetype IsMine(const CTxIn& txin) const;
|
||||
|
@ -1266,7 +1267,7 @@ public:
|
|||
void ChainTip(
|
||||
const CBlockIndex *pindex,
|
||||
const CBlock *pblock,
|
||||
boost::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added);
|
||||
std::optional<std::pair<SproutMerkleTree, SaplingMerkleTree>> added);
|
||||
void RunSaplingMigration(int blockHeight);
|
||||
void AddPendingSaplingMigrationTx(const CTransaction& tx);
|
||||
/** Saves witness caches and best block locator to disk. */
|
||||
|
@ -1467,7 +1468,7 @@ public:
|
|||
// Shielded key and address generalizations
|
||||
//
|
||||
|
||||
class PaymentAddressBelongsToWallet : public boost::static_visitor<bool>
|
||||
class PaymentAddressBelongsToWallet
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
|
@ -1479,19 +1480,19 @@ public:
|
|||
bool operator()(const libzcash::InvalidEncoding& no) const;
|
||||
};
|
||||
|
||||
class GetViewingKeyForPaymentAddress : public boost::static_visitor<boost::optional<libzcash::ViewingKey>>
|
||||
class GetViewingKeyForPaymentAddress
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
public:
|
||||
GetViewingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {}
|
||||
|
||||
boost::optional<libzcash::ViewingKey> operator()(const libzcash::SproutPaymentAddress &zaddr) const;
|
||||
boost::optional<libzcash::ViewingKey> operator()(const libzcash::SaplingPaymentAddress &zaddr) const;
|
||||
boost::optional<libzcash::ViewingKey> operator()(const libzcash::InvalidEncoding& no) const;
|
||||
std::optional<libzcash::ViewingKey> operator()(const libzcash::SproutPaymentAddress &zaddr) const;
|
||||
std::optional<libzcash::ViewingKey> operator()(const libzcash::SaplingPaymentAddress &zaddr) const;
|
||||
std::optional<libzcash::ViewingKey> operator()(const libzcash::InvalidEncoding& no) const;
|
||||
};
|
||||
|
||||
class HaveSpendingKeyForPaymentAddress : public boost::static_visitor<bool>
|
||||
class HaveSpendingKeyForPaymentAddress
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
|
@ -1503,16 +1504,16 @@ public:
|
|||
bool operator()(const libzcash::InvalidEncoding& no) const;
|
||||
};
|
||||
|
||||
class GetSpendingKeyForPaymentAddress : public boost::static_visitor<boost::optional<libzcash::SpendingKey>>
|
||||
class GetSpendingKeyForPaymentAddress
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
public:
|
||||
GetSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {}
|
||||
|
||||
boost::optional<libzcash::SpendingKey> operator()(const libzcash::SproutPaymentAddress &zaddr) const;
|
||||
boost::optional<libzcash::SpendingKey> operator()(const libzcash::SaplingPaymentAddress &zaddr) const;
|
||||
boost::optional<libzcash::SpendingKey> operator()(const libzcash::InvalidEncoding& no) const;
|
||||
std::optional<libzcash::SpendingKey> operator()(const libzcash::SproutPaymentAddress &zaddr) const;
|
||||
std::optional<libzcash::SpendingKey> operator()(const libzcash::SaplingPaymentAddress &zaddr) const;
|
||||
std::optional<libzcash::SpendingKey> operator()(const libzcash::InvalidEncoding& no) const;
|
||||
};
|
||||
|
||||
enum KeyAddResult {
|
||||
|
@ -1522,7 +1523,7 @@ enum KeyAddResult {
|
|||
KeyNotAdded,
|
||||
};
|
||||
|
||||
class AddViewingKeyToWallet : public boost::static_visitor<KeyAddResult>
|
||||
class AddViewingKeyToWallet
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
|
@ -1534,24 +1535,24 @@ public:
|
|||
KeyAddResult operator()(const libzcash::InvalidEncoding& no) const;
|
||||
};
|
||||
|
||||
class AddSpendingKeyToWallet : public boost::static_visitor<KeyAddResult>
|
||||
class AddSpendingKeyToWallet
|
||||
{
|
||||
private:
|
||||
CWallet *m_wallet;
|
||||
const Consensus::Params ¶ms;
|
||||
int64_t nTime;
|
||||
boost::optional<std::string> hdKeypath; // currently sapling only
|
||||
boost::optional<std::string> seedFpStr; // currently sapling only
|
||||
std::optional<std::string> hdKeypath; // currently sapling only
|
||||
std::optional<std::string> seedFpStr; // currently sapling only
|
||||
bool log;
|
||||
public:
|
||||
AddSpendingKeyToWallet(CWallet *wallet, const Consensus::Params ¶ms) :
|
||||
m_wallet(wallet), params(params), nTime(1), hdKeypath(boost::none), seedFpStr(boost::none), log(false) {}
|
||||
m_wallet(wallet), params(params), nTime(1), hdKeypath(std::nullopt), seedFpStr(std::nullopt), log(false) {}
|
||||
AddSpendingKeyToWallet(
|
||||
CWallet *wallet,
|
||||
const Consensus::Params ¶ms,
|
||||
int64_t _nTime,
|
||||
boost::optional<std::string> _hdKeypath,
|
||||
boost::optional<std::string> _seedFp,
|
||||
std::optional<std::string> _hdKeypath,
|
||||
std::optional<std::string> _seedFp,
|
||||
bool _log
|
||||
) : m_wallet(wallet), params(params), nTime(_nTime), hdKeypath(_hdKeypath), seedFpStr(_seedFp), log(_log) {}
|
||||
|
||||
|
|
|
@ -25,13 +25,13 @@ std::pair<std::string, PaymentAddress> AddressInfoFromViewingKey::operator()(con
|
|||
}
|
||||
|
||||
bool IsValidPaymentAddress(const libzcash::PaymentAddress& zaddr) {
|
||||
return zaddr.which() != 0;
|
||||
return !std::holds_alternative<libzcash::InvalidEncoding>(zaddr);
|
||||
}
|
||||
|
||||
bool IsValidViewingKey(const libzcash::ViewingKey& vk) {
|
||||
return vk.which() != 0;
|
||||
return !std::holds_alternative<libzcash::InvalidEncoding>(vk);
|
||||
}
|
||||
|
||||
bool IsValidSpendingKey(const libzcash::SpendingKey& zkey) {
|
||||
return zkey.which() != 0;
|
||||
return !std::holds_alternative<libzcash::InvalidEncoding>(zkey);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "zcash/address/sprout.hpp"
|
||||
#include "zcash/address/zip32.h"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <variant>
|
||||
|
||||
namespace libzcash {
|
||||
class InvalidEncoding {
|
||||
|
@ -14,18 +14,18 @@ public:
|
|||
friend bool operator<(const InvalidEncoding &a, const InvalidEncoding &b) { return true; }
|
||||
};
|
||||
|
||||
typedef boost::variant<InvalidEncoding, SproutPaymentAddress, SaplingPaymentAddress> PaymentAddress;
|
||||
typedef boost::variant<InvalidEncoding, SproutViewingKey, SaplingExtendedFullViewingKey> ViewingKey;
|
||||
typedef boost::variant<InvalidEncoding, SproutSpendingKey, SaplingExtendedSpendingKey> SpendingKey;
|
||||
typedef std::variant<InvalidEncoding, SproutPaymentAddress, SaplingPaymentAddress> PaymentAddress;
|
||||
typedef std::variant<InvalidEncoding, SproutViewingKey, SaplingExtendedFullViewingKey> ViewingKey;
|
||||
typedef std::variant<InvalidEncoding, SproutSpendingKey, SaplingExtendedSpendingKey> SpendingKey;
|
||||
|
||||
class AddressInfoFromSpendingKey : public boost::static_visitor<std::pair<std::string, PaymentAddress>> {
|
||||
class AddressInfoFromSpendingKey {
|
||||
public:
|
||||
std::pair<std::string, PaymentAddress> operator()(const SproutSpendingKey&) const;
|
||||
std::pair<std::string, PaymentAddress> operator()(const struct SaplingExtendedSpendingKey&) const;
|
||||
std::pair<std::string, PaymentAddress> operator()(const InvalidEncoding&) const;
|
||||
};
|
||||
|
||||
class AddressInfoFromViewingKey : public boost::static_visitor<std::pair<std::string, PaymentAddress>> {
|
||||
class AddressInfoFromViewingKey {
|
||||
public:
|
||||
std::pair<std::string, PaymentAddress> operator()(const SproutViewingKey&) const;
|
||||
std::pair<std::string, PaymentAddress> operator()(const struct SaplingExtendedFullViewingKey&) const;
|
||||
|
|
|
@ -929,17 +929,17 @@ void IncrementalMerkleTree<Depth, Hash>::append(Hash obj) {
|
|||
right = obj;
|
||||
} else {
|
||||
// Combine the leaves and propagate it up the tree
|
||||
boost::optional<Hash> combined = Hash::combine(*left, *right, 0);
|
||||
std::optional<Hash> combined = Hash::combine(*left, *right, 0);
|
||||
|
||||
// Set the "left" leaf to the object and make the "right" leaf none
|
||||
left = obj;
|
||||
right = boost::none;
|
||||
right = std::nullopt;
|
||||
|
||||
for (size_t i = 0; i < Depth; i++) {
|
||||
if (i < parents.size()) {
|
||||
if (parents[i]) {
|
||||
combined = Hash::combine(*parents[i], *combined, i+1);
|
||||
parents[i] = boost::none;
|
||||
parents[i] = std::nullopt;
|
||||
} else {
|
||||
parents[i] = *combined;
|
||||
break;
|
||||
|
@ -965,7 +965,7 @@ bool IncrementalMerkleTree<Depth, Hash>::is_complete(size_t depth) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (const boost::optional<Hash>& parent : parents) {
|
||||
for (const std::optional<Hash>& parent : parents) {
|
||||
if (!parent) {
|
||||
return false;
|
||||
}
|
||||
|
@ -996,7 +996,7 @@ size_t IncrementalMerkleTree<Depth, Hash>::next_depth(size_t skip) const {
|
|||
|
||||
size_t d = 1;
|
||||
|
||||
for (const boost::optional<Hash>& parent : parents) {
|
||||
for (const std::optional<Hash>& parent : parents) {
|
||||
if (!parent) {
|
||||
if (skip) {
|
||||
skip--;
|
||||
|
@ -1024,7 +1024,7 @@ Hash IncrementalMerkleTree<Depth, Hash>::root(size_t depth,
|
|||
|
||||
size_t d = 1;
|
||||
|
||||
for (const boost::optional<Hash>& parent : parents) {
|
||||
for (const std::optional<Hash>& parent : parents) {
|
||||
if (parent) {
|
||||
root = Hash::combine(*parent, root, d);
|
||||
} else {
|
||||
|
@ -1067,7 +1067,7 @@ MerklePath IncrementalMerkleTree<Depth, Hash>::path(std::deque<Hash> filler_hash
|
|||
|
||||
size_t d = 1;
|
||||
|
||||
for (const boost::optional<Hash>& parent : parents) {
|
||||
for (const std::optional<Hash>& parent : parents) {
|
||||
if (parent) {
|
||||
index.push_back(true);
|
||||
path.push_back(*parent);
|
||||
|
@ -1117,7 +1117,7 @@ void IncrementalWitness<Depth, Hash>::append(Hash obj) {
|
|||
|
||||
if (cursor->is_complete(cursor_depth)) {
|
||||
filled.push_back(cursor->root(cursor_depth));
|
||||
cursor = boost::none;
|
||||
cursor = std::nullopt;
|
||||
}
|
||||
} else {
|
||||
cursor_depth = tree.next_depth(filled.size());
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <array>
|
||||
#include <deque>
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
#include "uint256.h"
|
||||
#include "serialize.h"
|
||||
|
@ -125,11 +125,11 @@ public:
|
|||
|
||||
private:
|
||||
static EmptyMerkleRoots<Depth, Hash> emptyroots;
|
||||
boost::optional<Hash> left;
|
||||
boost::optional<Hash> right;
|
||||
std::optional<Hash> left;
|
||||
std::optional<Hash> right;
|
||||
|
||||
// Collapsed "left" subtrees ordered toward the root of the tree.
|
||||
std::vector<boost::optional<Hash>> parents;
|
||||
std::vector<std::optional<Hash>> parents;
|
||||
MerklePath path(std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
||||
Hash root(size_t depth, std::deque<Hash> filler_hashes = std::deque<Hash>()) const;
|
||||
bool is_complete(size_t depth = Depth) const;
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
private:
|
||||
IncrementalMerkleTree<Depth, Hash> tree;
|
||||
std::vector<Hash> filled;
|
||||
boost::optional<IncrementalMerkleTree<Depth, Hash>> cursor;
|
||||
std::optional<IncrementalMerkleTree<Depth, Hash>> cursor;
|
||||
size_t cursor_depth = 0;
|
||||
std::deque<Hash> partial_path() const;
|
||||
IncrementalWitness(IncrementalMerkleTree<Depth, Hash> tree) : tree(tree) {}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <memory>
|
||||
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <fstream>
|
||||
#include "tinyformat.h"
|
||||
#include "sync.h"
|
||||
|
|
|
@ -59,7 +59,7 @@ SaplingNote::SaplingNote(
|
|||
}
|
||||
|
||||
// Call librustzcash to compute the commitment
|
||||
boost::optional<uint256> SaplingNote::cmu() const {
|
||||
std::optional<uint256> SaplingNote::cmu() const {
|
||||
uint256 result;
|
||||
uint256 rcm_tmp = rcm();
|
||||
if (!librustzcash_sapling_compute_cmu(
|
||||
|
@ -70,14 +70,14 @@ boost::optional<uint256> SaplingNote::cmu() const {
|
|||
result.begin()
|
||||
))
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Call librustzcash to compute the nullifier
|
||||
boost::optional<uint256> SaplingNote::nullifier(const SaplingFullViewingKey& vk, const uint64_t position) const
|
||||
std::optional<uint256> SaplingNote::nullifier(const SaplingFullViewingKey& vk, const uint64_t position) const
|
||||
{
|
||||
auto ak = vk.ak;
|
||||
auto nk = vk.nk;
|
||||
|
@ -95,7 +95,7 @@ boost::optional<uint256> SaplingNote::nullifier(const SaplingFullViewingKey& vk,
|
|||
result.begin()
|
||||
))
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -167,7 +167,7 @@ SaplingNotePlaintext::SaplingNotePlaintext(
|
|||
}
|
||||
|
||||
|
||||
boost::optional<SaplingNote> SaplingNotePlaintext::note(const SaplingIncomingViewingKey& ivk) const
|
||||
std::optional<SaplingNote> SaplingNotePlaintext::note(const SaplingIncomingViewingKey& ivk) const
|
||||
{
|
||||
auto addr = ivk.address(d);
|
||||
if (addr) {
|
||||
|
@ -176,14 +176,14 @@ boost::optional<SaplingNote> SaplingNotePlaintext::note(const SaplingIncomingVie
|
|||
assert(leadbyte == 0x02);
|
||||
zip_212_enabled = Zip212Enabled::AfterZip212;
|
||||
};
|
||||
auto tmp = SaplingNote(d, addr.get().pk_d, value_, rseed, zip_212_enabled);
|
||||
auto tmp = SaplingNote(d, addr.value().pk_d, value_, rseed, zip_212_enabled);
|
||||
return tmp;
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
||||
std::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
||||
const SaplingOutCiphertext &ciphertext,
|
||||
const uint256& ovk,
|
||||
const uint256& cv,
|
||||
|
@ -193,13 +193,13 @@ boost::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
|||
{
|
||||
auto pt = AttemptSaplingOutDecryption(ciphertext, ovk, cv, cm, epk);
|
||||
if (!pt) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Deserialize from the plaintext
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << pt.get();
|
||||
ss << pt.value();
|
||||
SaplingOutgoingPlaintext ret;
|
||||
ss >> ret;
|
||||
assert(ss.size() == 0);
|
||||
|
@ -207,11 +207,11 @@ boost::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
|||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
const Consensus::Params& params,
|
||||
int height,
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
|
@ -223,7 +223,7 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
|||
auto ret = attempt_sapling_enc_decryption_deserialization(ciphertext, ivk, epk);
|
||||
|
||||
if (!ret) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
} else {
|
||||
const SaplingNotePlaintext plaintext = *ret;
|
||||
|
||||
|
@ -231,14 +231,14 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
|||
if (!plaintext_version_is_valid(params, height, plaintext.get_leadbyte())) {
|
||||
LogPrint("receiveunsafe", "Received note plaintext with invalid lead byte %d at height %d",
|
||||
plaintext.get_leadbyte(), height);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext_checks_without_height(plaintext, ivk, epk, cmu);
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_decryption_deserialization(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_decryption_deserialization(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk
|
||||
|
@ -247,25 +247,25 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
|
|||
auto encPlaintext = AttemptSaplingEncDecryption(ciphertext, ivk, epk);
|
||||
|
||||
if (!encPlaintext) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Deserialize from the plaintext
|
||||
SaplingNotePlaintext ret;
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << encPlaintext.get();
|
||||
ss << encPlaintext.value();
|
||||
ss >> ret;
|
||||
assert(ss.size() == 0);
|
||||
return ret;
|
||||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
const SaplingNotePlaintext &plaintext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk,
|
||||
|
@ -274,7 +274,7 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
{
|
||||
uint256 pk_d;
|
||||
if (!librustzcash_ivk_to_pkd(ivk.begin(), plaintext.d.data(), pk_d.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
uint256 cmu_expected;
|
||||
|
@ -287,11 +287,11 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
cmu_expected.begin()
|
||||
))
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (cmu_expected != cmu) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (plaintext.get_leadbyte() != 0x01) {
|
||||
|
@ -301,17 +301,17 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
uint256 expected_epk;
|
||||
uint256 esk = plaintext.generate_or_derive_esk();
|
||||
if (!librustzcash_sapling_ka_derivepublic(plaintext.d.data(), esk.begin(), expected_epk.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
if (expected_epk != epk) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
const Consensus::Params& params,
|
||||
int height,
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
|
@ -324,7 +324,7 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
|||
auto ret = attempt_sapling_enc_decryption_deserialization(ciphertext, epk, esk, pk_d);
|
||||
|
||||
if (!ret) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
} else {
|
||||
SaplingNotePlaintext plaintext = *ret;
|
||||
|
||||
|
@ -332,14 +332,14 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
|||
if (!plaintext_version_is_valid(params, height, plaintext.get_leadbyte())) {
|
||||
LogPrint("receiveunsafe", "Received note plaintext with invalid lead byte %d at height %d",
|
||||
plaintext.get_leadbyte(), height);
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext_checks_without_height(plaintext, epk, esk, pk_d, cmu);
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_decryption_deserialization(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_decryption_deserialization(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
|
@ -349,25 +349,25 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
|
|||
auto encPlaintext = AttemptSaplingEncDecryption(ciphertext, epk, esk, pk_d);
|
||||
|
||||
if (!encPlaintext) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
};
|
||||
|
||||
// Deserialize from the plaintext
|
||||
SaplingNotePlaintext ret;
|
||||
try {
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << encPlaintext.get();
|
||||
ss << encPlaintext.value();
|
||||
ss >> ret;
|
||||
assert(ss.size() == 0);
|
||||
return ret;
|
||||
} catch (const boost::thread_interrupted&) {
|
||||
throw;
|
||||
} catch (...) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
std::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_without_height(
|
||||
const SaplingNotePlaintext &plaintext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
|
@ -380,7 +380,7 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
// ZIP 212: Additionally check that the esk provided to this function
|
||||
// is consistent with the esk we can derive
|
||||
if (esk != plaintext.generate_or_derive_esk()) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,10 +388,10 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
// https://zips.z.cash/zip-0212#changes-to-the-process-of-receiving-sapling-notes
|
||||
uint256 expected_epk;
|
||||
if (!librustzcash_sapling_ka_derivepublic(plaintext.d.data(), esk.begin(), expected_epk.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
if (expected_epk != epk) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
uint256 cmu_expected;
|
||||
|
@ -404,24 +404,24 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::plaintext_checks_wit
|
|||
cmu_expected.begin()
|
||||
))
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (cmu_expected != cmu) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintextEncryptionResult> SaplingNotePlaintext::encrypt(const uint256& pk_d) const
|
||||
std::optional<SaplingNotePlaintextEncryptionResult> SaplingNotePlaintext::encrypt(const uint256& pk_d) const
|
||||
{
|
||||
// Get the encryptor
|
||||
auto sne = SaplingNoteEncryption::FromDiversifier(d, generate_or_derive_esk());
|
||||
if (!sne) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto enc = sne.get();
|
||||
auto enc = sne.value();
|
||||
|
||||
// Create the plaintext
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
@ -433,9 +433,9 @@ boost::optional<SaplingNotePlaintextEncryptionResult> SaplingNotePlaintext::encr
|
|||
// Encrypt the plaintext
|
||||
auto encciphertext = enc.encrypt_to_recipient(pk_d, pt);
|
||||
if (!encciphertext) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
return SaplingNotePlaintextEncryptionResult(encciphertext.get(), enc);
|
||||
return SaplingNotePlaintextEncryptionResult(encciphertext.value(), enc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "consensus/consensus.h"
|
||||
|
||||
#include <array>
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
namespace libzcash {
|
||||
|
||||
|
@ -82,8 +82,8 @@ public:
|
|||
|
||||
virtual ~SaplingNote() {};
|
||||
|
||||
boost::optional<uint256> cmu() const;
|
||||
boost::optional<uint256> nullifier(const SaplingFullViewingKey &vk, const uint64_t position) const;
|
||||
std::optional<uint256> cmu() const;
|
||||
std::optional<uint256> nullifier(const SaplingFullViewingKey &vk, const uint64_t position) const;
|
||||
uint256 rcm() const;
|
||||
|
||||
Zip212Enabled get_zip_212_enabled() const {
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
|
||||
SaplingNotePlaintext(const SaplingNote& note, std::array<unsigned char, ZC_MEMO_SIZE> memo);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> decrypt(
|
||||
static std::optional<SaplingNotePlaintext> decrypt(
|
||||
const Consensus::Params& params,
|
||||
int height,
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
|
@ -169,20 +169,20 @@ public:
|
|||
const uint256 &cmu
|
||||
);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> plaintext_checks_without_height(
|
||||
static std::optional<SaplingNotePlaintext> plaintext_checks_without_height(
|
||||
const SaplingNotePlaintext &plaintext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk,
|
||||
const uint256 &cmu
|
||||
);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> attempt_sapling_enc_decryption_deserialization(
|
||||
static std::optional<SaplingNotePlaintext> attempt_sapling_enc_decryption_deserialization(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk
|
||||
);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> decrypt(
|
||||
static std::optional<SaplingNotePlaintext> decrypt(
|
||||
const Consensus::Params& params,
|
||||
int height,
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
const uint256 &cmu
|
||||
);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> plaintext_checks_without_height(
|
||||
static std::optional<SaplingNotePlaintext> plaintext_checks_without_height(
|
||||
const SaplingNotePlaintext &plaintext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
|
@ -200,14 +200,14 @@ public:
|
|||
const uint256 &cmu
|
||||
);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> attempt_sapling_enc_decryption_deserialization(
|
||||
static std::optional<SaplingNotePlaintext> attempt_sapling_enc_decryption_deserialization(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
const uint256 &pk_d
|
||||
);
|
||||
|
||||
boost::optional<SaplingNote> note(const SaplingIncomingViewingKey& ivk) const;
|
||||
std::optional<SaplingNote> note(const SaplingIncomingViewingKey& ivk) const;
|
||||
|
||||
virtual ~SaplingNotePlaintext() {}
|
||||
|
||||
|
@ -227,7 +227,7 @@ public:
|
|||
READWRITE(memo_); // 512 bytes
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintextEncryptionResult> encrypt(const uint256& pk_d) const;
|
||||
std::optional<SaplingNotePlaintextEncryptionResult> encrypt(const uint256& pk_d) const;
|
||||
|
||||
uint256 rcm() const;
|
||||
uint256 generate_or_derive_esk() const;
|
||||
|
@ -254,7 +254,7 @@ public:
|
|||
READWRITE(esk); // 8 bytes
|
||||
}
|
||||
|
||||
static boost::optional<SaplingOutgoingPlaintext> decrypt(
|
||||
static std::optional<SaplingOutgoingPlaintext> decrypt(
|
||||
const SaplingOutCiphertext &ciphertext,
|
||||
const uint256& ovk,
|
||||
const uint256& cv,
|
||||
|
|
|
@ -90,7 +90,7 @@ void KDF(unsigned char K[NOTEENCRYPTION_CIPHER_KEYSIZE],
|
|||
|
||||
namespace libzcash {
|
||||
|
||||
boost::optional<SaplingNoteEncryption> SaplingNoteEncryption::FromDiversifier(
|
||||
std::optional<SaplingNoteEncryption> SaplingNoteEncryption::FromDiversifier(
|
||||
diversifier_t d,
|
||||
uint256 esk
|
||||
)
|
||||
|
@ -99,13 +99,13 @@ boost::optional<SaplingNoteEncryption> SaplingNoteEncryption::FromDiversifier(
|
|||
|
||||
// Compute epk given the diversifier
|
||||
if (!librustzcash_sapling_ka_derivepublic(d.begin(), esk.begin(), epk.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return SaplingNoteEncryption(epk, esk);
|
||||
}
|
||||
|
||||
boost::optional<SaplingEncCiphertext> SaplingNoteEncryption::encrypt_to_recipient(
|
||||
std::optional<SaplingEncCiphertext> SaplingNoteEncryption::encrypt_to_recipient(
|
||||
const uint256 &pk_d,
|
||||
const SaplingEncPlaintext &message
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ boost::optional<SaplingEncCiphertext> SaplingNoteEncryption::encrypt_to_recipien
|
|||
uint256 dhsecret;
|
||||
|
||||
if (!librustzcash_sapling_ka_agree(pk_d.begin(), esk.begin(), dhsecret.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Construct the symmetric key
|
||||
|
@ -141,7 +141,7 @@ boost::optional<SaplingEncCiphertext> SaplingNoteEncryption::encrypt_to_recipien
|
|||
return ciphertext;
|
||||
}
|
||||
|
||||
boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
||||
std::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk
|
||||
|
@ -150,7 +150,7 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
|||
uint256 dhsecret;
|
||||
|
||||
if (!librustzcash_sapling_ka_agree(epk.begin(), ivk.begin(), dhsecret.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Construct the symmetric key
|
||||
|
@ -170,13 +170,13 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
|||
0,
|
||||
cipher_nonce, K) != 0)
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
||||
std::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
|
@ -186,7 +186,7 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
|||
uint256 dhsecret;
|
||||
|
||||
if (!librustzcash_sapling_ka_agree(pk_d.begin(), esk.begin(), dhsecret.begin())) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Construct the symmetric key
|
||||
|
@ -206,7 +206,7 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
|||
0,
|
||||
cipher_nonce, K) != 0)
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
|
@ -245,7 +245,7 @@ SaplingOutCiphertext SaplingNoteEncryption::encrypt_to_ourselves(
|
|||
return ciphertext;
|
||||
}
|
||||
|
||||
boost::optional<SaplingOutPlaintext> AttemptSaplingOutDecryption(
|
||||
std::optional<SaplingOutPlaintext> AttemptSaplingOutDecryption(
|
||||
const SaplingOutCiphertext &ciphertext,
|
||||
const uint256 &ovk,
|
||||
const uint256 &cv,
|
||||
|
@ -270,7 +270,7 @@ boost::optional<SaplingOutPlaintext> AttemptSaplingOutDecryption(
|
|||
0,
|
||||
cipher_nonce, K) != 0)
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/zcash/zips/blob/master/protocol/protocol.pdf
|
|||
#include "zcash/Address.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
namespace libzcash {
|
||||
|
||||
|
@ -42,9 +43,9 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
static boost::optional<SaplingNoteEncryption> FromDiversifier(diversifier_t d, uint256 esk);
|
||||
static std::optional<SaplingNoteEncryption> FromDiversifier(diversifier_t d, uint256 esk);
|
||||
|
||||
boost::optional<SaplingEncCiphertext> encrypt_to_recipient(
|
||||
std::optional<SaplingEncCiphertext> encrypt_to_recipient(
|
||||
const uint256 &pk_d,
|
||||
const SaplingEncPlaintext &message
|
||||
);
|
||||
|
@ -67,7 +68,7 @@ public:
|
|||
|
||||
// Attempts to decrypt a Sapling note. This will not check that the contents
|
||||
// of the ciphertext are correct.
|
||||
boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
||||
std::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk
|
||||
|
@ -75,7 +76,7 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption(
|
|||
|
||||
// Attempts to decrypt a Sapling note using outgoing plaintext.
|
||||
// This will not check that the contents of the ciphertext are correct.
|
||||
boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
||||
std::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &epk,
|
||||
const uint256 &esk,
|
||||
|
@ -84,7 +85,7 @@ boost::optional<SaplingEncPlaintext> AttemptSaplingEncDecryption (
|
|||
|
||||
// Attempts to decrypt a Sapling note. This will not check that the contents
|
||||
// of the ciphertext are correct.
|
||||
boost::optional<SaplingOutPlaintext> AttemptSaplingOutDecryption(
|
||||
std::optional<SaplingOutPlaintext> AttemptSaplingOutDecryption(
|
||||
const SaplingOutCiphertext &ciphertext,
|
||||
const uint256 &ovk,
|
||||
const uint256 &cv,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <variant>
|
||||
|
||||
namespace libzcash {
|
||||
|
||||
|
@ -211,7 +211,7 @@ typedef std::array<unsigned char, GROTH_PROOF_SIZE> GrothProof;
|
|||
// TODO: Because PHGRProof is listed first, using the default
|
||||
// constructor for JSDescription() will create a JSDescription
|
||||
// with a PHGRProof. The default however should be GrothProof.
|
||||
typedef boost::variant<PHGRProof, GrothProof> SproutProof;
|
||||
typedef std::variant<PHGRProof, GrothProof> SproutProof;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ uint256 SaplingPaymentAddress::GetHash() const {
|
|||
return Hash(ss.begin(), ss.end());
|
||||
}
|
||||
|
||||
boost::optional<SaplingPaymentAddress> SaplingIncomingViewingKey::address(diversifier_t d) const {
|
||||
std::optional<SaplingPaymentAddress> SaplingIncomingViewingKey::address(diversifier_t d) const {
|
||||
uint256 pk_d;
|
||||
if (librustzcash_check_diversifier(d.data())) {
|
||||
librustzcash_ivk_to_pkd(this->begin(), d.data(), pk_d.begin());
|
||||
return SaplingPaymentAddress(d, pk_d);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ SaplingFullViewingKey SaplingSpendingKey::full_viewing_key() const {
|
|||
SaplingPaymentAddress SaplingSpendingKey::default_address() const {
|
||||
// Iterates within default_diversifier to ensure a valid address is returned
|
||||
auto addrOpt = full_viewing_key().in_viewing_key().address(default_diversifier(*this));
|
||||
assert(addrOpt != boost::none);
|
||||
assert(addrOpt != std::nullopt);
|
||||
return addrOpt.value();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "uint256.h"
|
||||
#include "zcash/Zcash.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace libzcash {
|
||||
|
||||
const size_t SerializedSaplingPaymentAddressSize = 43;
|
||||
|
@ -53,7 +55,7 @@ public:
|
|||
SaplingIncomingViewingKey(uint256 ivk) : uint256(ivk) { }
|
||||
|
||||
// Can pass in diversifier for Sapling addr
|
||||
boost::optional<SaplingPaymentAddress> address(diversifier_t d) const;
|
||||
std::optional<SaplingPaymentAddress> address(diversifier_t d) const;
|
||||
};
|
||||
|
||||
class SaplingFullViewingKey {
|
||||
|
|
|
@ -54,7 +54,7 @@ uint256 ovkForShieldingFromTaddr(HDSeed& seed) {
|
|||
|
||||
namespace libzcash {
|
||||
|
||||
boost::optional<SaplingExtendedFullViewingKey> SaplingExtendedFullViewingKey::Derive(uint32_t i) const
|
||||
std::optional<SaplingExtendedFullViewingKey> SaplingExtendedFullViewingKey::Derive(uint32_t i) const
|
||||
{
|
||||
CDataStream ss_p(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss_p << *this;
|
||||
|
@ -71,11 +71,11 @@ boost::optional<SaplingExtendedFullViewingKey> SaplingExtendedFullViewingKey::De
|
|||
ss_i >> xfvk_i;
|
||||
return xfvk_i;
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<std::pair<diversifier_index_t, libzcash::SaplingPaymentAddress>>
|
||||
std::optional<std::pair<diversifier_index_t, libzcash::SaplingPaymentAddress>>
|
||||
SaplingExtendedFullViewingKey::Address(diversifier_index_t j) const
|
||||
{
|
||||
CDataStream ss_xfvk(SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
@ -93,7 +93,7 @@ boost::optional<std::pair<diversifier_index_t, libzcash::SaplingPaymentAddress>>
|
|||
ss_addr >> addr;
|
||||
return std::make_pair(j_ret, addr);
|
||||
} else {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ libzcash::SaplingPaymentAddress SaplingExtendedFullViewingKey::DefaultAddress()
|
|||
if (!addr) {
|
||||
throw std::runtime_error("SaplingExtendedFullViewingKey::DefaultAddress(): No valid diversifiers out of 2^88!");
|
||||
}
|
||||
return addr.get().second;
|
||||
return addr.value().second;
|
||||
}
|
||||
|
||||
SaplingExtendedSpendingKey SaplingExtendedSpendingKey::Master(const HDSeed& seed)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "uint256.h"
|
||||
#include "zcash/address/sapling.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
const uint32_t ZIP32_HARDENED_KEY_LIMIT = 0x80000000;
|
||||
const size_t ZIP32_XFVK_SIZE = 169;
|
||||
|
@ -69,12 +69,12 @@ struct SaplingExtendedFullViewingKey {
|
|||
READWRITE(dk);
|
||||
}
|
||||
|
||||
boost::optional<SaplingExtendedFullViewingKey> Derive(uint32_t i) const;
|
||||
std::optional<SaplingExtendedFullViewingKey> Derive(uint32_t i) const;
|
||||
|
||||
// Returns the first index starting from j that generates a valid
|
||||
// payment address, along with the corresponding address. Returns
|
||||
// an error if the diversifier space is exhausted.
|
||||
boost::optional<std::pair<diversifier_index_t, libzcash::SaplingPaymentAddress>>
|
||||
std::optional<std::pair<diversifier_index_t, libzcash::SaplingPaymentAddress>>
|
||||
Address(diversifier_index_t j) const;
|
||||
|
||||
libzcash::SaplingPaymentAddress DefaultAddress() const;
|
||||
|
|
|
@ -374,7 +374,7 @@ CWalletTx CreateSaplingTxWithNoteData(const Consensus::Params& consensusParams,
|
|||
auto wtx = GetValidSaplingReceive(consensusParams, keyStore, sk, 10);
|
||||
auto testNote = GetTestSaplingNote(sk.DefaultAddress(), 10);
|
||||
auto fvk = sk.expsk.full_viewing_key();
|
||||
auto nullifier = testNote.note.nullifier(fvk, testNote.tree.witness().position()).get();
|
||||
auto nullifier = testNote.note.nullifier(fvk, testNote.tree.witness().position()).value();
|
||||
|
||||
mapSaplingNoteData_t noteDataMap;
|
||||
SaplingOutPoint outPoint {wtx.GetHash(), 0};
|
||||
|
@ -595,7 +595,7 @@ double benchmark_create_sapling_spend()
|
|||
SaplingNote note(address, GetRand(MAX_MONEY), libzcash::Zip212Enabled::BeforeZip212);
|
||||
SaplingMerkleTree tree;
|
||||
auto maybe_cmu = note.cmu();
|
||||
tree.append(maybe_cmu.get());
|
||||
tree.append(maybe_cmu.value());
|
||||
auto anchor = tree.root();
|
||||
auto witness = tree.witness();
|
||||
auto maybe_nf = note.nullifier(expsk.full_viewing_key(), witness.position());
|
||||
|
@ -653,7 +653,7 @@ double benchmark_create_sapling_output()
|
|||
throw JSONRPCError(RPC_INTERNAL_ERROR, "SaplingNotePlaintext::encrypt() failed");
|
||||
}
|
||||
|
||||
auto enc = res.get();
|
||||
auto enc = res.value();
|
||||
auto encryptor = enc.second;
|
||||
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
|
|
|
@ -63,7 +63,6 @@ EXPECTED_BOOST_INCLUDES=(
|
|||
boost/iostreams/concepts.hpp
|
||||
boost/iostreams/stream.hpp
|
||||
boost/math/distributions/poisson.hpp
|
||||
boost/optional.hpp
|
||||
boost/preprocessor/arithmetic/add.hpp
|
||||
boost/preprocessor/arithmetic/sub.hpp
|
||||
boost/preprocessor/cat.hpp
|
||||
|
@ -100,10 +99,6 @@ EXPECTED_BOOST_INCLUDES=(
|
|||
boost/uuid/uuid.hpp
|
||||
boost/uuid/uuid_generators.hpp
|
||||
boost/uuid/uuid_io.hpp
|
||||
boost/variant.hpp
|
||||
boost/variant/apply_visitor.hpp
|
||||
boost/variant/get.hpp
|
||||
boost/variant/static_visitor.hpp
|
||||
boost/version.hpp
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue