Bitcoin Core 29.99.0
P2P Digital Currency
feebumper.cpp
Go to the documentation of this file.
1// Copyright (c) 2017-2022 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 <common/system.h>
7#include <interfaces/chain.h>
8#include <node/types.h>
9#include <policy/fees.h>
10#include <policy/policy.h>
11#include <util/moneystr.h>
12#include <util/rbf.h>
13#include <util/translation.h>
14#include <wallet/coincontrol.h>
15#include <wallet/feebumper.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.tx)) {
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.mapValue.count("replaced_by_txid")) {
44 errors.push_back(Untranslated(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid"))));
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)
52 if (!AllInputsMine(wallet, *wtx.tx, filter)) {
53 errors.emplace_back(Untranslated("Transaction contains inputs that don't belong to this wallet"));
55 }
56 }
57
59}
60
62static feebumper::Result CheckFeeRate(const CWallet& wallet, const CMutableTransaction& mtx, const CFeeRate& newFeerate, const int64_t maxTxSize, CAmount old_fee, std::vector<bilingual_str>& errors)
63{
64 // check that fee rate is higher than mempool's minimum fee
65 // (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
66 // This may occur if the user set fee_rate or paytxfee too low, if fallbackfee is too low, or, perhaps,
67 // in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
68 // moment earlier. In this case, we report an error to the user, who may adjust the fee.
69 CFeeRate minMempoolFeeRate = wallet.chain().mempoolMinFee();
70
71 if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
72 errors.push_back(Untranslated(
73 strprintf("New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ",
74 FormatMoney(newFeerate.GetFeePerK()),
75 FormatMoney(minMempoolFeeRate.GetFeePerK()))));
77 }
78
79 std::vector<COutPoint> reused_inputs;
80 reused_inputs.reserve(mtx.vin.size());
81 for (const CTxIn& txin : mtx.vin) {
82 reused_inputs.push_back(txin.prevout);
83 }
84
85 std::optional<CAmount> combined_bump_fee = wallet.chain().calculateCombinedBumpFee(reused_inputs, newFeerate);
86 if (!combined_bump_fee.has_value()) {
87 errors.push_back(Untranslated(strprintf("Failed to calculate bump fees, because unconfirmed UTXOs depend on 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 // Check that in all cases the new fee doesn't violate maxTxFee
110 const CAmount max_tx_fee = wallet.m_default_max_tx_fee;
111 if (new_total_fee > max_tx_fee) {
112 errors.push_back(Untranslated(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
113 FormatMoney(new_total_fee), FormatMoney(max_tx_fee))));
115 }
116
118}
119
120static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, const CCoinControl& coin_control)
121{
122 // Get the fee rate of the original transaction. This is calculated from
123 // the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
124 // result.
125 int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
126 CFeeRate feerate(old_fee, txSize);
127 feerate += CFeeRate(1);
128
129 // The node has a configurable incremental relay fee. Increment the fee by
130 // the minimum of that and the wallet's conservative
131 // WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
132 // network wide policy for incremental relay fee that our node may not be
133 // aware of. This ensures we're over the required relay fee rate
134 // (Rule 4). The replacement tx will be at least as large as the
135 // original tx, so the total fee will be greater (Rule 3)
136 CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
137 CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
138 feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
139
140 // Fee rate must also be at least the wallet's GetMinimumFeeRate
141 CFeeRate min_feerate(GetMinimumFeeRate(wallet, coin_control, /*feeCalc=*/nullptr));
142
143 // Set the required fee rate for the replacement transaction in coin control.
144 return std::max(feerate, min_feerate);
145}
146
147namespace feebumper {
148
150{
151 LOCK(wallet.cs_wallet);
152 const CWalletTx* wtx = wallet.GetWalletTx(txid);
153 if (wtx == nullptr) return false;
154
155 std::vector<bilingual_str> errors_dummy;
156 feebumper::Result res = PreconditionChecks(wallet, *wtx, /* require_mine=*/ true, errors_dummy);
157 return res == feebumper::Result::OK;
158}
159
160Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<bilingual_str>& errors,
161 CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx, bool require_mine, const std::vector<CTxOut>& outputs, std::optional<uint32_t> original_change_index)
162{
163 // For now, cannot specify both new outputs to use and an output index to send change
164 if (!outputs.empty() && original_change_index.has_value()) {
165 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."));
167 }
168
169 // We are going to modify coin control later, copy to reuse
170 CCoinControl new_coin_control(coin_control);
171
172 LOCK(wallet.cs_wallet);
173 errors.clear();
174 auto it = wallet.mapWallet.find(txid);
175 if (it == wallet.mapWallet.end()) {
176 errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
178 }
179 const CWalletTx& wtx = it->second;
180
181 // Make sure that original_change_index is valid
182 if (original_change_index.has_value() && original_change_index.value() >= wtx.tx->vout.size()) {
183 errors.emplace_back(Untranslated("Change position is out of range"));
185 }
186
187 // Retrieve all of the UTXOs and add them to coin control
188 // While we're here, calculate the input amount
189 std::map<COutPoint, Coin> coins;
190 CAmount input_value = 0;
191 std::vector<CTxOut> spent_outputs;
192 for (const CTxIn& txin : wtx.tx->vin) {
193 coins[txin.prevout]; // Create empty map entry keyed by prevout.
194 }
195 wallet.chain().findCoins(coins);
196 for (const CTxIn& txin : wtx.tx->vin) {
197 const Coin& coin = coins.at(txin.prevout);
198 if (coin.out.IsNull()) {
199 errors.emplace_back(Untranslated(strprintf("%s:%u is already spent", txin.prevout.hash.GetHex(), txin.prevout.n)));
200 return Result::MISC_ERROR;
201 }
202 PreselectedInput& preset_txin = new_coin_control.Select(txin.prevout);
203 if (!wallet.IsMine(txin.prevout)) {
204 preset_txin.SetTxOut(coin.out);
205 }
206 input_value += coin.out.nValue;
207 spent_outputs.push_back(coin.out);
208 }
209
210 // Figure out if we need to compute the input weight, and do so if necessary
212 txdata.Init(*wtx.tx, std::move(spent_outputs), /* force=*/ true);
213 for (unsigned int i = 0; i < wtx.tx->vin.size(); ++i) {
214 const CTxIn& txin = wtx.tx->vin.at(i);
215 const Coin& coin = coins.at(txin.prevout);
216
217 if (new_coin_control.IsExternalSelected(txin.prevout)) {
218 // For external inputs, we estimate the size using the size of this input
219 int64_t input_weight = GetTransactionInputWeight(txin);
220 // Because signatures can have different sizes, we need to figure out all of the
221 // signature sizes and replace them with the max sized signature.
222 // In order to do this, we verify the script with a special SignatureChecker which
223 // will observe the signatures verified and record their sizes.
224 SignatureWeights weights;
225 TransactionSignatureChecker tx_checker(wtx.tx.get(), i, coin.out.nValue, txdata, MissingDataBehavior::FAIL);
226 SignatureWeightChecker size_checker(weights, tx_checker);
228 // Add the difference between max and current to input_weight so that it represents the largest the input could be
229 input_weight += weights.GetWeightDiffToMax();
230 new_coin_control.SetInputWeight(txin.prevout, input_weight);
231 }
232 }
233
234 Result result = PreconditionChecks(wallet, wtx, require_mine, errors);
235 if (result != Result::OK) {
236 return result;
237 }
238
239 // Calculate the old output amount.
240 CAmount output_value = 0;
241 for (const auto& old_output : wtx.tx->vout) {
242 output_value += old_output.nValue;
243 }
244
245 old_fee = input_value - output_value;
246
247 // Fill in recipients (and preserve a single change key if there
248 // is one). If outputs vector is non-empty, replace original
249 // outputs with its contents, otherwise use original outputs.
250 std::vector<CRecipient> recipients;
251 CAmount new_outputs_value = 0;
252 const auto& txouts = outputs.empty() ? wtx.tx->vout : outputs;
253 for (size_t i = 0; i < txouts.size(); ++i) {
254 const CTxOut& output = txouts.at(i);
255 CTxDestination dest;
256 ExtractDestination(output.scriptPubKey, dest);
257 if (original_change_index.has_value() ? original_change_index.value() == i : OutputIsChange(wallet, output)) {
258 new_coin_control.destChange = dest;
259 } else {
260 CRecipient recipient = {dest, output.nValue, false};
261 recipients.push_back(recipient);
262 }
263 new_outputs_value += output.nValue;
264 }
265
266 // If no recipients, means that we are sending coins to a change address
267 if (recipients.empty()) {
268 // Just as a sanity check, ensure that the change address exist
269 if (std::get_if<CNoDestination>(&new_coin_control.destChange)) {
270 errors.emplace_back(Untranslated("Unable to create transaction. Transaction must have at least one recipient"));
272 }
273
274 // Add change as recipient with SFFO flag enabled, so fees are deduced from it.
275 // If the output differs from the original tx output (because the user customized it) a new change output will be created.
276 recipients.emplace_back(CRecipient{new_coin_control.destChange, new_outputs_value, /*fSubtractFeeFromAmount=*/true});
277 new_coin_control.destChange = CNoDestination();
278 }
279
280 if (coin_control.m_feerate) {
281 // The user provided a feeRate argument.
282 // We calculate this here to avoid compiler warning on the cs_wallet lock
283 // We need to make a temporary transaction with no input witnesses as the dummy signer expects them to be empty for external inputs
284 CMutableTransaction temp_mtx{*wtx.tx};
285 for (auto& txin : temp_mtx.vin) {
286 txin.scriptSig.clear();
287 txin.scriptWitness.SetNull();
288 }
289 temp_mtx.vout = txouts;
290 const int64_t maxTxSize{CalculateMaximumSignedTxSize(CTransaction(temp_mtx), &wallet, &new_coin_control).vsize};
291 Result res = CheckFeeRate(wallet, temp_mtx, *new_coin_control.m_feerate, maxTxSize, old_fee, errors);
292 if (res != Result::OK) {
293 return res;
294 }
295 } else {
296 // The user did not provide a feeRate argument
297 new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, old_fee, new_coin_control);
298 }
299
300 // Fill in required inputs we are double-spending(all of them)
301 // N.B.: bip125 doesn't require all the inputs in the replaced transaction to be
302 // used in the replacement transaction, but it's very important for wallets to make
303 // sure that happens. If not, it would be possible to bump a transaction A twice to
304 // A2 and A3 where A2 and A3 don't conflict (or alternatively bump A to A2 and A2
305 // to A3 where A and A3 don't conflict). If both later get confirmed then the sender
306 // has accidentally double paid.
307 for (const auto& inputs : wtx.tx->vin) {
308 new_coin_control.Select(COutPoint(inputs.prevout));
309 }
310 new_coin_control.m_allow_other_inputs = true;
311
312 // We cannot source new unconfirmed inputs(bip125 rule 2)
313 new_coin_control.m_min_depth = 1;
314
315 auto res = CreateTransaction(wallet, recipients, /*change_pos=*/std::nullopt, new_coin_control, false);
316 if (!res) {
317 errors.emplace_back(Untranslated("Unable to create transaction.") + Untranslated(" ") + util::ErrorString(res));
319 }
320
321 const auto& txr = *res;
322 // Write back new fee if successful
323 new_fee = txr.fee;
324
325 // Write back transaction
326 mtx = CMutableTransaction(*txr.tx);
327
328 return Result::OK;
329}
330
332 LOCK(wallet.cs_wallet);
333
334 if (wallet.IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)) {
335 // Make a blank psbt
337
338 // First fill transaction with our data without signing,
339 // so external signers are not asked to sign more than once.
340 bool complete;
341 wallet.FillPSBT(psbtx, complete, SIGHASH_ALL, false /* sign */, true /* bip32derivs */);
342 auto err{wallet.FillPSBT(psbtx, complete, SIGHASH_ALL, true /* sign */, false /* bip32derivs */)};
343 if (err) return false;
344 complete = FinalizeAndExtractPSBT(psbtx, mtx);
345 return complete;
346 } else {
347 return wallet.SignTransaction(mtx);
348 }
349}
350
351Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<bilingual_str>& errors, uint256& bumped_txid)
352{
353 LOCK(wallet.cs_wallet);
354 if (!errors.empty()) {
355 return Result::MISC_ERROR;
356 }
357 auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
358 if (it == wallet.mapWallet.end()) {
359 errors.emplace_back(Untranslated("Invalid or non-wallet transaction id"));
360 return Result::MISC_ERROR;
361 }
362 const CWalletTx& oldWtx = it->second;
363
364 // make sure the transaction still has no descendants and hasn't been mined in the meantime
365 Result result = PreconditionChecks(wallet, oldWtx, /* require_mine=*/ false, errors);
366 if (result != Result::OK) {
367 return result;
368 }
369
370 // commit/broadcast the tx
371 CTransactionRef tx = MakeTransactionRef(std::move(mtx));
372 mapValue_t mapValue = oldWtx.mapValue;
373 mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
374
375 wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm);
376
377 // mark the original tx as bumped
378 bumped_txid = tx->GetHash();
379 if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
380 errors.emplace_back(Untranslated("Created new bumpfee transaction but could not mark the original transaction as replaced"));
381 }
382 return Result::OK;
383}
384
385} // namespace feebumper
386} // 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 kilovirtualbyte: CAmount / kvB.
Definition: feerate.h:33
CAmount GetFee(uint32_t num_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
Definition: feerate.cpp:23
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
Definition: feerate.h:63
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
uint32_t n
Definition: transaction.h:32
Txid hash
Definition: transaction.h:31
void clear()
Definition: script.h:576
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:296
An input of a transaction.
Definition: transaction.h:67
CScript scriptSig
Definition: transaction.h:70
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition: transaction.h:72
COutPoint prevout
Definition: transaction.h:69
An output of a transaction.
Definition: transaction.h:150
CScript scriptPubKey
Definition: transaction.h:153
CAmount nValue
Definition: transaction.h:152
bool IsNull() const
Definition: transaction.h:170
A UTXO entry.
Definition: coins.h:33
CTxOut out
unspent transaction output
Definition: coins.h:36
constexpr bool IsNull() const
Definition: uint256.h:48
std::string ToString() const
std::string GetHex() const
256-bit opaque blob.
Definition: uint256.h:196
Coin Control Features.
Definition: coincontrol.h:81
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:91
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 m_pay_tx_fee if set.
Definition: coincontrol.h:97
CTxDestination destChange
Custom change destination, if not set an address is generated.
Definition: coincontrol.h:84
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:300
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:177
const Txid & GetHash() const LIFETIMEBOUND
Definition: transaction.h:351
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: transaction.h:205
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: transaction.h:204
CTransactionRef tx
Definition: transaction.h:258
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:140
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ SIGHASH_ALL
Definition: interpreter.h:30
@ 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 uint256 &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:160
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
Definition: feebumper.cpp:351
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
Definition: feebumper.cpp:331
bool TransactionCanBeBumped(const CWallet &wallet, const uint256 &txid)
Return whether transaction can be bumped.
Definition: feebumper.cpp:149
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:73
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:1368
std::map< std::string, std::string > mapValue_t
Definition: transaction.h:149
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
std::underlying_type_t< isminetype > isminefilter
used for bitflags of isminetype
Definition: wallet.h:48
CFeeRate GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control, FeeCalculation *feeCalc)
Estimate the minimum fee rate considering user set parameters and the required fee.
Definition: fees.cpp:29
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, const CCoinControl &coin_control)
Definition: feebumper.cpp:120
@ ISMINE_SPENDABLE
Definition: types.h:44
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:22
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for replacement txs
Definition: wallet.h:124
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:62
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:142
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
Definition: walletutil.h:77
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:13
is a home for public enum and struct type definitions that are used internally by node code,...
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:310
static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
Definition: policy.h:114
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:424
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:423
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:495
A mutable version of CTransaction.
Definition: transaction.h:378
std::vector< CTxIn > vin
Definition: transaction.h:379
void SetNull()
Definition: script.h:595
A version of CTransaction with the PSBT format.
Definition: psbt.h:1111
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:23
int64_t GetWeightDiffToMax() const
Definition: feebumper.h:99
#define LOCK(cs)
Definition: sync.h:257
#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