21 if (
wallet.HasWalletSpend(wtx.GetHash())) {
22 errors.push_back(
Untranslated(
"Transaction has descendants in the wallet"));
27 if (
wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
28 errors.push_back(
Untranslated(
"Transaction has descendants in the mempool"));
33 if (wtx.GetDepthInMainChain() != 0) {
34 errors.push_back(
Untranslated(
"Transaction has been mined, or is conflicted with a mined transaction"));
39 errors.push_back(
Untranslated(
"Transaction is not BIP 125 replaceable"));
43 if (wtx.mapValue.count(
"replaced_by_txid")) {
44 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")));
51 if (!
wallet.IsAllFromMe(*wtx.tx, filter)) {
52 errors.push_back(
Untranslated(
"Transaction contains inputs that don't belong to this wallet"));
72 Untranslated(
"New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- "),
86 CFeeRate nOldFeeRate(old_fee, txSize);
90 if (new_total_fee < minTotalFee) {
91 errors.push_back(
strprintf(
Untranslated(
"Insufficient total fee %s, must be at least %s (oldFee %s + incrementalFee %s)"),
97 if (new_total_fee < requiredFee) {
98 errors.push_back(
strprintf(
Untranslated(
"Insufficient total fee (cannot be less than required fee %s)"),
105 if (new_total_fee > max_tx_fee) {
106 errors.push_back(
strprintf(
Untranslated(
"Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)"),
130 CFeeRate node_incremental_relay_fee =
wallet.chain().relayIncrementalFee();
132 feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
138 return std::max(feerate, min_feerate);
147 if (wtx ==
nullptr)
return false;
149 std::vector<bilingual_str> errors_dummy;
162 auto it =
wallet.mapWallet.find(txid);
163 if (it ==
wallet.mapWallet.end()) {
164 errors.push_back(
Untranslated(
"Invalid or non-wallet transaction id"));
175 std::vector<CRecipient> recipients;
176 for (
const auto& output : wtx.
tx->vout) {
177 if (!
wallet.IsChange(output)) {
188 old_fee = wtx.
GetDebit(filter) - wtx.
tx->GetValueOut();
210 for (
const auto& inputs : wtx.
tx->vin) {
220 int change_pos_in_out = -1;
223 if (!
wallet.CreateTransaction(recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, fee_calc_out,
false)) {
235 for (
auto& input : mtx.
vin) {
236 if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
245 return wallet.SignTransaction(mtx);
251 if (!errors.empty()) {
255 if (it ==
wallet.mapWallet.end()) {
256 errors.push_back(
Untranslated(
"Invalid or non-wallet transaction id"));
275 bumped_txid = tx->GetHash();
281 errors.push_back(
Untranslated(
"Created new bumpfee transaction but could not mark the original transaction as replaced"));
std::shared_ptr< const CTransaction > CTransactionRef
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, const CCoinControl &coin_control)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
int m_min_depth
Minimum chain depth value for coin availability.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
bool SignalsOptInRBF(const CTransaction &tx)
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, bool use_max_sig)
CFeeRate GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control, FeeCalculation *feeCalc)
Estimate the minimum fee rate considering user set parameters and the required fee.
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.
mapValue_t mapValue
Key/value map with information about the transaction.
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.
int64_t CAmount
Amount in satoshis (Can be negative)
void push_back(const T &value)
bool TransactionCanBeBumped(const CWallet &wallet, const uint256 &txid)
Return whether transaction can be bumped.
CTxDestination destChange
Custom change destination, if not set an address is generated.
void Select(const COutPoint &output)
bool fAllowOtherInputs
If false, allows unselected inputs, but requires all selected inputs be used.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::string ToString() const
const uint256 & GetHash() const
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::map< std::string, std::string > mapValue_t
CFeeRate incrementalRelayFee
A transaction with a bunch of additional info that only the owner cares about.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
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.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Fee rate in satoshis per kilobyte: CAmount / kB.
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
CAmount GetFee(uint32_t num_bytes) const
Return the fee in satoshis for the given size in bytes.
A mutable version of CTransaction.
static const CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for BIP 125 replacement txs
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
std::vector< std::pair< std::string, std::string > > vOrderForm