X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fqt%2Ftransactionrecord.cpp;h=98b61718c200f4708eebd608a461503bb6d4d590;hb=d4488b9d263e4799f7bb4a1aaa1f692aa995f517;hp=5df2c3d7beed2510d1345a04ff9722cad1b448b0;hpb=77a43545b4491b9703d803765da9059d2bdd5aaa;p=novacoin.git diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 5df2c3d..98b6171 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -3,6 +3,8 @@ #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) @@ -25,13 +27,16 @@ QList TransactionRecord::decomposeTransaction(const CWallet * { QList 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 mapValue = wtx.mapValue; + + bool fCoinBase = wtx.IsCoinBase(), + fCoinStake = wtx.IsCoinStake(); - if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake()) + if (nNet > 0 || fCoinBase || fCoinStake) { // // Credit @@ -41,14 +46,14 @@ QList TransactionRecord::decomposeTransaction(const CWallet * 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 { @@ -56,21 +61,19 @@ QList TransactionRecord::decomposeTransaction(const CWallet * 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);