|
1 | 1 | #include "bitcoin/block.h" |
| 2 | +#include "bitcoin/feerate.h" |
2 | 3 | #include "bitcoin/script.h" |
3 | 4 | #include "bitcoin/tx.h" |
4 | 5 | #include "bitcoind.h" |
@@ -229,48 +230,6 @@ static const char *feerate_name(enum feerate feerate) |
229 | 230 | /* Mutual recursion via timer. */ |
230 | 231 | static void next_updatefee_timer(struct chain_topology *topo); |
231 | 232 |
|
232 | | -/* bitcoind considers 250 satoshi per kw to be the minimum acceptable fee: |
233 | | - * less than this won't even relay. |
234 | | - */ |
235 | | -#define BITCOIND_MINRELAYTXFEE_PER_KW 250 |
236 | | -/* |
237 | | - * But bitcoind uses vbytes (ie. (weight + 3) / 4) for this |
238 | | - * calculation, rather than weight, meaning we can disagree since we do |
239 | | - * it sanely (as specified in BOLT #3). |
240 | | - */ |
241 | | -#define FEERATE_BITCOIND_SEES(feerate, weight) \ |
242 | | - (((feerate) * (weight)) / 1000 * 1000 / ((weight) + 3)) |
243 | | -/* ie. fee = (feerate * weight) // 1000 |
244 | | - * bitcoind needs (worst-case): fee * 1000 / (weight + 3) >= 4000 |
245 | | - * |
246 | | - * (feerate * weight) // 1000 * 1000 // (weight + 3) >= 4000 |
247 | | - * |
248 | | - * The feerate needs to be higher for lower weight, and our minimum tx weight |
249 | | - * is 464 (version (4) + count_tx_in (1) + tx_in (32 + 4 + 1 + 4) + |
250 | | - * count_tx_out (1) + amount (8) + P2WSH (1 + 1 + 32) + witness 1 + 1 + <sig> |
251 | | - * + 1 + <key>). Assume it's 400 to give a significant safety margin (it |
252 | | - * only makes 1 difference in the result anyway). |
253 | | - */ |
254 | | -#define MINIMUM_TX_WEIGHT 400 |
255 | | -/* |
256 | | - * This formula is satisfied by a feerate of 4030 (hand-search). |
257 | | - */ |
258 | | -#define FEERATE_FLOOR 253 |
259 | | -u32 feerate_floor(void) |
260 | | -{ |
261 | | - /* Assert that bitcoind will see this as above minRelayTxFee */ |
262 | | - BUILD_ASSERT(FEERATE_BITCOIND_SEES(FEERATE_FLOOR, MINIMUM_TX_WEIGHT) |
263 | | - >= BITCOIND_MINRELAYTXFEE_PER_KW); |
264 | | - /* And a lesser value won't do */ |
265 | | - BUILD_ASSERT(FEERATE_BITCOIND_SEES(FEERATE_FLOOR-1, MINIMUM_TX_WEIGHT) |
266 | | - < BITCOIND_MINRELAYTXFEE_PER_KW); |
267 | | - /* And I'm right about it being OK for larger txs, too */ |
268 | | - BUILD_ASSERT(FEERATE_BITCOIND_SEES(FEERATE_FLOOR, (MINIMUM_TX_WEIGHT*2)) |
269 | | - >= BITCOIND_MINRELAYTXFEE_PER_KW); |
270 | | - |
271 | | - return FEERATE_FLOOR; |
272 | | -} |
273 | | - |
274 | 233 | /* We sanitize feerates if necessary to put them in descending order. */ |
275 | 234 | static void update_feerates(struct bitcoind *bitcoind, |
276 | 235 | const u32 *satoshi_per_kw, |
|
0 commit comments