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());
}
return true;
if (isEmpty)
return false;
- const uint256& hash = tx.GetHash();
+ const uint256& hash = tx.GetTxid();
if (contains(hash))
fFound = true;
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);
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())
{
bool AddOrphanTx(const CTransaction& tx, NodeId peer)
{
- uint256 hash = tx.GetHash();
+ uint256 hash = tx.GetTxid();
if (mapOrphanTransactions.count(hash))
return false;
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;
}
}
{
{
LOCK(mempool.cs);
- uint256 hash = tx.GetHash();
+ uint256 hash = tx.GetTxid();
double dPriorityDelta = 0;
CAmount nFeeDelta = 0;
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
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;
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;
}
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;
}
// 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)
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;
}
// 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;
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))
// 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.
// 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");
}
}
- 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);
}
// 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);
CTransaction tx;
vRecv >> tx;
- CInv inv(MSG_TX, tx.GetHash());
+ CInv inv(MSG_TX, tx.GetTxid());
pfrom->AddInventoryKnown(inv);
LOCK(cs_main);
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
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
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(),
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);
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
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);
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);
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
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
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());
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)
{
// 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))
{
nInputSum += nInputSize;
// transaction hash
- uint256 txhash = out.tx->GetHash();
+ uint256 txhash = out.tx->GetTxid();
itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex()));
// vout index
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)
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())
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()));
int i = 0;
BOOST_FOREACH (CTransaction& tx, pblock->vtx)
{
- uint256 txHash = tx.GetHash();
+ uint256 txHash = tx.GetTxid();
setTxIndex[txHash] = i++;
if (tx.IsCoinBase())
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;
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");
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)
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());
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
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;
*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";
*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;
// 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;
{
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;
{
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;
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);
// 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):
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;
}
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;
}
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;
// 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;
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;
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;
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));
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;
}
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;
}
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;
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);
}
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);
}
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))
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;
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));
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
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);
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));
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));
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));
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();
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;
}
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);
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);
{
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())
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)
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]);
}
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);
}
}
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());
}
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());
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())
SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, wtx);
- return wtx.GetHash().GetHex();
+ return wtx.GetTxid().GetHex();
}
Value listaddressgroupings(const Array& params, bool fHelp)
SendMoney(address.Get(), nAmount, false, wtx);
- return wtx.GetHash().GetHex();
+ return wtx.GetTxid().GetHex();
}
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
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;
}
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)) {
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
bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb)
{
- uint256 hash = wtxIn.GetHash();
+ uint256 hash = wtxIn.GetTxid();
if (fFromLoadWallet)
{
}
else
LogPrintf("AddToWallet(): found %s in block %s not in index\n",
- wtxIn.GetHash().ToString(),
+ wtxIn.GetTxid().ToString(),
wtxIn.hashBlock.ToString());
}
AddToSpends(hash);
}
//// 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)
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
}
{
{
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))
{
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;
if (!ExtractDestination(txout.scriptPubKey, address))
{
LogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
- this->GetHash().ToString());
+ this->GetTxid().ToString());
address = CNoDestination();
}
bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
{
- return pwalletdb->WriteTx(GetHash(), *this);
+ return pwalletdb->WriteTx(GetTxid(), *this);
}
void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
{
const uint256& wtxid = item.first;
CWalletTx& wtx = item.second;
- assert(wtx.GetHash() == wtxid);
+ assert(wtx.GetTxid() == wtxid);
int nDepth = wtx.GetDepthInMainChain();
if (!IsCoinBase())
{
if (GetDepthInMainChain() == 0) {
- LogPrintf("Relaying wtx %s\n", GetHash().ToString());
+ LogPrintf("Relaying wtx %s\n", GetTxid().ToString());
RelayTransaction((CTransaction)*this);
return true;
}
set<uint256> result;
if (pwallet != NULL)
{
- uint256 myHash = GetHash();
+ uint256 myHash = GetTxid();
result = pwallet->GetConflicts(myHash);
result.erase(myHash);
}
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))
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);
{
CWalletTx& wtx = *item.second;
if (wtx.RelayWalletTransaction())
- result.push_back(wtx.GetHash());
+ result.push_back(wtx.GetTxid());
}
return result;
}
// 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
{
CWalletTx &coin = mapWallet[txin.prevout.hash];
coin.BindWallet(this);
- NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED);
+ NotifyTransactionChanged(this, coin.GetTxid(), CT_UPDATED);
}
if (fFileBacked)
}
// Track how many getdata requests our transaction gets
- mapRequestCount[wtxNew.GetHash()] = 0;
+ mapRequestCount[wtxNew.GetTxid()] = 0;
if (fBroadcastTransactions)
{
// 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;
}
{
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;
if (pwtx)
{
- if (!WriteTx(pwtx->GetHash(), *pwtx))
+ if (!WriteTx(pwtx->GetTxid(), *pwtx))
return DB_LOAD_FAIL;
}
else
// 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
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
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);