| 3813 | } |
| 3814 | |
| 3815 | static 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)) |
nothing calls this directly
no test coverage detected