Skip to content

Commit f620dcd

Browse files
committed
splice: enable and test mutli-channel splice script
Turns on mutli channel splices in splice script and adds a test for it. Changelog-Changed: Splice script now supports splicing over multiple channels
1 parent bdbf216 commit f620dcd

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

plugins/spender/splice.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,6 @@ validate_splice_cmd(struct splice_cmd *splice_cmd)
12611261
{
12621262
struct splice_script_result *action;
12631263
int paying_fee_count = 0;
1264-
int channels = 0;
12651264
for (size_t i = 0; i < tal_count(splice_cmd->actions); i++) {
12661265
action = splice_cmd->actions[i];
12671266
/* Taking fee from onchain wallet requires recursive looping
@@ -1297,14 +1296,6 @@ validate_splice_cmd(struct splice_cmd *splice_cmd)
12971296
JSONRPC2_INVALID_PARAMS,
12981297
"Dynamic bitcoin address amounts"
12991298
" not supported for now");
1300-
if (action->channel_id) {
1301-
if (channels)
1302-
return command_fail(splice_cmd->cmd,
1303-
JSONRPC2_INVALID_PARAMS,
1304-
"Multi-channel splice not"
1305-
"supported for now");
1306-
channels++;
1307-
}
13081299
if (action->bitcoin_address)
13091300
return command_fail(splice_cmd->cmd,
13101301
JSONRPC2_INVALID_PARAMS,

tests/test_splice.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,35 @@ def test_script_splice_in(node_factory, bitcoind, chainparams):
195195
l1.wait_for_channel_onchain(l2.info['id'])
196196
account_info = only_one([acct for acct in l1.rpc.bkpr_listbalances()['accounts'] if acct['account'] == account_id])
197197
assert not account_info['account_closed']
198+
199+
200+
@pytest.mark.openchannel('v1')
201+
@pytest.mark.openchannel('v2')
202+
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
203+
def test_script_two_chan_splice_in(node_factory, bitcoind):
204+
l1, l2, l3 = node_factory.line_graph(3, fundamount=1000000, wait_for_announce=True, opts={'experimental-splicing': None})
205+
206+
chan_id1 = l2.get_channel_id(l1)
207+
chan_id2 = l2.get_channel_id(l3)
208+
209+
# l2 will splice funds into the channels with l1 and l3 at the same time
210+
result = l2.rpc.splice(f"wallet -> 200999; 100000 -> {chan_id1}; 100000 -> {chan_id2}; * -> wallet", force_feerate=True, debug_log=True)
211+
212+
l3.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
213+
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
214+
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
215+
216+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
217+
assert result['txid'] in list(bitcoind.rpc.getrawmempool(True).keys())
218+
219+
bitcoind.generate_block(6, wait_for_mempool=1)
220+
221+
l3.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
222+
l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
223+
l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
224+
225+
inv = l2.rpc.invoice(10**2, '1', 'no_1')
226+
l1.rpc.pay(inv['bolt11'])
227+
228+
inv = l3.rpc.invoice(10**2, '2', 'no_2')
229+
l2.rpc.pay(inv['bolt11'])

0 commit comments

Comments
 (0)