bool CzPIVWallet::RegenerateMint(const CDeterministicMint& dMint, CZerocoinMint& mint) { if (!CheckSeed(dMint)) { uint256 hashSeed = Hash(seedMaster.begin(), seedMaster.end()); return error("%s: master seed does not match!\ndmint:\n %s \nhashSeed: %s\nseed: %s", __func__, dMint.ToString(), hashSeed.GetHex(), seedMaster.GetHex()); } //Generate the coin PrivateCoin coin(Params().Zerocoin_Params(false), dMint.GetDenomination(), false); CDeterministicMint dMintDummy; GenerateMint(dMint.GetCount(), dMint.GetDenomination(), coin, dMintDummy); //Fill in the zerocoinmint object's details CBigNum bnValue = coin.getPublicCoin().getValue(); if (GetPubCoinHash(bnValue) != dMint.GetPubcoinHash()) return error("%s: failed to correctly generate mint, pubcoin hash mismatch", __func__); mint.SetValue(bnValue); CBigNum bnSerial = coin.getSerialNumber(); if (GetSerialHash(bnSerial) != dMint.GetSerialHash()) return error("%s: failed to correctly generate mint, serial hash mismatch", __func__); mint.SetSerialNumber(bnSerial); mint.SetRandomness(coin.getRandomness()); mint.SetPrivKey(coin.getPrivKey()); mint.SetVersion(coin.getVersion()); mint.SetDenomination(dMint.GetDenomination()); mint.SetUsed(dMint.IsUsed()); mint.SetTxHash(dMint.GetTxHash()); mint.SetHeight(dMint.GetHeight()); return true; }
bool CzTNXTracker::UpdateState(const CMintMeta& meta) { CWalletDB walletdb(strWalletFile); if (meta.isDeterministic) { CDeterministicMint dMint; if (!walletdb.ReadDeterministicMint(meta.hashPubcoin, dMint)) { // Check archive just in case if (!meta.isArchived) return error("%s: failed to read deterministic mint from database", __func__); // Unarchive this mint since it is being requested and updated if (!walletdb.UnarchiveDeterministicMint(meta.hashPubcoin, dMint)) return error("%s: failed to unarchive deterministic mint from database", __func__); } dMint.SetTxHash(meta.txid); dMint.SetHeight(meta.nHeight); dMint.SetUsed(meta.isUsed); dMint.SetDenomination(meta.denom); dMint.SetStakeHash(meta.hashStake); if (!walletdb.WriteDeterministicMint(dMint)) return error("%s: failed to update deterministic mint when writing to db", __func__); } else { CZerocoinMint mint; if (!walletdb.ReadZerocoinMint(meta.hashPubcoin, mint)) return error("%s: failed to read mint from database", __func__); mint.SetTxHash(meta.txid); mint.SetHeight(meta.nHeight); mint.SetUsed(meta.isUsed); mint.SetDenomination(meta.denom); if (!walletdb.WriteZerocoinMint(mint)) return error("%s: failed to write mint to database", __func__); } mapSerialHashes[meta.hashSerial] = meta; return true; }