mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
dual-fund: Fail if you try to buy a liquidity ad w/o dualfunding on
Fixes #5271 In-Collaboration-With: Base58 'n Coding Seminar Participants Changelog-Changed: `fundchannel` now errors if you try to buy a liquidity ad but dont' have `experimental-dual-fund` enabled
This commit is contained in:
parent
f67ab2a86e
commit
95ec897ac0
2 changed files with 28 additions and 1 deletions
|
@ -1611,13 +1611,21 @@ connect_ok(struct command *cmd,
|
||||||
json_tok_full_len(features_tok),
|
json_tok_full_len(features_tok),
|
||||||
json_tok_full(buf, features_tok));
|
json_tok_full(buf, features_tok));
|
||||||
|
|
||||||
|
dest->state = MULTIFUNDCHANNEL_CONNECTED;
|
||||||
|
|
||||||
/* Set the open protocol to use now */
|
/* Set the open protocol to use now */
|
||||||
if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
|
if (feature_negotiated(plugin_feature_set(mfc->cmd->plugin),
|
||||||
dest->their_features,
|
dest->their_features,
|
||||||
OPT_DUAL_FUND))
|
OPT_DUAL_FUND))
|
||||||
dest->protocol = OPEN_CHANNEL;
|
dest->protocol = OPEN_CHANNEL;
|
||||||
|
else if (!amount_sat_zero(dest->request_amt) || !(!dest->rates))
|
||||||
|
/* Return an error */
|
||||||
|
fail_destination_msg(dest, FUNDING_V2_NOT_SUPPORTED,
|
||||||
|
"Tried to buy a liquidity ad"
|
||||||
|
" but we(?) don't have"
|
||||||
|
" experimental-dual-fund"
|
||||||
|
" enabled");
|
||||||
|
|
||||||
dest->state = MULTIFUNDCHANNEL_CONNECTED;
|
|
||||||
return connect_done(dest);
|
return connect_done(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1391,3 +1391,22 @@ def test_zeroconf_forward(node_factory, bitcoind):
|
||||||
wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 4)
|
wait_for(lambda: len(l3.rpc.listchannels()['channels']) == 4)
|
||||||
inv = l1.rpc.invoice(42, 'back1', 'desc')['bolt11']
|
inv = l1.rpc.invoice(42, 'back1', 'desc')['bolt11']
|
||||||
l3.rpc.pay(inv)
|
l3.rpc.pay(inv)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.openchannel('v1')
|
||||||
|
def test_buy_liquidity_ad_no_v2(node_factory, bitcoind):
|
||||||
|
""" Test that you can't actually request amt for a
|
||||||
|
node that doesn' support v2 opens """
|
||||||
|
|
||||||
|
l1, l2, = node_factory.get_nodes(2)
|
||||||
|
amount = 500000
|
||||||
|
feerate = 2000
|
||||||
|
|
||||||
|
l1.fundwallet(amount * 100)
|
||||||
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
|
|
||||||
|
# l1 leases a channel from l2
|
||||||
|
with pytest.raises(RpcError, match=r"Tried to buy a liquidity ad but we[(][?][)] don't have experimental-dual-fund enabled"):
|
||||||
|
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
|
||||||
|
feerate='{}perkw'.format(feerate),
|
||||||
|
compact_lease='029a002d000000004b2003e8')
|
||||||
|
|
Loading…
Add table
Reference in a new issue