Skip to content

Commit 28afbd2

Browse files
committed
[zPIV] v1 serials modulus fix + isStandardTx fix for publicSpends.
cleanup, publicCoinSpend object leftover removed + minor log added to CheckProofOfStake.
1 parent ddc3f15 commit 28afbd2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/kernel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ bool CheckProofOfStake(const CBlock block, uint256& hashProofOfStake, std::uniqu
372372
uint256 hashBlock;
373373
CTransaction txPrev;
374374
if (!GetTransaction(txin.prevout.hash, txPrev, hashBlock, true))
375-
return error("CheckProofOfStake() : INFO: read txPrev failed");
375+
return error("CheckProofOfStake() : INFO: read txPrev failed, tx id prev: %s, block id %s",
376+
txin.prevout.hash.GetHex(), block.GetHash().GetHex());
376377

377378
//verify signature and script
378379
if (!VerifyScript(txin.scriptSig, txPrev.vout[txin.prevout.n].scriptPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, TransactionSignatureChecker(&tx, 0)))

src/main.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
739739
}
740740

741741
for (const CTxIn& txin : tx.vin) {
742-
if (txin.IsZerocoinSpend())
742+
if (txin.IsZerocoinSpend() || txin.IsZerocoinPublicSpend())
743743
continue;
744744
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed
745745
// keys. (remember the 520 byte limit on redeemScript size) That works
@@ -1042,16 +1042,17 @@ bool ContextualCheckZerocoinSpendNoSerialCheck(const CTransaction& tx, const Coi
10421042
}
10431043
}
10441044

1045+
bool v1Serial = spend->getVersion() < libzerocoin::PrivateCoin::PUBKEY_VERSION;
10451046
if (pindex->nHeight >= Params().Zerocoin_Block_Public_Spend_Enabled()) {
10461047
//Reject V1 old serials.
1047-
if (spend->getVersion() < libzerocoin::PrivateCoin::PUBKEY_VERSION) {
1048+
if (v1Serial) {
10481049
return error("%s : zPIV v1 serial spend not spendable, serial %s, tx %s\n", __func__,
10491050
spend->getCoinSerialNumber().GetHex(), tx.GetHash().GetHex());
10501051
}
10511052
}
10521053

10531054
//Reject serial's that are not in the acceptable value range
1054-
if (!spend->HasValidSerial(Params().Zerocoin_Params(false))) {
1055+
if (!spend->HasValidSerial(Params().Zerocoin_Params(v1Serial))) {
10551056
// Up until this block our chain was not checking serials correctly..
10561057
if (!isBlockBetweenFakeSerialAttackRange(pindex->nHeight))
10571058
return error("%s : zPIV spend with serial %s from tx %s is not in valid range\n", __func__,
@@ -1817,15 +1818,13 @@ bool AcceptableInputs(CTxMemPool& pool, CValidationState& state, const CTransact
18171818

18181819
bool GetOutput(const uint256& hash, unsigned int index, CValidationState& state, CTxOut& out)
18191820
{
1820-
libzerocoin::ZerocoinParams* params = Params().Zerocoin_Params(false);
1821-
PublicCoinSpend ret(params);
18221821
CTransaction txPrev;
18231822
uint256 hashBlock;
18241823
if (!GetTransaction(hash, txPrev, hashBlock, true)) {
18251824
return state.DoS(100, error("Output not found"));
18261825
}
18271826
if (index > txPrev.vout.size()) {
1828-
return state.DoS(100, error("Output not found, invalid index %d", index));
1827+
return state.DoS(100, error("Output not found, invalid index %d for %s",index, hash.GetHex()));
18291828
}
18301829
out = txPrev.vout[index];
18311830
return true;

0 commit comments

Comments
 (0)