Browse Source

Clean up sprout turdz

pull/305/head
Duke Leto 3 years ago
parent
commit
5686f0c691
  1. 6
      qa/rpc-tests/zkey_import_export.py
  2. 8
      src/coins.cpp
  3. 16
      src/main.cpp
  4. 6
      src/script/interpreter.cpp
  5. 17
      src/wallet/rpcwallet.cpp

6
qa/rpc-tests/zkey_import_export.py

@ -58,11 +58,7 @@ class ZkeyImportExportTest (BitcoinTestFramework):
try:
assert_equal(amts, [tx["amount"] for tx in txs])
for tx in txs:
# make sure JoinSplit keys exist and have valid values
assert_equal("jsindex" in tx, True)
assert_equal("jsoutindex" in tx, True)
assert_greater_than(tx["jsindex"], -1)
assert_greater_than(tx["jsoutindex"], -1)
# TODO: make sure spend keys exist and have valid values
except AssertionError:
logging.error(
'Expected amounts: %r; txs: %r',

8
src/coins.cpp

@ -191,7 +191,7 @@ void CCoinsViewCache::AbstractPushAnchor(
// We don't want to overwrite an anchor we already have.
// This occurs when a block doesn't modify mapAnchors at all,
// because there are no joinsplits. We could get around this a
// because there are no ShieldedSpends. We could get around this a
// different way (make all blocks modify mapAnchors somehow)
// but this is simpler to reason about.
if (currentRoot != newrt) {
@ -212,6 +212,7 @@ void CCoinsViewCache::AbstractPushAnchor(
}
//TODO: delete
/*
template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree)
{
AbstractPushAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(
@ -221,6 +222,7 @@ template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree)
hashSproutAnchor
);
}
*/
template<> void CCoinsViewCache::PushAnchor(const SaplingMerkleTree &tree)
{
@ -614,9 +616,9 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
// Shielded transfers do not reveal any information about the value or age of a note, so we
// cannot apply the priority algorithm used for transparent utxos. Instead, we just
// use the maximum priority for all (partially or fully) shielded transactions.
// (Note that coinbase transactions cannot contain JoinSplits, or Sapling shielded Spends or Outputs.)
// (Note that coinbase transactions cannot contain Sapling shielded Spends or Outputs.)
if (tx.vjoinsplit.size() > 0 || tx.vShieldedSpend.size() > 0 || tx.vShieldedOutput.size() > 0 || tx.IsCoinImport() || tx.IsPegsImport()) {
if (tx.vShieldedSpend.size() > 0 || tx.vShieldedOutput.size() > 0 || tx.IsCoinImport() || tx.IsPegsImport()) {
return MAX_PRIORITY;
}

16
src/main.cpp

@ -1405,8 +1405,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
if (!tx.fOverwintered && tx.nVersion < SPROUT_MIN_TX_VERSION) {
return state.DoS(100, error("CheckTransaction(): version too low"),
REJECT_INVALID, "bad-txns-version-too-low");
}
else if (tx.fOverwintered) {
} else if (tx.fOverwintered) {
if (tx.nVersion < OVERWINTER_MIN_TX_VERSION) {
return state.DoS(100, error("CheckTransaction(): overwinter version too low"),
REJECT_INVALID, "bad-tx-overwinter-version-too-low");
@ -1422,16 +1421,13 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
}
}
//TODO: desprout
// Transactions containing empty `vin` must have either non-empty
// `vjoinsplit` or non-empty `vShieldedSpend`.
if (tx.vin.empty() && tx.vjoinsplit.empty() && tx.vShieldedSpend.empty())
// Transactions containing empty `vin` must have non-empty `vShieldedSpend`.
if (tx.vin.empty() && tx.vShieldedSpend.empty())
return state.DoS(10, error("CheckTransaction(): vin empty"),
REJECT_INVALID, "bad-txns-vin-empty");
// Transactions containing empty `vout` must have either non-empty
// `vjoinsplit` or non-empty `vShieldedOutput`.
if (tx.vout.empty() && tx.vjoinsplit.empty() && tx.vShieldedOutput.empty())
// Transactions containing empty `vout` must have non-empty `vShieldedOutput`.
if (tx.vout.empty() && tx.vShieldedOutput.empty())
return state.DoS(10, error("CheckTransaction(): vout empty"),
REJECT_INVALID, "bad-txns-vout-empty");
@ -4434,10 +4430,12 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
// pool. So we invert the sign here.
saplingValue += -tx.valueBalance;
/*
for (auto js : tx.vjoinsplit) {
sproutValue += js.vpub_old;
sproutValue -= js.vpub_new;
}
*/
// Ignore following stats unless -zindex enabled
if (!fZindex)

6
src/script/interpreter.cpp

@ -1,8 +1,8 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2016-2021 The Hush developers
// Distributed under the GPLv3 software license, see the accompanying
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
* *
@ -19,9 +19,7 @@
******************************************************************************/
#include <cryptoconditions.h>
#include "interpreter.h"
#include "consensus/upgrades.h"
#include "primitives/transaction.h"
#include "cc/eval.h"
@ -32,8 +30,6 @@
#include "script/script.h"
#include "uint256.h"
using namespace std;
typedef vector<unsigned char> valtype;

17
src/wallet/rpcwallet.cpp

@ -2234,7 +2234,7 @@ UniValue gettransaction(const UniValue& params, bool fHelp, const CPubKey& mypk)
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"gettransaction \"txid\" ( includeWatchonly )\n"
"\nGet detailed information about in-wallet transaction <txid>\n"
"\nGet detailed information about in-wallet transaction <txid>. Also see z_viewtransaction for ztx details\n"
"\nArguments:\n"
"1. \"txid\" (string, required) The transaction id\n"
"2. \"includeWatchonly\" (bool, optional, default=false) Whether to include watchonly addresses in balance calculation and details[]\n"
@ -2258,17 +2258,6 @@ UniValue gettransaction(const UniValue& params, bool fHelp, const CPubKey& mypk)
" }\n"
" ,...\n"
" ],\n"
" \"vjoinsplit\" : [\n"
" {\n"
" \"anchor\" : \"treestateref\", (string) Merkle root of note commitment tree\n"
" \"nullifiers\" : [ string, ... ] (string) Nullifiers of input notes\n"
" \"commitments\" : [ string, ... ] (string) Note commitments for note outputs\n"
" \"macs\" : [ string, ... ] (string) Message authentication tags\n"
" \"vpub_old\" : x.xxx (numeric) The amount removed from the transparent value pool\n"
" \"vpub_new\" : x.xxx, (numeric) The amount added to the transparent value pool\n"
" }\n"
" ,...\n"
" ],\n"
" \"hex\" : \"data\" (string) Raw data for transaction\n"
"}\n"
@ -4842,7 +4831,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
if (toSapling) {
mtx.vShieldedOutput.push_back(OutputDescription());
} else {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sprout zaddr not valid");
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, not a Sapling zaddr!");
}
}
CTransaction tx(mtx);
@ -5123,7 +5112,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
contextualTx.nLockTime = chainActive.LastTip()->GetHeight();
if (contextualTx.nVersion == 1) {
contextualTx.nVersion = 2; // Tx format should support vjoinsplits
contextualTx.nVersion = 2; // Tx format should support ztx's
}
// Create operation and add to global queue

Loading…
Cancel
Save