+#include <QtGlobal>
+
#include "transactionrecord.h"
#include "headers.h"
QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
- int64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
- int64 nCredit = wtx.GetCredit(true);
- int64 nDebit = wtx.GetDebit();
- int64 nNet = nCredit - nDebit;
+ qint64 nTime = wtx.nTimeDisplayed = wtx.GetTxTime();
+ qint64 nCredit = wtx.GetCredit(true);
+ qint64 nDebit = wtx.GetDebit();
+ qint64 nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;
if (nCredit == 0)
{
- int64 nUnmatured = 0;
+ qint64 nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout);
sub.credit = nUnmatured;
{
if(wallet->IsMine(txout))
{
- std::vector<unsigned char> vchPubKey;
- if (ExtractPubKey(txout.scriptPubKey, wallet, vchPubKey))
+ CBitcoinAddress address;
+ if (ExtractAddress(txout.scriptPubKey, wallet, address))
{
- sub.address = PubKeyToAddress(vchPubKey);
+ sub.address = address.ToString();
}
break;
}
if (fAllFromMe && fAllToMe)
{
// Payment to self
- int64 nChange = wtx.GetChange();
+ qint64 nChange = wtx.GetChange();
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",
-(nDebit - nChange), nCredit - nChange));
//
// Debit
//
- int64 nTxFee = nDebit - wtx.GetValueOut();
+ qint64 nTxFee = nDebit - wtx.GetValueOut();
for (int nOut = 0; nOut < wtx.vout.size(); nOut++)
{
{
// 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;
+ qint64 nValue = txout.nValue;
/* Add fee to first output */
if (nTxFee > 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;
// For generated transactions, determine maturity
if(type == TransactionRecord::Generated)
{
- int64 nCredit = wtx.GetCredit(true);
+ qint64 nCredit = wtx.GetCredit(true);
if (nCredit == 0)
{
status.maturity = TransactionStatus::Immature;
{
return status.cur_num_blocks != nBestHeight;
}
+
+std::string TransactionRecord::getTxID()
+{
+ return hash.ToString() + strprintf("-%03d", idx);
+}
+