Bitcoin Core  21.99.0
P2P Digital Currency
walletmodeltransaction.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2019 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 #ifdef HAVE_CONFIG_H
7 #endif
8 
10 
11 #include <policy/policy.h>
12 
13 WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
14  recipients(_recipients),
15  fee(0)
16 {
17 }
18 
19 QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
20 {
21  return recipients;
22 }
23 
25 {
26  return wtx;
27 }
28 
30 {
31  wtx = newTx;
32 }
33 
35 {
36  return wtx ? GetVirtualTransactionSize(*wtx) : 0;
37 }
38 
40 {
41  return fee;
42 }
43 
45 {
46  fee = newFee;
47 }
48 
50 {
51  const CTransaction* walletTransaction = wtx.get();
52  int i = 0;
53  for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
54  {
55  SendCoinsRecipient& rcp = (*it);
56  {
57  if (i == nChangePosRet)
58  i++;
59  rcp.amount = walletTransaction->vout[i].nValue;
60  i++;
61  }
62  }
63 }
64 
66 {
67  CAmount totalTransactionAmount = 0;
68  for (const SendCoinsRecipient &rcp : recipients)
69  {
70  totalTransactionAmount += rcp.amount;
71  }
72  return totalTransactionAmount;
73 }
SendCoinsRecipient::amount
CAmount amount
Definition: sendcoinsrecipient.h:33
policy.h
WalletModelTransaction::recipients
QList< SendCoinsRecipient > recipients
Definition: walletmodeltransaction.h:42
WalletModelTransaction::getTransactionSize
unsigned int getTransactionSize()
Definition: walletmodeltransaction.cpp:34
bitcoin-config.h
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
WalletModelTransaction::wtx
CTransactionRef wtx
Definition: walletmodeltransaction.h:43
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
WalletModelTransaction::WalletModelTransaction
WalletModelTransaction(const QList< SendCoinsRecipient > &recipients)
Definition: walletmodeltransaction.cpp:13
SendCoinsRecipient
Definition: sendcoinsrecipient.h:19
CTransaction::vout
const std::vector< CTxOut > vout
Definition: transaction.h:271
WalletModelTransaction::setTransactionFee
void setTransactionFee(const CAmount &newFee)
Definition: walletmodeltransaction.cpp:44
WalletModelTransaction::getTransactionFee
CAmount getTransactionFee() const
Definition: walletmodeltransaction.cpp:39
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
WalletModelTransaction::fee
CAmount fee
Definition: walletmodeltransaction.h:44
WalletModelTransaction::getRecipients
QList< SendCoinsRecipient > getRecipients() const
Definition: walletmodeltransaction.cpp:19
WalletModelTransaction::getTotalTransactionAmount
CAmount getTotalTransactionAmount() const
Definition: walletmodeltransaction.cpp:65
walletmodeltransaction.h
WalletModelTransaction::setWtx
void setWtx(const CTransactionRef &)
Definition: walletmodeltransaction.cpp:29
WalletModelTransaction::getWtx
CTransactionRef & getWtx()
Definition: walletmodeltransaction.cpp:24
GetVirtualTransactionSize
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
Definition: policy.cpp:280
it
auto it
Definition: validation.cpp:355
WalletModelTransaction::reassignAmounts
void reassignAmounts(int nChangePosRet)
Definition: walletmodeltransaction.cpp:49