Skip to content

Commit

Permalink
plugins: use "slow" feerate for mutual close negotiation.
Browse files Browse the repository at this point in the history
We're rarely in a hurry here, and bitcoind is aggressive with fees.
You can always spend this output if you really have to, using CPFP.

Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: Protocol: mutual closing feerate reduced to "slow" to avoid overpaying.
  • Loading branch information
rustyrussell committed Oct 7, 2020
1 parent 6f870df commit c0af8ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion plugins/bcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static struct command_result *estimatefees_final_step(struct bitcoin_cli *bcli)

response = jsonrpc_stream_success(bcli->cmd);
json_add_u64(response, "opening", stash->normal);
json_add_u64(response, "mutual_close", stash->normal);
json_add_u64(response, "mutual_close", stash->slow);
json_add_u64(response, "unilateral_close",
stash->very_urgent * bitcoind->commit_fee_percent / 100);
json_add_u64(response, "delayed_to_us", stash->normal);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_closing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def test_closing(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.line_graph(2)
chan = l1.get_channel_scid(l2)
fee = basic_fee(7500) if not chainparams['elements'] else 8955
fee = basic_fee(3750) if not chainparams['elements'] else 4477

l1.pay(l2, 200000000)

Expand Down
10 changes: 6 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,15 +1484,16 @@ def test_feerates(node_factory):
assert feerates['perkw']['max_acceptable'] == 15000 * 10
assert feerates['perkw']['min_acceptable'] == 253

# Set ECONOMICAL/4 feerate, for all but min
# Set ECONOMICAL/4 feerate, for all but min (so, no mutual_close feerate)
l1.set_feerates((15000, 11000, 6250, 0), True)
wait_for(lambda: len(l1.rpc.feerates('perkb')['perkb']) == len(types) + 2)
wait_for(lambda: len(l1.rpc.feerates('perkb')['perkb']) == len(types) - 1 + 2)
feerates = l1.rpc.feerates('perkb')
assert feerates['perkb']['unilateral_close'] == 15000 * 4
assert feerates['perkb']['htlc_resolution'] == 11000 * 4
assert feerates['perkb']['penalty'] == 11000 * 4
assert 'mutual_close' not in feerates['perkb']
for t in types:
if t not in ("unilateral_close", "htlc_resolution", "penalty"):
if t not in ("unilateral_close", "htlc_resolution", "penalty", "mutual_close"):
assert feerates['perkb'][t] == 25000
assert feerates['warning_missing_feerates'] == 'Some fee estimates unavailable: bitcoind startup?'
assert 'perkw' not in feerates
Expand All @@ -1506,8 +1507,9 @@ def test_feerates(node_factory):
assert feerates['perkw']['unilateral_close'] == 15000
assert feerates['perkw']['htlc_resolution'] == 11000
assert feerates['perkw']['penalty'] == 11000
assert feerates['perkw']['mutual_close'] == 5000
for t in types:
if t not in ("unilateral_close", "htlc_resolution", "penalty"):
if t not in ("unilateral_close", "htlc_resolution", "penalty", "mutual_close"):
assert feerates['perkw'][t] == 25000 // 4
assert 'warning' not in feerates
assert 'perkb' not in feerates
Expand Down
18 changes: 9 additions & 9 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,8 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 8955501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 941045000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 4477501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 945523000, 'tag': 'withdrawal'},
]

l2_wallet_mvts = [
Expand All @@ -1612,16 +1612,16 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 0, 'debit': 8100000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 991900000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 941045000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 945523000, 'debit': 0, 'tag': 'deposit'},
]
elif EXPERIMENTAL_FEATURES:
# option_anchor_outputs
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 8430501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 941570000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 4215501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 945785000, 'tag': 'withdrawal'},
]

l2_wallet_mvts = [
Expand All @@ -1635,15 +1635,15 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 0, 'debit': 4575000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 995425000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 941570000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 945785000, 'debit': 0, 'tag': 'deposit'},
]
else:
l2_l3_mvts = [
{'type': 'chain_mvt', 'credit': 1000000000, 'debit': 0, 'tag': 'deposit'},
{'type': 'channel_mvt', 'credit': 0, 'debit': 100000000, 'tag': 'routed'},
{'type': 'channel_mvt', 'credit': 50000501, 'debit': 0, 'tag': 'routed'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 5430501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 944570000, 'tag': 'withdrawal'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 2715501, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 0, 'debit': 947285000, 'tag': 'withdrawal'},
]

l2_wallet_mvts = [
Expand All @@ -1657,7 +1657,7 @@ def test_coin_movement_notices(node_factory, bitcoind, chainparams):
{'type': 'chain_mvt', 'credit': 0, 'debit': 4575000, 'tag': 'chain_fees'},
{'type': 'chain_mvt', 'credit': 995425000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 100001000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 944570000, 'debit': 0, 'tag': 'deposit'},
{'type': 'chain_mvt', 'credit': 947285000, 'debit': 0, 'tag': 'deposit'},
]

l1, l2, l3 = node_factory.line_graph(3, opts=[
Expand Down

0 comments on commit c0af8ff

Please sign in to comment.