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

Function json_rbf_channel_call

plugins/funder.c:1048–1124  ·  view source on GitHub ↗

Peer has asked us to RBF */

Source from the content-addressed store, hash-verified

1046
1047/* Peer has asked us to RBF */
1048static struct command_result *
1049json_rbf_channel_call(struct command *cmd,
1050 const char *buf,
1051 const jsmntok_t *params)
1052{
1053 struct open_info *info = new_open_info(cmd);
1054 u64 feerate_our_max, feerate_our_min;
1055 const char *err, *chan_key;
1056 struct out_req *req;
1057
1058 info->their_last_funding = tal(info, struct amount_sat);
1059 info->our_last_funding = tal(info, struct amount_sat);
1060 err = json_scan(tmpctx, buf, params,
1061 "{rbf_channel:"
1062 "{id:%"
1063 ",channel_id:%"
1064 ",their_last_funding_msat:%"
1065 ",their_funding_msat:%"
1066 ",our_last_funding_msat:%"
1067 ",funding_feerate_per_kw:%"
1068 ",feerate_our_max:%"
1069 ",feerate_our_min:%"
1070 ",locktime:%"
1071 ",channel_max_msat:%}}",
1072 JSON_SCAN(json_to_node_id, &info->id),
1073 JSON_SCAN(json_to_channel_id, &info->cid),
1074 JSON_SCAN(json_to_msat_as_sats,
1075 info->their_last_funding),
1076 JSON_SCAN(json_to_msat_as_sats,
1077 &info->their_funding),
1078 JSON_SCAN(json_to_msat_as_sats,
1079 info->our_last_funding),
1080 JSON_SCAN(json_to_u64, &info->funding_feerate_perkw),
1081 JSON_SCAN(json_to_u64, &feerate_our_max),
1082 JSON_SCAN(json_to_u64, &feerate_our_min),
1083 JSON_SCAN(json_to_u32, &info->locktime),
1084 JSON_SCAN(json_to_msat_as_sats, &info->channel_max));
1085
1086 if (err)
1087 plugin_err(cmd->plugin,
1088 "`rbf_channel` payload did not scan %s: %.*s",
1089 err, json_tok_full_len(params),
1090 json_tok_full(buf, params));
1091
1092 /* Lease info isn't necessarily included, ignore any err */
1093 /* FIXME: blockheights?? */
1094 json_scan(tmpctx, buf, params,
1095 "{rbf_channel:{"
1096 "requested_lease_msat:%}}",
1097 JSON_SCAN(json_to_msat_as_sats, &info->requested_lease));
1098
1099 /* We don't fund anything that's above or below our feerate */
1100 if (info->funding_feerate_perkw < feerate_our_min
1101 || info->funding_feerate_perkw > feerate_our_max) {
1102
1103 plugin_log(cmd->plugin, LOG_DBG,
1104 "their feerate %"PRIu64" is out of"
1105 " our bounds (%"PRIu64"-%"PRIu64")",

Callers

nothing calls this directly

Calls 10

new_open_infoFunction · 0.85
plugin_errFunction · 0.70
plugin_logFunction · 0.70
command_hook_successFunction · 0.70
send_outreqFunction · 0.70
json_scanFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
fmt_channel_idFunction · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected