dual-funding: convert to runtime flag, --experimental-dual-fund

You can now activate dual-funded channels using the
`--experimental-dual-fund` flag

Changelog-Changed: Config: `--experimental-dual-fund` runtime flag will enable dual-funded protocol on this node
This commit is contained in:
niftynei
2021-03-11 18:19:40 -06:00
committed by Rusty Russell
parent 737658503f
commit 3e8f575f9e
25 changed files with 1617 additions and 131 deletions

View File

@@ -2,8 +2,7 @@ from fixtures import * # noqa: F401,F403
from fixtures import TEST_NETWORK
from pyln.client import RpcError
from utils import (
only_one, wait_for, sync_blockheight, EXPERIMENTAL_FEATURES, DEVELOPER,
first_channel_id
only_one, wait_for, sync_blockheight, DEVELOPER, first_channel_id
)
import pytest
@@ -17,7 +16,7 @@ def find_next_feerate(node, peer):
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
def test_multifunding_v2_best_effort(node_factory, bitcoind):
'''
Check that best_effort flag works.
@@ -25,10 +24,10 @@ def test_multifunding_v2_best_effort(node_factory, bitcoind):
disconnects = ["-WIRE_INIT",
"-WIRE_ACCEPT_CHANNEL",
"-WIRE_FUNDING_SIGNED"]
l1 = node_factory.get_node(options={'dev-force-features': '+223'},
l1 = node_factory.get_node(options={'experimental-dual-fund': None},
allow_warning=True,
may_reconnect=True)
l2 = node_factory.get_node(options={'dev-force-features': '+223'},
l2 = node_factory.get_node(options={'experimental-dual-fund': None},
allow_warning=True,
may_reconnect=True)
l3 = node_factory.get_node(disconnect=disconnects)
@@ -101,7 +100,7 @@ def test_multifunding_v2_best_effort(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_v2_open_sigs_restart(node_factory, bitcoind):
disconnects_1 = ['-WIRE_TX_SIGNATURES']
disconnects_2 = ['+WIRE_TX_SIGNATURES']
@@ -146,7 +145,7 @@ def test_v2_open_sigs_restart(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
# Same thing as above, except the transaction mines
# while we're asleep
@@ -154,10 +153,10 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
disconnects_2 = ['+WIRE_TX_SIGNATURES']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects_1,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'disconnect': disconnects_2,
'may_reconnect': True}])
@@ -197,11 +196,10 @@ def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_v2_rbf(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223'},
{'dev-force-features': '+223'}])
opts=[{'experimental-dual-fund': None},
{'experimental-dual-fund': None}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
amount = 2**24
@@ -275,10 +273,9 @@ def test_v2_rbf(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts={'dev-force-features': '+223',
opts={'experimental-dual-fund': None,
'may_reconnect': True,
'allow_warning': True})
@@ -356,17 +353,17 @@ def test_v2_rbf_multi(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
disconnects = ['-WIRE_INIT_RBF',
'@WIRE_INIT_RBF',
'+WIRE_INIT_RBF']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -408,16 +405,16 @@ def test_rbf_reconnect_init(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
disconnects = ['-WIRE_ACK_RBF',
'@WIRE_ACK_RBF',
'+WIRE_ACK_RBF']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True}])
@@ -460,7 +457,7 @@ def test_rbf_reconnect_ack(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
@unittest.skipIf(not DEVELOPER, "disconnect=... needs DEVELOPER=1")
def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
disconnects = ['=WIRE_TX_ADD_INPUT', # Initial funding succeeds
'-WIRE_TX_ADD_INPUT',
@@ -474,10 +471,10 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
'+WIRE_TX_COMPLETE']
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -528,7 +525,6 @@ def test_rbf_reconnect_tx_construct(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
disconnects = ['=WIRE_TX_SIGNATURES', # Initial funding succeeds
'-WIRE_TX_SIGNATURES', # When we send tx-sigs, RBF
@@ -538,10 +534,10 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
'+WIRE_TX_SIGNATURES'] # When we RBF again
l1, l2 = node_factory.get_nodes(2,
opts=[{'dev-force-features': '+223',
opts=[{'experimental-dual-fund': None,
'disconnect': disconnects,
'may_reconnect': True},
{'dev-force-features': '+223',
{'experimental-dual-fund': None,
'may_reconnect': True}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
@@ -662,10 +658,9 @@ def test_rbf_reconnect_tx_sigs(node_factory, bitcoind, chainparams):
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "dual-funding is experimental only")
def test_rbf_no_overlap(node_factory, bitcoind, chainparams):
l1, l2 = node_factory.get_nodes(2,
opts={'dev-force-features': '+223',
opts={'experimental-dual-fund': None,
'allow_warning': True})
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)