scripted-diff: Migrate from boost::optional to std::optional

-BEGIN VERIFY SCRIPT-
sed -i 's/boost::none/std::nullopt/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/boost::optional/std::optional/g' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h* ./src/*/*/*.cpp ;
sed -i 's/std::optional<\(.*\)&>/std::optional<std::reference_wrapper<\1>>/' ./src/*/*.h ./src/*/*.cpp ;
sed -i 's/is_initialized()/has_value()/' ./src/*.cpp ./src/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include <boost\/optional.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#include "boost\/optional.hpp"\n//' ./src/*.h ;
-END VERIFY SCRIPT-
This commit is contained in:
Jack Grigg 2020-10-21 01:44:15 +01:00
parent 521eb81a95
commit d8d0918951
55 changed files with 358 additions and 375 deletions

View File

@ -229,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;
@ -238,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.
//!
@ -296,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();

View File

@ -105,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 =

View File

@ -14,7 +14,6 @@
#include <optional>
#include <variant>
#include <boost/optional.hpp>
namespace Consensus {
@ -81,7 +80,7 @@ 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 std::variant<libzcash::SaplingPaymentAddress, CScript> FundingStreamAddress;
@ -212,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,
@ -264,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;

View File

@ -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,10 +152,10 @@ 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)
{
@ -163,5 +163,5 @@ boost::optional<int> NextActivationHeight(
if (idx) {
return params.vUpgrades[idx.value()].nActivationHeight;
}
return boost::none;
return std::nullopt;
}

View File

@ -8,7 +8,6 @@
#include "consensus/params.h"
#include <optional>
#include <boost/optional.hpp>
enum UpgradeState {
UPGRADE_DISABLED,
@ -84,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);

View File

@ -151,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;
@ -648,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
@ -666,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;
@ -691,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;

View File

@ -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()

View File

@ -8,7 +8,6 @@
#include <optional>
#include <string>
#include <vector>
#include <boost/optional.hpp>
extern bool fExperimentalDeveloperEncryptWallet;
extern bool fExperimentalDeveloperSetPoolSizeZero;
@ -16,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

View File

@ -94,12 +94,12 @@ 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());
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

View File

@ -443,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);

View File

@ -4,7 +4,6 @@
#include "consensus/upgrades.h"
#include <optional>
#include <boost/optional.hpp>
class UpgradesTest : public ::testing::Test {
protected:
@ -149,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) {
@ -178,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);
}

View File

@ -16,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);
@ -26,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) :

View File

@ -86,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;
@ -2793,7 +2793,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.
@ -3853,7 +3853,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(
@ -3889,9 +3889,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;
@ -3913,12 +3913,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;
@ -4659,17 +4659,17 @@ bool static LoadBlockIndexDB()
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 {

View File

@ -134,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;

View File

@ -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);

View File

@ -10,7 +10,6 @@
#include <set>
#include <vector>
#include "boost/optional.hpp"
#include "primitives/transaction.h"
#include "uint256.h"
@ -123,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();
};

View File

@ -14,7 +14,6 @@
#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>
@ -277,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.value() - currentHeight) * params.PoWTargetSpacing(nextHeight.value() - 1);
} else {
return boost::none;
return std::nullopt;
}
}
@ -643,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();
}

View File

@ -76,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);

View File

@ -111,7 +111,7 @@ 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);
}
}
@ -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);

View File

@ -8,7 +8,6 @@
#include "primitives/block.h"
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <stdint.h>
#include <variant>

View File

@ -30,7 +30,7 @@ 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 &&
if (params.nPowAllowMinDifficultyBlocksAfterHeight != std::nullopt &&
pindexLast->nHeight >= params.nPowAllowMinDifficultyBlocksAfterHeight.value())
{
// Special difficulty rule for testnet:

View File

@ -84,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);
@ -1060,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 Consensus::Params& consensusParams = Params().GetConsensus();

View File

@ -24,7 +24,6 @@
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <rust/ed25519/types.h>
@ -539,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
@ -785,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.
@ -800,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);

View File

@ -13,7 +13,6 @@
#include <stdint.h>
#include <boost/test/unit_test.hpp>
#include <boost/optional.hpp>
using namespace std;
@ -84,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);
}

View File

@ -24,17 +24,17 @@ 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.value();
auto encryptor = enc.second;
@ -54,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;
@ -75,9 +75,9 @@ 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) {
@ -227,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)
@ -245,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()
@ -566,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);

View File

@ -19,7 +19,6 @@
#include "zcash/NoteEncryption.hpp"
#include <optional>
#include <boost/optional.hpp>
#define NO_MEMO {{0xF6}}
@ -47,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 {
@ -61,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);
@ -90,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() {}

View File

@ -841,8 +841,8 @@ bool CTxMemPool::IsRecentlyEvicted(const uint256& txId) {
void CTxMemPool::EnsureSizeLimit() {
AssertLockHeld(cs);
boost::optional<uint256> maybeDropTxId;
while ((maybeDropTxId = weightedTxTree->maybeDropRandom()).is_initialized()) {
std::optional<uint256> maybeDropTxId;
while ((maybeDropTxId = weightedTxTree->maybeDropRandom()).has_value()) {
uint256 txId = maybeDropTxId.value();
recentlyEvicted->add(txId);
std::list<CTransaction> removed;

View File

@ -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;

View File

@ -37,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) {}
@ -59,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. */

