diff --git a/src/coins.cpp b/src/coins.cpp index b4f9faba7..51ef207bf 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -394,7 +394,7 @@ bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const { boost::unordered_map intermediates; - BOOST_FOREACH(const CPourTx &pour, tx.vpour) + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256& serial, pour.serials) { diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp index 857166848..3978132cf 100644 --- a/src/gtest/test_checktransaction.cpp +++ b/src/gtest/test_checktransaction.cpp @@ -15,9 +15,9 @@ TEST(checktransaction_tests, check_vpub_not_both_nonzero) { CMutableTransaction newTx(tx); CValidationState state; - newTx.vpour.push_back(CPourTx()); + newTx.vpour.push_back(JSDescription()); - CPourTx *pourtx = &newTx.vpour[0]; + JSDescription *pourtx = &newTx.vpour[0]; pourtx->vpub_old = 1; pourtx->vpub_new = 1; diff --git a/src/main.cpp b/src/main.cpp index 6b41a6772..c2dd70885 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -876,7 +876,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) return false; } else { // Ensure that zk-SNARKs verify - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { if (!pour.Verify(*pzcashParams, tx.joinSplitPubKey)) { return state.DoS(100, error("CheckTransaction(): pour does not verify"), REJECT_INVALID, "bad-txns-pour-verification-failed"); @@ -921,7 +921,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } // Ensure that pour values are well-formed - BOOST_FOREACH(const CPourTx& pour, tx.vpour) + BOOST_FOREACH(const JSDescription& pour, tx.vpour) { if (pour.vpub_old < 0) { return state.DoS(100, error("CheckTransaction(): pour.vpub_old negative"), @@ -968,7 +968,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio // Check for duplicate pour serials in this transaction set vPourSerials; - BOOST_FOREACH(const CPourTx& pour, tx.vpour) + BOOST_FOREACH(const JSDescription& pour, tx.vpour) { BOOST_FOREACH(const uint256& serial, pour.serials) { @@ -1104,7 +1104,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { if (pool.mapSerials.count(serial)) { @@ -1586,7 +1586,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach } // spend serials - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { inputs.SetSerial(serial, true); } @@ -1908,7 +1908,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex } // unspend serials - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { view.SetSerial(serial, false); } @@ -2157,7 +2157,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &bucket_commitment, pour.commitments) { // Insert the bucket commitments into our temporary tree. diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index ca073fa18..0035d7d32 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -9,7 +9,7 @@ #include "tinyformat.h" #include "utilstrencodings.h" -CPourTx::CPourTx(ZCJoinSplit& params, +JSDescription::JSDescription(ZCJoinSplit& params, const uint256& pubKeyHash, const uint256& anchor, const boost::array& inputs, @@ -37,7 +37,7 @@ CPourTx::CPourTx(ZCJoinSplit& params, ); } -bool CPourTx::Verify( +bool JSDescription::Verify( ZCJoinSplit& params, const uint256& pubKeyHash ) const { @@ -54,7 +54,7 @@ bool CPourTx::Verify( ); } -uint256 CPourTx::h_sig(ZCJoinSplit& params, const uint256& pubKeyHash) const +uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& pubKeyHash) const { return params.h_sig(randomSeed, serials, pubKeyHash); } @@ -139,7 +139,7 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) { *const_cast*>(&vin) = tx.vin; *const_cast*>(&vout) = tx.vout; *const_cast(&nLockTime) = tx.nLockTime; - *const_cast*>(&vpour) = tx.vpour; + *const_cast*>(&vpour) = tx.vpour; *const_cast(&joinSplitPubKey) = tx.joinSplitPubKey; *const_cast(&joinSplitSig) = tx.joinSplitSig; *const_cast(&hash) = tx.hash; @@ -156,7 +156,7 @@ CAmount CTransaction::GetValueOut() const throw std::runtime_error("CTransaction::GetValueOut(): value out of range"); } - for (std::vector::const_iterator it(vpour.begin()); it != vpour.end(); ++it) + for (std::vector::const_iterator it(vpour.begin()); it != vpour.end(); ++it) { // NB: vpub_old "takes" money from the value pool just as outputs do nValueOut += it->vpub_old; @@ -170,7 +170,7 @@ CAmount CTransaction::GetValueOut() const CAmount CTransaction::GetPourValueIn() const { CAmount nValue = 0; - for (std::vector::const_iterator it(vpour.begin()); it != vpour.end(); ++it) + for (std::vector::const_iterator it(vpour.begin()); it != vpour.end(); ++it) { // NB: vpub_new "gives" money to the value pool just as inputs do nValue += it->vpub_new; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index b3849515e..9a2a15ead 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -17,7 +17,7 @@ #include "zcash/Zcash.h" #include "zcash/JoinSplit.hpp" -class CPourTx +class JSDescription { public: // These values 'enter from' and 'exit to' the value @@ -65,9 +65,9 @@ public: // This is a zk-SNARK which ensures that this pour is valid. boost::array proof; - CPourTx(): vpub_old(0), vpub_new(0) { } + JSDescription(): vpub_old(0), vpub_new(0) { } - CPourTx(ZCJoinSplit& params, + JSDescription(ZCJoinSplit& params, const uint256& pubKeyHash, const uint256& rt, const boost::array& inputs, @@ -98,7 +98,7 @@ public: READWRITE(proof); } - friend bool operator==(const CPourTx& a, const CPourTx& b) + friend bool operator==(const JSDescription& a, const JSDescription& b) { return ( a.vpub_old == b.vpub_old && @@ -114,7 +114,7 @@ public: ); } - friend bool operator!=(const CPourTx& a, const CPourTx& b) + friend bool operator!=(const JSDescription& a, const JSDescription& b) { return !(a == b); } @@ -303,7 +303,7 @@ public: const std::vector vin; const std::vector vout; const uint32_t nLockTime; - const std::vector vpour; + const std::vector vpour; const uint256 joinSplitPubKey; const joinsplit_sig_t joinSplitSig; @@ -325,7 +325,7 @@ public: READWRITE(*const_cast*>(&vout)); READWRITE(*const_cast(&nLockTime)); if (nVersion >= 2) { - READWRITE(*const_cast*>(&vpour)); + READWRITE(*const_cast*>(&vpour)); if (vpour.size() > 0) { READWRITE(*const_cast(&joinSplitPubKey)); READWRITE(*const_cast(&joinSplitSig)); @@ -382,7 +382,7 @@ struct CMutableTransaction std::vector vin; std::vector vout; uint32_t nLockTime; - std::vector vpour; + std::vector vpour; uint256 joinSplitPubKey; CTransaction::joinsplit_sig_t joinSplitSig; diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index d2f3b94fa..818e38a6f 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -92,7 +92,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) Array vpour; for (unsigned int i = 0; i < tx.vpour.size(); i++) { - const CPourTx& pourtx = tx.vpour[i]; + const JSDescription& pourtx = tx.vpour[i]; Object pour; pour.push_back(Pair("anchor", pourtx.anchor.GetHex())); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index c9c3fb855..032f66ba0 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(chained_pours) ZCIncrementalMerkleTree tree; - CPourTx ptx1; + JSDescription ptx1; ptx1.anchor = tree.root(); ptx1.commitments[0] = appendRandomCommitment(tree); ptx1.commitments[1] = appendRandomCommitment(tree); @@ -232,13 +232,13 @@ BOOST_AUTO_TEST_CASE(chained_pours) // Although it's not possible given our assumptions, if // two pours create the same treestate twice, we should // still be able to anchor to it. - CPourTx ptx1b; + JSDescription ptx1b; ptx1b.anchor = tree.root(); ptx1b.commitments[0] = ptx1.commitments[0]; ptx1b.commitments[1] = ptx1.commitments[1]; - CPourTx ptx2; - CPourTx ptx3; + JSDescription ptx2; + JSDescription ptx3; ptx2.anchor = tree.root(); ptx3.anchor = tree.root(); diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index 3d8714c0e..352ed8781 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -122,7 +122,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) { } if (tx.nVersion >= 2) { for (int pour = 0; pour < pours; pour++) { - CPourTx pourtx; + JSDescription pourtx; if (insecure_rand() % 2 == 0) { pourtx.vpub_old = insecure_rand() % 100000000; } else { diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 91c5f9140..b0ee9d5c7 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification) auto witness = merkleTree.witness(); - // create CPourTx + // create JSDescription uint256 pubKeyHash; boost::array inputs = { libzcash::JSInput(witness, note, k), @@ -342,13 +342,13 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification) }; { - CPourTx pourtx(*p, pubKeyHash, rt, inputs, outputs, 0, 0); + JSDescription pourtx(*p, pubKeyHash, rt, inputs, outputs, 0, 0); BOOST_CHECK(pourtx.Verify(*p, pubKeyHash)); CDataStream ss(SER_DISK, CLIENT_VERSION); ss << pourtx; - CPourTx pourtx_deserialized; + JSDescription pourtx_deserialized; ss >> pourtx_deserialized; BOOST_CHECK(pourtx_deserialized == pourtx); @@ -357,13 +357,13 @@ BOOST_AUTO_TEST_CASE(test_basic_pour_verification) { // Ensure that the balance equation is working. - BOOST_CHECK_THROW(CPourTx(*p, pubKeyHash, rt, inputs, outputs, 10, 0), std::invalid_argument); - BOOST_CHECK_THROW(CPourTx(*p, pubKeyHash, rt, inputs, outputs, 0, 10), std::invalid_argument); + BOOST_CHECK_THROW(JSDescription(*p, pubKeyHash, rt, inputs, outputs, 10, 0), std::invalid_argument); + BOOST_CHECK_THROW(JSDescription(*p, pubKeyHash, rt, inputs, outputs, 0, 10), std::invalid_argument); } { // Ensure that it won't verify if the root is changed. - auto test = CPourTx(*p, pubKeyHash, rt, inputs, outputs, 0, 0); + auto test = JSDescription(*p, pubKeyHash, rt, inputs, outputs, 0, 0); test.anchor = GetRandHash(); BOOST_CHECK(!test.Verify(*p, pubKeyHash)); } @@ -393,8 +393,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) BOOST_CHECK(!CheckTransactionWithoutProofVerification(newTx, state)); BOOST_CHECK(state.GetRejectReason() == "bad-txns-vout-empty"); - newTx.vpour.push_back(CPourTx()); - CPourTx *pourtx = &newTx.vpour[0]; + newTx.vpour.push_back(JSDescription()); + JSDescription *pourtx = &newTx.vpour[0]; pourtx->serials[0] = GetRandHash(); pourtx->serials[1] = GetRandHash(); @@ -422,9 +422,9 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) CMutableTransaction newTx(tx); CValidationState state; - newTx.vpour.push_back(CPourTx()); + newTx.vpour.push_back(JSDescription()); - CPourTx *pourtx = &newTx.vpour[0]; + JSDescription *pourtx = &newTx.vpour[0]; pourtx->vpub_old = -1; BOOST_CHECK(!CheckTransaction(newTx, state)); @@ -448,9 +448,9 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) pourtx->vpub_new = (MAX_MONEY / 2) + 10; - newTx.vpour.push_back(CPourTx()); + newTx.vpour.push_back(JSDescription()); - CPourTx *pourtx2 = &newTx.vpour[1]; + JSDescription *pourtx2 = &newTx.vpour[1]; pourtx2->vpub_new = (MAX_MONEY / 2) + 10; BOOST_CHECK(!CheckTransaction(newTx, state)); @@ -461,8 +461,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) CMutableTransaction newTx(tx); CValidationState state; - newTx.vpour.push_back(CPourTx()); - CPourTx *pourtx = &newTx.vpour[0]; + newTx.vpour.push_back(JSDescription()); + JSDescription *pourtx = &newTx.vpour[0]; pourtx->serials[0] = GetRandHash(); pourtx->serials[1] = pourtx->serials[0]; @@ -472,8 +472,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) pourtx->serials[1] = GetRandHash(); - newTx.vpour.push_back(CPourTx()); - CPourTx *pourtx2 = &newTx.vpour[1]; + newTx.vpour.push_back(JSDescription()); + JSDescription *pourtx2 = &newTx.vpour[1]; pourtx2->serials[0] = GetRandHash(); pourtx2->serials[1] = pourtx->serials[0]; @@ -486,8 +486,8 @@ BOOST_AUTO_TEST_CASE(test_simple_pour_invalidity) CMutableTransaction newTx(tx); CValidationState state; - newTx.vpour.push_back(CPourTx()); - CPourTx *pourtx = &newTx.vpour[0]; + newTx.vpour.push_back(JSDescription()); + JSDescription *pourtx = &newTx.vpour[0]; pourtx->serials[0] = GetRandHash(); pourtx->serials[1] = GetRandHash(); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index c3f6c829f..9a4b6c24f 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -99,7 +99,7 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, const CTransaction& tx = mapTx[hash].GetTx(); for (unsigned int i = 0; i < tx.vin.size(); i++) mapNextTx[tx.vin[i].prevout] = CInPoint(&tx, i); - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { mapSerials[serial] = &tx; } @@ -148,7 +148,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list& rem } BOOST_FOREACH(const CTxIn& txin, tx.vin) mapNextTx.erase(txin.prevout); - BOOST_FOREACH(const CPourTx& pour, tx.vpour) { + BOOST_FOREACH(const JSDescription& pour, tx.vpour) { BOOST_FOREACH(const uint256& serial, pour.serials) { mapSerials.erase(serial); } @@ -200,7 +200,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot) for (std::map::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) { const CTransaction& tx = it->second.GetTx(); - BOOST_FOREACH(const CPourTx& pour, tx.vpour) { + BOOST_FOREACH(const JSDescription& pour, tx.vpour) { if (pour.anchor == invalidRoot) { transactionsToRemove.push_back(tx); break; @@ -230,7 +230,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list } } - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { std::map::iterator it = mapSerials.find(serial); if (it != mapSerials.end()) { @@ -317,7 +317,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const boost::unordered_map intermediates; - BOOST_FOREACH(const CPourTx &pour, tx.vpour) { + BOOST_FOREACH(const JSDescription &pour, tx.vpour) { BOOST_FOREACH(const uint256 &serial, pour.serials) { assert(!pcoins->GetSerial(serial)); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d009ca08d..81fe0e656 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2393,18 +2393,18 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp) pzcashParams->loadProvingKey(); } - CPourTx* samplejoinsplit = NULL; + JSDescription* samplejoinsplit = NULL; if (benchmarktype == "verifyjoinsplit") { uint256 pubKeyHash; uint256 anchor = ZCIncrementalMerkleTree().root(); - samplejoinsplit = new CPourTx(*pzcashParams, - pubKeyHash, - anchor, - {JSInput(), JSInput()}, - {JSOutput(), JSOutput()}, - 0, - 0); + samplejoinsplit = new JSDescription(*pzcashParams, + pubKeyHash, + anchor, + {JSInput(), JSInput()}, + {JSOutput(), JSOutput()}, + 0, + 0); } for (int i = 0; i < samplecount; i++) { @@ -2644,7 +2644,7 @@ Value zc_raw_pour(const json_spirit::Array& params, bool fHelp) mtx.nVersion = 2; mtx.joinSplitPubKey = joinSplitPubKey; - CPourTx pourtx(*pzcashParams, + JSDescription pourtx(*pzcashParams, joinSplitPubKey, anchor, {vpourin[0], vpourin[1]}, diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index cbcb467c8..66c028591 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1065,7 +1065,7 @@ void CWallet::WitnessBucketCommitment(std::vector commitments, BOOST_FOREACH(const CTransaction& tx, block.vtx) { - BOOST_FOREACH(const CPourTx& pour, tx.vpour) + BOOST_FOREACH(const JSDescription& pour, tx.vpour) { BOOST_FOREACH(const uint256 &bucket_commitment, pour.commitments) { diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 5aac4bbc3..d2aeec657 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -76,7 +76,7 @@ double benchmark_create_joinsplit() uint256 anchor = ZCIncrementalMerkleTree().root(); timer_start(); - CPourTx pourtx(*pzcashParams, + JSDescription pourtx(*pzcashParams, pubKeyHash, anchor, {JSInput(), JSInput()}, @@ -89,7 +89,7 @@ double benchmark_create_joinsplit() return ret; } -double benchmark_verify_joinsplit(const CPourTx &joinsplit) +double benchmark_verify_joinsplit(const JSDescription &joinsplit) { timer_start(); uint256 pubKeyHash; diff --git a/src/zcbenchmarks.h b/src/zcbenchmarks.h index e59fff1d9..906cadcc1 100644 --- a/src/zcbenchmarks.h +++ b/src/zcbenchmarks.h @@ -8,7 +8,7 @@ extern double benchmark_sleep(); extern double benchmark_parameter_loading(); extern double benchmark_create_joinsplit(); extern double benchmark_solve_equihash(); -extern double benchmark_verify_joinsplit(const CPourTx &joinsplit); +extern double benchmark_verify_joinsplit(const JSDescription &joinsplit); extern double benchmark_verify_equihash(); extern double benchmark_large_tx();