#include "transactionrecord.h"
+#include "headers.h"
/* Return positive answer if transaction should be shown in list.
*/
/*
* Decompose CWallet transaction to model transaction records.
*/
-QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWalletTx &wtx)
+QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
{
int64 nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- nUnmatured += txout.GetCredit();
+ nUnmatured += wallet->GetCredit(txout);
sub.credit = nUnmatured;
}
}
sub.type = TransactionRecord::RecvWithAddress;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
- if (txout.IsMine())
+ if(wallet->IsMine(txout))
{
- std::vector<unsigned char> vchPubKey;
- if (ExtractPubKey(txout.scriptPubKey, true, vchPubKey))
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
{
- sub.address = PubKeyToAddress(vchPubKey);
+ sub.address = address.ToString();
}
break;
}
{
bool fAllFromMe = true;
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
- fAllFromMe = fAllFromMe && txin.IsMine();
+ fAllFromMe = fAllFromMe && wallet->IsMine(txin);
bool fAllToMe = true;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- fAllToMe = fAllToMe && txout.IsMine();
+ fAllToMe = fAllToMe && wallet->IsMine(txout);
if (fAllFromMe && fAllToMe)
{
TransactionRecord sub(hash, nTime);
sub.idx = parts.size();
- if (txout.IsMine())
+ if(wallet->IsMine(txout))
{
// Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address.
continue;
}
- else if (!mapValue["to"].empty())
+ else if(!mapValue["to"].empty())
{
// Sent to IP
sub.type = TransactionRecord::SendToIP;
{
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
- uint160 hash160;
- if (ExtractHash160(txout.scriptPubKey, hash160))
- sub.address = Hash160ToAddress(hash160);
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, 0, address))
+ {
+ sub.address = address.ToString();
+ }
}
int64 nValue = txout.nValue;
//
bool fAllMine = true;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
- fAllMine = fAllMine && txout.IsMine();
+ fAllMine = fAllMine && wallet->IsMine(txout);
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
- fAllMine = fAllMine && txin.IsMine();
+ fAllMine = fAllMine && wallet->IsMine(txin);
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nNet, 0));
}
// Sort order, unrecorded transactions sort to the top
status.sortKey = strprintf("%010d-%01d-%010u-%03d",
- (pindex ? pindex->nHeight : INT_MAX),
+ (pindex ? pindex->nHeight : std::numeric_limits<int>::max()),
(wtx.IsCoinBase() ? 1 : 0),
wtx.nTimeReceived,
idx);
if (!wtx.IsFinal())
{
- if (wtx.nLockTime < 500000000)
+ if (wtx.nLockTime < LOCKTIME_THRESHOLD)
{
status.status = TransactionStatus::OpenUntilBlock;
status.open_for = nBestHeight - wtx.nLockTime;
{
status.status = TransactionStatus::Offline;
}
- else if (status.depth < 6)
+ else if (status.depth < NumConfirmations)
{
status.status = TransactionStatus::Unconfirmed;
}
{
return status.cur_num_blocks != nBestHeight;
}
+
+std::string TransactionRecord::getTxID()
+{
+ return hash.ToString() + strprintf("-%03d", idx);
+}
+