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

Function json_queryrates

lightningd/dual_open_control.c:4161–4300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4159}
4160
4161static struct command_result *json_queryrates(struct command *cmd,
4162 const char *buffer,
4163 const jsmntok_t *obj UNNEEDED,
4164 const jsmntok_t *params)
4165{
4166 struct node_id *id;
4167 struct peer *peer;
4168 struct channel *channel;
4169 u32 *feerate_per_kw_funding;
4170 u32 *feerate_per_kw, anchor_feerate;
4171 struct amount_sat *amount, *request_amt;
4172 struct wally_psbt *psbt;
4173 struct open_attempt *oa;
4174 u32 *our_upfront_shutdown_script_wallet_index;
4175 struct command_result *res;
4176 int fds[2];
4177
4178 if (!param_check(cmd, buffer, params,
4179 p_req("id", param_node_id, &id),
4180 p_req("amount", param_sat, &amount),
4181 p_req("request_amt", param_sat, &request_amt),
4182 p_opt("commitment_feerate", param_feerate, &feerate_per_kw),
4183 p_opt("funding_feerate", param_feerate, &feerate_per_kw_funding),
4184 NULL))
4185 return command_param_failed();
4186
4187 res = init_set_feerate(cmd, &feerate_per_kw, &feerate_per_kw_funding);
4188 if (res)
4189 return res;
4190
4191 peer = peer_by_id(cmd->ld, id);
4192 if (!peer) {
4193 return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
4194 }
4195
4196 if (peer->connected != PEER_CONNECTED)
4197 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
4198 "Peer %s",
4199 peer->connected == PEER_DISCONNECTED
4200 ? "not connected" : "still connecting");
4201
4202 if (!feature_negotiated(cmd->ld->our_features,
4203 peer->their_features,
4204 OPT_DUAL_FUND)) {
4205 return command_fail(cmd, FUNDING_V2_NOT_SUPPORTED,
4206 "v2 openchannel not supported "
4207 "by peer, can't query rates");
4208 }
4209
4210 /* BOLT #2:
4211 * - if both nodes advertised `option_support_large_channel`:
4212 * - MAY set `funding_satoshis` greater than or equal to 2^24 satoshi.
4213 * - otherwise:
4214 * - MUST set `funding_satoshis` to less than 2^24 satoshi.
4215 */
4216 if (!feature_negotiated(cmd->ld->our_features,
4217 peer->their_features, OPT_LARGE_CHANNELS)
4218 && amount_sat_greater(*amount, chainparams->max_funding))

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
init_set_feerateFunction · 0.85
peer_by_idFunction · 0.85
feature_negotiatedFunction · 0.85
amount_sat_greaterFunction · 0.85
derive_tmp_channel_idFunction · 0.85
new_channel_open_attemptFunction · 0.85
create_psbtFunction · 0.85
wallet_can_spendFunction · 0.85
tal_bytelenFunction · 0.85
amount_sat_is_zeroFunction · 0.85
desired_channel_typeFunction · 0.85

Tested by

no test coverage detected