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

Function json_queryrates

lightningd/dual_open_control.c:3815–3959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3813}
3814
3815static struct command_result *json_queryrates(struct command *cmd,
3816 const char *buffer,
3817 const jsmntok_t *obj UNNEEDED,
3818 const jsmntok_t *params)
3819{
3820 struct node_id *id;
3821 struct peer *peer;
3822 struct channel *channel;
3823 u32 *feerate_per_kw_funding;
3824 u32 *feerate_per_kw, anchor_feerate;
3825 struct amount_sat *amount, *request_amt;
3826 struct wally_psbt *psbt;
3827 struct open_attempt *oa;
3828 u32 *our_upfront_shutdown_script_wallet_index;
3829 struct command_result *res;
3830 int fds[2];
3831
3832 if (!param_check(cmd, buffer, params,
3833 p_req("id", param_node_id, &id),
3834 p_req("amount", param_sat, &amount),
3835 p_req("request_amt", param_sat, &request_amt),
3836 p_opt("commitment_feerate", param_feerate, &feerate_per_kw),
3837 p_opt("funding_feerate", param_feerate, &feerate_per_kw_funding),
3838 NULL))
3839 return command_param_failed();
3840
3841 res = init_set_feerate(cmd, &feerate_per_kw, &feerate_per_kw_funding);
3842 if (res)
3843 return res;
3844
3845 peer = peer_by_id(cmd->ld, id);
3846 if (!peer) {
3847 return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer");
3848 }
3849
3850 if (peer->connected != PEER_CONNECTED)
3851 return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED,
3852 "Peer %s",
3853 peer->connected == PEER_DISCONNECTED
3854 ? "not connected" : "still connecting");
3855
3856 if (!feature_negotiated(cmd->ld->our_features,
3857 peer->their_features,
3858 OPT_DUAL_FUND)) {
3859 return command_fail(cmd, FUNDING_V2_NOT_SUPPORTED,
3860 "v2 openchannel not supported "
3861 "by peer, can't query rates");
3862 }
3863
3864 /* BOLT #2:
3865 * - if both nodes advertised `option_support_large_channel`:
3866 * - MAY set `funding_satoshis` greater than or equal to 2^24 satoshi.
3867 * - otherwise:
3868 * - MUST set `funding_satoshis` to less than 2^24 satoshi.
3869 */
3870 if (!feature_negotiated(cmd->ld->our_features,
3871 peer->their_features, OPT_LARGE_CHANNELS)
3872 && 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