Skip to content

Commit 29119d5

Browse files
ddustinsangbida
authored andcommitted
Add splicein command
splicein is the convience method for splicing in using the splice script system. Changelog-Added: New command `splicein` allows for convenient splicing funds into a channel
1 parent 3ef72bf commit 29119d5

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

plugins/spender/splice.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,57 @@ json_splice(struct command *cmd, const char *buf, const jsmntok_t *params)
22032203
return send_outreq(req);
22042204
}
22052205

2206+
static struct command_result *
2207+
json_splicein(struct command *cmd, const char *buf, const jsmntok_t *params)
2208+
{
2209+
struct out_req *req;
2210+
const char *channel, *amount;
2211+
struct splice_cmd *splice_cmd;
2212+
char *script;
2213+
2214+
if (!param(cmd, buf, params,
2215+
p_req("channel", param_string, &channel),
2216+
p_req("amount", param_string, &amount),
2217+
NULL))
2218+
return command_param_failed();
2219+
2220+
script = tal_fmt(NULL,
2221+
"wallet -> %s + fee; %s -> %s",
2222+
amount, amount, channel);
2223+
2224+
splice_cmd = tal(cmd, struct splice_cmd);
2225+
2226+
splice_cmd->cmd = cmd;
2227+
splice_cmd->script = tal_steal(splice_cmd, script);
2228+
splice_cmd->psbt = create_psbt(splice_cmd, 0, 0, 0);
2229+
splice_cmd->dryrun = false;
2230+
splice_cmd->wetrun = false;
2231+
splice_cmd->feerate_per_kw = 0;
2232+
splice_cmd->force_feerate = false;
2233+
splice_cmd->wallet_inputs_to_signed = 0;
2234+
splice_cmd->fee_calculated = false;
2235+
splice_cmd->initial_funds = AMOUNT_SAT(0);
2236+
splice_cmd->emergency_sat = AMOUNT_SAT(0);
2237+
splice_cmd->debug_log = NULL;
2238+
splice_cmd->debug_counter = 0;
2239+
splice_cmd->needed_funds = AMOUNT_SAT(0);
2240+
memset(&splice_cmd->final_txid, 0, sizeof(splice_cmd->final_txid));
2241+
2242+
req = jsonrpc_request_start(cmd, "listpeerchannels",
2243+
listpeerchannels_get_result,
2244+
splice_error, splice_cmd);
2245+
2246+
return send_outreq(req);
2247+
}
2248+
22062249
const struct plugin_command splice_commands[] = {
22072250
{
22082251
"dev-splice",
22092252
json_splice
22102253
},
2254+
{
2255+
"splicein",
2256+
json_splicein
2257+
},
22112258
};
22122259
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
@@ -308,7 +308,6 @@ def test_script_two_chan_splice_inout(node_factory, bitcoind):
308308
l2.rpc.pay(inv['bolt11'])
309309

310310

311-
@pytest.mark.xfail(strict=True)
312311
@pytest.mark.openchannel('v1')
313312
@pytest.mark.openchannel('v2')
314313
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

0 commit comments

Comments
 (0)