Bitcoin Core 32.99.0
P2P Digital Currency
feebumper.cpp
Go to the documentation of this file.
1// Copyright (c) 2017-present 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#include <wallet/feebumper.h>
6
7#include <coins.h>
8#include <common/system.h>
10#include <interfaces/chain.h>
11#include <policy/policy.h>
12#include <util/moneystr.h>
13#include <util/rbf.h>
14#include <util/translation.h>
15#include <wallet/coincontrol.h>
16#include <wallet/fees.h>
17#include <wallet/receive.h>
18#include <wallet/spend.h>
19#include <wallet/wallet.h>
20
21namespace wallet {
24static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, bool require_mine, std::vector<bilingual_str>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
25{
26 if (wallet.HasWalletSpend(wtx.GetTx())) {
27 errors.emplace_back(Untranslated("Transaction has descendants in the wallet"));
29 }
30
31 {
32 if (wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
33 errors.emplace_back(Untranslated("Transaction has descendants in the mempool"));
35 }
36 }
37
38 if (wallet.GetTxDepthInMainChain(wtx) != 0) {
39 errors.emplace_back(Untranslated("Transaction has been mined, or is conflicted with a mined transaction"));
41 }
42
43 if (wtx.m_replaced_by_txid) {
44 errors.push_back(Untranslated(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.m_replaced_by_txid->ToString())));
46 }
47
48 if (require_mine) {
49 // check that original tx consists entirely of our inputs
50 // if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
51 if (!AllInputsMine(wallet, *wtx.GetTx())) {
52 errors.emplace_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
54 }
55 }
56
58}
59
61static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTransaction& mtx, const CFeeRate& newFeerate, const int64_t maxTxSize, CAmount old_fee, std::vector<bilingual_str>& errors)
62{
63 // check that fee rate is higher than mempool's minimum fee
64 // (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
65 // This may occur if fallbackfee is too low, or, perhaps,
66 // in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
67 // moment earlier. In this case, we report an error to the user, who may adjust the fee.
68 CFeeRate minMempoolFeeRate = wallet.chain().mempoolMinFee();
69
70 if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
71 errors.push_back(Untranslated(
72 strprintf("New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ",
73 FormatMoney(newFeerate.GetFeePerK()),
74 FormatMoney(minMempoolFeeRate.GetFeePerK()))));
76 }
77
78 std::vector<COutPoint> reused_inputs;
79 reused_inputs.reserve(mtx.vin.size());
80 for (const CTxIn& txin : mtx.vin) {
81 reused_inputs.push_back(txin.prevout);
82 }
83
84 const std::optional<CAmount> combined_bump_fee = wallet.chain().calculateCombinedBumpFee(reused_inputs, newFeerate);
85 if (!combined_bump_fee.has_value()) {
86 errors.push_back(Untranslated(strprintf("Failed to calculate bump fees, because unconfirmed UTXOs depend on an enormous cluster of unconfirmed transactions.")));
88 }
89 CAmount new_total_fee = newFeerate.GetFee(maxTxSize) + combined_bump_fee.value();
90
91 CFeeRate incrementalRelayFee = wallet.chain().relayIncrementalFee();
92
93 // Min total fee is old fee + relay fee
94 CAmount minTotalFee = old_fee + incrementalRelayFee.GetFee(maxTxSize);
95
96 if (new_total_fee < minTotalFee) {
97 errors.push_back(Untranslated(strprintf("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)",
98 FormatMoney(new_total_fee), FormatMoney(minTotalFee), FormatMoney(old_fee), FormatMoney(incrementalRelayFee.GetFee(maxTxSize)))));
100 }
101
102 CAmount requiredFee = GetRequiredFee(wallet, maxTxSize);
103 if (new_total_fee < requiredFee) {
104 errors.push_back(Untranslated(strprintf("Insufficient total fee (cannot be less than required fee %s)",
105 FormatMoney(requiredFee))));
107 }
108
109 const CFeeRate new_feerate{new_total_fee, static_cast<int32_t>(maxTxSize)};
110 if (new_feerate > wallet.m_max_tx_fee_rate) {
111 errors.push_back(Untranslated(strprintf("New fee rate %s %s/kvB is too high (cannot be higher than -maxfeerate %s %s/kvB)",
112 FormatMoney(new_feerate.GetFeePerK()), CURRENCY_UNIT, FormatMoney(wallet.m_max_tx_fee_rate.GetFeePerK()), CURRENCY_UNIT)));
114 }
115
116 // Check that in all cases the new fee doesn't violate maxTxFee
117 const CAmount max_tx_fee = wallet.m_max_tx_fee;
118 if (new_total_fee > max_tx_fee) {
119 errors.push_back(Untranslated(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
120 FormatMoney(new_total_fee), FormatMoney(max_tx_fee))));
122 }
123
125}
126
127static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, const CCoinControl& coin_control)
128{
129 // Get the fee rate of the original transaction. This is calculated from
130 // the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
131 // result.
132 int64_t txSize = GetVirtualTransactionSize(*(wtx.GetTx()));
133 CFeeRate feerate(old_fee, txSize);
134 feerate += CFeeRate(1);
135
136 // The node has a configurable incremental relay fee. Increment the fee by
137 // the minimum of that and the wallet's conservative
138 // WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
139 // network wide policy for incremental relay fee that our node may not be
140 // aware of. This ensures we're over the required relay fee rate
141 // (Rule 4). The replacement tx will be at least as large as the
142 // original tx, so the total fee will be greater (Rule 3)
143 CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
144 CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
145 feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
146
147 // Fee rate must also be at least the wallet's GetMinimumFeeRate
148 CFeeRate min_feerate(GetMinimumFeeRate(wallet, coin_control).fee_rate);
149
150 // Set the required fee rate for the replacement transaction in coin control.
151 return std::max(feerate, min_feerate);
152}
153
154namespace feebumper {
155
156bool TransactionCanBeBumped(const CWallet& wallet, const Txid& txid)
157{
158 LOCK(wallet.cs_wallet);
159 const CWalletTx* wtx = wallet.GetWalletTx(txid);
160 if (wtx == nullptr) return false;
161
162 std::vector<bilingual_str> errors_dummy;
163 feebumper::Result res = PreconditionChecks(wallet, *wtx, /* require_mine=*/ true, errors_dummy);
164 return res == feebumper::Result::OK;
165}
166
167Result CreateRateBumpTransaction(CWallet& wallet, const Txid& txid, const CCoinControl& coin_control, std::vector<bilingual_str>& errors,
168 CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx, bool require_mine, const std::vector<CTxOut>& outputs, std::optional<uint32_t> original_change_index)
169{
170 // For now, cannot specify both new outputs to use and an output index to send change
171 if (!outputs.empty() && original_change_index.has_value()) {
172 errors.emplace_back(Untranslated("The options 'outputs' and 'original_change_index' are incompatible. You can only either specify a new set of outputs, or designate a change output to be recycled."));
174 }
175
176 // We are going to modify coin control later, copy to reuse
177 CCoinControl new_coin_control(coin_control);
178
179 LOCK(wallet.cs_wallet);
180 errors.clear();
181 auto it = wallet.mapWallet.find(txid);
182 if (it == wallet.mapWallet.end()) {
183 errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
185 }
186 const CWalletTx& wtx = it->second;
187 const CTransactionRef& tx = wtx.GetTx();
188
189 // Make sure that original_change_index is valid
190 if (original_change_index.has_value() && original_change_index.value() >= tx->vout.size()) {
191 errors.emplace_back(Untranslated("Change position is out of range"));
193 }
194
195 // Retrieve all of the UTXOs and add them to coin control
196 // While we're here, calculate the input amount
197 std::map<COutPoint, Coin> coins;
198 CAmount input_value = 0;
199 std::vector<CTxOut> spent_outputs;
200 for (const CTxIn& txin : tx->vin) {
201 coins[txin.prevout]; // Create empty map entry keyed by prevout.
202 }
203 wallet.chain().findCoins(coins);
204 for (const CTxIn& txin : tx->vin) {
205 const Coin& coin = coins.at(txin.prevout);
206 if (coin.out.IsNull()) {
207 errors.emplace_back(Untranslated(strprintf("%s:%u is already spent", txin.prevout.hash.GetHex(), txin.prevout.n)));
208 return Result::MISC_ERROR;
209 }
210 PreselectedInput& preset_txin = new_coin_control.Select(txin.prevout);
211 if (!wallet.IsMine(txin.prevout)) {
212 preset_txin.SetTxOut(coin.out);
213 }
214 input_value += coin.out.nValue;
215 spent_outputs.push_back(coin.out);
216 }
217
218 // Figure out if we need to compute the input weight, and do so if necessary
220 txdata.Init(*tx, std::move(spent_outputs), /* force=*/ true);
221 for (unsigned int i = 0; i < tx->vin.size(); ++i) {
222 const CTxIn& txin = tx->vin.at(i);
223 const Coin& coin = coins.at(txin.prevout);
224
225 if (new_coin_control.IsExternalSelected(txin.prevout)) {
226 // For external inputs, we estimate the size using the size of this input
227 int64_t input_weight = GetTransactionInputWeight(txin);
228 // Because signatures can have different sizes, we need to figure out all of the
229 // signature sizes and replace them with the max sized signature.
230 // In order to do this, we verify the script with a special SignatureChecker which
231 // will observe the signatures verified and record their sizes.
232 SignatureWeights weights;
233 TransactionSignatureChecker tx_checker(tx.get(), i, coin.out.nValue, txdata, MissingDataBehavior::FAIL);
234 SignatureWeightChecker size_checker(weights, tx_checker);
236 // Add the difference between max and current to input_weight so that it represents the largest the input could be
237 input_weight += weights.GetWeightDiffToMax();
238 new_coin_control.SetInputWeight(txin.prevout, input_weight);
239 }
240 }
241
242 Result result = PreconditionChecks(wallet, wtx, require_mine, errors);
243 if (result != Result::OK) {
244 return result;
245 }
246
247 // Calculate the old output amount.
248 CAmount output_value = 0;
249 for (const auto& old_output : tx->vout) {
250 output_value += old_output.nValue;
251 }
252
253 old_fee = input_value - output_value;
254
255 // Fill in recipients (and preserve a single change key if there
256 // is one). If outputs vector is non-empty, replace original
257 // outputs with its contents, otherwise use original outputs.
258 std::vector<CRecipient> recipients;
259 CAmount new_outputs_value = 0;
260 const auto& txouts = outputs.empty() ? tx->vout : outputs;
261 for (size_t i = 0; i < txouts.size(); ++i) {
262 const CTxOut& output = txouts.at(i);
263 CTxDestination dest;
264 ExtractDestination(output.scriptPubKey, dest);
265 if (original_change_index.has_value() ? original_change_index.value() == i : OutputIsChange(wallet, output)) {
266 new_coin_control.destChange = dest;
267 } else {
268 CRecipient recipient = {dest, output.nValue, false};
269 recipients.push_back(recipient);
270 }
271 new_outputs_value += output.nValue;
272 }
273
274 // If no recipients, means that we are sending coins to a change address
275 if (recipients.empty()) {
276 // Just as a sanity check, ensure that the change address exist
277 if (std::get_if<CNoDestination>(&new_coin_control.destChange)) {
278 errors.emplace_back(Untranslated("Unable to create transaction. Transaction must have at least one recipient"));
280 }
281
282 // Add change as recipient with SFFO flag enabled, so fees are deduced from it.
283 // If the output differs from the original tx output (because the user customized it) a new change output will be created.
284 recipients.emplace_back(CRecipient{new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true});
285 new_coin_control.destChange = CNoDestination();
286 }
287
288 if (coin_control.m_feerate) {
289 // The user provided a feeRate argument.
290 // We calculate this here to avoid compiler warning on the cs_wallet lock
291 // We need to make a temporary transaction with no input witnesses as the dummy signer expects them to be empty for external inputs
292 CMutableTransaction temp_mtx{*tx};
293 for (auto& txin : temp_mtx.vin) {
294 txin.scriptSig.clear();
295 txin.scriptWitness.SetNull();
296 }
297 temp_mtx.vout = txouts;
298 const int64_t maxTxSize{CalculateMaximumSignedTxSize(CTransaction(temp_mtx), &wallet, &new_coin_control).vsize};
299 Result res = CheckFeeRate(wallet, temp_mtx, *new_coin_control.m_feerate, maxTxSize, old_fee, errors);
300 if (res != Result::OK) {
301 return res;
302 }
303 } else {
304 // The user did not provide a feeRate argument
305 new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, old_fee, new_coin_control);
306 }
307
308 // Fill in required inputs we are double-spending(all of them)
309 // N.B.: bip125 doesn't require all the inputs in the replaced transaction to be
310 // used in the replacement transaction, but it's very important for wallets to make
311 // sure that happens. If not, it would be possible to bump a transaction A twice to
312 // A2 and A3 where A2 and A3 don't conflict (or alternatively bump A to A2 and A2
313 // to A3 where A and A3 don't conflict). If both later get confirmed then the sender
314 // has accidentally double paid.
315 for (const auto& inputs : tx->vin) {
316 new_coin_control.Select(COutPoint(inputs.prevout));
317 }
318 new_coin_control.m_allow_other_inputs = true;
319
320 // We cannot source new unconfirmed inputs(bip125 rule 2)
321 new_coin_control.m_min_depth = 1;
322
323 auto res = CreateTransaction(wallet, recipients, /*change_pos=*/std::nullopt, new_coin_control, false);
324 if (!res) {
325 errors.emplace_back(Untranslated("Unable to create transaction.") + Untranslated(" ") + util::ErrorString(res));
327 }
328
329 const auto& txr = *res;
330 // Write back new fee if successful
331 new_fee = txr.fee;
332
333 // Write back transaction
334 mtx = CMutableTransaction(*txr.tx);
335
336 return Result::OK;
337}
338
340 LOCK(wallet.cs_wallet);
341
342 if (wallet.IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
343 // Make a blank psbt
345
346 // First fill transaction with our data without signing,
347 // so external signers are not asked to sign more than once.
348 bool complete;
349 wallet.FillPSBT(psbtx, {.sign = false, .bip32_derivs = true}, complete);
350 auto err{wallet.FillPSBT(psbtx, {.sign = true, .bip32_derivs = false}, complete)};
351 if (err) return false;
352 complete = FinalizeAndExtractPSBT(psbtx, mtx);
353 return complete;
354 } else {
355 return wallet.SignTransaction(mtx);
356 }
357}
358
359Result CommitTransaction(CWallet& wallet, const Txid& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, Txid& bumped_txid)
360{
361 LOCK(wallet.cs_wallet);
362 if (!errors.empty()) {
363 return Result::MISC_ERROR;
364 }
365 auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
366 if (it == wallet.mapWallet.end()) {
367 errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
368 return Result::MISC_ERROR;
369 }
370 const CWalletTx& oldWtx = it->second;
371
372 // make sure the transaction still has no descendants and hasn't been mined in the meantime
373 Result result = PreconditionChecks(wallet, oldWtx, /* require_mine=*/ false, errors);
374 if (result != Result::OK) {
375 return result;
376 }
377
378 // commit/broadcast the tx
379 CTransactionRef tx = MakeTransactionRef(std::move(mtx));
380 wallet.CommitTransaction(tx, oldWtx.GetHash(), oldWtx.m_comment, oldWtx.m_comment_to, oldWtx.m_messages, oldWtx.m_payment_requests);
381
382 // mark the original tx as bumped
383 bumped_txid = tx->GetHash();
384 if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
385 errors.emplace_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced"));
386 }
387 return Result::OK;
388}
389
390} // namespace feebumper
391} // namespace wallet
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
Definition: addresstype.cpp:49
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Definition: addresstype.h:143
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Definition: feerate.h:32
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
Definition: feerate.h:71
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
Definition: feerate.cpp:21
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:30
uint32_t n
Definition: transaction.h:33
Txid hash
Definition: transaction.h:32
void clear()
Definition: script.h:569
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:287
An input of a transaction.
Definition: transaction.h:63
CScript scriptSig
Definition: transaction.h:66
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition: transaction.h:68
COutPoint prevout
Definition: transaction.h:65
An output of a transaction.
Definition: transaction.h:141
CScript scriptPubKey
Definition: transaction.h:144
CAmount nValue
Definition: transaction.h:143
bool IsNull() const
Definition: transaction.h:161
A UTXO entry.
Definition: coins.h:46
CTxOut out
unspent transaction output
Definition: coins.h:49
A version of CTransaction with the PSBT format.
Definition: psbt.h:1239
constexpr bool IsNull() const
Wrapped uint256 methods.
std::string GetHex() const
Coin Control Features.
Definition: coincontrol.h:83
PreselectedInput & Select(const COutPoint &outpoint)
Lock-in the given output for spending.
Definition: coincontrol.cpp:40
bool IsExternalSelected(const COutPoint &outpoint) const
Returns true if the given output is selected as an external input.
Definition: coincontrol.cpp:25
int m_min_depth
Minimum chain depth value for coin availability.
Definition: coincontrol.h:109
bool m_allow_other_inputs
If true, the selection process can add extra unselected inputs from the wallet while requires all sel...
Definition: coincontrol.h:93
void SetInputWeight(const COutPoint &outpoint, int64_t weight)
Set an input's weight.
Definition: coincontrol.cpp:67
std::optional< CFeeRate > m_feerate
Override the wallet's fee rate if set.
Definition: coincontrol.h:97
CTxDestination destChange
Custom change destination, if not set an address is generated.
Definition: coincontrol.h:86
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:318
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:194
std::vector< std::string > m_messages
Definition: transaction.h:207
const Txid & GetHash() const LIFETIMEBOUND
Definition: transaction.h:390
std::optional< std::string > m_comment_to
Definition: transaction.h:203
std::optional< std::string > m_comment
Definition: transaction.h:202
std::vector< std::string > m_payment_requests
Definition: transaction.h:209
CTransactionRef GetTx() const
Definition: transaction.h:351
void SetTxOut(const CTxOut &txout)
Set the previous output for this input.
Definition: coincontrol.cpp:90
static int64_t GetTransactionInputWeight(const CTxIn &txin)
Definition: validation.h:147
const std::string CURRENCY_UNIT
Definition: feerate.h:19
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, script_verify_flags flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ FAIL
Just act as if the signature was invalid.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
Definition: moneystr.cpp:19
bilingual_str ErrorString(const Result< T > &result)
Definition: result.h:93
Result CreateRateBumpTransaction(CWallet &wallet, const Txid &txid, const CCoinControl &coin_control, std::vector< bilingual_str > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx, bool require_mine, const std::vector< CTxOut > &outputs, std::optional< uint32_t > original_change_index)
Create bumpfee transaction based on feerate estimates.
Definition: feebumper.cpp:167
bool TransactionCanBeBumped(const CWallet &wallet, const Txid &txid)
Return whether transaction can be bumped.
Definition: feebumper.cpp:156
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
Definition: feebumper.cpp:339
Result CommitTransaction(CWallet &wallet, const Txid &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, Txid &bumped_txid)
Commit the bumpfee transaction.
Definition: feebumper.cpp:359
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:74
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Definition: spend.cpp:1448
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx)
Returns whether all of the inputs belong to the wallet.
Definition: receive.cpp:23
MinimumFeeRateResult GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control)
Estimate the minimum fee rate considering user set parameters and the required fee.
Definition: fees.cpp:32
static feebumper::Result PreconditionChecks(const CWallet &wallet, const CWalletTx &wtx, bool require_mine, std::vector< bilingual_str > &errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Check whether transaction has descendant in wallet or mempool, or has been mined, or conflicts with a...
Definition: feebumper.cpp:24
constexpr CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for replacement txs
Definition: wallet.h:127
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, const CCoinControl &coin_control)
Definition: feebumper.cpp:127
static feebumper::Result CheckFeeRate(const CWallet &wallet, const CMutableTransaction &mtx, const CFeeRate &newFeerate, const int64_t maxTxSize, CAmount old_fee, std::vector< bilingual_str > &errors)
Check if the user provided a valid feeRate.
Definition: feebumper.cpp:61
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, const CCoinControl *coin_control)
Calculate the size of the transaction using CoinControl to determine whether to expect signature grin...
Definition: spend.cpp:144
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:56
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
Definition: fees.cpp:16
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:395
constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
Definition: policy.h:118
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:418
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:417
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
Definition: psbt.cpp:818
A mutable version of CTransaction.
Definition: transaction.h:372
std::vector< CTxIn > vin
Definition: transaction.h:373
void SetNull()
Definition: script.h:588
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
int64_t vsize
Definition: spend.h:28
int64_t GetWeightDiffToMax() const
Definition: feebumper.h:99
#define LOCK(cs)
Definition: sync.h:268
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1172
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:82