29 stakeUniqueness(stakeInput->GetUniqueness()),
32 stakeValue(stakeInput->GetValue())
36 uint64_t nStakeModifier = 0;
38 LogPrintf(
"%s : ERROR: Failed to get kernel stake modifier\n", __func__);
67 const bool res = hashProofOfStake < bnTarget;
69 if (!fSkipLog || res) {
75 "\nhashProofOfStake=%s"
78 "\nbnTarget=%s (res: %d)\n\n",
91 static bool LoadStakeInput(
const CBlock& block, std::unique_ptr<CStakeInput>& stake,
int nHeight)
95 return error(
"called on non PoS block");
98 const CTxIn& txin = block.
vtx[1]->vin[0];
103 return stake !=
nullptr;
117 if (!stakeInput)
return false;
122 if (nTimeTx <= pindexPrev->nTime && !fRegTest)
return false;
125 CStakeKernel stakeKernel(pindexPrev, stakeInput, nBits, nTimeTx);
141 const int nHeight = pindexPrev->
nHeight + 1;
143 std::unique_ptr<CStakeInput> stakeInput;
144 if (!LoadStakeInput(block, stakeInput, nHeight)) {
145 strError =
"stake input initialization failed";
152 strError =
"kernel hash check fails";
157 if (stakeInput->IsZPIV())
return true;
161 if (!stakeInput->GetTxOutFrom(stakePrevout)) {
162 strError =
"unable to get stake prevout for coinstake";
165 const auto& tx = block.
vtx[1];
166 const CTxIn& txin = tx->vin[0];
191 std::unique_ptr<CStakeInput> stakeInput;
192 if (!LoadStakeInput(block, stakeInput, pindexPrev->
nHeight + 1))
193 return error(
"%s : stake input initialization failed", __func__);
196 hashRet = stakeKernel.
GetHash();
arith_uint256 UintToArith256(const uint256 &a)
const CChainParams & Params()
Return the currently selected parameters.
const_iterator end() const
const_iterator begin() const
std::vector< CTransactionRef > vtx
bool IsProofOfStake() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetStakeModifierV2() const
int nHeight
height of the entry in the chain. The genesis block has height 0
bool IsRegTestNet() const
static CLegacyZPivStake * NewZPivStake(const CTxIn &txin, int nHeight)
CDataStream stakeModifier
bool CheckKernelHash(bool fSkipLog=false) const
CDataStream stakeUniqueness
CStakeKernel(const CBlockIndex *const pindexPrev, CStakeInput *stakeInput, unsigned int nBits, int nTimeTx)
CStakeKernel Constructor.
An input of a transaction.
bool IsZerocoinSpend() const
An output of a transaction.
256-bit unsigned big integer.
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
std::string GetHex() const
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, unsigned int flags, const BaseSignatureChecker &checker, SigVersion sigversion, ScriptError *serror)
bool CheckProofOfStake(const CBlock &block, std::string &strError, const CBlockIndex *pindexPrev)
bool Stake(const CBlockIndex *pindexPrev, CStakeInput *stakeInput, unsigned int nBits, int64_t &nTimeTx)
bool GetStakeKernelHash(uint256 &hashRet, const CBlock &block, const CBlockIndex *pindexPrev)
#define LogPrint(category,...)
const char * ScriptErrorString(const ScriptError serror)
enum ScriptError_t ScriptError
bool GetOldStakeModifier(CStakeInput *stake, uint64_t &nStakeModifier)
bool error(const char *fmt, const Args &... args)
int64_t GetAdjustedTime()
int64_t GetCurrentTimeSlot()
bool NetworkUpgradeActive(int nHeight, const Consensus::Params ¶ms, Consensus::UpgradeIndex idx)
Returns true if the given network upgrade is active as of the given block height.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.