MCPcopy Create free account
hub / github.com/ElementsProject/lightning / openchannel_init_dest

Function openchannel_init_dest

plugins/spender/openchannel.c:976–1040  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

974}
975
976struct command_result *
977openchannel_init_dest(struct multifundchannel_destination *dest)
978{
979 struct multifundchannel_command *mfc = dest->mfc;
980 struct command *cmd = mfc->cmd;
981 struct out_req *req;
982
983 plugin_log(cmd->plugin, LOG_DBG,
984 "mfc %"PRIu64", dest %u: openchannel_init %s.",
985 mfc->id, dest->index,
986 node_id_to_hexstr(tmpctx, &dest->id));
987
988 req = jsonrpc_request_start(cmd->plugin, cmd,
989 "openchannel_init",
990 &openchannel_init_ok,
991 &openchannel_init_err,
992 dest);
993
994 json_add_node_id(req->js, "id", &dest->id);
995 assert(!dest->all);
996 json_add_string(req->js, "amount",
997 fmt_amount_sat(tmpctx, dest->amount));
998
999 /* Copy the original parent down */
1000 tal_wally_start();
1001 wally_psbt_clone_alloc(mfc->psbt, 0, &dest->psbt);
1002 tal_wally_end_onto(mfc, dest->psbt, struct wally_psbt);
1003
1004 json_add_psbt(req->js, "initialpsbt", dest->psbt);
1005 if (mfc->cmtmt_feerate_str)
1006 json_add_string(req->js, "commitment_feerate",
1007 mfc->cmtmt_feerate_str);
1008 if (mfc->feerate_str) {
1009 json_add_string(req->js, "funding_feerate",
1010 mfc->feerate_str);
1011
1012 /* If there's no commitment feerate provided, we assume
1013 * that the same feerate is to be used on both. This mimics
1014 * the behavior of the old-style feerate stuffs */
1015 if (!mfc->cmtmt_feerate_str)
1016 json_add_string(req->js, "commitment_feerate",
1017 mfc->feerate_str);
1018 }
1019 json_add_bool(req->js, "announce", dest->announce);
1020 if (dest->close_to_str)
1021 json_add_string(req->js, "close_to", dest->close_to_str);
1022
1023 if (amount_msat_greater(dest->push_msat, AMOUNT_MSAT(0)))
1024 plugin_log(cmd->plugin, LOG_INFORM,
1025 "Using openchannel for %s open, "
1026 "ignoring `push_msat` of %s",
1027 node_id_to_hexstr(tmpctx, &dest->id),
1028 type_to_string(tmpctx, struct amount_msat,
1029 &dest->push_msat));
1030
1031 /* Request some sats from the peer! */
1032 if (!amount_sat_zero(dest->request_amt)) {
1033 json_add_string(req->js, "request_amt",

Callers 1

perform_channel_startFunction · 0.85

Calls 13

fmt_amount_satFunction · 0.85
tal_wally_startFunction · 0.85
json_add_psbtFunction · 0.85
amount_msat_greaterFunction · 0.85
amount_sat_zeroFunction · 0.85
lease_rates_tohexFunction · 0.85
plugin_logFunction · 0.50
node_id_to_hexstrFunction · 0.50
json_add_node_idFunction · 0.50
json_add_stringFunction · 0.50
json_add_boolFunction · 0.50
type_to_stringClass · 0.50

Tested by

no test coverage detected