Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
spend.h
Go to the documentation of this file.
1// Copyright (c) 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#ifndef BITCOIN_WALLET_SPEND_H
6#define BITCOIN_WALLET_SPEND_H
7
10#include <wallet/wallet.h>
11
16int GetTxSpendSize(const CWallet &wallet, const CWalletTx &wtx,
17 unsigned int out, bool use_max_sig = false);
18
19class COutput {
20public:
21 const CWalletTx *tx;
22 int i;
23 int nDepth;
24
30
33
36
43
49 bool fSafe;
50
51 COutput(const CWallet &wallet, const CWalletTx &wtx, int iIn, int nDepthIn,
52 bool fSpendableIn, bool fSolvableIn, bool fSafeIn,
53 bool use_max_sig_in = false) {
54 tx = &wtx;
55 i = iIn;
59 fSafe = fSafeIn;
60 nInputBytes = -1;
62 // If known and signable by the given wallet, compute nInputBytes
63 // Failure will keep this value -1
64 if (fSpendable) {
66 }
67 }
68
69 std::string ToString() const;
70
71 inline CInputCoin GetInputCoin() const {
72 return CInputCoin(tx->tx, i, nInputBytes);
73 }
74};
75
77int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet,
78 bool use_max_sig = false);
79
87 const CWallet *wallet,
88 const std::vector<CTxOut> &txouts,
89 bool use_max_sig = false);
91 const CWallet *wallet,
92 bool use_max_sig = false)
94
99 const CCoinControl *coinControl = nullptr,
103 const uint64_t nMaximumCount = 0)
105
107 const CCoinControl *coinControl = nullptr);
108
113 const CTransaction &tx, int output)
115
122
124GroupOutputs(const CWallet &wallet, const std::vector<COutput> &outputs,
127 const CoinEligibilityFilter &filter, bool positive_only);
128
143 std::vector<COutput> coins,
146 bool &bnb_used);
147
157bool SelectCoins(const CWallet &wallet,
163
173 const CCoinControl &coin_control, bool sign = true);
174
181 bool lockUnspents,
182 const std::set<int> &setSubtractFeeFromOutputs,
184
185#endif // BITCOIN_WALLET_SPEND_H
static constexpr Amount SATOSHI
Definition amount.h:143
static constexpr Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition amount.h:165
Coin Control Features.
Definition coincontrol.h:21
Fee rate in satoshis per kilobyte: Amount / kB.
Definition feerate.h:21
A mutable version of CTransaction.
int nDepth
Definition spend.h:23
bool fSafe
Whether this output is considered safe to spend.
Definition spend.h:49
bool fSolvable
Whether we know how to spend this output, ignoring the lack of keys.
Definition spend.h:35
int nInputBytes
Pre-computed estimated size of this output as a fully-signed input in a transaction.
Definition spend.h:29
bool fSpendable
Whether we have the private keys to spend this output.
Definition spend.h:32
const CWalletTx * tx
Definition spend.h:21
CInputCoin GetInputCoin() const
Definition spend.h:71
std::string ToString() const
Definition spend.cpp:31
int i
Definition spend.h:22
bool use_max_sig
Whether to use the maximum sized, 72 byte signature when calculating the size of the input spend.
Definition spend.h:42
COutput(const CWallet &wallet, const CWalletTx &wtx, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn, bool use_max_sig_in=false)
Definition spend.h:51
The basic transaction that is broadcasted on the network and contained in blocks.
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition wallet.h:254
A transaction with a bunch of additional info that only the owner cares about.
Definition transaction.h:65
CTransactionRef tx
static std::vector< COutput > vCoins
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(Amount::zero()), 0, false)
bool error(const char *fmt, const Args &...args)
Definition logging.h:226
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition rcu.h:257
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
bool CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Definition spend.cpp:993
bool SelectCoinsMinConf(const CWallet &wallet, const Amount nTargetValue, const CoinEligibilityFilter &eligibility_filter, std::vector< COutput > coins, std::set< CInputCoin > &setCoinsRet, Amount &nValueRet, const CoinSelectionParams &coin_selection_params, bool &bnb_used)
Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is st...
Definition spend.cpp:422
void AvailableCoins(const CWallet &wallet, std::vector< COutput > &vCoins, const CCoinControl *coinControl=nullptr, const Amount nMinimumAmount=SATOSHI, const Amount nMaximumAmount=MAX_MONEY, const Amount nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
populate vCoins with vector of available COutputs.
Definition spend.cpp:73
std::map< CTxDestination, std::vector< COutput > > ListCoins(const CWallet &wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Return list of available coins and locked coins grouped by non-change output address.
Definition spend.cpp:252
const CTxOut & FindNonChangeParentOutput(const CWallet &wallet, const CTransaction &tx, int output) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Find non-change parent output.
Definition spend.cpp:232
Amount GetAvailableBalance(const CWallet &wallet, const CCoinControl *coinControl=nullptr)
Definition spend.cpp:217
bool FundTransaction(CWallet &wallet, CMutableTransaction &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl coinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
Definition spend.cpp:1032
bool SelectCoins(const CWallet &wallet, const std::vector< COutput > &vAvailableCoins, const Amount nTargetValue, std::set< CInputCoin > &setCoinsRet, Amount &nValueRet, const CCoinControl &coin_control, CoinSelectionParams &coin_selection_params, bool &bnb_used) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Select a set of coins such that nValueRet >= nTargetValue and at least all coins from coin_control ar...
Definition spend.cpp:474
std::vector< OutputGroup > GroupOutputs(const CWallet &wallet, const std::vector< COutput > &outputs, bool separate_coins, const CFeeRate &effective_feerate, const CFeeRate &long_term_feerate, const CoinEligibilityFilter &filter, bool positive_only)
Definition spend.cpp:307
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, bool use_max_sig=false)
Get the marginal bytes of spending the specified output.
Definition spend.cpp:36
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, bool use_max_sig=false)
Calculate the size of the transaction assuming all signatures are max size Use DummySignatureCreator,...
Definition spend.cpp:47
int GetTxSpendSize(const CWallet &wallet, const CWalletTx &wtx, unsigned int out, bool use_max_sig=false)
Get the marginal bytes if spending the specified output from this transaction.
Definition spend.cpp:26
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
Definition standard.h:85
Bilingual messages:
Definition translation.h:17
#define EXCLUSIVE_LOCKS_REQUIRED(...)