Browse Source

bitcoin: If we fail to estimate the fee in testnet use the minfee

When developing in regtest or testnet it is really inconvenient to
have to fake traffic and generate blocks just to get estimatesmartfee
to return a valid estimate. This just sets the minfee if bitcoind
doesn't return a valid estimate.

Reported-by: Rene Pickhardt <@renepickhardt>
Signed-off-by: Christian Decker <@cdecker>
plugin-1
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
46b2e7502c
  1. 15
      lightningd/bitcoind.c
  2. 1
      tests/test_misc.py

15
lightningd/bitcoind.c

@ -1,6 +1,7 @@
/* Code for talking to bitcoind. We use bitcoin-cli. */
#include "bitcoin/base58.h"
#include "bitcoin/block.h"
#include "bitcoin/feerate.h"
#include "bitcoin/shadouble.h"
#include "bitcoind.h"
#include "lightningd.h"
@ -352,7 +353,21 @@ static bool process_estimatefee(struct bitcoin_cli *bcli)
if (!extract_feerate(bcli, bcli->output, bcli->output_bytes, &feerate)) {
log_unusual(bcli->bitcoind->log, "Unable to estimate %s/%u fee",
efee->estmode[efee->i], efee->blocks[efee->i]);
#if DEVELOPER
/* This is needed to test for failed feerate estimates
* in DEVELOPER mode */
efee->satoshi_per_kw[efee->i] = 0;
#else
/* If we are in testnet mode we want to allow payments
* with the minimal fee even if the estimate didn't
* work out. This is less disruptive than erring out
* all the time. */
if (get_chainparams(bcli->bitcoind->ld)->testnet)
efee->satoshi_per_kw[efee->i] = FEERATE_FLOOR;
else
efee->satoshi_per_kw[efee->i] = 0;
#endif
} else
/* Rate in satoshi per kw. */
efee->satoshi_per_kw[efee->i]

1
tests/test_misc.py

@ -864,6 +864,7 @@ def test_ipv4_and_ipv6(node_factory):
assert int(bind[0]['port']) == port
@unittest.skipIf(not DEVELOPER, "Without DEVELOPER=1 we snap to FEERATE_FLOOR on testnets")
def test_feerates(node_factory):
l1 = node_factory.get_node(options={'log-level': 'io'}, start=False)
l1.daemon.rpcproxy.mock_rpc('estimatesmartfee', {

Loading…
Cancel
Save