#include "wallet.h"
#include "base58.h"
+extern CWallet* pwalletMain;
+
/* Return positive answer if transaction should be shown in list.
*/
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
{
QList<TransactionRecord> parts;
int64_t nTime = wtx.GetTxTime();
- int64_t nCredit = wtx.GetCredit(true);
+ int64_t nCredit = wtx.GetCredit(MINE_ALL);
int64_t nDebit = wtx.GetDebit(MINE_ALL);
int64_t nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash(), hashPrev = 0;
std::map<std::string, std::string> mapValue = wtx.mapValue;
+
+ bool fCoinBase = wtx.IsCoinBase(),
+ fCoinStake = wtx.IsCoinStake();
- if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())
+ if (nNet > 0 || fCoinBase || fCoinStake)
{
//
// Credit
if(wallet->IsMine(txout))
{
TransactionRecord sub(hash, nTime);
- CTxDestination address;
sub.idx = parts.size(); // sequence number
sub.credit = txout.nValue;
- if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))
+
+ CBitcoinAddress addressRet;
+ if (pwalletMain->ExtractAddress(txout.scriptPubKey, addressRet))
{
- // Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress;
- sub.address = CBitcoinAddress(address).ToString();
+ sub.address = addressRet.ToString();
}
else
{
sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"];
}
- if (wtx.IsCoinBase())
- {
- // Generated (proof-of-work)
- sub.type = TransactionRecord::Generated;
- }
- if (wtx.IsCoinStake())
- {
- // Generated (proof-of-stake)
-
- if (hashPrev == hash)
- continue; // last coinstake output
+ if (fCoinBase || fCoinStake)
+ {
+ // Generated
sub.type = TransactionRecord::Generated;
- sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;
- hashPrev = hash;
+ if (fCoinStake)
+ {
+ // proof-of-stake
+ if (hashPrev == hash)
+ continue; // last coinstake output
+ sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;
+ hashPrev = hash;
+ }
}
parts.append(sub);