Cleanup
[novacoin.git] / src / qt / transactionrecord.cpp
index 7c50f91..98b6171 100644 (file)
@@ -32,8 +32,11 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
     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
@@ -46,63 +49,31 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
                 sub.idx = parts.size(); // sequence number
                 sub.credit = txout.nValue;
 
-                txnouttype whichType;
-                std::vector<valtype> vSolutions;
-                if (Solver(txout.scriptPubKey, whichType, vSolutions))
+                CBitcoinAddress addressRet;
+                if (pwalletMain->ExtractAddress(txout.scriptPubKey, addressRet))
                 {
-                    CTxDestination address;
-                    if (whichType == TX_PUBKEY)
-                    {
-                        // Pay-to-Pubkey
-                        address = CPubKey(vSolutions[0]).GetID();
-                        sub.type = TransactionRecord::RecvWithAddress;
-                        sub.address = CBitcoinAddress(address).ToString();
-                    }
-                    else if (whichType == TX_PUBKEYHASH)
-                    {
-                        // Pay-to-PubkeyHash
-                        address = CKeyID(uint160(vSolutions[0]));
-                        sub.type = TransactionRecord::RecvWithAddress;
-                        sub.address = CBitcoinAddress(address).ToString();
-                    }
-                    else if (whichType == TX_SCRIPTHASH)
-                    {
-                        // Pay-to-ScriptHash
-                        address = CScriptID(uint160(vSolutions[0]));
-                        sub.type = TransactionRecord::RecvWithAddress;
-                        sub.address = CBitcoinAddress(address).ToString();
-                    }
-                    else if (whichType == TX_PUBKEY_DROP)
-                    {
-                        // Pay-to-Pubkey-R
-                        sub.type = TransactionRecord::RecvWithAddress;
-
-                        CMalleableKeyView view;
-                        pwalletMain->CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view);
-                        sub.address = view.GetMalleablePubKey().ToString();
-                    }
-                    else
-                    {
-                        // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
-                        sub.type = TransactionRecord::RecvFromOther;
-                        sub.address = mapValue["from"];
-                    }
+                    sub.type = TransactionRecord::RecvWithAddress;
+                    sub.address = addressRet.ToString();
                 }
-                if (wtx.IsCoinBase())
+                else
                 {
-                    // Generated (proof-of-work)
-                    sub.type = TransactionRecord::Generated;
+                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
+                    sub.type = TransactionRecord::RecvFromOther;
+                    sub.address = mapValue["from"];
                 }
-                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);