Skip to content

Commit 79dc604

Browse files
committed
Miner: sapling tree hash connection.
1 parent e43380d commit 79dc604

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/miner.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "amount.h"
1414
#include "consensus/merkle.h"
1515
#include "consensus/tx_verify.h" // needed in case of no ENABLE_WALLET
16+
#include "consensus/params.h"
17+
#include "consensus/upgrades.h"
1618
#include "hash.h"
1719
#include "masternode-sync.h"
1820
#include "net.h"
@@ -441,6 +443,24 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
441443
nLastBlockSize = nBlockSize;
442444
LogPrintf("%s : total size %u\n", __func__, nBlockSize);
443445

446+
// Sapling
447+
if (NetworkUpgradeActive(nHeight, consensus, Consensus::UPGRADE_V5_DUMMY)) {
448+
pblock->nVersion = 8;
449+
SaplingMerkleTree sapling_tree;
450+
assert(view.GetSaplingAnchorAt(view.GetBestAnchor(), sapling_tree));
451+
452+
// Update the Sapling commitment tree.
453+
for (const auto &tx : pblock->vtx) {
454+
if (tx->isSapling() && tx->hasSaplingData()) {
455+
for (const OutputDescription &odesc : tx->sapData->vShieldedOutput) {
456+
sapling_tree.append(odesc.cmu);
457+
}
458+
}
459+
}
460+
// Update header
461+
pblock->hashFinalSaplingRoot = sapling_tree.root();
462+
}
463+
444464
// Fill in header
445465
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
446466
if (!fProofOfStake)

0 commit comments

Comments
 (0)