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);
88 CAmount minTotalFee = nOldFeeRate.
GetFee(maxTxSize) + incrementalRelayFee.
GetFee(maxTxSize);
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)"),
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) {
179 recipients.push_back(recipient);
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;
251 if (!errors.empty()) {
254 auto it = txid.
IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
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
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
const uint256 & GetHash() const
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
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.
std::map< std::string, std::string > mapValue_t
virtual CFeeRate mempoolMinFee()=0
Mempool minimum fee.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
static CTransactionRef MakeTransactionRef()
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int m_min_depth
Minimum chain depth value for coin availability.
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
const CWalletTx * GetWalletTx(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SignalsOptInRBF(const CTransaction &tx)
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash)
Mark a transaction as replaced by another transaction (e.g., BIP 125).
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 GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
interfaces::Chain & chain() const
Interface for accessing chain state.
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.
std::string ToString() const
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)
Optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm)
Submit the transaction to the node's mempool and then relay to peers.
bool TransactionCanBeBumped(const CWallet &wallet, const uint256 &txid)
Return whether transaction can be bumped.
static CFeeRate EstimateFeeRate(const CWallet &wallet, const CWalletTx &wtx, const CAmount old_fee, CCoinControl &coin_control)
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.
An outpoint - a combination of a transaction hash and an index n into its vout.
CFeeRate incrementalRelayFee
A transaction with a bunch of additional info that only the owner cares about.
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...
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
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.
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.
Optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
virtual CFeeRate relayIncrementalFee()=0
Relay incremental fee setting (-incrementalrelayfee), reflecting cost of relay.
int64_t CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, bool use_max_sig)
std::vector< std::pair< std::string, std::string > > vOrderForm