Auto merge of #1144 - bitcartel:zc.v0.11.2.z7_tx_malleability_gettxid, r=bitcartel
A fix for transaction malleability This PR fixes transaction malleability by not including the sigscript of transaction inputs and joinsplit sigs when hashing the txid. This PR supercedes PR #1101 which was a minimal solution based on a new serialization flag. This PR introduces GetTxid() to distinguish between getting a transaction id and the double sha256 hash. The key changes are: - Adding GetTxid() method to CTransaction which makes a copy of the transaction, clearing out the sigscript and joinsplitsig fields, before hashing. - Verifying that every call to GetHash() actually wants a txid, and replacing with GetTxid(). - Renaming GetHash() to GetSerializeHash() - Rationale: In future, upstream code we want to merge will use GetHash() but we don't know the intent. We should check to see if the intent is to receive a txid (most likely) in which case we replace with GetTxid(), or if upstream actually wants a double hash of the transaction we can use GetSerializeHash(). - Updated genesis data in chainparams.cpp Note that coinbase transactions are excluded as they need the sigscript hashed to help avoid duplicate txids per BIP34: - This modification is related to a question from @ebfull on PR #1101 - "Can we think of a way this change allows us to construct two transactions with the same txid which can simultaneously appear in the blockchain? My guess is it would be possible to construct a coinbase transaction of such a form... this surely breaks invariants." This PR Passes all tests in test_bitcoin (test data was updated in bloom_tests, miner_tests and script_tests).
This commit is contained in:
@@ -498,7 +498,7 @@ static void OutputTxJSON(const CTransaction& tx)
|
||||
|
||||
static void OutputTxHash(const CTransaction& tx)
|
||||
{
|
||||
string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
|
||||
string strHexHash = tx.GetTxid().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
|
||||
|
||||
fprintf(stdout, "%s\n", strHexHash.c_str());
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx)
|
||||
return true;
|
||||
if (isEmpty)
|
||||
return false;
|
||||
const uint256& hash = tx.GetHash();
|
||||
const uint256& hash = tx.GetTxid();
|
||||
if (contains(hash))
|
||||
fFound = true;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
//genesis.nBits = 0x1d00ffff;
|
||||
genesis.nBits = 0x207fffff;
|
||||
genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||
genesis.nSolution = {400496, 12965800, 7933378, 26516310, 3573504, 12897574, 9332739, 12534918};
|
||||
genesis.nSolution = {400496, 12965800, 7933378, 26516310, 3573504, 12897574, 9332739, 12534918 };
|
||||
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x5ff8e250c158c0694814582883343e8a0de5b7e7a5236324d4bf3293a56b6bc5"));
|
||||
@@ -158,10 +158,10 @@ public:
|
||||
//! Modify the testnet genesis block so the timestamp is valid for a later start.
|
||||
genesis.nTime = 1296688602;
|
||||
genesis.nBits = 0x207fffff;
|
||||
genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
genesis.nSolution = {830051, 14471730, 2076450, 21556280, 12194645, 22042975, 16221394, 24048626};
|
||||
genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||
genesis.nSolution = {72259, 18942116, 2293670, 7851750, 998282, 2855279, 12981515, 15324503};
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x69675325ac7fb1f5a6bebb7fc8581f9160cbf970817f50b5199df7ff7b2833bd"));
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x20a21e2f7d7079d517cb19f8db30bafd396652d34c2705093531d0172e40ebc6"));
|
||||
|
||||
vFixedSeeds.clear();
|
||||
vSeeds.clear();
|
||||
@@ -226,11 +226,11 @@ public:
|
||||
nEquihashK = 5;
|
||||
genesis.nTime = 1296688602;
|
||||
genesis.nBits = 0x207fffff;
|
||||
genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000003");
|
||||
genesis.nSolution = {21, 374, 135, 192, 103, 221, 198, 303, 87, 330, 306, 464, 98, 239, 146, 471, 35, 137, 53, 387, 97, 454, 412, 434, 75, 352, 180, 367, 121, 480, 158, 482};
|
||||
genesis.nNonce = uint256S("0x0000000000000000000000000000000000000000000000000000000000000005");
|
||||
genesis.nSolution = {8, 205, 95, 334, 13, 385, 266, 399, 58, 389, 129, 383, 110, 284, 460, 499, 45, 496, 269, 348, 65, 242, 212, 272, 141, 477, 394, 469, 175, 185, 270, 365};
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
nDefaultPort = 18444;
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x37e57b7047e1a59918a8f98b9bbebc0b6e16e246211ad1f5c664d7e8f7d8d709"));
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x0d5badaa07ac1914c9b2429825cafe9273763f2c5d44eadabf1e333e50a9e281"));
|
||||
nPruneAfterHeight = 1000;
|
||||
|
||||
vFixedSeeds.clear(); //! Regtest mode doesn't have any fixed seeds.
|
||||
|
||||
@@ -88,7 +88,7 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey,
|
||||
|
||||
void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
|
||||
{
|
||||
entry.pushKV("txid", tx.GetHash().GetHex());
|
||||
entry.pushKV("txid", tx.GetTxid().GetHex());
|
||||
entry.pushKV("version", tx.nVersion);
|
||||
entry.pushKV("locktime", (int64_t)tx.nLockTime);
|
||||
|
||||
|
||||
@@ -1384,7 +1384,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
BOOST_FOREACH(const CWalletTx& wtxOld, vWtx)
|
||||
{
|
||||
uint256 hash = wtxOld.GetHash();
|
||||
uint256 hash = wtxOld.GetTxid();
|
||||
std::map<uint256, CWalletTx>::iterator mi = pwalletMain->mapWallet.find(hash);
|
||||
if (mi != pwalletMain->mapWallet.end())
|
||||
{
|
||||
|
||||
40
src/main.cpp
40
src/main.cpp
@@ -553,7 +553,7 @@ CBlockTreeDB *pblocktree = NULL;
|
||||
|
||||
bool AddOrphanTx(const CTransaction& tx, NodeId peer)
|
||||
{
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
if (mapOrphanTransactions.count(hash))
|
||||
return false;
|
||||
|
||||
@@ -607,7 +607,7 @@ void EraseOrphansFor(NodeId peer)
|
||||
map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
|
||||
if (maybeErase->second.fromPeer == peer)
|
||||
{
|
||||
EraseOrphanTx(maybeErase->second.tx.GetHash());
|
||||
EraseOrphanTx(maybeErase->second.tx.GetTxid());
|
||||
++nErased;
|
||||
}
|
||||
}
|
||||
@@ -1033,7 +1033,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
|
||||
{
|
||||
{
|
||||
LOCK(mempool.cs);
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
double dPriorityDelta = 0;
|
||||
CAmount nFeeDelta = 0;
|
||||
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
||||
@@ -1088,7 +1088,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
return state.DoS(0, false, REJECT_NONSTANDARD, "non-final");
|
||||
|
||||
// is it already in the memory pool?
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
if (pool.exists(hash))
|
||||
return false;
|
||||
|
||||
@@ -1280,7 +1280,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
||||
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
||||
}
|
||||
hashBlock = header.GetHash();
|
||||
if (txOut.GetHash() != hash)
|
||||
if (txOut.GetTxid() != hash)
|
||||
return error("%s: txid mismatch", __func__);
|
||||
return true;
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
||||
CBlock block;
|
||||
if (ReadBlockFromDisk(block, pindexSlow)) {
|
||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||
if (tx.GetHash() == hash) {
|
||||
if (tx.GetTxid() == hash) {
|
||||
txOut = tx;
|
||||
hashBlock = pindexSlow->GetBlockHash();
|
||||
return true;
|
||||
@@ -1593,7 +1593,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
||||
}
|
||||
|
||||
// add outputs
|
||||
inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight);
|
||||
inputs.ModifyCoins(tx.GetTxid())->FromTx(tx, nHeight);
|
||||
}
|
||||
|
||||
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
|
||||
@@ -1605,7 +1605,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
||||
bool CScriptCheck::operator()() {
|
||||
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
|
||||
if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error)) {
|
||||
return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetHash().ToString(), nIn, ScriptErrorString(error));
|
||||
return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetTxid().ToString(), nIn, ScriptErrorString(error));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1620,11 +1620,11 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c
|
||||
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
|
||||
// for an attacker to attempt to split the network.
|
||||
if (!inputs.HaveInputs(tx))
|
||||
return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString()));
|
||||
return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetTxid().ToString()));
|
||||
|
||||
// are the JoinSplit's requirements met?
|
||||
if (!inputs.HaveJoinSplitRequirements(tx))
|
||||
return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString()));
|
||||
return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetTxid().ToString()));
|
||||
|
||||
CAmount nValueIn = 0;
|
||||
CAmount nFees = 0;
|
||||
@@ -1661,13 +1661,13 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c
|
||||
|
||||
if (nValueIn < tx.GetValueOut())
|
||||
return state.DoS(100, error("CheckInputs(): %s value in (%s) < value out (%s)",
|
||||
tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())),
|
||||
tx.GetTxid().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())),
|
||||
REJECT_INVALID, "bad-txns-in-belowout");
|
||||
|
||||
// Tally transaction fees
|
||||
CAmount nTxFee = nValueIn - tx.GetValueOut();
|
||||
if (nTxFee < 0)
|
||||
return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetHash().ToString()),
|
||||
return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetTxid().ToString()),
|
||||
REJECT_INVALID, "bad-txns-fee-negative");
|
||||
nFees += nTxFee;
|
||||
if (!MoneyRange(nFees))
|
||||
@@ -1886,7 +1886,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
||||
// undo transactions in reverse order
|
||||
for (int i = block.vtx.size() - 1; i >= 0; i--) {
|
||||
const CTransaction &tx = block.vtx[i];
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
|
||||
// Check that all outputs are available and match the outputs in the block itself
|
||||
// exactly.
|
||||
@@ -2067,7 +2067,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
|
||||
// unless those are already completely spent.
|
||||
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
|
||||
const CCoins* coins = view.AccessCoins(tx.GetHash());
|
||||
const CCoins* coins = view.AccessCoins(tx.GetTxid());
|
||||
if (coins && !coins->IsPruned())
|
||||
return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"),
|
||||
REJECT_INVALID, "bad-txns-BIP30");
|
||||
@@ -2165,7 +2165,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
}
|
||||
}
|
||||
|
||||
vPos.push_back(std::make_pair(tx.GetHash(), pos));
|
||||
vPos.push_back(std::make_pair(tx.GetTxid(), pos));
|
||||
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
|
||||
}
|
||||
|
||||
@@ -2222,7 +2222,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// Watch for changes to the previous coinbase transaction.
|
||||
static uint256 hashPrevBestCoinBase;
|
||||
GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase);
|
||||
hashPrevBestCoinBase = block.vtx[0].GetHash();
|
||||
hashPrevBestCoinBase = block.vtx[0].GetTxid();
|
||||
|
||||
int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3;
|
||||
LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
|
||||
@@ -4654,7 +4654,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
CTransaction tx;
|
||||
vRecv >> tx;
|
||||
|
||||
CInv inv(MSG_TX, tx.GetHash());
|
||||
CInv inv(MSG_TX, tx.GetTxid());
|
||||
pfrom->AddInventoryKnown(inv);
|
||||
|
||||
LOCK(cs_main);
|
||||
@@ -4676,7 +4676,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s: accepted %s (poolsz %u)\n",
|
||||
pfrom->id, pfrom->cleanSubVer,
|
||||
tx.GetHash().ToString(),
|
||||
tx.GetTxid().ToString(),
|
||||
mempool.mapTx.size());
|
||||
|
||||
// Recursively process any orphan transactions that depended on this one
|
||||
@@ -4745,7 +4745,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||
} else {
|
||||
assert(recentRejects);
|
||||
recentRejects->insert(tx.GetHash());
|
||||
recentRejects->insert(tx.GetTxid());
|
||||
|
||||
if (pfrom->fWhitelisted) {
|
||||
// Always relay transactions received from whitelisted peers, even
|
||||
@@ -4761,7 +4761,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
int nDoS = 0;
|
||||
if (state.IsInvalid(nDoS))
|
||||
{
|
||||
LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(),
|
||||
LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetTxid().ToString(),
|
||||
pfrom->id, pfrom->cleanSubVer,
|
||||
state.GetRejectReason());
|
||||
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),
|
||||
|
||||
@@ -23,7 +23,7 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, CBloomFilter& filter)
|
||||
|
||||
for (unsigned int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
const uint256& hash = block.vtx[i].GetHash();
|
||||
const uint256& hash = block.vtx[i].GetTxid();
|
||||
if (filter.IsRelevantAndUpdate(block.vtx[i]))
|
||||
{
|
||||
vMatch.push_back(true);
|
||||
@@ -49,7 +49,7 @@ CMerkleBlock::CMerkleBlock(const CBlock& block, const std::set<uint256>& txids)
|
||||
|
||||
for (unsigned int i = 0; i < block.vtx.size(); i++)
|
||||
{
|
||||
const uint256& hash = block.vtx[i].GetHash();
|
||||
const uint256& hash = block.vtx[i].GetTxid();
|
||||
if (txids.count(hash))
|
||||
vMatch.push_back(true);
|
||||
else
|
||||
|
||||
@@ -211,7 +211,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
dPriority = tx.ComputePriority(dPriority, nTxSize);
|
||||
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
mempool.ApplyDeltas(hash, dPriority, nTotalIn);
|
||||
|
||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
||||
@@ -255,7 +255,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
continue;
|
||||
|
||||
// Skip free transactions if we're past the minimum block size:
|
||||
const uint256& hash = tx.GetHash();
|
||||
const uint256& hash = tx.GetTxid();
|
||||
double dPriorityDelta = 0;
|
||||
CAmount nFeeDelta = 0;
|
||||
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
||||
@@ -302,7 +302,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
if (fPrintPriority)
|
||||
{
|
||||
LogPrintf("priority %.1f fee %s txid %s\n",
|
||||
dPriority, feeRate.ToString(), tx.GetHash().ToString());
|
||||
dPriority, feeRate.ToString(), tx.GetTxid().ToString());
|
||||
}
|
||||
|
||||
// Add transactions that depend on this one to the priority queue
|
||||
|
||||
@@ -1751,7 +1751,7 @@ void RelayTransaction(const CTransaction& tx)
|
||||
|
||||
void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
|
||||
{
|
||||
CInv inv(MSG_TX, tx.GetHash());
|
||||
CInv inv(MSG_TX, tx.GetTxid());
|
||||
{
|
||||
LOCK(cs_mapRelay);
|
||||
// Expire old relay messages
|
||||
|
||||
@@ -344,7 +344,7 @@ bool CBlockPolicyEstimator::isPriDataPoint(const CFeeRate &fee, double pri)
|
||||
void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool fCurrentEstimate)
|
||||
{
|
||||
unsigned int txHeight = entry.GetHeight();
|
||||
uint256 hash = entry.GetTx().GetHash();
|
||||
uint256 hash = entry.GetTx().GetTxid();
|
||||
if (mapMemPoolTxs[hash].stats != NULL) {
|
||||
LogPrint("estimatefee", "Blockpolicy error mempool tx %s already being tracked\n",
|
||||
hash.ToString().c_str());
|
||||
|
||||
@@ -55,7 +55,7 @@ uint256 CBlock::BuildMerkleTree(bool* fMutated) const
|
||||
vMerkleTree.clear();
|
||||
vMerkleTree.reserve(vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes.
|
||||
for (std::vector<CTransaction>::const_iterator it(vtx.begin()); it != vtx.end(); ++it)
|
||||
vMerkleTree.push_back(it->GetHash());
|
||||
vMerkleTree.push_back(it->GetTxid());
|
||||
int j = 0;
|
||||
bool mutated = false;
|
||||
for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
|
||||
|
||||
@@ -116,11 +116,6 @@ CMutableTransaction::CMutableTransaction(const CTransaction& tx) : nVersion(tx.n
|
||||
|
||||
}
|
||||
|
||||
uint256 CMutableTransaction::GetHash() const
|
||||
{
|
||||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
void CTransaction::UpdateHash() const
|
||||
{
|
||||
*const_cast<uint256*>(&hash) = SerializeHash(*this);
|
||||
@@ -132,6 +127,7 @@ CTransaction::CTransaction(const CMutableTransaction &tx) : nVersion(tx.nVersion
|
||||
joinSplitPubKey(tx.joinSplitPubKey), joinSplitSig(tx.joinSplitSig)
|
||||
{
|
||||
UpdateHash();
|
||||
UpdateTxid();
|
||||
}
|
||||
|
||||
CTransaction& CTransaction::operator=(const CTransaction &tx) {
|
||||
@@ -143,6 +139,7 @@ CTransaction& CTransaction::operator=(const CTransaction &tx) {
|
||||
*const_cast<uint256*>(&joinSplitPubKey) = tx.joinSplitPubKey;
|
||||
*const_cast<joinsplit_sig_t*>(&joinSplitSig) = tx.joinSplitSig;
|
||||
*const_cast<uint256*>(&hash) = tx.hash;
|
||||
*const_cast<uint256*>(&txid) = tx.txid;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -211,8 +208,9 @@ unsigned int CTransaction::CalculateModifiedSize(unsigned int nTxSize) const
|
||||
std::string CTransaction::ToString() const
|
||||
{
|
||||
std::string str;
|
||||
str += strprintf("CTransaction(hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
|
||||
GetHash().ToString().substr(0,10),
|
||||
str += strprintf("CTransaction(txid=%s, hash=%s, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%u)\n",
|
||||
txid.ToString().substr(0,10),
|
||||
hash.ToString().substr(0,10),
|
||||
nVersion,
|
||||
vin.size(),
|
||||
vout.size(),
|
||||
@@ -223,3 +221,32 @@ std::string CTransaction::ToString() const
|
||||
str += " " + vout[i].ToString() + "\n";
|
||||
return str;
|
||||
}
|
||||
|
||||
// Update the txid which is non-malleable.
|
||||
// Signature data is cleared before the transaction is serialized and hashed.
|
||||
void CTransaction::UpdateTxid() const
|
||||
{
|
||||
// Create a deep copy of this transaction
|
||||
CMutableTransaction tx(*this);
|
||||
|
||||
// We keep the sigscript for coinbase txs to avoid duplicate txids (BIP34 and BIP30)
|
||||
if (!IsCoinBase()) {
|
||||
// Clear sigscript from all transaction inputs.
|
||||
for (CTxIn & txIn : tx.vin) {
|
||||
txIn.scriptSig.clear();
|
||||
}
|
||||
|
||||
// Clear joinSplitSig by filling the buffer with zero
|
||||
tx.joinSplitSig.assign(0);
|
||||
}
|
||||
|
||||
*const_cast<uint256*>(&txid) = SerializeHash(tx);
|
||||
}
|
||||
|
||||
// Return a txid which is non-malleable.
|
||||
uint256 CMutableTransaction::GetTxid() const
|
||||
{
|
||||
CTransaction tx(*this);
|
||||
return tx.GetTxid();
|
||||
}
|
||||
|
||||
|
||||
@@ -288,6 +288,8 @@ private:
|
||||
/** Memory only. */
|
||||
const uint256 hash;
|
||||
void UpdateHash() const;
|
||||
const uint256 txid;
|
||||
void UpdateTxid() const;
|
||||
|
||||
public:
|
||||
typedef boost::array<unsigned char, 64> joinsplit_sig_t;
|
||||
@@ -331,18 +333,16 @@ public:
|
||||
READWRITE(*const_cast<joinsplit_sig_t*>(&joinSplitSig));
|
||||
}
|
||||
}
|
||||
if (ser_action.ForRead())
|
||||
if (ser_action.ForRead()) {
|
||||
UpdateHash();
|
||||
UpdateTxid();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull() const {
|
||||
return vin.empty() && vout.empty();
|
||||
}
|
||||
|
||||
const uint256& GetHash() const {
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Return sum of txouts.
|
||||
CAmount GetValueOut() const;
|
||||
// GetValueIn() is a method on CCoinsViewCache, because
|
||||
@@ -373,6 +373,11 @@ public:
|
||||
}
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
// Return the txid, which is the double SHA256 hash over portions of the transaction.
|
||||
const uint256& GetTxid() const {
|
||||
return txid;
|
||||
}
|
||||
};
|
||||
|
||||
/** A mutable version of CTransaction. */
|
||||
@@ -407,10 +412,10 @@ struct CMutableTransaction
|
||||
}
|
||||
}
|
||||
|
||||
/** Compute the hash of this CMutableTransaction. This is computed on the
|
||||
* fly, as opposed to GetHash() in CTransaction, which uses a cached result.
|
||||
/** Compute the non-malleable txid of this CMutableTransaction. This is computed on the
|
||||
* fly, as opposed to GetTxid() in CTransaction, which uses a cached result.
|
||||
*/
|
||||
uint256 GetHash() const;
|
||||
uint256 GetTxid() const;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_PRIMITIVES_TRANSACTION_H
|
||||
|
||||
@@ -496,7 +496,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
{
|
||||
// unselect already spent, very unlikely scenario, this could happen
|
||||
// when selected are spent elsewhere, like rpc or another computer
|
||||
uint256 txhash = out.tx->GetHash();
|
||||
uint256 txhash = out.tx->GetTxid();
|
||||
COutPoint outpt(txhash, out.i);
|
||||
if (model->isSpent(outpt))
|
||||
{
|
||||
@@ -782,7 +782,7 @@ void CoinControlDialog::updateView()
|
||||
nInputSum += nInputSize;
|
||||
|
||||
// transaction hash
|
||||
uint256 txhash = out.tx->GetHash();
|
||||
uint256 txhash = out.tx->GetTxid();
|
||||
itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex()));
|
||||
|
||||
// vout index
|
||||
|
||||
@@ -240,7 +240,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
|
||||
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
|
||||
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
|
||||
|
||||
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetHash(), rec->idx) + "<br>";
|
||||
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetTxid(), rec->idx) + "<br>";
|
||||
|
||||
// Message from normal bitcoin:URI (bitcoin:123...?message=example)
|
||||
Q_FOREACH (const PAIRTYPE(string, string)& r, wtx.vOrderForm)
|
||||
|
||||
@@ -39,7 +39,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
|
||||
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
|
||||
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
|
||||
CAmount nNet = nCredit - nDebit;
|
||||
uint256 hash = wtx.GetHash();
|
||||
uint256 hash = wtx.GetTxid();
|
||||
std::map<std::string, std::string> mapValue = wtx.mapValue;
|
||||
|
||||
if (nNet > 0 || wtx.IsCoinBase())
|
||||
|
||||
@@ -80,7 +80,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
|
||||
txs.push_back(objTx);
|
||||
}
|
||||
else
|
||||
txs.push_back(tx.GetHash().GetHex());
|
||||
txs.push_back(tx.GetTxid().GetHex());
|
||||
}
|
||||
result.push_back(Pair("tx", txs));
|
||||
result.push_back(Pair("time", block.GetBlockTime()));
|
||||
|
||||
@@ -561,7 +561,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||
int i = 0;
|
||||
BOOST_FOREACH (CTransaction& tx, pblock->vtx)
|
||||
{
|
||||
uint256 txHash = tx.GetHash();
|
||||
uint256 txHash = tx.GetTxid();
|
||||
setTxIndex[txHash] = i++;
|
||||
|
||||
if (tx.IsCoinBase())
|
||||
|
||||
@@ -57,7 +57,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeH
|
||||
|
||||
void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry)
|
||||
{
|
||||
entry.push_back(Pair("txid", tx.GetHash().GetHex()));
|
||||
entry.push_back(Pair("txid", tx.GetTxid().GetHex()));
|
||||
entry.push_back(Pair("version", tx.nVersion));
|
||||
entry.push_back(Pair("locktime", (int64_t)tx.nLockTime));
|
||||
Array vin;
|
||||
@@ -307,7 +307,7 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
||||
|
||||
unsigned int ntxFound = 0;
|
||||
BOOST_FOREACH(const CTransaction&tx, block.vtx)
|
||||
if (setTxids.count(tx.GetHash()))
|
||||
if (setTxids.count(tx.GetTxid()))
|
||||
ntxFound++;
|
||||
if (ntxFound != setTxids.size())
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "(Not all) transactions not found in specified block");
|
||||
@@ -818,7 +818,7 @@ Value sendrawtransaction(const Array& params, bool fHelp)
|
||||
CTransaction tx;
|
||||
if (!DecodeHexTx(tx, params[0].get_str()))
|
||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||
uint256 hashTx = tx.GetHash();
|
||||
uint256 hashTx = tx.GetTxid();
|
||||
|
||||
bool fOverrideFees = false;
|
||||
if (params.size() > 1)
|
||||
|
||||
@@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
|
||||
CMutableTransaction tx;
|
||||
tx.vin.resize(1);
|
||||
tx.vin[0].prevout.n = 0;
|
||||
tx.vin[0].prevout.hash = txPrev.GetHash();
|
||||
tx.vin[0].prevout.hash = txPrev.GetTxid();
|
||||
tx.vout.resize(1);
|
||||
tx.vout[0].nValue = 1*CENT;
|
||||
tx.vout[0].scriptPubKey = GetScriptForDestination(key.GetPubKey().GetID());
|
||||
@@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
|
||||
for (unsigned int j = 0; j < tx.vin.size(); j++)
|
||||
{
|
||||
tx.vin[j].prevout.n = j;
|
||||
tx.vin[j].prevout.hash = txPrev.GetHash();
|
||||
tx.vin[j].prevout.hash = txPrev.GetTxid();
|
||||
}
|
||||
SignSignature(keystore, txPrev, tx, 0);
|
||||
// Re-use same signature for other inputs
|
||||
|
||||
@@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
||||
|
||||
wtx.mapValue["comment"] = "z";
|
||||
pwalletMain->AddToWallet(wtx, false, &walletdb);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]);
|
||||
vpwtx[0]->nTimeReceived = (unsigned int)1333333335;
|
||||
vpwtx[0]->nOrderPos = -1;
|
||||
|
||||
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
||||
*static_cast<CTransaction*>(&wtx) = CTransaction(tx);
|
||||
}
|
||||
pwalletMain->AddToWallet(wtx, false, &walletdb);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]);
|
||||
vpwtx[1]->nTimeReceived = (unsigned int)1333333336;
|
||||
|
||||
wtx.mapValue["comment"] = "x";
|
||||
@@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
||||
*static_cast<CTransaction*>(&wtx) = CTransaction(tx);
|
||||
}
|
||||
pwalletMain->AddToWallet(wtx, false, &walletdb);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetHash()]);
|
||||
vpwtx.push_back(&pwalletMain->mapWallet[wtx.GetTxid()]);
|
||||
vpwtx[2]->nTimeReceived = (unsigned int)1333333329;
|
||||
vpwtx[2]->nOrderPos = -1;
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -504,7 +504,7 @@ BOOST_AUTO_TEST_CASE(coins_coinbase_spends)
|
||||
// Create coinbase spend
|
||||
CMutableTransaction mtx2;
|
||||
mtx2.vin.resize(1);
|
||||
mtx2.vin[0].prevout = COutPoint(tx.GetHash(), 0);
|
||||
mtx2.vin[0].prevout = COutPoint(tx.GetTxid(), 0);
|
||||
mtx2.vin[0].scriptSig = CScript() << OP_1;
|
||||
mtx2.vin[0].nSequence = 0;
|
||||
|
||||
|
||||
@@ -791,12 +791,6 @@
|
||||
"SIGPUSHONLY",
|
||||
"P2SH(P2PK) with non-push scriptSig"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f01 0x46 0x304402205451ce65ad844dbb978b8bdedf5082e33b43cae8279c30f2c74d9e9ee49a94f802203fe95a7ccf74da7a232ee523ef4a53cb4d14bdd16289680cdb97a63819b8f42f",
|
||||
"2 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 0x21 0x02a673638cb9587cb68ea08dbef685c6f2d2a751a8b3c6f2a7e9a4999e6e4bfaf5 3 CHECKMULTISIG",
|
||||
"P2SH,STRICTENC",
|
||||
"2-of-3 with one valid and one invalid signature due to parse error, nSigs > validSigs"
|
||||
],
|
||||
[
|
||||
"11 0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001",
|
||||
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
@@ -812,3 +806,4 @@
|
||||
|
||||
["The End"]
|
||||
]
|
||||
|
||||
|
||||
@@ -909,3 +909,4 @@
|
||||
|
||||
["The End"]
|
||||
]
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||
{
|
||||
txChild[i].vin.resize(1);
|
||||
txChild[i].vin[0].scriptSig = CScript() << OP_11;
|
||||
txChild[i].vin[0].prevout.hash = txParent.GetHash();
|
||||
txChild[i].vin[0].prevout.hash = txParent.GetTxid();
|
||||
txChild[i].vin[0].prevout.n = i;
|
||||
txChild[i].vout.resize(1);
|
||||
txChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
|
||||
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||
{
|
||||
txGrandChild[i].vin.resize(1);
|
||||
txGrandChild[i].vin[0].scriptSig = CScript() << OP_11;
|
||||
txGrandChild[i].vin[0].prevout.hash = txChild[i].GetHash();
|
||||
txGrandChild[i].vin[0].prevout.hash = txChild[i].GetTxid();
|
||||
txGrandChild[i].vin[0].prevout.n = 0;
|
||||
txGrandChild[i].vout.resize(1);
|
||||
txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
|
||||
@@ -60,17 +60,17 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||
BOOST_CHECK_EQUAL(removed.size(), 0);
|
||||
|
||||
// Just the parent:
|
||||
testPool.addUnchecked(txParent.GetHash(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txParent.GetTxid(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1));
|
||||
testPool.remove(txParent, removed, true);
|
||||
BOOST_CHECK_EQUAL(removed.size(), 1);
|
||||
removed.clear();
|
||||
|
||||
// Parent, children, grandchildren:
|
||||
testPool.addUnchecked(txParent.GetHash(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txParent.GetTxid(), CTxMemPoolEntry(txParent, 0, 0, 0.0, 1));
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
testPool.addUnchecked(txChild[i].GetHash(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txGrandChild[i].GetHash(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txChild[i].GetTxid(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txGrandChild[i].GetTxid(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1));
|
||||
}
|
||||
// Remove Child[0], GrandChild[0] should be removed:
|
||||
testPool.remove(txChild[0], removed, true);
|
||||
@@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
||||
// Add children and grandchildren, but NOT the parent (simulate the parent being in a block)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
testPool.addUnchecked(txChild[i].GetHash(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txGrandChild[i].GetHash(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txChild[i].GetTxid(), CTxMemPoolEntry(txChild[i], 0, 0, 0.0, 1));
|
||||
testPool.addUnchecked(txGrandChild[i].GetTxid(), CTxMemPoolEntry(txGrandChild[i], 0, 0, 0.0, 1));
|
||||
}
|
||||
// Now remove the parent, as might happen if a block-re-org occurs but the parent cannot be
|
||||
// put into the mempool (maybe because it is non-standard):
|
||||
|
||||
@@ -253,14 +253,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vin.resize(1);
|
||||
// NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG
|
||||
tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP << OP_CHECKMULTISIG << OP_1;
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vin[0].prevout.n = 0;
|
||||
tx.vout.resize(1);
|
||||
tx.vout[0].nValue = 50000LL;
|
||||
for (unsigned int i = 0; i < 1001; ++i)
|
||||
{
|
||||
tx.vout[0].nValue -= 10;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
@@ -275,12 +275,12 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
for (unsigned int i = 0; i < 18; ++i)
|
||||
tx.vin[0].scriptSig << vchData << OP_DROP;
|
||||
tx.vin[0].scriptSig << OP_1;
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vout[0].nValue = 50000LL;
|
||||
for (unsigned int i = 0; i < 128; ++i)
|
||||
{
|
||||
tx.vout[0].nValue -= 350;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
mempool.clear();
|
||||
|
||||
// orphan in mempool
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
@@ -297,17 +297,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
|
||||
// child with higher priority than parent
|
||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx.vin[0].prevout.hash = txFirst[1]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[1]->GetTxid();
|
||||
tx.vout[0].nValue = 39000LL;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
tx.vin.resize(2);
|
||||
tx.vin[1].scriptSig = CScript() << OP_1;
|
||||
tx.vin[1].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[1].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vin[1].prevout.n = 0;
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
@@ -318,39 +318,39 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vin[0].prevout.SetNull();
|
||||
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
|
||||
tx.vout[0].nValue = 0;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
// invalid (pre-p2sh) txn in mempool
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vin[0].prevout.n = 0;
|
||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
script = CScript() << OP_0;
|
||||
tx.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(script));
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
tx.vin[0].scriptSig = CScript() << (std::vector<unsigned char>)script;
|
||||
tx.vout[0].nValue -= 10000;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
// double spend txn pair in mempool
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
delete pblocktemplate;
|
||||
@@ -370,19 +370,19 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
SetMockTime(chainActive.Tip()->GetMedianTimePast()+1);
|
||||
|
||||
// height locked
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetHash();
|
||||
tx.vin[0].prevout.hash = txFirst[0]->GetTxid();
|
||||
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx.vin[0].nSequence = 0;
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
tx.nLockTime = chainActive.Tip()->nHeight+1;
|
||||
hash = tx.GetHash();
|
||||
hash = tx.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(!CheckFinalTx(tx, LOCKTIME_MEDIAN_TIME_PAST));
|
||||
|
||||
// time locked
|
||||
tx2.vin.resize(1);
|
||||
tx2.vin[0].prevout.hash = txFirst[1]->GetHash();
|
||||
tx2.vin[0].prevout.hash = txFirst[1]->GetTxid();
|
||||
tx2.vin[0].prevout.n = 0;
|
||||
tx2.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx2.vin[0].nSequence = 0;
|
||||
@@ -390,7 +390,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx2.vout[0].nValue = 79000LL;
|
||||
tx2.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
tx2.nLockTime = chainActive.Tip()->GetMedianTimePast()+1;
|
||||
hash = tx2.GetHash();
|
||||
hash = tx2.GetTxid();
|
||||
mempool.addUnchecked(hash, CTxMemPoolEntry(tx2, 11, GetTime(), 111.0, 11));
|
||||
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(multisig_verify)
|
||||
txTo[i].vin.resize(1);
|
||||
txTo[i].vout.resize(1);
|
||||
txTo[i].vin[0].prevout.n = i;
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txTo[i].vout[0].nValue = 1;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(multisig_Sign)
|
||||
txTo[i].vin.resize(1);
|
||||
txTo[i].vout.resize(1);
|
||||
txTo[i].vin[0].prevout.n = i;
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txTo[i].vout[0].nValue = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1)
|
||||
uint256 merkleRoot1 = block.BuildMerkleTree();
|
||||
std::vector<uint256> vTxid(nTx, uint256());
|
||||
for (unsigned int j=0; j<nTx; j++)
|
||||
vTxid[j] = block.vtx[j].GetHash();
|
||||
vTxid[j] = block.vtx[j].GetTxid();
|
||||
int nHeight = 1, nTx_ = nTx;
|
||||
while (nTx_ > 1) {
|
||||
nTx_ = (nTx_+1)/2;
|
||||
|
||||
@@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||
for (int j = 0; j < 10; j++) { // For each fee/pri multiple
|
||||
for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx
|
||||
tx.vin[0].prevout.n = 10000*blocknum+100*j+k; // make transaction unique
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx)));
|
||||
txHashes[j].push_back(hash);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||
for (int j = 0; j < 10; j++) { // For each fee/pri multiple
|
||||
for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx
|
||||
tx.vin[0].prevout.n = 10000*blocknum+100*j+k;
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx)));
|
||||
txHashes[j].push_back(hash);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||
for (int j = 0; j < 10; j++) { // For each fee/pri multiple
|
||||
for (int k = 0; k < 5; k++) { // add 4 fee txs for every priority tx
|
||||
tx.vin[0].prevout.n = 10000*blocknum+100*j+k;
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
mpool.addUnchecked(hash, CTxMemPoolEntry(tx, feeV[k/4][j], GetTime(), priV[k/4][j], blocknum, mpool.HasNoInputsOf(tx)));
|
||||
CTransaction btx;
|
||||
if (mpool.lookup(hash, btx))
|
||||
|
||||
@@ -40,7 +40,7 @@ Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict, Scri
|
||||
txTo.vin.resize(1);
|
||||
txTo.vout.resize(1);
|
||||
txTo.vin[0].prevout.n = 0;
|
||||
txTo.vin[0].prevout.hash = txFrom.GetHash();
|
||||
txTo.vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txTo.vin[0].scriptSig = scriptSig;
|
||||
txTo.vout[0].nValue = 1;
|
||||
|
||||
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(sign)
|
||||
txTo[i].vin.resize(1);
|
||||
txTo[i].vout.resize(1);
|
||||
txTo[i].vin[0].prevout.n = i;
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txTo[i].vout[0].nValue = 1;
|
||||
#ifdef ENABLE_WALLET
|
||||
BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("IsMine %d", i));
|
||||
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(set)
|
||||
txTo[i].vin.resize(1);
|
||||
txTo[i].vout.resize(1);
|
||||
txTo[i].vin[0].prevout.n = i;
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetHash();
|
||||
txTo[i].vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txTo[i].vout[0].nValue = 1*CENT;
|
||||
txTo[i].vout[0].scriptPubKey = inner[i];
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||
txFrom.vout[6].scriptPubKey = GetScriptForDestination(CScriptID(twentySigops));
|
||||
txFrom.vout[6].nValue = 6000;
|
||||
|
||||
coins.ModifyCoins(txFrom.GetHash())->FromTx(txFrom, 0);
|
||||
coins.ModifyCoins(txFrom.GetTxid())->FromTx(txFrom, 0);
|
||||
|
||||
CMutableTransaction txTo;
|
||||
txTo.vout.resize(1);
|
||||
@@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
txTo.vin[i].prevout.n = i;
|
||||
txTo.vin[i].prevout.hash = txFrom.GetHash();
|
||||
txTo.vin[i].prevout.hash = txFrom.GetTxid();
|
||||
}
|
||||
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 0));
|
||||
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 1));
|
||||
@@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||
txToNonStd1.vout[0].nValue = 1000;
|
||||
txToNonStd1.vin.resize(1);
|
||||
txToNonStd1.vin[0].prevout.n = 5;
|
||||
txToNonStd1.vin[0].prevout.hash = txFrom.GetHash();
|
||||
txToNonStd1.vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txToNonStd1.vin[0].scriptSig << static_cast<vector<unsigned char> >(sixteenSigops);
|
||||
|
||||
BOOST_CHECK(!::AreInputsStandard(txToNonStd1, coins));
|
||||
@@ -372,7 +372,7 @@ BOOST_AUTO_TEST_CASE(AreInputsStandard)
|
||||
txToNonStd2.vout[0].nValue = 1000;
|
||||
txToNonStd2.vin.resize(1);
|
||||
txToNonStd2.vin[0].prevout.n = 6;
|
||||
txToNonStd2.vin[0].prevout.hash = txFrom.GetHash();
|
||||
txToNonStd2.vin[0].prevout.hash = txFrom.GetTxid();
|
||||
txToNonStd2.vin[0].scriptSig << static_cast<vector<unsigned char> >(twentySigops);
|
||||
|
||||
BOOST_CHECK(!::AreInputsStandard(txToNonStd2, coins));
|
||||
|
||||
@@ -79,7 +79,7 @@ CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CMu
|
||||
txSpend.nLockTime = 0;
|
||||
txSpend.vin.resize(1);
|
||||
txSpend.vout.resize(1);
|
||||
txSpend.vin[0].prevout.hash = txCredit.GetHash();
|
||||
txSpend.vin[0].prevout.hash = txCredit.GetTxid();
|
||||
txSpend.vin[0].prevout.n = 0;
|
||||
txSpend.vin[0].scriptSig = scriptSig;
|
||||
txSpend.vin[0].nSequence = std::numeric_limits<unsigned int>::max();
|
||||
|
||||
@@ -279,14 +279,14 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
||||
dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
|
||||
dummyTransactions[0].vout[1].nValue = 50*CENT;
|
||||
dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG;
|
||||
coinsRet.ModifyCoins(dummyTransactions[0].GetHash())->FromTx(dummyTransactions[0], 0);
|
||||
coinsRet.ModifyCoins(dummyTransactions[0].GetTxid())->FromTx(dummyTransactions[0], 0);
|
||||
|
||||
dummyTransactions[1].vout.resize(2);
|
||||
dummyTransactions[1].vout[0].nValue = 21*CENT;
|
||||
dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey().GetID());
|
||||
dummyTransactions[1].vout[1].nValue = 22*CENT;
|
||||
dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
|
||||
coinsRet.ModifyCoins(dummyTransactions[1].GetHash())->FromTx(dummyTransactions[1], 0);
|
||||
coinsRet.ModifyCoins(dummyTransactions[1].GetTxid())->FromTx(dummyTransactions[1], 0);
|
||||
|
||||
return dummyTransactions;
|
||||
}
|
||||
@@ -508,13 +508,13 @@ BOOST_AUTO_TEST_CASE(test_Get)
|
||||
|
||||
CMutableTransaction t1;
|
||||
t1.vin.resize(3);
|
||||
t1.vin[0].prevout.hash = dummyTransactions[0].GetHash();
|
||||
t1.vin[0].prevout.hash = dummyTransactions[0].GetTxid();
|
||||
t1.vin[0].prevout.n = 1;
|
||||
t1.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
|
||||
t1.vin[1].prevout.hash = dummyTransactions[1].GetHash();
|
||||
t1.vin[1].prevout.hash = dummyTransactions[1].GetTxid();
|
||||
t1.vin[1].prevout.n = 0;
|
||||
t1.vin[1].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
|
||||
t1.vin[2].prevout.hash = dummyTransactions[1].GetHash();
|
||||
t1.vin[2].prevout.hash = dummyTransactions[1].GetTxid();
|
||||
t1.vin[2].prevout.n = 1;
|
||||
t1.vin[2].scriptSig << std::vector<unsigned char>(65, 0) << std::vector<unsigned char>(33, 4);
|
||||
t1.vout.resize(2);
|
||||
@@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
|
||||
CMutableTransaction t;
|
||||
t.vin.resize(1);
|
||||
t.vin[0].prevout.hash = dummyTransactions[0].GetHash();
|
||||
t.vin[0].prevout.hash = dummyTransactions[0].GetTxid();
|
||||
t.vin[0].prevout.n = 1;
|
||||
t.vin[0].scriptSig << std::vector<unsigned char>(65, 0);
|
||||
t.vout.resize(1);
|
||||
|
||||
@@ -118,17 +118,17 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
|
||||
{
|
||||
LOCK(cs);
|
||||
std::deque<uint256> txToRemove;
|
||||
txToRemove.push_back(origTx.GetHash());
|
||||
if (fRecursive && !mapTx.count(origTx.GetHash())) {
|
||||
txToRemove.push_back(origTx.GetTxid());
|
||||
if (fRecursive && !mapTx.count(origTx.GetTxid())) {
|
||||
// If recursively removing but origTx isn't in the mempool
|
||||
// be sure to remove any children that are in the pool. This can
|
||||
// happen during chain re-orgs if origTx isn't re-accepted into
|
||||
// the mempool for any reason.
|
||||
for (unsigned int i = 0; i < origTx.vout.size(); i++) {
|
||||
std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(origTx.GetHash(), i));
|
||||
std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(origTx.GetTxid(), i));
|
||||
if (it == mapNextTx.end())
|
||||
continue;
|
||||
txToRemove.push_back(it->second.ptx->GetHash());
|
||||
txToRemove.push_back(it->second.ptx->GetTxid());
|
||||
}
|
||||
}
|
||||
while (!txToRemove.empty())
|
||||
@@ -143,7 +143,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
|
||||
std::map<COutPoint, CInPoint>::iterator it = mapNextTx.find(COutPoint(hash, i));
|
||||
if (it == mapNextTx.end())
|
||||
continue;
|
||||
txToRemove.push_back(it->second.ptx->GetHash());
|
||||
txToRemove.push_back(it->second.ptx->GetTxid());
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
@@ -254,7 +254,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
|
||||
std::vector<CTxMemPoolEntry> entries;
|
||||
BOOST_FOREACH(const CTransaction& tx, vtx)
|
||||
{
|
||||
uint256 hash = tx.GetHash();
|
||||
uint256 hash = tx.GetTxid();
|
||||
if (mapTx.count(hash))
|
||||
entries.push_back(mapTx[hash]);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
|
||||
std::list<CTransaction> dummy;
|
||||
remove(tx, dummy, false);
|
||||
removeConflicts(tx, conflicts);
|
||||
ClearPrioritisation(tx.GetHash());
|
||||
ClearPrioritisation(tx.GetTxid());
|
||||
}
|
||||
// After the txs in the new block have been removed from the mempool, update policy estimates
|
||||
minerPolicyEstimator->processBlock(nBlockHeight, entries, fCurrentEstimate);
|
||||
@@ -361,7 +361,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||
}
|
||||
}
|
||||
for (std::map<COutPoint, CInPoint>::const_iterator it = mapNextTx.begin(); it != mapNextTx.end(); it++) {
|
||||
uint256 hash = it->second.ptx->GetHash();
|
||||
uint256 hash = it->second.ptx->GetTxid();
|
||||
map<uint256, CTxMemPoolEntry>::const_iterator it2 = mapTx.find(hash);
|
||||
const CTransaction& tx = it2->second.GetTx();
|
||||
assert(it2 != mapTx.end());
|
||||
@@ -371,7 +371,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const
|
||||
}
|
||||
|
||||
for (std::map<uint256, const CTransaction*>::const_iterator it = mapNullifiers.begin(); it != mapNullifiers.end(); it++) {
|
||||
uint256 hash = it->second->GetHash();
|
||||
uint256 hash = it->second->GetTxid();
|
||||
map<uint256, CTxMemPoolEntry>::const_iterator it2 = mapTx.find(hash);
|
||||
const CTransaction& tx = it2->second.GetTx();
|
||||
assert(it2 != mapTx.end());
|
||||
|
||||
@@ -74,7 +74,7 @@ void WalletTxToJSON(const CWalletTx& wtx, Object& entry)
|
||||
entry.push_back(Pair("blockindex", wtx.nIndex));
|
||||
entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime()));
|
||||
}
|
||||
uint256 hash = wtx.GetHash();
|
||||
uint256 hash = wtx.GetTxid();
|
||||
entry.push_back(Pair("txid", hash.GetHex()));
|
||||
Array conflicts;
|
||||
BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts())
|
||||
@@ -439,7 +439,7 @@ Value sendtoaddress(const Array& params, bool fHelp)
|
||||
|
||||
SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, wtx);
|
||||
|
||||
return wtx.GetHash().GetHex();
|
||||
return wtx.GetTxid().GetHex();
|
||||
}
|
||||
|
||||
Value listaddressgroupings(const Array& params, bool fHelp)
|
||||
@@ -916,7 +916,7 @@ Value sendfrom(const Array& params, bool fHelp)
|
||||
|
||||
SendMoney(address.Get(), nAmount, false, wtx);
|
||||
|
||||
return wtx.GetHash().GetHex();
|
||||
return wtx.GetTxid().GetHex();
|
||||
}
|
||||
|
||||
|
||||
@@ -1023,7 +1023,7 @@ Value sendmany(const Array& params, bool fHelp)
|
||||
if (!pwalletMain->CommitTransaction(wtx, keyChange))
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed");
|
||||
|
||||
return wtx.GetHash().GetHex();
|
||||
return wtx.GetTxid().GetHex();
|
||||
}
|
||||
|
||||
// Defined in rpcmisc.cpp
|
||||
@@ -1135,7 +1135,7 @@ Value ListReceived(const Array& params, bool fByAccounts)
|
||||
tallyitem& item = mapTally[address];
|
||||
item.nAmount += txout.nValue;
|
||||
item.nConf = min(item.nConf, nDepth);
|
||||
item.txids.push_back(wtx.GetHash());
|
||||
item.txids.push_back(wtx.GetTxid());
|
||||
if (mine & ISMINE_WATCH_ONLY)
|
||||
item.fIsWatchonly = true;
|
||||
}
|
||||
@@ -2324,7 +2324,7 @@ Value listunspent(const Array& params, bool fHelp)
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
const CScript& pk = out.tx->vout[out.i].scriptPubKey;
|
||||
Object entry;
|
||||
entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
|
||||
entry.push_back(Pair("txid", out.tx->GetTxid().GetHex()));
|
||||
entry.push_back(Pair("vout", out.i));
|
||||
CTxDestination address;
|
||||
if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
|
||||
|
||||
@@ -58,7 +58,7 @@ struct CompareValueOnly
|
||||
|
||||
std::string COutput::ToString() const
|
||||
{
|
||||
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue));
|
||||
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetTxid().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue));
|
||||
}
|
||||
|
||||
const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const
|
||||
@@ -613,7 +613,7 @@ void CWallet::MarkDirty()
|
||||
|
||||
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb)
|
||||
{
|
||||
uint256 hash = wtxIn.GetHash();
|
||||
uint256 hash = wtxIn.GetTxid();
|
||||
|
||||
if (fFromLoadWallet)
|
||||
{
|
||||
@@ -676,7 +676,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
}
|
||||
else
|
||||
LogPrintf("AddToWallet(): found %s in block %s not in index\n",
|
||||
wtxIn.GetHash().ToString(),
|
||||
wtxIn.GetTxid().ToString(),
|
||||
wtxIn.hashBlock.ToString());
|
||||
}
|
||||
AddToSpends(hash);
|
||||
@@ -705,7 +705,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
}
|
||||
|
||||
//// debug print
|
||||
LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetHash().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
|
||||
LogPrintf("AddToWallet %s %s%s\n", wtxIn.GetTxid().ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""));
|
||||
|
||||
// Write to disk
|
||||
if (fInsertedNew || fUpdated)
|
||||
@@ -723,7 +723,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
|
||||
if ( !strCmd.empty())
|
||||
{
|
||||
boost::replace_all(strCmd, "%s", wtxIn.GetHash().GetHex());
|
||||
boost::replace_all(strCmd, "%s", wtxIn.GetTxid().GetHex());
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
}
|
||||
|
||||
@@ -740,7 +740,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
||||
{
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
|
||||
bool fExisted = mapWallet.count(tx.GetTxid()) != 0;
|
||||
if (fExisted && !fUpdate) return false;
|
||||
if (fExisted || IsMine(tx) || IsFromMe(tx))
|
||||
{
|
||||
@@ -935,7 +935,7 @@ int CWalletTx::GetRequestCount() const
|
||||
else
|
||||
{
|
||||
// Did anyone request this transaction?
|
||||
map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(GetHash());
|
||||
map<uint256, int>::const_iterator mi = pwallet->mapRequestCount.find(GetTxid());
|
||||
if (mi != pwallet->mapRequestCount.end())
|
||||
{
|
||||
nRequests = (*mi).second;
|
||||
@@ -993,7 +993,7 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
|
||||
if (!ExtractDestination(txout.scriptPubKey, address))
|
||||
{
|
||||
LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
|
||||
this->GetHash().ToString());
|
||||
this->GetTxid().ToString());
|
||||
address = CNoDestination();
|
||||
}
|
||||
|
||||
@@ -1048,7 +1048,7 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, CAmount& nReceived,
|
||||
|
||||
bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
|
||||
{
|
||||
return pwalletdb->WriteTx(GetHash(), *this);
|
||||
return pwalletdb->WriteTx(GetTxid(), *this);
|
||||
}
|
||||
|
||||
void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
||||
@@ -1167,7 +1167,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
{
|
||||
const uint256& wtxid = item.first;
|
||||
CWalletTx& wtx = item.second;
|
||||
assert(wtx.GetHash() == wtxid);
|
||||
assert(wtx.GetTxid() == wtxid);
|
||||
|
||||
int nDepth = wtx.GetDepthInMainChain();
|
||||
|
||||
@@ -1192,7 +1192,7 @@ bool CWalletTx::RelayWalletTransaction()
|
||||
if (!IsCoinBase())
|
||||
{
|
||||
if (GetDepthInMainChain() == 0) {
|
||||
LogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
||||
LogPrintf("Relaying wtx %s\n", GetTxid().ToString());
|
||||
RelayTransaction((CTransaction)*this);
|
||||
return true;
|
||||
}
|
||||
@@ -1205,7 +1205,7 @@ set<uint256> CWalletTx::GetConflicts() const
|
||||
set<uint256> result;
|
||||
if (pwallet != NULL)
|
||||
{
|
||||
uint256 myHash = GetHash();
|
||||
uint256 myHash = GetTxid();
|
||||
result = pwallet->GetConflicts(myHash);
|
||||
result.erase(myHash);
|
||||
}
|
||||
@@ -1303,7 +1303,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const
|
||||
return nAvailableCreditCached;
|
||||
|
||||
CAmount nCredit = 0;
|
||||
uint256 hashTx = GetHash();
|
||||
uint256 hashTx = GetTxid();
|
||||
for (unsigned int i = 0; i < vout.size(); i++)
|
||||
{
|
||||
if (!pwallet->IsSpent(hashTx, i))
|
||||
@@ -1349,7 +1349,7 @@ CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const
|
||||
CAmount nCredit = 0;
|
||||
for (unsigned int i = 0; i < vout.size(); i++)
|
||||
{
|
||||
if (!pwallet->IsSpent(GetHash(), i))
|
||||
if (!pwallet->IsSpent(GetTxid(), i))
|
||||
{
|
||||
const CTxOut &txout = vout[i];
|
||||
nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY);
|
||||
@@ -1418,7 +1418,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
{
|
||||
CWalletTx& wtx = *item.second;
|
||||
if (wtx.RelayWalletTransaction())
|
||||
result.push_back(wtx.GetHash());
|
||||
result.push_back(wtx.GetTxid());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1954,7 +1954,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
|
||||
// Note how the sequence number is set to max()-1 so that the
|
||||
// nLockTime set above actually works.
|
||||
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
|
||||
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
|
||||
txNew.vin.push_back(CTxIn(coin.first->GetTxid(),coin.second,CScript(),
|
||||
std::numeric_limits<unsigned int>::max()-1));
|
||||
|
||||
// Sign
|
||||
@@ -2042,7 +2042,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
||||
{
|
||||
CWalletTx &coin = mapWallet[txin.prevout.hash];
|
||||
coin.BindWallet(this);
|
||||
NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
|
||||
NotifyTransactionChanged(this, coin.GetTxid(), CT_UPDATED);
|
||||
}
|
||||
|
||||
if (fFileBacked)
|
||||
@@ -2050,7 +2050,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey)
|
||||
}
|
||||
|
||||
// Track how many getdata requests our transaction gets
|
||||
mapRequestCount[wtxNew.GetHash()] = 0;
|
||||
mapRequestCount[wtxNew.GetTxid()] = 0;
|
||||
|
||||
if (fBroadcastTransactions)
|
||||
{
|
||||
@@ -2781,7 +2781,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const
|
||||
// Make sure the merkle branch connects to this block
|
||||
if (!fMerkleVerified)
|
||||
{
|
||||
if (CBlock::CheckMerkleBranch(GetHash(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot)
|
||||
if (CBlock::CheckMerkleBranch(GetTxid(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot)
|
||||
return 0;
|
||||
fMerkleVerified = true;
|
||||
}
|
||||
@@ -2794,7 +2794,7 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
int nResult = GetDepthInMainChainINTERNAL(pindexRet);
|
||||
if (nResult == 0 && !mempool.exists(GetHash()))
|
||||
if (nResult == 0 && !mempool.exists(GetTxid()))
|
||||
return -1; // Not in chain, not in mempool
|
||||
|
||||
return nResult;
|
||||
|
||||
@@ -288,7 +288,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
|
||||
|
||||
if (pwtx)
|
||||
{
|
||||
if (!WriteTx(pwtx->GetHash(), *pwtx))
|
||||
if (!WriteTx(pwtx->GetTxid(), *pwtx))
|
||||
return DB_LOAD_FAIL;
|
||||
}
|
||||
else
|
||||
@@ -312,7 +312,7 @@ DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
|
||||
// Since we're changing the order, write it back
|
||||
if (pwtx)
|
||||
{
|
||||
if (!WriteTx(pwtx->GetHash(), *pwtx))
|
||||
if (!WriteTx(pwtx->GetTxid(), *pwtx))
|
||||
return DB_LOAD_FAIL;
|
||||
}
|
||||
else
|
||||
@@ -371,7 +371,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
CWalletTx wtx;
|
||||
ssValue >> wtx;
|
||||
CValidationState state;
|
||||
if (!(CheckTransaction(wtx, state) && (wtx.GetHash() == hash) && state.IsValid()))
|
||||
if (!(CheckTransaction(wtx, state) && (wtx.GetTxid() == hash) && state.IsValid()))
|
||||
return false;
|
||||
|
||||
// Undo serialize changes in 31600
|
||||
|
||||
@@ -171,7 +171,7 @@ double benchmark_large_tx()
|
||||
auto orig_tx = CTransaction(m_orig_tx);
|
||||
|
||||
CMutableTransaction spending_tx;
|
||||
auto input_hash = orig_tx.GetHash();
|
||||
auto input_hash = orig_tx.GetTxid();
|
||||
// Add NUM_INPUTS inputs
|
||||
for (size_t i = 0; i < NUM_INPUTS; i++) {
|
||||
spending_tx.vin.emplace_back(input_hash, 0);
|
||||
|
||||
Reference in New Issue
Block a user