MCPcopy Create free account
hub / github.com/ElementsProject/elements / EstimateFeeRate

Function EstimateFeeRate

src/wallet/feebumper.cpp:121–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CAmount old_fee, const CCoinControl& coin_control)
122{
123 // Get the fee rate of the original transaction. This is calculated from
124 // the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
125 // result.
126 int64_t txSize = GetVirtualTransactionSize(*(wtx.tx));
127 CFeeRate feerate(old_fee, txSize);
128 feerate += CFeeRate(1);
129
130 // The node has a configurable incremental relay fee. Increment the fee by
131 // the minimum of that and the wallet's conservative
132 // WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
133 // network wide policy for incremental relay fee that our node may not be
134 // aware of. This ensures we're over the required relay fee rate
135 // (BIP 125 rule 4). The replacement tx will be at least as large as the
136 // original tx, so the total fee will be greater (BIP 125 rule 3)
137 CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
138 CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
139 feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
140
141 // Fee rate must also be at least the wallet's GetMinimumFeeRate
142 CFeeRate min_feerate(GetMinimumFeeRate(wallet, coin_control, /* feeCalc */ nullptr));
143
144 // Set the required fee rate for the replacement transaction in coin control.
145 return std::max(feerate, min_feerate);
146}
147
148namespace feebumper {
149

Callers 1

Calls 4

GetMinimumFeeRateFunction · 0.85
relayIncrementalFeeMethod · 0.80
CFeeRateClass · 0.70

Tested by

no test coverage detected