26 if (
wallet.HasWalletSpend(wtx.GetTx())) {
32 if (
wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
38 if (
wallet.GetTxDepthInMainChain(wtx) != 0) {
39 errors.emplace_back(
Untranslated(
"Transaction has been mined, or is conflicted with a mined transaction"));
43 if (wtx.m_replaced_by_txid) {
44 errors.push_back(
Untranslated(
strprintf(
"Cannot bump transaction %s which was already bumped by transaction %s", wtx.GetHash().ToString(), wtx.m_replaced_by_txid->ToString())));
52 errors.emplace_back(
Untranslated(
"Transaction contains inputs that don't belong to this wallet"));
72 strprintf(
"New fee rate (%s) is lower than the minimum fee rate (%s) to get into the mempool -- ",
86 errors.push_back(
Untranslated(
strprintf(
"Failed to calculate bump fees, because unconfirmed UTXOs depend on an enormous cluster of unconfirmed transactions.")));
160 if (wtx ==
nullptr)
return false;
172 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."));
181 auto it =
wallet.mapWallet.find(txid);
182 if (it ==
wallet.mapWallet.end()) {
197 std::map<COutPoint, Coin> coins;
203 wallet.chain().findCoins(coins);
205 const Coin& coin = coins.at(
txin.prevout);
221 for (
unsigned int i = 0; i < tx->vin.size(); ++i) {
223 const Coin& coin = coins.at(
txin.prevout);
258 std::vector<CRecipient> recipients;
260 const auto&
txouts = outputs.empty() ? tx->vout : outputs;
261 for (
size_t i = 0; i <
txouts.size(); ++i) {
269 recipients.push_back(recipient);
275 if (recipients.empty()) {
278 errors.emplace_back(
Untranslated(
"Unable to create transaction. Transaction must have at least one recipient"));
294 txin.scriptSig.clear();
295 txin.scriptWitness.SetNull();
315 for (
const auto& inputs : tx->vin) {
349 wallet.FillPSBT(
psbtx, {.sign =
false, .bip32_derivs =
true}, complete);
350 auto err{
wallet.FillPSBT(
psbtx, {.sign =
true, .bip32_derivs =
false}, complete)};
351 if (err)
return false;
366 if (it ==
wallet.mapWallet.end()) {
385 errors.emplace_back(
Untranslated(
"Created new bumpfee transaction but could not mark the original transaction as replaced"));
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
int64_t CAmount
Amount in satoshis (Can be negative)
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
An outpoint - a combination of a transaction hash and an index n into its vout.
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
An output of a transaction.
CTxOut out
unspent transaction output
A version of CTransaction with the PSBT format.
constexpr bool IsNull() const
Wrapped uint256 methods.
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.
CTransactionRef GetTx() const
static int64_t GetTransactionInputWeight(const CTxIn &txin)
const std::string CURRENCY_UNIT
bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, script_verify_flags flags, const BaseSignatureChecker &checker, ScriptError *serror)
@ FAIL
Just act as if the signature was invalid.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
bilingual_str ErrorString(const Result< T > &result)
Result CreateRateBumpTransaction(CWallet &wallet, const Txid &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.
bool TransactionCanBeBumped(const CWallet &wallet, const Txid &txid)
Return whether transaction can be bumped.
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
Result CommitTransaction(CWallet &wallet, const Txid &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, Txid &bumped_txid)
Commit the bumpfee transaction.
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
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...
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx)
Returns whether all of the inputs belong to the wallet.
MinimumFeeRateResult GetMinimumFeeRate(const CWallet &wallet, const CCoinControl &coin_control)
Estimate the minimum fee rate considering user set parameters and the required fee.
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...
constexpr CAmount WALLET_INCREMENTAL_RELAY_FEE
minimum recommended increment for replacement txs
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 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.
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...
@ WALLET_FLAG_EXTERNAL_SIGNER
Indicates that the wallet needs an external signer.
CAmount GetRequiredFee(const CWallet &wallet, unsigned int nTxBytes)
Return the minimum required absolute fee for this size based on the required fee rate.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
A mutable version of CTransaction.
std::vector< CTxOut > vout
void Init(const T &tx, std::vector< CTxOut > &&spent_outputs, bool force=false)
Initialize this PrecomputedTransactionData with transaction data.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.