View File

@ -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()) {

View File

@ -20,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.
@ -28,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

View File

@ -57,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,
@ -296,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;
@ -313,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);
@ -355,7 +355,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
// 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;
@ -375,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;
@ -413,7 +413,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
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;
@ -438,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};
}
@ -502,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;
@ -533,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);
@ -583,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) {
@ -714,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;
@ -723,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);
@ -735,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);
@ -746,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()) {

View File

@ -51,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;
};
@ -59,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,
@ -123,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();
@ -181,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);

View File

@ -140,7 +140,7 @@ 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].value());
}

View File

@ -58,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,
@ -353,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);
@ -476,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 };
}
@ -587,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;
@ -618,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);
@ -667,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) {
@ -825,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;
@ -974,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);
@ -985,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);
@ -996,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()) {

View File

@ -61,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,
@ -142,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!
@ -197,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);

View File

@ -224,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;
@ -252,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;

View File

@ -105,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;
@ -1161,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);
@ -1216,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);
@ -1238,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);
@ -1286,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);
@ -1328,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);
}
@ -1348,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);
@ -1393,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);
@ -1510,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);

View File

@ -13,7 +13,6 @@
#include <future>
#include <memory>
#include <boost/optional.hpp>
#include <leveldb/db.h>

View File

@ -398,8 +398,8 @@ 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 = std::visit(
AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus(), nTime, hdKeypath, seedFpStr, true), spendingkey);

View File

@ -2989,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(
@ -3099,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());
@ -4297,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);
}
@ -5079,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);
}

View File

@ -38,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>
@ -1124,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"));
}
@ -1151,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"));
}
@ -1160,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"));
}
@ -1172,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);
@ -1207,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();
@ -1218,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"));
@ -1229,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();
@ -1239,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);
@ -1290,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);
@ -1320,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);
@ -1338,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);
@ -1346,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);
@ -1885,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"));
@ -1902,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"));
@ -1915,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"));
@ -1931,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"));
@ -1965,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();
@ -1975,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);
@ -2029,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);
@ -2037,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);

View File

