Merge branch 'dev' into sietch
Conflicts: src/coins.cpp
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -333,13 +334,6 @@ void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) {
|
||||
}
|
||||
|
||||
void CCoinsViewCache::SetNullifiers(const CTransaction& tx, bool spent) {
|
||||
for (const JSDescription &joinsplit : tx.vjoinsplit) {
|
||||
for (const uint256 &nullifier : joinsplit.nullifiers) {
|
||||
std::pair<CNullifiersMap::iterator, bool> ret = cacheSproutNullifiers.insert(std::make_pair(nullifier, CNullifiersCacheEntry()));
|
||||
ret.first->second.entered = spent;
|
||||
ret.first->second.flags |= CNullifiersCacheEntry::DIRTY;
|
||||
}
|
||||
}
|
||||
for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
|
||||
std::pair<CNullifiersMap::iterator, bool> ret = cacheSaplingNullifiers.insert(std::make_pair(spendDescription.nullifier, CNullifiersCacheEntry()));
|
||||
ret.first->second.entered = spent;
|
||||
@@ -622,6 +616,7 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr
|
||||
|
||||
bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
/*
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
|
||||
@@ -653,15 +648,45 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const
|
||||
}
|
||||
*/
|
||||
|
||||
||||||| merged common ancestors
|
||||
boost::unordered_map<uint256, SproutMerkleTree, CCoinsKeyHasher> intermediates;
|
||||
|
||||
BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers)
|
||||
{
|
||||
if (GetNullifier(nullifier, SPROUT)) {
|
||||
// If the nullifier is set, this transaction
|
||||
// double-spends!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SproutMerkleTree tree;
|
||||
auto it = intermediates.find(joinsplit.anchor);
|
||||
if (it != intermediates.end()) {
|
||||
tree = it->second;
|
||||
} else if (!GetSproutAnchorAt(joinsplit.anchor, tree)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_FOREACH(const uint256& commitment, joinsplit.commitments)
|
||||
{
|
||||
tree.append(commitment);
|
||||
}
|
||||
|
||||
intermediates.insert(std::make_pair(tree.root(), tree));
|
||||
}
|
||||
|
||||
for (const SpendDescription &spendDescription : tx.vShieldedSpend) {
|
||||
if (GetNullifier(spendDescription.nullifier, SAPLING)) { // Prevent double spends
|
||||
fprintf(stderr,"%s: existing nullifier!",__FUNCTION__);
|
||||
LogPrintf("%s: sapling nullifier %s exists, preventing double spend\n", __FUNCTION__, spendDescription.nullifier.GetHex().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
SaplingMerkleTree tree;
|
||||
if (!GetSaplingAnchorAt(spendDescription.anchor, tree)) {
|
||||
fprintf(stderr,"%s: missing Sapling anchor!",__FUNCTION__);
|
||||
LogPrintf("%s: missing sapling anchor: %s \n", __FUNCTION__, spendDescription.anchor.GetHex().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user