PIVX Core  5.6.99
P2P Digital Currency
walletmodeltransaction.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2017-2021 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
7 
8 #include "wallet/wallet.h"
9 
10 WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient>& recipients) : recipients(recipients),
11  walletTransaction(0),
12  keyChange(0),
13  fee(0)
14 { }
15 
17 {
18  delete keyChange;
19 }
20 
21 QList<SendCoinsRecipient> WalletModelTransaction::getRecipients()
22 {
23  return recipients;
24 }
25 
27 {
28  return walletTransaction;
29 }
30 
32 {
33  return (!walletTransaction ? 0 : (::GetSerializeSize(*walletTransaction, PROTOCOL_VERSION)));
34 }
35 
37 {
38  return fee;
39 }
40 
42 {
43  fee = newFee;
44 }
45 
47 {
48  unsigned int count = 0;
49  for (const SendCoinsRecipient& rcp : recipients) {
50  if (rcp.fSubtractFee) count++;
51  }
52  return count;
53 }
54 
56 {
57  CAmount totalTransactionAmount = 0;
58  for (const SendCoinsRecipient& rcp : recipients) {
59  totalTransactionAmount += rcp.amount;
60  }
61  return totalTransactionAmount;
62 }
63 
65 {
66  keyChange = new CReserveKey(wallet);
67  return keyChange;
68 }
69 
71 {
72  return keyChange;
73 }
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
A key allocated from the key pool.
Definition: wallet.h:1256
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:577
unsigned int subtractFeeFromRecipents() const
void setTransactionFee(const CAmount &newFee)
const QList< SendCoinsRecipient > recipients
QList< SendCoinsRecipient > getRecipients()
CReserveKey * newPossibleKeyChange(CWallet *wallet)
CTransactionRef & getTransaction()
WalletModelTransaction(const QList< SendCoinsRecipient > &recipients)
unsigned int GetSerializeSize(const std::array< T, N > &item)
array
Definition: serialize.h:847
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:456