Dash Core  0.12.2.1
P2P Digital Currency
walletmodeltransaction.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 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 
6 
7 #include "wallet/wallet.h"
8 
9 WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &recipients) :
10  recipients(recipients),
11  walletTransaction(0),
12  keyChange(0),
13  fee(0)
14 {
16 }
17 
19 {
20  delete keyChange;
21  delete walletTransaction;
22 }
23 
24 QList<SendCoinsRecipient> WalletModelTransaction::getRecipients()
25 {
26  return recipients;
27 }
28 
30 {
31  return walletTransaction;
32 }
33 
35 {
37 }
38 
40 {
41  return fee;
42 }
43 
45 {
46  fee = newFee;
47 }
48 
50 {
51  int i = 0;
52  for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
53  {
54  SendCoinsRecipient& rcp = (*it);
55 
56  if (rcp.paymentRequest.IsInitialized())
57  {
58  CAmount subtotal = 0;
59  const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
60  for (int j = 0; j < details.outputs_size(); j++)
61  {
62  const payments::Output& out = details.outputs(j);
63  if (out.amount() <= 0) continue;
64  if (i == nChangePosRet)
65  i++;
66  subtotal += walletTransaction->vout[i].nValue;
67  i++;
68  }
69  rcp.amount = subtotal;
70  }
71  else // normal recipient (no payment request)
72  {
73  if (i == nChangePosRet)
74  i++;
75  rcp.amount = walletTransaction->vout[i].nValue;
76  i++;
77  }
78  }
79 }
80 
82 {
83  CAmount totalTransactionAmount = 0;
84  Q_FOREACH(const SendCoinsRecipient &rcp, recipients)
85  {
86  totalTransactionAmount += rcp.amount;
87  }
88  return totalTransactionAmount;
89 }
90 
92 {
94 }
95 
97 {
98  return keyChange;
99 }
void newPossibleKeyChange(CWallet *wallet)
void reassignAmounts(int nChangePosRet)
QList< SendCoinsRecipient > getRecipients()
const ::payments::Output & outputs(int index) const
int64_t CAmount
Definition: amount.h:14
QList< SendCoinsRecipient > recipients
unsigned int GetSerializeSize(char a, int, int=0)
Definition: serialize.h:202
void setTransactionFee(const CAmount &newFee)
Definition: wallet.py:1
PaymentRequestPlus paymentRequest
Definition: walletmodel.h:59
static const int PROTOCOL_VERSION
Definition: version.h:13
const std::vector< CTxOut > vout
Definition: transaction.h:234
WalletModelTransaction(const QList< SendCoinsRecipient > &recipients)
const payments::PaymentDetails & getDetails() const