Make all CCoinsView methods pure-virtual.
This commit is contained in:
parent
efa2dc70e8
commit
cc2fd60617
|
@ -378,7 +378,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& strInput)
|
||||||
// starts as a clone of the raw tx:
|
// starts as a clone of the raw tx:
|
||||||
CMutableTransaction mergedTx(txVariants[0]);
|
CMutableTransaction mergedTx(txVariants[0]);
|
||||||
bool fComplete = true;
|
bool fComplete = true;
|
||||||
CCoinsView viewDummy;
|
CCoinsViewDummy viewDummy;
|
||||||
CCoinsViewCache view(&viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
|
|
||||||
if (!registers.count("privatekeys"))
|
if (!registers.count("privatekeys"))
|
||||||
|
|
|
@ -45,32 +45,6 @@ bool CCoins::Spend(uint32_t nPos)
|
||||||
Cleanup();
|
Cleanup();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool CCoinsView::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; }
|
|
||||||
bool CCoinsView::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; }
|
|
||||||
bool CCoinsView::GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const { return false; }
|
|
||||||
bool CCoinsView::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return false; }
|
|
||||||
bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return false; }
|
|
||||||
bool CCoinsView::HaveCoins(const uint256 &txid) const { return false; }
|
|
||||||
uint256 CCoinsView::GetBestBlock() const { return uint256(); }
|
|
||||||
uint256 CCoinsView::GetBestAnchor(ShieldedType type) const { return uint256(); };
|
|
||||||
HistoryIndex CCoinsView::GetHistoryLength(uint32_t epochId) const { return 0; }
|
|
||||||
HistoryNode CCoinsView::GetHistoryAt(uint32_t epochId, HistoryIndex index) const { return HistoryNode(); }
|
|
||||||
uint256 CCoinsView::GetHistoryRoot(uint32_t epochId) const { return uint256(); }
|
|
||||||
|
|
||||||
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins,
|
|
||||||
const uint256 &hashBlock,
|
|
||||||
const uint256 &hashSproutAnchor,
|
|
||||||
const uint256 &hashSaplingAnchor,
|
|
||||||
const uint256 &hashOrchardAnchor,
|
|
||||||
CAnchorsSproutMap &mapSproutAnchors,
|
|
||||||
CAnchorsSaplingMap &mapSaplingAnchors,
|
|
||||||
CAnchorsOrchardMap &mapOrchardAnchors,
|
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
|
||||||
CNullifiersMap &mapSaplingNullifiers,
|
|
||||||
CNullifiersMap &mapOrchardNullifiers,
|
|
||||||
CHistoryCacheMap &historyCacheMap) { return false; }
|
|
||||||
bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; }
|
|
||||||
|
|
||||||
|
|
||||||
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { }
|
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { }
|
||||||
|
|
||||||
|
|
60
src/coins.h
60
src/coins.h
|
@ -364,38 +364,38 @@ class CCoinsView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Retrieve the tree (Sprout) at a particular anchored root in the chain
|
//! Retrieve the tree (Sprout) at a particular anchored root in the chain
|
||||||
virtual bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
virtual bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const = 0;
|
||||||
|
|
||||||
//! Retrieve the tree (Sapling) at a particular anchored root in the chain
|
//! Retrieve the tree (Sapling) at a particular anchored root in the chain
|
||||||
virtual bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
virtual bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const = 0;
|
||||||
|
|
||||||
//! Retrieve the tree (Orchard) at a particular anchored root in the chain
|
//! Retrieve the tree (Orchard) at a particular anchored root in the chain
|
||||||
virtual bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const;
|
virtual bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const = 0;
|
||||||
|
|
||||||
//! Determine whether a nullifier is spent or not
|
//! Determine whether a nullifier is spent or not
|
||||||
virtual bool GetNullifier(const uint256 &nullifier, ShieldedType type) const;
|
virtual bool GetNullifier(const uint256 &nullifier, ShieldedType type) const = 0;
|
||||||
|
|
||||||
//! Retrieve the CCoins (unspent transaction outputs) for a given txid
|
//! Retrieve the CCoins (unspent transaction outputs) for a given txid
|
||||||
virtual bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
virtual bool GetCoins(const uint256 &txid, CCoins &coins) const = 0;
|
||||||
|
|
||||||
//! Just check whether we have data for a given txid.
|
//! Just check whether we have data for a given txid.
|
||||||
//! This may (but cannot always) return true for fully spent transactions
|
//! This may (but cannot always) return true for fully spent transactions
|
||||||
virtual bool HaveCoins(const uint256 &txid) const;
|
virtual bool HaveCoins(const uint256 &txid) const = 0;
|
||||||
|
|
||||||
//! Retrieve the block hash whose state this CCoinsView currently represents
|
//! Retrieve the block hash whose state this CCoinsView currently represents
|
||||||
virtual uint256 GetBestBlock() const;
|
virtual uint256 GetBestBlock() const = 0;
|
||||||
|
|
||||||
//! Get the current "tip" or the latest anchored tree root in the chain
|
//! Get the current "tip" or the latest anchored tree root in the chain
|
||||||
virtual uint256 GetBestAnchor(ShieldedType type) const;
|
virtual uint256 GetBestAnchor(ShieldedType type) const = 0;
|
||||||
|
|
||||||
//! Get the current chain history length (which should be roughly chain height x2)
|
//! Get the current chain history length (which should be roughly chain height x2)
|
||||||
virtual HistoryIndex GetHistoryLength(uint32_t epochId) const;
|
virtual HistoryIndex GetHistoryLength(uint32_t epochId) const = 0;
|
||||||
|
|
||||||
//! Get history node at specified index
|
//! Get history node at specified index
|
||||||
virtual HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const;
|
virtual HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const = 0;
|
||||||
|
|
||||||
//! Get current history root
|
//! Get current history root
|
||||||
virtual uint256 GetHistoryRoot(uint32_t epochId) const;
|
virtual uint256 GetHistoryRoot(uint32_t epochId) const = 0;
|
||||||
|
|
||||||
//! Do a bulk modification (multiple CCoins changes + BestBlock change).
|
//! Do a bulk modification (multiple CCoins changes + BestBlock change).
|
||||||
//! The passed mapCoins can be modified.
|
//! The passed mapCoins can be modified.
|
||||||
|
@ -410,15 +410,47 @@ public:
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers,
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
CNullifiersMap &mapOrchardNullifiers,
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
CHistoryCacheMap &historyCacheMap);
|
CHistoryCacheMap &historyCacheMap) = 0;
|
||||||
|
|
||||||
//! Calculate statistics about the unspent transaction output set
|
//! Calculate statistics about the unspent transaction output set
|
||||||
virtual bool GetStats(CCoinsStats &stats) const;
|
virtual bool GetStats(CCoinsStats &stats) const = 0;
|
||||||
|
|
||||||
//! As we use CCoinsViews polymorphically, have a virtual destructor
|
//! As we use CCoinsViews polymorphically, have a virtual destructor
|
||||||
virtual ~CCoinsView() {}
|
virtual ~CCoinsView() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CCoinsViewDummy : public CCoinsView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~CCoinsViewDummy() {}
|
||||||
|
|
||||||
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; }
|
||||||
|
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; }
|
||||||
|
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const { return false; }
|
||||||
|
bool GetNullifier(const uint256 &nullifier, ShieldedType type) const { return false; }
|
||||||
|
bool GetCoins(const uint256 &txid, CCoins &coins) const { return false; }
|
||||||
|
bool HaveCoins(const uint256 &txid) const { return false; }
|
||||||
|
uint256 GetBestBlock() const { return uint256(); }
|
||||||
|
uint256 GetBestAnchor(ShieldedType type) const { return uint256(); };
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const { return HistoryNode(); }
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const { return uint256(); }
|
||||||
|
|
||||||
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
|
const uint256 &hashBlock,
|
||||||
|
const uint256 &hashSproutAnchor,
|
||||||
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) { return false; }
|
||||||
|
|
||||||
|
bool GetStats(CCoinsStats &stats) const { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
/** CCoinsView backed by another CCoinsView */
|
/** CCoinsView backed by another CCoinsView */
|
||||||
class CCoinsViewBacked : public CCoinsView
|
class CCoinsViewBacked : public CCoinsView
|
||||||
|
@ -428,6 +460,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewBacked(CCoinsView *viewIn);
|
CCoinsViewBacked(CCoinsView *viewIn);
|
||||||
|
~CCoinsViewBacked() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
||||||
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
||||||
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const;
|
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const;
|
||||||
|
|
|
@ -161,6 +161,14 @@ public:
|
||||||
|
|
||||||
uint256 GetBestBlock() const { return hashBestBlock_; }
|
uint256 GetBestBlock() const { return hashBestBlock_; }
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const {
|
||||||
|
throw std::runtime_error("`GetHistoryAt` unimplemented for mock CCoinsViewTest");
|
||||||
|
}
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
throw std::runtime_error("`GetHistoryRoot` unimplemented for mock CCoinsViewTest");
|
||||||
|
}
|
||||||
|
|
||||||
void BatchWriteNullifiers(CNullifiersMap& mapNullifiers, std::map<uint256, bool>& cacheNullifiers)
|
void BatchWriteNullifiers(CNullifiersMap& mapNullifiers, std::map<uint256, bool>& cacheNullifiers)
|
||||||
{
|
{
|
||||||
for (CNullifiersMap::iterator it = mapNullifiers.begin(); it != mapNullifiers.end(); ) {
|
for (CNullifiersMap::iterator it = mapNullifiers.begin(); it != mapNullifiers.end(); ) {
|
||||||
|
@ -282,7 +290,7 @@ public:
|
||||||
JSDescription jsd;
|
JSDescription jsd;
|
||||||
jsd.nullifiers[0] = sproutNullifier;
|
jsd.nullifiers[0] = sproutNullifier;
|
||||||
mutableTx.vJoinSplit.emplace_back(jsd);
|
mutableTx.vJoinSplit.emplace_back(jsd);
|
||||||
|
|
||||||
saplingNullifier = GetRandHash();
|
saplingNullifier = GetRandHash();
|
||||||
SpendDescription sd;
|
SpendDescription sd;
|
||||||
sd.nullifier = saplingNullifier;
|
sd.nullifier = saplingNullifier;
|
||||||
|
@ -685,7 +693,7 @@ template<typename Tree> void anchorsFlushImpl(ShieldedType type)
|
||||||
cache.PushAnchor(tree);
|
cache.PushAnchor(tree);
|
||||||
cache.Flush();
|
cache.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CCoinsViewCacheTest cache(&base);
|
CCoinsViewCacheTest cache(&base);
|
||||||
Tree tree;
|
Tree tree;
|
||||||
|
@ -775,7 +783,7 @@ template<typename Tree> void anchorsTestImpl(ShieldedType type)
|
||||||
{
|
{
|
||||||
Tree test_tree2;
|
Tree test_tree2;
|
||||||
GetAnchorAt(cache, newrt, test_tree2);
|
GetAnchorAt(cache, newrt, test_tree2);
|
||||||
|
|
||||||
EXPECT_TRUE(test_tree2.root() == newrt);
|
EXPECT_TRUE(test_tree2.root() == newrt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
class FakeCoinsViewDB : public CCoinsView {
|
class FakeCoinsViewDB : public CCoinsView {
|
||||||
public:
|
public:
|
||||||
FakeCoinsViewDB() {}
|
FakeCoinsViewDB() {}
|
||||||
|
~FakeCoinsViewDB() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
||||||
return false;
|
return false;
|
||||||
|
@ -17,6 +18,10 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -39,21 +44,6 @@ public:
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
|
||||||
const uint256 &hashBlock,
|
|
||||||
const uint256 &hashSproutAnchor,
|
|
||||||
const uint256 &hashSaplingAnchor,
|
|
||||||
CAnchorsSproutMap &mapSproutAnchors,
|
|
||||||
CAnchorsSaplingMap &mapSaplingAnchors,
|
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
|
||||||
CNullifiersMap saplingNullifiersMap) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GetStats(CCoinsStats &stats) const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
HistoryIndex GetHistoryLength(uint32_t branchId) const {
|
HistoryIndex GetHistoryLength(uint32_t branchId) const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +51,29 @@ public:
|
||||||
HistoryNode GetHistoryAt(uint32_t branchId, HistoryIndex index) const {
|
HistoryNode GetHistoryAt(uint32_t branchId, HistoryIndex index) const {
|
||||||
return HistoryNode();
|
return HistoryNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
return uint256();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
|
const uint256 &hashBlock,
|
||||||
|
const uint256 &hashSproutAnchor,
|
||||||
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetStats(CCoinsStats &stats) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HistoryNode getLeafN(uint64_t block_num) {
|
HistoryNode getLeafN(uint64_t block_num) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ extern CMutableTransaction GetValidTransaction(uint32_t consensusBranchId=SPROUT
|
||||||
class FakeCoinsViewDB : public CCoinsView {
|
class FakeCoinsViewDB : public CCoinsView {
|
||||||
public:
|
public:
|
||||||
FakeCoinsViewDB() {}
|
FakeCoinsViewDB() {}
|
||||||
|
~FakeCoinsViewDB() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
||||||
return false;
|
return false;
|
||||||
|
@ -27,6 +28,10 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,14 +61,30 @@ public:
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t branchId) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryNode GetHistoryAt(uint32_t branchId, HistoryIndex index) const {
|
||||||
|
return HistoryNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
return uint256();
|
||||||
|
}
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashSproutAnchor,
|
const uint256 &hashSproutAnchor,
|
||||||
const uint256 &hashSaplingAnchor,
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
CAnchorsSproutMap &mapSproutAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CAnchorsSaplingMap &mapSaplingAnchors,
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap &mapSaplingNullifiers) {
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,8 +241,7 @@ TEST(TransactionBuilder, TransparentToOrchard)
|
||||||
libzcash::diversifier_index_t j(0);
|
libzcash::diversifier_index_t j(0);
|
||||||
auto recipient = ivk.Address(j);
|
auto recipient = ivk.Address(j);
|
||||||
|
|
||||||
TransactionBuilderCoinsViewDB fakeDB;
|
auto orchardAnchor = uint256();
|
||||||
auto orchardAnchor = fakeDB.GetBestAnchor(ShieldedType::ORCHARD);
|
|
||||||
|
|
||||||
// Create a shielding transaction from transparent to Orchard
|
// Create a shielding transaction from transparent to Orchard
|
||||||
// 0.00005 t-ZEC in, 0.00004 z-ZEC out, default fee
|
// 0.00005 t-ZEC in, 0.00004 z-ZEC out, default fee
|
||||||
|
|
|
@ -45,23 +45,33 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 GetBestBlock() const {
|
uint256 GetBestBlock() const {
|
||||||
uint256 a;
|
throw std::runtime_error("`GetBestBlock` unimplemented for mock TransactionBuilderCoinsViewDB");
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 GetBestAnchor(ShieldedType type) const {
|
uint256 GetBestAnchor(ShieldedType type) const {
|
||||||
uint256 a;
|
throw std::runtime_error("`GetBestAnchor` unimplemented for mock TransactionBuilderCoinsViewDB");
|
||||||
return a;
|
}
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const {
|
||||||
|
throw std::runtime_error("`GetHistoryAt` unimplemented for mock TransactionBuilderCoinsViewDB");
|
||||||
|
}
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
throw std::runtime_error("`GetHistoryRoot` unimplemented for mock TransactionBuilderCoinsViewDB");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashSproutAnchor,
|
const uint256 &hashSproutAnchor,
|
||||||
const uint256 &hashSaplingAnchor,
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
CAnchorsSproutMap &mapSproutAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CAnchorsSaplingMap &mapSaplingAnchors,
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap saplingNullifiersMap) {
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
ValidationFakeCoinsViewDB() {}
|
ValidationFakeCoinsViewDB() {}
|
||||||
ValidationFakeCoinsViewDB(uint256 blockHash, uint256 txid, CTxOut txOut, int nHeight) :
|
ValidationFakeCoinsViewDB(uint256 blockHash, uint256 txid, CTxOut txOut, int nHeight) :
|
||||||
coin(std::make_pair(std::make_pair(blockHash, txid), std::make_pair(txOut, nHeight))) {}
|
coin(std::make_pair(std::make_pair(blockHash, txid), std::make_pair(txOut, nHeight))) {}
|
||||||
|
~ValidationFakeCoinsViewDB() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const {
|
||||||
return false;
|
return false;
|
||||||
|
@ -41,6 +42,10 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetOrchardAnchorAt(const uint256 &rt, OrchardMerkleFrontier &tree) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
bool GetNullifier(const uint256 &nf, ShieldedType type) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -80,14 +85,30 @@ public:
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t branchId) const {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryNode GetHistoryAt(uint32_t branchId, HistoryIndex index) const {
|
||||||
|
return HistoryNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
return uint256();
|
||||||
|
}
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashSproutAnchor,
|
const uint256 &hashSproutAnchor,
|
||||||
const uint256 &hashSaplingAnchor,
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
CAnchorsSproutMap &mapSproutAnchors,
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
CAnchorsSaplingMap &mapSaplingAnchors,
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
CNullifiersMap &mapSproutNullifiers,
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
CNullifiersMap saplingNullifiersMap) {
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,8 @@ class CCoinsViewErrorCatcher : public CCoinsViewBacked
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {}
|
CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {}
|
||||||
|
~CCoinsViewErrorCatcher() {}
|
||||||
|
|
||||||
bool GetCoins(const uint256 &txid, CCoins &coins) const {
|
bool GetCoins(const uint256 &txid, CCoins &coins) const {
|
||||||
try {
|
try {
|
||||||
return CCoinsViewBacked::GetCoins(txid, coins);
|
return CCoinsViewBacked::GetCoins(txid, coins);
|
||||||
|
|
|
@ -1843,7 +1843,7 @@ bool AcceptToMemoryPool(
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
CCoinsView dummy;
|
CCoinsViewDummy dummy;
|
||||||
CCoinsViewCache view(&dummy);
|
CCoinsViewCache view(&dummy);
|
||||||
|
|
||||||
CAmount nValueIn = 0;
|
CAmount nValueIn = 0;
|
||||||
|
|
|
@ -511,7 +511,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, mempool.cs);
|
LOCK2(cs_main, mempool.cs);
|
||||||
|
|
||||||
CCoinsView viewDummy;
|
CCoinsViewDummy viewDummy;
|
||||||
CCoinsViewCache view(&viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
|
|
||||||
CCoinsViewCache& viewChain = *pcoinsTip;
|
CCoinsViewCache& viewChain = *pcoinsTip;
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
|
||||||
CMutableTransaction mergedTx(txVariants[0]);
|
CMutableTransaction mergedTx(txVariants[0]);
|
||||||
|
|
||||||
// Fetch previous transactions (inputs):
|
// Fetch previous transactions (inputs):
|
||||||
CCoinsView viewDummy;
|
CCoinsViewDummy viewDummy;
|
||||||
CCoinsViewCache view(&viewDummy);
|
CCoinsViewCache view(&viewDummy);
|
||||||
{
|
{
|
||||||
LOCK(mempool.cs);
|
LOCK(mempool.cs);
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
hashBestSaplingAnchor_ = SaplingMerkleTree::empty_root();
|
hashBestSaplingAnchor_ = SaplingMerkleTree::empty_root();
|
||||||
hashBestOrchardAnchor_ = OrchardMerkleFrontier::empty_root();
|
hashBestOrchardAnchor_ = OrchardMerkleFrontier::empty_root();
|
||||||
}
|
}
|
||||||
|
~CCoinsViewTest() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256& rt, SproutMerkleTree &tree) const {
|
bool GetSproutAnchorAt(const uint256& rt, SproutMerkleTree &tree) const {
|
||||||
if (rt == SproutMerkleTree::empty_root()) {
|
if (rt == SproutMerkleTree::empty_root()) {
|
||||||
|
@ -192,6 +193,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const { return HistoryNode(); }
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const { return uint256(); }
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap& mapCoins,
|
bool BatchWrite(CCoinsMap& mapCoins,
|
||||||
const uint256& hashBlock,
|
const uint256& hashBlock,
|
||||||
const uint256& hashSproutAnchor,
|
const uint256& hashSproutAnchor,
|
||||||
|
@ -243,6 +248,7 @@ class CCoinsViewCacheTest : public CCoinsViewCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCoinsViewCacheTest(CCoinsView* base) : CCoinsViewCache(base) {}
|
CCoinsViewCacheTest(CCoinsView* base) : CCoinsViewCache(base) {}
|
||||||
|
~CCoinsViewCacheTest() {}
|
||||||
|
|
||||||
void SelfTest() const
|
void SelfTest() const
|
||||||
{
|
{
|
||||||
|
@ -279,7 +285,7 @@ public:
|
||||||
JSDescription jsd;
|
JSDescription jsd;
|
||||||
jsd.nullifiers[0] = sproutNullifier;
|
jsd.nullifiers[0] = sproutNullifier;
|
||||||
mutableTx.vJoinSplit.emplace_back(jsd);
|
mutableTx.vJoinSplit.emplace_back(jsd);
|
||||||
|
|
||||||
saplingNullifier = InsecureRand256();
|
saplingNullifier = InsecureRand256();
|
||||||
SpendDescription sd;
|
SpendDescription sd;
|
||||||
sd.nullifier = saplingNullifier;
|
sd.nullifier = saplingNullifier;
|
||||||
|
|
|
@ -281,7 +281,7 @@ BOOST_DATA_TEST_CASE(AreInputsStandard, boost::unit_test::data::xrange(static_ca
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
uint32_t consensusBranchId = NetworkUpgradeInfo[sample].nBranchId;
|
uint32_t consensusBranchId = NetworkUpgradeInfo[sample].nBranchId;
|
||||||
CCoinsView coinsDummy;
|
CCoinsViewDummy coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CKey key[6];
|
CKey key[6];
|
||||||
|
|
|
@ -551,7 +551,7 @@ BOOST_DATA_TEST_CASE(test_Get, boost::unit_test::data::xrange(static_cast<int>(C
|
||||||
uint32_t consensusBranchId = NetworkUpgradeInfo[sample].nBranchId;
|
uint32_t consensusBranchId = NetworkUpgradeInfo[sample].nBranchId;
|
||||||
|
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsViewDummy coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
auto chainparams = Params();
|
auto chainparams = Params();
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsViewDummy coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandardV2)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
auto chainparams = Params();
|
auto chainparams = Params();
|
||||||
CBasicKeyStore keystore;
|
CBasicKeyStore keystore;
|
||||||
CCoinsView coinsDummy;
|
CCoinsViewDummy coinsDummy;
|
||||||
CCoinsViewCache coins(&coinsDummy);
|
CCoinsViewCache coins(&coinsDummy);
|
||||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ protected:
|
||||||
CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
CCoinsViewDB(std::string dbName, size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||||
public:
|
public:
|
||||||
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||||
|
~CCoinsViewDB() {}
|
||||||
|
|
||||||
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
||||||
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
||||||
|
|
|
@ -662,6 +662,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
|
CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn);
|
||||||
|
~CCoinsViewMemPool() {}
|
||||||
|
|
||||||
bool GetNullifier(const uint256 &txid, ShieldedType type) const;
|
bool GetNullifier(const uint256 &txid, ShieldedType type) const;
|
||||||
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
||||||
bool HaveCoins(const uint256 &txid) const;
|
bool HaveCoins(const uint256 &txid) const;
|
||||||
|
|
|
@ -33,6 +33,38 @@ public:
|
||||||
// Always return false so we treat every nullifier as being unspent.
|
// Always return false so we treat every nullifier as being unspent.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetCoins(const uint256 &txid, CCoins &coins) const { return false; }
|
||||||
|
bool HaveCoins(const uint256 &txid) const { return false; }
|
||||||
|
uint256 GetBestBlock() const {
|
||||||
|
throw std::runtime_error("`GetBestBlock` unimplemented for mock AssumeShieldedInputsExistAndAreSpendable");
|
||||||
|
}
|
||||||
|
uint256 GetBestAnchor(ShieldedType type) const {
|
||||||
|
throw std::runtime_error("`GetBestAnchor` unimplemented for mock AssumeShieldedInputsExistAndAreSpendable");
|
||||||
|
}
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const {
|
||||||
|
throw std::runtime_error("`GetHistoryAt` unimplemented for mock AssumeShieldedInputsExistAndAreSpendable");
|
||||||
|
}
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const {
|
||||||
|
throw std::runtime_error("`GetHistoryRoot` unimplemented for mock AssumeShieldedInputsExistAndAreSpendable");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
|
const uint256 &hashBlock,
|
||||||
|
const uint256 &hashSproutAnchor,
|
||||||
|
const uint256 &hashSaplingAnchor,
|
||||||
|
const uint256 &hashOrchardAnchor,
|
||||||
|
CAnchorsSproutMap &mapSproutAnchors,
|
||||||
|
CAnchorsSaplingMap &mapSaplingAnchors,
|
||||||
|
CAnchorsOrchardMap &mapOrchardAnchors,
|
||||||
|
CNullifiersMap &mapSproutNullifiers,
|
||||||
|
CNullifiersMap &mapSaplingNullifiers,
|
||||||
|
CNullifiersMap &mapOrchardNullifiers,
|
||||||
|
CHistoryCacheMap &historyCacheMap) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool GetStats(CCoinsStats &stats) const { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sprout
|
// Sprout
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include "wallet/orchard.h"
|
#include "wallet/orchard.h"
|
||||||
#include "zcash/Address.hpp"
|
#include "zcash/Address.hpp"
|
||||||
|
|
||||||
#include "gtest/test_transaction_builder.h"
|
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
using namespace libzcash;
|
using namespace libzcash;
|
||||||
|
@ -30,9 +28,7 @@ CTransaction FakeOrchardTx(const OrchardSpendingKey& sk, libzcash::diversifier_i
|
||||||
auto fvk = sk.ToFullViewingKey();
|
auto fvk = sk.ToFullViewingKey();
|
||||||
auto ivk = fvk.ToIncomingViewingKey();
|
auto ivk = fvk.ToIncomingViewingKey();
|
||||||
auto recipient = ivk.Address(j);
|
auto recipient = ivk.Address(j);
|
||||||
|
auto orchardAnchor = uint256();
|
||||||
TransactionBuilderCoinsViewDB fakeDB;
|
|
||||||
auto orchardAnchor = fakeDB.GetBestAnchor(ShieldedType::ORCHARD);
|
|
||||||
|
|
||||||
// Create a shielding transaction from transparent to Orchard
|
// Create a shielding transaction from transparent to Orchard
|
||||||
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, 0.0001 fee
|
// 0.0005 t-ZEC in, 0.0004 z-ZEC out, 0.0001 fee
|
||||||
|
|
|
@ -458,6 +458,7 @@ public:
|
||||||
OrchardMerkleFrontier emptyOrchardTree;
|
OrchardMerkleFrontier emptyOrchardTree;
|
||||||
orchardTrees.push_back(emptyOrchardTree);
|
orchardTrees.push_back(emptyOrchardTree);
|
||||||
}
|
}
|
||||||
|
~FakeCoinsViewDB() {}
|
||||||
|
|
||||||
void SetSaplingTrees(std::vector<std::string> trees) {
|
void SetSaplingTrees(std::vector<std::string> trees) {
|
||||||
saplingTrees.clear();
|
saplingTrees.clear();
|
||||||
|
@ -546,6 +547,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HistoryIndex GetHistoryLength(uint32_t epochId) const { return 0; }
|
||||||
|
HistoryNode GetHistoryAt(uint32_t epochId, HistoryIndex index) const { return HistoryNode(); }
|
||||||
|
uint256 GetHistoryRoot(uint32_t epochId) const { return uint256(); }
|
||||||
|
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashSproutAnchor,
|
const uint256 &hashSproutAnchor,
|
||||||
|
|
Loading…
Reference in New Issue