Skip to content

Commit c2aa7d4

Browse files
committed
splice: Add easy spliceout command
Adds a RPC command for easily splicing out. Built on top of the splice script framework. Changelog-Added: New command `spliceout` for easily splicing out of channels
1 parent 8908159 commit c2aa7d4

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

plugins/spender/splice.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,10 +1462,63 @@ json_splice(struct command *cmd, const char *buf, const jsmntok_t *params)
14621462
return send_outreq(req);
14631463
}
14641464

1465+
static struct command_result *
1466+
json_spliceout(struct command *cmd, const char *buf, const jsmntok_t *params)
1467+
{
1468+
struct out_req *req;
1469+
const char *channel, *amount, *destination;
1470+
struct splice_cmd *splice_cmd;
1471+
bool *force_feerate;
1472+
char *script;
1473+
1474+
if (!param(cmd, buf, params,
1475+
p_req("channel", param_string, &channel),
1476+
p_req("amount", param_string, &amount),
1477+
p_opt("destination", param_string, &destination),
1478+
p_opt_def("force_feerate", param_bool, &force_feerate,
1479+
false),
1480+
NULL))
1481+
return command_param_failed();
1482+
1483+
if (!destination)
1484+
destination = "wallet";
1485+
1486+
script = tal_fmt(NULL,
1487+
"%s -> %s + fee; 100%% -> %s",
1488+
channel, amount, destination);
1489+
1490+
splice_cmd = tal(cmd, struct splice_cmd);
1491+
1492+
splice_cmd->cmd = cmd;
1493+
splice_cmd->script = tal_steal(splice_cmd, script);
1494+
splice_cmd->psbt = create_psbt(splice_cmd, 0, 0, 0);
1495+
splice_cmd->dryrun = false;
1496+
splice_cmd->wetrun = false;
1497+
splice_cmd->feerate_per_kw = 0;
1498+
splice_cmd->force_feerate = *force_feerate;
1499+
splice_cmd->wallet_inputs_to_signed = 0;
1500+
splice_cmd->fee_calculated = false;
1501+
splice_cmd->initial_funds = AMOUNT_SAT(0);
1502+
splice_cmd->emergency_sat = AMOUNT_SAT(0);
1503+
splice_cmd->debug_log = NULL;
1504+
splice_cmd->debug_counter = 0;
1505+
memset(&splice_cmd->final_txid, 0, sizeof(splice_cmd->final_txid));
1506+
1507+
req = jsonrpc_request_start(cmd, "listpeerchannels",
1508+
listpeerchannels_get_result,
1509+
splice_error, splice_cmd);
1510+
1511+
return send_outreq(req);
1512+
}
1513+
14651514
const struct plugin_command splice_commands[] = {
14661515
{
14671516
"dev-splice",
14681517
json_splice
14691518
},
1519+
{
1520+
"spliceout",
1521+
json_spliceout
1522+
},
14701523
};
14711524
const size_t num_splice_commands = ARRAY_SIZE(splice_commands);

tests/test_splice.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def test_script_splice_in(node_factory, bitcoind, chainparams):
197197
assert not account_info['account_closed']
198198

199199

200-
@pytest.mark.xfail(strict=True)
201200
@pytest.mark.openchannel('v1')
202201
@pytest.mark.openchannel('v2')
203202
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

0 commit comments

Comments
 (0)