23 if (
wallet.HasWalletSpend(wtx.GetHash())) {
24 errors.push_back(
Untranslated(
"Transaction has descendants in the wallet"));
29 if (
wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
30 errors.push_back(
Untranslated(
"Transaction has descendants in the mempool"));
35 if (
wallet.GetTxDepthInMainChain(wtx) != 0) {
36 errors.push_back(
Untranslated(
"Transaction has been mined, or is conflicted with a mined transaction"));
41 errors.push_back(
Untranslated(
"Transaction is not BIP 125 replaceable"));
45 if (wtx.mapValue.count(
"replaced_by_txid")) {
46 errors.push_back(
strprintf(
Untranslated(
"Cannot bump transaction %s which was already bumped by transaction %s"), wtx.GetHash().ToString(), wtx.mapValue.at(
"replaced_by_txid")));
54 errors.push_back(
Untranslated(
"Transaction contains inputs that don't belong to this wallet"));
74 Untranslated(
"New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- "),
88 CFeeRate nOldFeeRate(old_fee, txSize);
92 if (new_total_fee < minTotalFee) {
93 errors.push_back(
strprintf(
Untranslated(
"Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)"),
99 if (new_total_fee < requiredFee) {
100 errors.push_back(
strprintf(
Untranslated(
"Insufficient total fee (cannot be less than required fee %s)"),
107 if (new_total_fee > max_tx_fee) {
108 errors.push_back(
strprintf(
Untranslated(
"Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)"),
132 CFeeRate node_incremental_relay_fee =
wallet.chain().relayIncrementalFee();
134 feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
140 return std::max(feerate, min_feerate);
149 if (wtx ==
nullptr)
return false;
151 std::vector<bilingual_str> errors_dummy;
164 auto it =
wallet.mapWallet.find(txid);
165 if (it ==
wallet.mapWallet.end()) {
166 errors.push_back(
Untranslated(
"Invalid or non-wallet transaction id"));
177 std::vector<CRecipient> recipients;
178 for (
const auto& output : wtx.
tx->vout) {
212 for (
const auto& inputs : wtx.
tx->vin) {
222 int change_pos_in_out = -1;
225 if (!
CreateTransaction(
wallet, recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, fee_calc_out,
false)) {
237 for (
auto& input : mtx.
vin) {
238 if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
247 return wallet.SignTransaction(mtx);
253 if (!errors.empty()) {
257 if (it ==
wallet.mapWallet.end()) {
258 errors.push_back(
Untranslated(
"Invalid or non-wallet transaction id"));
277 bumped_txid = tx->GetHash();
283 errors.push_back(
Untranslated(
"Created new bumpfee transaction but could not mark the original transaction as replaced"));
int64_t CAmount
Amount in satoshis (Can be negative)
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
void Select(const COutPoint &output)
int m_min_depth
Minimum chain depth value for coin availability.
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
CTxDestination destChange
Custom change destination, if not set an address is generated.
bool fAllowOtherInputs
If false, allows unselected inputs, but requires all selected inputs be used.
Fee rate in satoshis per kilobyte: CAmount / kB.
CAmount GetFee(uint32_t num_bytes) const
Return the fee in satoshis for the given size in bytes.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
A transaction with a bunch of additional info that only the owner cares about.
mapValue_t mapValue
Key/value map with information about the transaction.
const uint256 & GetHash() const
std::vector< std::pair< std::string, std::string > > vOrderForm
std::string ToString() const
void push_back(const T &value)
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, const CCoinControl &coin_control)
static feebumper::Result CheckFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CFeeRate &newFeerate, const int64_t maxTxSize, std::vector< bilingual_str > &errors)
Check if the user provided a valid feeRate.
static feebumper::Result PreconditionChecks(const CWallet &wallet, const CWalletTx &wtx, 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...
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
Result CreateRateBumpTransaction(CWallet &wallet, const uint256 &txid, const CCoinControl &coin_control, std::vector< bilingual_str > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction based on feerate estimates.
bool TransactionCanBeBumped(const CWallet &wallet, const uint256 &txid)
Return whether transaction can be bumped.
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
CFeeRate incrementalRelayFee
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, const CCoinControl *coin_control)
Calculate the size of the transaction assuming all signatures are max size Use DummySignatureCreator,...
bool CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
A mutable version of CTransaction.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
bool SignalsOptInRBF(const CTransaction &tx)
Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,...
CFeeRate GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control, FeeCalculation *feeCalc)
Estimate the minimum fee rate considering user set parameters and the required fee.
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
std::map< std::string, std::string > mapValue_t
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS