Bitcoin Core  0.19.99
P2P Digital Currency
feebumper.cpp
Go to the documentation of this file.
1 // Copyright (c) 2017-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 #include <interfaces/chain.h>
6 #include <wallet/coincontrol.h>
7 #include <wallet/feebumper.h>
8 #include <wallet/fees.h>
9 #include <wallet/wallet.h>
10 #include <policy/fees.h>
11 #include <policy/policy.h>
12 #include <util/moneystr.h>
13 #include <util/rbf.h>
14 #include <util/system.h>
15 #include <util/validation.h>
16 
19 static feebumper::Result PreconditionChecks(const CWallet& wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
20 {
21  if (wallet.HasWalletSpend(wtx.GetHash())) {
22  errors.push_back("Transaction has descendants in the wallet");
24  }
25 
26  {
27  if (wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
28  errors.push_back("Transaction has descendants in the mempool");
30  }
31  }
32 
33  if (wtx.GetDepthInMainChain() != 0) {
34  errors.push_back("Transaction has been mined, or is conflicted with a mined transaction");
36  }
37 
38  if (!SignalsOptInRBF(*wtx.tx)) {
39  errors.push_back("Transaction is not BIP 125 replaceable");
41  }
42 
43  if (wtx.mapValue.count("replaced_by_txid")) {
44  errors.push_back(strprintf("Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.mapValue.at("replaced_by_txid")));
46  }
47 
48  // check that original tx consists entirely of our inputs
49  // 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)
50  isminefilter filter = wallet.GetLegacyScriptPubKeyMan() && wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) ? ISMINE_WATCH_ONLY : ISMINE_SPENDABLE;
51  if (!wallet.IsAllFromMe(*wtx.tx, filter)) {
52  errors.push_back("Transaction contains inputs that don't belong to this wallet");
54  }
55 
56 
57  return feebumper::Result::OK;
58 }
59 
61 static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CFeeRate& newFeerate, const int64_t maxTxSize, std::vector<std::string>& errors) {
62  // check that fee rate is higher than mempool's minimum fee
63  // (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
64  // This may occur if the user set FeeRate, TotalFee or paytxfee too low, if fallbackfee is too low, or, perhaps,
65  // in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
66  // moment earlier. In this case, we report an error to the user, who may adjust the fee.
67  CFeeRate minMempoolFeeRate = wallet.chain().mempoolMinFee();
68 
69  if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
70  errors.push_back(strprintf(
71  "New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ",
72  FormatMoney(newFeerate.GetFeePerK()),
73  FormatMoney(minMempoolFeeRate.GetFeePerK())));
75  }
76 
77  CAmount new_total_fee = newFeerate.GetFee(maxTxSize);
78 
80 
81  // Given old total fee and transaction size, calculate the old feeRate
83  CAmount old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
84  const int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
85  CFeeRate nOldFeeRate(old_fee, txSize);
86  // Min total fee is old fee + relay fee
87  CAmount minTotalFee = nOldFeeRate.GetFee(maxTxSize) + incrementalRelayFee.GetFee(maxTxSize);
88 
89  if (new_total_fee < minTotalFee) {
90  errors.push_back(strprintf("Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)",
91  FormatMoney(new_total_fee), FormatMoney(minTotalFee), FormatMoney(nOldFeeRate.GetFee(maxTxSize)), FormatMoney(incrementalRelayFee.GetFee(maxTxSize))));
93  }
94 
95  CAmount requiredFee = GetRequiredFee(wallet, maxTxSize);
96  if (new_total_fee < requiredFee) {
97  errors.push_back(strprintf("Insufficient total fee (cannot be less than required fee %s)",
98  FormatMoney(requiredFee)));
100  }
101 
102  // Check that in all cases the new fee doesn't violate maxTxFee
103  const CAmount max_tx_fee = wallet.m_default_max_tx_fee;
104  if (new_total_fee > max_tx_fee) {
105  errors.push_back(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
106  FormatMoney(new_total_fee), FormatMoney(max_tx_fee)));
108  }
109 
110  return feebumper::Result::OK;
111 }
112 
113 static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, CCoinControl& coin_control)
114 {
115  // Get the fee rate of the original transaction. This is calculated from
116  // the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
117  // result.
118  int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
119  CFeeRate feerate(old_fee, txSize);
120  feerate += CFeeRate(1);
121 
122  // The node has a configurable incremental relay fee. Increment the fee by
123  // the minimum of that and the wallet's conservative
124  // WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
125  // network wide policy for incremental relay fee that our node may not be
126  // aware of. This ensures we're over the required relay fee rate
127  // (BIP 125 rule 4). The replacement tx will be at least as large as the
128  // original tx, so the total fee will be greater (BIP 125 rule 3)
129  CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
130  CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
131  feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
132 
133  // Fee rate must also be at least the wallet's GetMinimumFeeRate
134  CFeeRate min_feerate(GetMinimumFeeRate(wallet, coin_control, /* feeCalc */ nullptr));
135 
136  // Set the required fee rate for the replacement transaction in coin control.
137  return std::max(feerate, min_feerate);
138 }
139 
140 namespace feebumper {
141 
142 bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
143 {
144  auto locked_chain = wallet.chain().lock();
145  LOCK(wallet.cs_wallet);
146  const CWalletTx* wtx = wallet.GetWalletTx(txid);
147  if (wtx == nullptr) return false;
148 
149  std::vector<std::string> errors_dummy;
150  feebumper::Result res = PreconditionChecks(wallet, *wtx, errors_dummy);
151  return res == feebumper::Result::OK;
152 }
153 
154 Result CreateTotalBumpTransaction(const CWallet* wallet, const uint256& txid, const CCoinControl& coin_control, CAmount total_fee, std::vector<std::string>& errors,
155  CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx)
156 {
157  new_fee = total_fee;
158 
159  auto locked_chain = wallet->chain().lock();
160  LOCK(wallet->cs_wallet);
161  errors.clear();
162  auto it = wallet->mapWallet.find(txid);
163  if (it == wallet->mapWallet.end()) {
164  errors.push_back("Invalid or non-wallet transaction id");
166  }
167  const CWalletTx& wtx = it->second;
168 
169  Result result = PreconditionChecks(*wallet, wtx, errors);
170  if (result != Result::OK) {
171  return result;
172  }
173 
174  // figure out which output was change
175  // if there was no change output or multiple change outputs, fail
176  int nOutput = -1;
177  for (size_t i = 0; i < wtx.tx->vout.size(); ++i) {
178  if (wallet->IsChange(wtx.tx->vout[i])) {
179  if (nOutput != -1) {
180  errors.push_back("Transaction has multiple change outputs");
181  return Result::WALLET_ERROR;
182  }
183  nOutput = i;
184  }
185  }
186  if (nOutput == -1) {
187  errors.push_back("Transaction does not have a change output");
188  return Result::WALLET_ERROR;
189  }
190 
191  // Calculate the expected size of the new transaction.
192  int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
193  const int64_t maxNewTxSize = CalculateMaximumSignedTxSize(*wtx.tx, wallet);
194  if (maxNewTxSize < 0) {
195  errors.push_back("Transaction contains inputs that cannot be signed");
197  }
198 
199  // calculate the old fee and fee-rate
201  old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
202  CFeeRate nOldFeeRate(old_fee, txSize);
203  // The wallet uses a conservative WALLET_INCREMENTAL_RELAY_FEE value to
204  // future proof against changes to network wide policy for incremental relay
205  // fee that our node may not be aware of.
206  CFeeRate nodeIncrementalRelayFee = wallet->chain().relayIncrementalFee();
207  CFeeRate walletIncrementalRelayFee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
208  if (nodeIncrementalRelayFee > walletIncrementalRelayFee) {
209  walletIncrementalRelayFee = nodeIncrementalRelayFee;
210  }
211 
212  CAmount minTotalFee = nOldFeeRate.GetFee(maxNewTxSize) + nodeIncrementalRelayFee.GetFee(maxNewTxSize);
213  if (total_fee < minTotalFee) {
214  errors.push_back(strprintf("Insufficient totalFee, must be at least %s (oldFee %s + incrementalFee %s)",
215  FormatMoney(minTotalFee), FormatMoney(nOldFeeRate.GetFee(maxNewTxSize)), FormatMoney(nodeIncrementalRelayFee.GetFee(maxNewTxSize))));
217  }
218  CAmount requiredFee = GetRequiredFee(*wallet, maxNewTxSize);
219  if (total_fee < requiredFee) {
220  errors.push_back(strprintf("Insufficient totalFee (cannot be less than required fee %s)",
221  FormatMoney(requiredFee)));
223  }
224 
225  // Check that in all cases the new fee doesn't violate maxTxFee
226  const CAmount max_tx_fee = wallet->m_default_max_tx_fee;
227  if (new_fee > max_tx_fee) {
228  errors.push_back(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
229  FormatMoney(new_fee), FormatMoney(max_tx_fee)));
230  return Result::WALLET_ERROR;
231  }
232 
233  // check that fee rate is higher than mempool's minimum fee
234  // (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
235  // This may occur if the user set TotalFee or paytxfee too low, if fallbackfee is too low, or, perhaps,
236  // in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
237  // moment earlier. In this case, we report an error to the user, who may use total_fee to make an adjustment.
238  CFeeRate minMempoolFeeRate = wallet->chain().mempoolMinFee();
239  CFeeRate nNewFeeRate = CFeeRate(total_fee, maxNewTxSize);
240  if (nNewFeeRate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
241  errors.push_back(strprintf(
242  "New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- "
243  "the totalFee value should be at least %s to add transaction",
244  FormatMoney(nNewFeeRate.GetFeePerK()),
245  FormatMoney(minMempoolFeeRate.GetFeePerK()),
246  FormatMoney(minMempoolFeeRate.GetFee(maxNewTxSize))));
247  return Result::WALLET_ERROR;
248  }
249 
250  // Now modify the output to increase the fee.
251  // If the output is not large enough to pay the fee, fail.
252  CAmount nDelta = new_fee - old_fee;
253  assert(nDelta > 0);
254  mtx = CMutableTransaction{*wtx.tx};
255  CTxOut* poutput = &(mtx.vout[nOutput]);
256  if (poutput->nValue < nDelta) {
257  errors.push_back("Change output is too small to bump the fee");
258  return Result::WALLET_ERROR;
259  }
260 
261  // If the output would become dust, discard it (converting the dust to fee)
262  poutput->nValue -= nDelta;
263  if (poutput->nValue <= GetDustThreshold(*poutput, GetDiscardRate(*wallet))) {
264  wallet->WalletLogPrintf("Bumping fee and discarding dust output\n");
265  new_fee += poutput->nValue;
266  mtx.vout.erase(mtx.vout.begin() + nOutput);
267  }
268 
269  // Mark new tx not replaceable, if requested.
270  if (!coin_control.m_signal_bip125_rbf.get_value_or(wallet->m_signal_rbf)) {
271  for (auto& input : mtx.vin) {
272  if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
273  }
274  }
275 
276  return Result::OK;
277 }
278 
279 
280 Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<std::string>& errors,
281  CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx)
282 {
283  // We are going to modify coin control later, copy to re-use
284  CCoinControl new_coin_control(coin_control);
285 
286  auto locked_chain = wallet.chain().lock();
287  LOCK(wallet.cs_wallet);
288  errors.clear();
289  auto it = wallet.mapWallet.find(txid);
290  if (it == wallet.mapWallet.end()) {
291  errors.push_back("Invalid or non-wallet transaction id");
293  }
294  const CWalletTx& wtx = it->second;
295 
296  Result result = PreconditionChecks(wallet, wtx, errors);
297  if (result != Result::OK) {
298  return result;
299  }
300 
301  // Fill in recipients(and preserve a single change key if there is one)
302  std::vector<CRecipient> recipients;
303  for (const auto& output : wtx.tx->vout) {
304  if (!wallet.IsChange(output)) {
305  CRecipient recipient = {output.scriptPubKey, output.nValue, false};
306  recipients.push_back(recipient);
307  } else {
308  CTxDestination change_dest;
309  ExtractDestination(output.scriptPubKey, change_dest);
310  new_coin_control.destChange = change_dest;
311  }
312  }
313 
315  old_fee = wtx.GetDebit(filter) - wtx.tx->GetValueOut();
316 
317  if (coin_control.m_feerate) {
318  // The user provided a feeRate argument.
319  // We calculate this here to avoid compiler warning on the cs_wallet lock
320  const int64_t maxTxSize = CalculateMaximumSignedTxSize(*wtx.tx, &wallet);
321  Result res = CheckFeeRate(wallet, wtx, *new_coin_control.m_feerate, maxTxSize, errors);
322  if (res != Result::OK) {
323  return res;
324  }
325  } else {
326  // The user did not provide a feeRate argument
327  new_coin_control.m_feerate = EstimateFeeRate(wallet, wtx, old_fee, new_coin_control);
328  }
329 
330  // Fill in required inputs we are double-spending(all of them)
331  // N.B.: bip125 doesn't require all the inputs in the replaced transaction to be
332  // used in the replacement transaction, but it's very important for wallets to make
333  // sure that happens. If not, it would be possible to bump a transaction A twice to
334  // A2 and A3 where A2 and A3 don't conflict (or alternatively bump A to A2 and A2
335  // to A3 where A and A3 don't conflict). If both later get confirmed then the sender
336  // has accidentally double paid.
337  for (const auto& inputs : wtx.tx->vin) {
338  new_coin_control.Select(COutPoint(inputs.prevout));
339  }
340  new_coin_control.fAllowOtherInputs = true;
341 
342  // We cannot source new unconfirmed inputs(bip125 rule 2)
343  new_coin_control.m_min_depth = 1;
344 
346  CAmount fee_ret;
347  int change_pos_in_out = -1; // No requested location for change
348  std::string fail_reason;
349  if (!wallet.CreateTransaction(*locked_chain, recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, false)) {
350  errors.push_back("Unable to create transaction: " + fail_reason);
351  return Result::WALLET_ERROR;
352  }
353 
354  // Write back new fee if successful
355  new_fee = fee_ret;
356 
357  // Write back transaction
358  mtx = CMutableTransaction(*tx_new);
359  // Mark new tx not replaceable, if requested.
360  if (!coin_control.m_signal_bip125_rbf.get_value_or(wallet.m_signal_rbf)) {
361  for (auto& input : mtx.vin) {
362  if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
363  }
364  }
365 
366  return Result::OK;
367 }
368 
370  auto locked_chain = wallet.chain().lock();
371  LOCK(wallet.cs_wallet);
372  return wallet.SignTransaction(mtx);
373 }
374 
375 Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<std::string>& errors, uint256& bumped_txid)
376 {
377  auto locked_chain = wallet.chain().lock();
378  LOCK(wallet.cs_wallet);
379  if (!errors.empty()) {
380  return Result::MISC_ERROR;
381  }
382  auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
383  if (it == wallet.mapWallet.end()) {
384  errors.push_back("Invalid or non-wallet transaction id");
385  return Result::MISC_ERROR;
386  }
387  CWalletTx& oldWtx = it->second;
388 
389  // make sure the transaction still has no descendants and hasn't been mined in the meantime
390  Result result = PreconditionChecks(wallet, oldWtx, errors);
391  if (result != Result::OK) {
392  return result;
393  }
394 
395  // commit/broadcast the tx
396  CTransactionRef tx = MakeTransactionRef(std::move(mtx));
397  mapValue_t mapValue = oldWtx.mapValue;
398  mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
399 
400  wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm);
401 
402  // mark the original tx as bumped
403  bumped_txid = tx->GetHash();
404  if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
405  // TODO: see if JSON-RPC has a standard way of returning a response
406  // along with an exception. It would be good to return information about
407  // wtxBumped to the caller even if marking the original transaction
408  // replaced does not succeed for some reason.
409  errors.push_back("Created new bumpfee transaction but could not mark the original transaction as replaced");
410  }
411  return Result::OK;
412 }
413 
414 } // namespace feebumper
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:408
CAmount nValue
Definition: transaction.h:136
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
Definition: wallet.cpp:1377
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
Definition: feebumper.cpp:369
const CWalletTx * GetWalletTx(const uint256 &hash) const
Definition: wallet.cpp:255
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:156
std::map< std::string, std::string > mapValue_t
Definition: wallet.h:198
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< std::string > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
Definition: feebumper.cpp:375
virtual CFeeRate mempoolMinFee()=0
Mempool minimum fee.
#define strprintf
Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for...
Definition: tinyformat.h:1164
std::vector< CTxIn > vin
Definition: transaction.h:368
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
Definition: wallet.cpp:1819
static CTransactionRef MakeTransactionRef()
Definition: transaction.h:409
bool CreateTransaction(interfaces::Chain::Lock &locked_chain, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, 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: wallet.cpp:2583
CFeeRate GetDiscardRate(const CWallet &wallet)
Return the maximum feerate for discarding change.
Definition: fees.cpp:83
int m_min_depth
Minimum chain depth value for coin availability.
Definition: coincontrol.h:48
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
Definition: wallet.h:969
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:238
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
Definition: moneystr.cpp:12
bool SignalsOptInRBF(const CTransaction &tx)
Definition: rbf.cpp:9
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash)
Mark a transaction as replaced by another transaction (e.g., BIP 125).
Definition: wallet.cpp:688
bool IsChange(const CTxOut &txout) const
Definition: wallet.cpp:1224
bool IsNull() const
Definition: uint256.h:30
Coin Control Features.
Definition: coincontrol.h:22
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:28
mapValue_t mapValue
Key/value map with information about the transaction.
Definition: wallet.h:289
interfaces::Chain & chain() const
Interface for accessing chain state.
Definition: wallet.h:786
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Optional< bool > m_signal_bip125_rbf
Override the wallet&#39;s m_signal_rbf if set.
Definition: coincontrol.h:40
void push_back(const T &value)
Definition: prevector.h:427
CScript scriptPubKey
Definition: wallet.h:193
Result CreateTotalBumpTransaction(const CWallet *wallet, const uint256 &txid, const CCoinControl &coin_control, CAmount total_fee, std::vector< std::string > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction based on total amount.
Definition: feebumper.cpp:154
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm)
Submit the transaction to the node&#39;s mempool and then relay to peers.
Definition: wallet.cpp:2950
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
Definition: wallet.h:1138
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
Definition: wallet.cpp:4194
#define LOCK(cs)
Definition: sync.h:179
bool TransactionCanBeBumped(const CWallet &wallet, const uint256 &txid)
Return whether transaction can be bumped.
Definition: feebumper.cpp:142
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, CCoinControl &coin_control)
Definition: feebumper.cpp:113
CTxDestination destChange
Custom change destination, if not set an address is generated.
Definition: coincontrol.h:26
void Select(const COutPoint &output)
Definition: coincontrol.h:69
bool fAllowOtherInputs
If false, allows unselected inputs, but requires all selected inputs be used.
Definition: coincontrol.h:30
uint8_t isminefilter
Definition: wallet.h:29
bool SignTransaction(CMutableTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Definition: wallet.cpp:2414
An output of a transaction.
Definition: transaction.h:133
std::string ToString() const
Definition: uint256.cpp:60
const uint256 & GetHash() const
Definition: wallet.h:539
virtual std::unique_ptr< Lock > lock(bool try_lock=false)=0
Return Lock interface.
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:18
std::vector< CTxOut > vout
Definition: transaction.h:369
CAmount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFeeIn)
Definition: policy.cpp:14
CFeeRate incrementalRelayFee
Definition: settings.cpp:12
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:253
static feebumper::Result CheckFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CFeeRate &newFeerate, const int64_t maxTxSize, std::vector< std::string > &errors)
Check if the user provided a valid feeRate.
Definition: feebumper.cpp:61
256-bit opaque blob.
Definition: uint256.h:120
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
Result CreateRateBumpTransaction(CWallet &wallet, const uint256 &txid, const CCoinControl &coin_control, std::vector< std::string > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction based on feerate estimates.
Definition: feebumper.cpp:280
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:606
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:19
RecursiveMutex cs_wallet
Definition: wallet.h:717
A mutable version of CTransaction.
Definition: transaction.h:366
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
Definition: wallet.h:72
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:12
Optional< CFeeRate > m_feerate
Override the wallet&#39;s m_pay_tx_fee if set.
Definition: coincontrol.h:36
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:143
auto it
Definition: validation.cpp:362
bool m_signal_rbf
Definition: wallet.h:956
static feebumper::Result PreconditionChecks(const CWallet &wallet, const CWalletTx &wtx, std::vector< std::string > &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:19
virtual CFeeRate relayIncrementalFee()=0
Relay incremental fee setting (-incrementalrelayfee), reflecting cost of relay.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Definition: feerate.h:41
CTransactionRef tx
Definition: wallet.h:349
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
Definition: wallet.cpp:1493
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: wallet.h:290
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
Definition: feerate.cpp:23