@ -615,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);
@ -666,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();
}
@ -1525,7 +1525,7 @@ void CWallet::UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx) {
if (item.second.nullifier) {
mapSaplingNullifiersToNotes.erase(item.second.nullifier.value());
}
item.second.nullifier = boost::none;
item.second.nullifier = std::nullopt;
}
else {
uint64_t position = nd.witnesses.front().position();
@ -1536,20 +1536,20 @@ 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.value().note(nd.ivk);
assert(optNote != boost::none);
assert(optNote != std::nullopt);
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);
assert(optNullifier != std::nullopt);
uint256 nullifier = optNullifier.value();
mapSaplingNullifiersToNotes[nullifier] = op;
item.second.nullifier = nullifier;
@ -1842,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],
@ -1988,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) &&
@ -2015,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) &&
@ -2340,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];
@ -2359,23 +2359,23 @@ boost::optional<std::pair<
nd.ivk,
output.ephemeralKey,
output.cmu);
assert(maybe_pt != boost::none);
assert(maybe_pt != std::nullopt);
auto notePt = maybe_pt.value();
auto maybe_pa = nd.ivk.address(notePt.d);
assert(maybe_pa != boost::none);
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];
@ -2385,14 +2385,14 @@ 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);
assert(maybe_pt != std::nullopt);
auto notePt = maybe_pt.value();
auto maybe_pa = nd.ivk.address(notePt.d);
@ -2402,7 +2402,7 @@ boost::optional<std::pair<
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
{
@ -2435,10 +2435,10 @@ boost::optional<std::pair<
}
// 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
{
@ -2460,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,
@ -2475,7 +2475,7 @@ boost::optional<std::pair<
}
// Couldn't recover with any of the provided OutgoingViewingKeys
return boost::none;
return std::nullopt;
}
int64_t CWalletTx::GetTxTime() const
@ -2681,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());
@ -2701,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);
}
@ -2731,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());
}
@ -3871,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);
@ -5130,7 +5130,7 @@ 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.value();
auto maybe_pa = nd.ivk.address(notePt.d);
@ -5188,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;
@ -5213,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
@ -5244,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

View File

@ -228,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.
@ -291,7 +291,7 @@ public:
std::list<SaplingWitness> witnesses;
int witnessHeight;
libzcash::SaplingIncomingViewingKey ivk;
boost::optional<uint256> nullifier;
std::optional<uint256> nullifier;
ADD_SERIALIZE_METHODS;
@ -565,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;
@ -1179,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();
@ -1204,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;
/**
@ -1232,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,
@ -1245,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;
@ -1267,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. */
@ -1487,9 +1487,9 @@ private:
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
@ -1511,9 +1511,9 @@ private:
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 {
@ -1541,18 +1541,18 @@ private:
CWallet *m_wallet;
const Consensus::Params &params;
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 &params) :
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 &params,
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) {}

View File

@ -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());

View File

@ -4,7 +4,6 @@
#include <array>
#include <deque>
#include <optional>
#include <boost/optional.hpp>
#include "uint256.h"
#include "serialize.h"
@ -126,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;
@ -193,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) {}

View File

@ -6,7 +6,6 @@
#include <memory>
#include <boost/format.hpp>
#include <boost/optional.hpp>
#include <fstream>
#include "tinyformat.h"
#include "sync.h"

View File

@ -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) {
@ -179,11 +179,11 @@ boost::optional<SaplingNote> SaplingNotePlaintext::note(const SaplingIncomingVie
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,7 +193,7 @@ 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
@ -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,7 +247,7 @@ 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
@ -261,11 +261,11 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
} 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,7 +349,7 @@ 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
@ -363,11 +363,11 @@ boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::attempt_sapling_enc_
} 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,22 +404,22 @@ 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.value();
@ -433,7 +433,7 @@ 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.value(), enc);
}

View File

@ -10,7 +10,6 @@
#include <array>
#include <optional>
#include <boost/optional.hpp>
namespace libzcash {
@ -83,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 {
@ -161,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,
@ -170,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,
@ -193,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,
@ -201,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() {}
@ -228,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;
@ -255,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,

View File

@ -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;

View File

@ -43,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
);
@ -68,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
@ -76,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,
@ -85,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,

View File

@ -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();
}

View File

@ -55,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 {

View File

@ -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;
}
}

View File

@ -11,7 +11,6 @@
#include "zcash/address/sapling.hpp"
#include <optional>
#include <boost/optional.hpp>
const uint32_t ZIP32_HARDENED_KEY_LIMIT = 0x80000000;
const size_t ZIP32_XFVK_SIZE = 169;
@ -70,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;