| 3132 | |
| 3133 | #if DEVELOPER |
| 3134 | static struct command_result *json_queryrates(struct command *cmd, |
| 3135 | const char *buffer, |
| 3136 | const jsmntok_t *obj UNNEEDED, |
| 3137 | const jsmntok_t *params) |
| 3138 | { |
| 3139 | struct node_id *id; |
| 3140 | struct peer *peer; |
| 3141 | struct channel *channel; |
| 3142 | u32 *feerate_per_kw_funding; |
| 3143 | u32 *feerate_per_kw; |
| 3144 | struct amount_sat *amount, *request_amt; |
| 3145 | struct wally_psbt *psbt; |
| 3146 | struct open_attempt *oa; |
| 3147 | u32 *our_upfront_shutdown_script_wallet_index; |
| 3148 | struct command_result *res; |
| 3149 | int fds[2]; |
| 3150 | |
| 3151 | if (!param(cmd, buffer, params, |
| 3152 | p_req("id", param_node_id, &id), |
| 3153 | p_req("amount", param_sat, &amount), |
| 3154 | p_req("request_amt", param_sat, &request_amt), |
| 3155 | p_opt("commitment_feerate", param_feerate, &feerate_per_kw), |
| 3156 | p_opt("funding_feerate", param_feerate, &feerate_per_kw_funding), |
| 3157 | NULL)) |
| 3158 | return command_param_failed(); |
| 3159 | |
| 3160 | res = init_set_feerate(cmd, &feerate_per_kw, &feerate_per_kw_funding); |
| 3161 | if (res) |
| 3162 | return res; |
| 3163 | |
| 3164 | peer = peer_by_id(cmd->ld, id); |
| 3165 | if (!peer) { |
| 3166 | return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer"); |
| 3167 | } |
| 3168 | |
| 3169 | if (peer->connected != PEER_CONNECTED) |
| 3170 | return command_fail(cmd, FUNDING_PEER_NOT_CONNECTED, |
| 3171 | "Peer %s", |
| 3172 | peer->connected == PEER_DISCONNECTED |
| 3173 | ? "not connected" : "still connecting"); |
| 3174 | |
| 3175 | /* FIXME: This is wrong: we should always create a new channel? */ |
| 3176 | channel = peer_any_unsaved_channel(peer, NULL); |
| 3177 | if (!channel) { |
| 3178 | channel = new_unsaved_channel(peer, |
| 3179 | peer->ld->config.fee_base, |
| 3180 | peer->ld->config.fee_per_satoshi); |
| 3181 | |
| 3182 | /* We derive initial channel_id *now*, so we can tell it to |
| 3183 | * connectd. */ |
| 3184 | derive_tmp_channel_id(&channel->cid, |
| 3185 | &channel->local_basepoints.revocation); |
| 3186 | } |
| 3187 | |
| 3188 | if (channel->open_attempt |
| 3189 | || !list_empty(&channel->inflights)) |
| 3190 | return command_fail(cmd, FUNDING_STATE_INVALID, |
| 3191 | "Channel funding in-progress. %s", |
nothing calls this directly
no test coverage detected