@@ -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+
22062249const struct plugin_command splice_commands [] = {
22072250 {
22082251 "dev-splice" ,
22092252 json_splice
22102253 },
2254+ {
2255+ "splicein" ,
2256+ json_splicein
2257+ },
22112258};
22122259const size_t num_splice_commands = ARRAY_SIZE (splice_commands );
0 commit comments