LCOV - code coverage report
Current view: top level - src/qt - walletmodeltransaction.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 48 0.0 %
Date: 2015-10-12 22:39:14 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2013 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include "walletmodeltransaction.h"
       6             : 
       7             : #include "wallet/wallet.h"
       8             : 
       9           0 : WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &recipients) :
      10             :     recipients(recipients),
      11             :     walletTransaction(0),
      12             :     keyChange(0),
      13           0 :     fee(0)
      14             : {
      15           0 :     walletTransaction = new CWalletTx();
      16           0 : }
      17             : 
      18           0 : WalletModelTransaction::~WalletModelTransaction()
      19             : {
      20           0 :     delete keyChange;
      21           0 :     delete walletTransaction;
      22           0 : }
      23             : 
      24           0 : QList<SendCoinsRecipient> WalletModelTransaction::getRecipients()
      25             : {
      26           0 :     return recipients;
      27             : }
      28             : 
      29           0 : CWalletTx *WalletModelTransaction::getTransaction()
      30             : {
      31           0 :     return walletTransaction;
      32             : }
      33             : 
      34           0 : unsigned int WalletModelTransaction::getTransactionSize()
      35             : {
      36           0 :     return (!walletTransaction ? 0 : (::GetSerializeSize(*(CTransaction*)walletTransaction, SER_NETWORK, PROTOCOL_VERSION)));
      37             : }
      38             : 
      39           0 : CAmount WalletModelTransaction::getTransactionFee()
      40             : {
      41           0 :     return fee;
      42             : }
      43             : 
      44           0 : void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
      45             : {
      46           0 :     fee = newFee;
      47           0 : }
      48             : 
      49           0 : void WalletModelTransaction::reassignAmounts(int nChangePosRet)
      50             : {
      51           0 :     int i = 0;
      52           0 :     for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
      53             :     {
      54           0 :         SendCoinsRecipient& rcp = (*it);
      55             : 
      56           0 :         if (rcp.paymentRequest.IsInitialized())
      57             :         {
      58             :             CAmount subtotal = 0;
      59             :             const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
      60           0 :             for (int j = 0; j < details.outputs_size(); j++)
      61             :             {
      62           0 :                 const payments::Output& out = details.outputs(j);
      63           0 :                 if (out.amount() <= 0) continue;
      64           0 :                 if (i == nChangePosRet)
      65           0 :                     i++;
      66           0 :                 subtotal += walletTransaction->vout[i].nValue;
      67           0 :                 i++;
      68             :             }
      69           0 :             rcp.amount = subtotal;
      70             :         }
      71             :         else // normal recipient (no payment request)
      72             :         {
      73           0 :             if (i == nChangePosRet)
      74           0 :                 i++;
      75           0 :             rcp.amount = walletTransaction->vout[i].nValue;
      76           0 :             i++;
      77             :         }
      78             :     }
      79           0 : }
      80             : 
      81           0 : CAmount WalletModelTransaction::getTotalTransactionAmount()
      82             : {
      83           0 :     CAmount totalTransactionAmount = 0;
      84           0 :     Q_FOREACH(const SendCoinsRecipient &rcp, recipients)
      85             :     {
      86           0 :         totalTransactionAmount += rcp.amount;
      87             :     }
      88           0 :     return totalTransactionAmount;
      89             : }
      90             : 
      91           0 : void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet)
      92             : {
      93           0 :     keyChange = new CReserveKey(wallet);
      94           0 : }
      95             : 
      96           0 : CReserveKey *WalletModelTransaction::getPossibleKeyChange()
      97             : {
      98           0 :     return keyChange;
      99           0 : }

Generated by: LCOV version 1.11