Bitcoin Core  24.99.0
P2P Digital Currency
walletmodeltransaction.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 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 {
16 }
17 
18 QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
19 {
20  return recipients;
21 }
22 
24 {
25  return wtx;
26 }
27 
29 {
30  wtx = newTx;
31 }
32 
34 {
35  return wtx ? GetVirtualTransactionSize(*wtx) : 0;
36 }
37 
39 {
40  return fee;
41 }
42 
44 {
45  fee = newFee;
46 }
47 
49 {
50  const CTransaction* walletTransaction = wtx.get();
51  int i = 0;
52  for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
53  {
54  SendCoinsRecipient& rcp = (*it);
55  {
56  if (i == nChangePosRet)
57  i++;
58  rcp.amount = walletTransaction->vout[i].nValue;
59  i++;
60  }
61  }
62 }
63 
65 {
66  CAmount totalTransactionAmount = 0;
67  for (const SendCoinsRecipient &rcp : recipients)
68  {
69  totalTransactionAmount += rcp.amount;
70  }
71  return totalTransactionAmount;
72 }
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:295
const std::vector< CTxOut > vout
Definition: transaction.h:306
void setTransactionFee(const CAmount &newFee)
void reassignAmounts(int nChangePosRet)
void setWtx(const CTransactionRef &)
QList< SendCoinsRecipient > getRecipients() const
QList< SendCoinsRecipient > recipients
WalletModelTransaction(const QList< SendCoinsRecipient > &recipients)
CAmount getTotalTransactionAmount() const
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:295
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:421