Browse Source

Rename vpour to vjoinsplit.

pull/145/head
Sean Bowe 8 years ago
parent
commit
8675d94b63
  1. 2
      src/coins.cpp
  2. 4
      src/gtest/test_checktransaction.cpp
  3. 26
      src/main.cpp
  4. 12
      src/primitives/transaction.cpp
  5. 12
      src/primitives/transaction.h
  6. 10
      src/rpcrawtransaction.cpp
  7. 6
      src/script/interpreter.cpp
  8. 24
      src/test/coins_tests.cpp
  9. 2
      src/test/sighash_tests.cpp
  10. 24
      src/test/transaction_tests.cpp
  11. 10
      src/txmempool.cpp
  12. 2
      src/wallet/rpcwallet.cpp
  13. 2
      src/wallet/wallet.cpp

2
src/coins.cpp

@ -394,7 +394,7 @@ bool CCoinsViewCache::HavePourRequirements(const CTransaction& tx) const
{
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
BOOST_FOREACH(const JSDescription &pour, tx.vpour)
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit)
{
BOOST_FOREACH(const uint256& serial, pour.serials)
{

4
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(JSDescription());
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vpour[0];
JSDescription *pourtx = &newTx.vjoinsplit[0];
pourtx->vpub_old = 1;
pourtx->vpub_new = 1;

26
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 JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
if (!pour.Verify(*pzcashParams, tx.joinSplitPubKey)) {
return state.DoS(100, error("CheckTransaction(): pour does not verify"),
REJECT_INVALID, "bad-txns-pour-verification-failed");
@ -891,11 +891,11 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
// Basic checks that don't depend on any context
// Transactions can contain empty `vin` and `vout` so long as
// `vpour` is non-empty.
if (tx.vin.empty() && tx.vpour.empty())
// `vjoinsplit` is non-empty.
if (tx.vin.empty() && tx.vjoinsplit.empty())
return state.DoS(10, error("CheckTransaction(): vin empty"),
REJECT_INVALID, "bad-txns-vin-empty");
if (tx.vout.empty() && tx.vpour.empty())
if (tx.vout.empty() && tx.vjoinsplit.empty())
return state.DoS(10, error("CheckTransaction(): vout empty"),
REJECT_INVALID, "bad-txns-vout-empty");
@ -921,7 +921,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
}
// Ensure that pour values are well-formed
BOOST_FOREACH(const JSDescription& pour, tx.vpour)
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit)
{
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<uint256> vPourSerials;
BOOST_FOREACH(const JSDescription& pour, tx.vpour)
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit)
{
BOOST_FOREACH(const uint256& serial, pour.serials)
{
@ -983,7 +983,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
if (tx.IsCoinBase())
{
// There should be no pours in a coinbase transaction
if (tx.vpour.size() > 0)
if (tx.vjoinsplit.size() > 0)
return state.DoS(100, error("CheckTransaction(): coinbase has pours"),
REJECT_INVALID, "bad-cb-has-pours");
@ -998,7 +998,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
return state.DoS(10, error("CheckTransaction(): prevout is null"),
REJECT_INVALID, "bad-txns-prevout-null");
if (tx.vpour.size() > 0) {
if (tx.vjoinsplit.size() > 0) {
// TODO: #966.
static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
// Empty output script.
@ -1104,7 +1104,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
return false;
}
}
BOOST_FOREACH(const JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
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 JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
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 JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
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 JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &bucket_commitment, pour.commitments) {
// Insert the bucket commitments into our temporary tree.
@ -4734,7 +4734,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
EraseOrphanTx(hash);
}
// TODO: currently, prohibit pours from entering mapOrphans
else if (fMissingInputs && tx.vpour.size() == 0)
else if (fMissingInputs && tx.vjoinsplit.size() == 0)
{
AddOrphanTx(tx, pfrom->GetId());

12
src/primitives/transaction.cpp

@ -111,7 +111,7 @@ std::string CTxOut::ToString() const
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime),
vpour(tx.vpour), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig)
vjoinsplit(tx.vjoinsplit), joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig)
{
}
@ -126,9 +126,9 @@ void CTransaction::UpdateHash() const
*const_cast<uint256*>(&hash) = SerializeHash(*this);
}
CTransaction::CTransaction() : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), vpour(), joinSplitPubKey(), joinSplitSig() { }
CTransaction::CTransaction() : nVersion(CTransaction::CURRENT_VERSION), vin(), vout(), nLockTime(0), vjoinsplit(), joinSplitPubKey(), joinSplitSig() { }
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), vpour(tx.vpour),
CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion), vin(tx.vin), vout(tx.vout), nLockTime(tx.nLockTime), vjoinsplit(tx.vjoinsplit),
joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig)
{
UpdateHash();
@ -139,7 +139,7 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) {
*const_cast<std::vector<CTxIn>*>(&vin) = tx.vin;
*const_cast<std::vector<CTxOut>*>(&vout) = tx.vout;
*const_cast<unsigned int*>(&nLockTime) = tx.nLockTime;
*const_cast<std::vector<JSDescription>*>(&vpour) = tx.vpour;
*const_cast<std::vector<JSDescription>*>(&vjoinsplit) = tx.vjoinsplit;
*const_cast<uint256*>(&joinSplitPubKey) = tx.joinSplitPubKey;
*const_cast<joinsplit_sig_t*>(&joinSplitSig) = tx.joinSplitSig;
*const_cast<uint256*>(&hash) = tx.hash;
@ -156,7 +156,7 @@ CAmount CTransaction::GetValueOut() const
throw std::runtime_error("CTransaction::GetValueOut(): value out of range");
}
for (std::vector<JSDescription>::const_iterator it(vpour.begin()); it != vpour.end(); ++it)
for (std::vector<JSDescription>::const_iterator it(vjoinsplit.begin()); it != vjoinsplit.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<JSDescription>::const_iterator it(vpour.begin()); it != vpour.end(); ++it)
for (std::vector<JSDescription>::const_iterator it(vjoinsplit.begin()); it != vjoinsplit.end(); ++it)
{
// NB: vpub_new "gives" money to the value pool just as inputs do
nValue += it->vpub_new;

12
src/primitives/transaction.h

@ -303,7 +303,7 @@ public:
const std::vector<CTxIn> vin;
const std::vector<CTxOut> vout;
const uint32_t nLockTime;
const std::vector<JSDescription> vpour;
const std::vector<JSDescription> vjoinsplit;
const uint256 joinSplitPubKey;
const joinsplit_sig_t joinSplitSig;
@ -325,8 +325,8 @@ public:
READWRITE(*const_cast<std::vector<CTxOut>*>(&vout));
READWRITE(*const_cast<uint32_t*>(&nLockTime));
if (nVersion >= 2) {
READWRITE(*const_cast<std::vector<JSDescription>*>(&vpour));
if (vpour.size() > 0) {
READWRITE(*const_cast<std::vector<JSDescription>*>(&vjoinsplit));
if (vjoinsplit.size() > 0) {
READWRITE(*const_cast<uint256*>(&joinSplitPubKey));
READWRITE(*const_cast<joinsplit_sig_t*>(&joinSplitSig));
}
@ -382,7 +382,7 @@ struct CMutableTransaction
std::vector<CTxIn> vin;
std::vector<CTxOut> vout;
uint32_t nLockTime;
std::vector<JSDescription> vpour;
std::vector<JSDescription> vjoinsplit;
uint256 joinSplitPubKey;
CTransaction::joinsplit_sig_t joinSplitSig;
@ -399,8 +399,8 @@ struct CMutableTransaction
READWRITE(vout);
READWRITE(nLockTime);
if (nVersion >= 2) {
READWRITE(vpour);
if (vpour.size() > 0) {
READWRITE(vjoinsplit);
if (vjoinsplit.size() > 0) {
READWRITE(joinSplitPubKey);
READWRITE(joinSplitSig);
}

10
src/rpcrawtransaction.cpp

@ -90,9 +90,9 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
}
entry.push_back(Pair("vout", vout));
Array vpour;
for (unsigned int i = 0; i < tx.vpour.size(); i++) {
const JSDescription& pourtx = tx.vpour[i];
Array vjoinsplit;
for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) {
const JSDescription& pourtx = tx.vjoinsplit[i];
Object pour;
pour.push_back(Pair("anchor", pourtx.anchor.GetHex()));
@ -128,10 +128,10 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
uint256 pubKeyHash;
pour.push_back(Pair("valid", pourtx.Verify(*pzcashParams, pubKeyHash)));
vpour.push_back(pour);
vjoinsplit.push_back(pour);
}
entry.push_back(Pair("vpour", vpour));
entry.push_back(Pair("vjoinsplit", vjoinsplit));
if (!hashBlock.IsNull()) {
entry.push_back(Pair("blockhash", hashBlock.GetHex()));

6
src/script/interpreter.cpp

@ -1072,7 +1072,7 @@ public:
// Serialize nLockTime
::Serialize(s, txTo.nLockTime, nType, nVersion);
// Serialize vpour
// Serialize vjoinsplit
if (txTo.nVersion >= 2) {
//
// SIGHASH_* functions will hash portions of
@ -1080,8 +1080,8 @@ public:
// keeps the JoinSplit cryptographically bound
// to the transaction.
//
::Serialize(s, txTo.vpour, nType, nVersion);
if (txTo.vpour.size() > 0) {
::Serialize(s, txTo.vjoinsplit, nType, nVersion);
if (txTo.vjoinsplit.size() > 0) {
::Serialize(s, txTo.joinSplitPubKey, nType, nVersion);
CTransaction::joinsplit_sig_t nullSig = {};

24
src/test/coins_tests.cpp

@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(chained_pours)
{
CMutableTransaction mtx;
mtx.vpour.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx2);
BOOST_CHECK(!cache.HavePourRequirements(mtx));
}
@ -260,35 +260,35 @@ BOOST_AUTO_TEST_CASE(chained_pours)
// ptx2 is trying to anchor to ptx1 but ptx1
// appears afterwards -- not a permitted ordering
CMutableTransaction mtx;
mtx.vpour.push_back(ptx2);
mtx.vpour.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx1);
BOOST_CHECK(!cache.HavePourRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vpour.push_back(ptx1);
mtx.vpour.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx2);
BOOST_CHECK(cache.HavePourRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vpour.push_back(ptx1);
mtx.vpour.push_back(ptx2);
mtx.vpour.push_back(ptx3);
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx3);
BOOST_CHECK(cache.HavePourRequirements(mtx));
}
{
CMutableTransaction mtx;
mtx.vpour.push_back(ptx1);
mtx.vpour.push_back(ptx1b);
mtx.vpour.push_back(ptx2);
mtx.vpour.push_back(ptx3);
mtx.vjoinsplit.push_back(ptx1);
mtx.vjoinsplit.push_back(ptx1b);
mtx.vjoinsplit.push_back(ptx2);
mtx.vjoinsplit.push_back(ptx3);
BOOST_CHECK(cache.HavePourRequirements(mtx));
}

2
src/test/sighash_tests.cpp

@ -140,7 +140,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
pourtx.macs[0] = GetRandHash();
pourtx.macs[1] = GetRandHash();
tx.vpour.push_back(pourtx);
tx.vjoinsplit.push_back(pourtx);
}
unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES];

24
src/test/transaction_tests.cpp

@ -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(JSDescription());
JSDescription *pourtx = &newTx.vpour[0];
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[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(JSDescription());
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vpour[0];
JSDescription *pourtx = &newTx.vjoinsplit[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(JSDescription());
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx2 = &newTx.vpour[1];
JSDescription *pourtx2 = &newTx.vjoinsplit[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(JSDescription());
JSDescription *pourtx = &newTx.vpour[0];
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[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(JSDescription());
JSDescription *pourtx2 = &newTx.vpour[1];
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx2 = &newTx.vjoinsplit[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(JSDescription());
JSDescription *pourtx = &newTx.vpour[0];
newTx.vjoinsplit.push_back(JSDescription());
JSDescription *pourtx = &newTx.vjoinsplit[0];
pourtx->serials[0] = GetRandHash();
pourtx->serials[1] = GetRandHash();

10
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 JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) {
mapSerials[serial] = &tx;
}
@ -148,7 +148,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
}
BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout);
BOOST_FOREACH(const JSDescription& pour, tx.vpour) {
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256& serial, pour.serials) {
mapSerials.erase(serial);
}
@ -200,7 +200,7 @@ void CTxMemPool::removeWithAnchor(const uint256 &invalidRoot)
for (std::map<uint256, CTxMemPoolEntry>::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
const CTransaction& tx = it->second.GetTx();
BOOST_FOREACH(const JSDescription& pour, tx.vpour) {
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) {
if (pour.anchor == invalidRoot) {
transactionsToRemove.push_back(tx);
break;
@ -230,7 +230,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list<CTransaction>
}
}
BOOST_FOREACH(const JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) {
std::map<uint256, const CTransaction*>::iterator it = mapSerials.find(serial);
if (it != mapSerials.end()) {
@ -317,7 +317,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
boost::unordered_map<uint256, ZCIncrementalMerkleTree, CCoinsKeyHasher> intermediates;
BOOST_FOREACH(const JSDescription &pour, tx.vpour) {
BOOST_FOREACH(const JSDescription &pour, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &serial, pour.serials) {
assert(!pcoins->GetSerial(serial));
}

2
src/wallet/rpcwallet.cpp

@ -2654,7 +2654,7 @@ Value zc_raw_pour(const json_spirit::Array& params, bool fHelp)
assert(pourtx.Verify(*pzcashParams, joinSplitPubKey));
mtx.vpour.push_back(pourtx);
mtx.vjoinsplit.push_back(pourtx);
// TODO: #966.
static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));

2
src/wallet/wallet.cpp

@ -1065,7 +1065,7 @@ void CWallet::WitnessBucketCommitment(std::vector<uint256> commitments,
BOOST_FOREACH(const CTransaction& tx, block.vtx)
{
BOOST_FOREACH(const JSDescription& pour, tx.vpour)
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit)
{
BOOST_FOREACH(const uint256 &bucket_commitment, pour.commitments)
{

Loading…
Cancel
Save