aboutsummaryrefslogtreecommitdiff
path: root/src/qt/transactionrecord.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/transactionrecord.cpp')
-rw-r--r--src/qt/transactionrecord.cpp86
1 files changed, 39 insertions, 47 deletions
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index cc30cf747d..60ab2d57d7 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -5,17 +5,17 @@
#include <qt/transactionrecord.h>
#include <consensus/consensus.h>
+#include <interface/wallet.h>
#include <key_io.h>
-#include <validation.h>
#include <timedata.h>
-#include <wallet/wallet.h>
+#include <validation.h>
#include <stdint.h>
/* Return positive answer if transaction should be shown in list.
*/
-bool TransactionRecord::showTransaction(const CWalletTx &wtx)
+bool TransactionRecord::showTransaction()
{
// There are currently no cases where we hide transactions, but
// we may want to use this in the future for things like RBF.
@@ -25,17 +25,17 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx)
/*
* Decompose CWallet transaction to model transaction records.
*/
-QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
+QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface::WalletTx& wtx)
{
QList<TransactionRecord> parts;
- int64_t nTime = wtx.GetTxTime();
- CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
- CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
+ int64_t nTime = wtx.time;
+ CAmount nCredit = wtx.credit;
+ CAmount nDebit = wtx.debit;
CAmount nNet = nCredit - nDebit;
- uint256 hash = wtx.GetHash();
- std::map<std::string, std::string> mapValue = wtx.mapValue;
+ uint256 hash = wtx.tx->GetHash();
+ std::map<std::string, std::string> mapValue = wtx.value_map;
- if (nNet > 0 || wtx.IsCoinBase())
+ if (nNet > 0 || wtx.is_coinbase)
{
//
// Credit
@@ -43,7 +43,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{
const CTxOut& txout = wtx.tx->vout[i];
- isminetype mine = wallet->IsMine(txout);
+ isminetype mine = wtx.txout_is_mine[i];
if(mine)
{
TransactionRecord sub(hash, nTime);
@@ -51,11 +51,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.idx = i; // vout index
sub.credit = txout.nValue;
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
- if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
+ if (wtx.txout_address_is_mine[i])
{
// Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress;
- sub.address = EncodeDestination(address);
+ sub.address = EncodeDestination(wtx.txout_address[i]);
}
else
{
@@ -63,7 +63,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"];
}
- if (wtx.IsCoinBase())
+ if (wtx.is_coinbase)
{
// Generated
sub.type = TransactionRecord::Generated;
@@ -77,17 +77,15 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
{
bool involvesWatchAddress = false;
isminetype fAllFromMe = ISMINE_SPENDABLE;
- for (const CTxIn& txin : wtx.tx->vin)
+ for (isminetype mine : wtx.txin_is_mine)
{
- isminetype mine = wallet->IsMine(txin);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllFromMe > mine) fAllFromMe = mine;
}
isminetype fAllToMe = ISMINE_SPENDABLE;
- for (const CTxOut& txout : wtx.tx->vout)
+ for (isminetype mine : wtx.txout_is_mine)
{
- isminetype mine = wallet->IsMine(txout);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllToMe > mine) fAllToMe = mine;
}
@@ -95,7 +93,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (fAllFromMe && fAllToMe)
{
// Payment to self
- CAmount nChange = wtx.GetChange();
+ CAmount nChange = wtx.change;
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
@@ -115,19 +113,18 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress;
- if(wallet->IsMine(txout))
+ if(wtx.txout_is_mine[nOut])
{
// Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address.
continue;
}
- CTxDestination address;
- if (ExtractDestination(txout.scriptPubKey, address))
+ if (!boost::get<CNoDestination>(&wtx.txout_address[nOut]))
{
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
- sub.address = EncodeDestination(address);
+ sub.address = EncodeDestination(wtx.txout_address[nOut]);
}
else
{
@@ -161,50 +158,46 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
return parts;
}
-void TransactionRecord::updateStatus(const CWalletTx &wtx)
+void TransactionRecord::updateStatus(const interface::WalletTxStatus& wtx, int numBlocks, int64_t adjustedTime)
{
- AssertLockHeld(cs_main);
// Determine transaction status
- // Find the block the tx is in
- const CBlockIndex* pindex = LookupBlockIndex(wtx.hashBlock);
-
// Sort order, unrecorded transactions sort to the top
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
- (pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
- (wtx.IsCoinBase() ? 1 : 0),
- wtx.nTimeReceived,
+ wtx.block_height,
+ wtx.is_coinbase ? 1 : 0,
+ wtx.time_received,
idx);
- status.countsForBalance = wtx.IsTrusted() && !(wtx.GetBlocksToMaturity() > 0);
- status.depth = wtx.GetDepthInMainChain();
- status.cur_num_blocks = chainActive.Height();
+ status.countsForBalance = wtx.is_trusted && !(wtx.blocks_to_maturity > 0);
+ status.depth = wtx.depth_in_main_chain;
+ status.cur_num_blocks = numBlocks;
- if (!CheckFinalTx(*wtx.tx))
+ if (!wtx.is_final)
{
- if (wtx.tx->nLockTime < LOCKTIME_THRESHOLD)
+ if (wtx.lock_time < LOCKTIME_THRESHOLD)
{
status.status = TransactionStatus::OpenUntilBlock;
- status.open_for = wtx.tx->nLockTime - chainActive.Height();
+ status.open_for = wtx.lock_time - numBlocks;
}
else
{
status.status = TransactionStatus::OpenUntilDate;
- status.open_for = wtx.tx->nLockTime;
+ status.open_for = wtx.lock_time;
}
}
// For generated transactions, determine maturity
else if(type == TransactionRecord::Generated)
{
- if (wtx.GetBlocksToMaturity() > 0)
+ if (wtx.blocks_to_maturity > 0)
{
status.status = TransactionStatus::Immature;
- if (wtx.IsInMainChain())
+ if (wtx.is_in_main_chain)
{
- status.matures_in = wtx.GetBlocksToMaturity();
+ status.matures_in = wtx.blocks_to_maturity;
// Check if the block was requested by anyone
- if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
+ if (adjustedTime - wtx.time_received > 2 * 60 && wtx.request_count == 0)
status.status = TransactionStatus::MaturesWarning;
}
else
@@ -223,14 +216,14 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
{
status.status = TransactionStatus::Conflicted;
}
- else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
+ else if (adjustedTime - wtx.time_received > 2 * 60 && wtx.request_count == 0)
{
status.status = TransactionStatus::Offline;
}
else if (status.depth == 0)
{
status.status = TransactionStatus::Unconfirmed;
- if (wtx.isAbandoned())
+ if (wtx.is_abandoned)
status.status = TransactionStatus::Abandoned;
}
else if (status.depth < RecommendedNumConfirmations)
@@ -245,10 +238,9 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
status.needsUpdate = false;
}
-bool TransactionRecord::statusUpdateNeeded() const
+bool TransactionRecord::statusUpdateNeeded(int numBlocks) const
{
- AssertLockHeld(cs_main);
- return status.cur_num_blocks != chainActive.Height() || status.needsUpdate;
+ return status.cur_num_blocks != numBlocks || status.needsUpdate;
}
QString TransactionRecord::getTxHash() const