| 2186 | } |
| 2187 | |
| 2188 | static struct command_result * |
| 2189 | check_offer_sendamount_payable(struct command *cmd, const char *offerstr) |
| 2190 | { |
| 2191 | const char *err; |
| 2192 | struct tlv_offer *b12offer = |
| 2193 | offer_decode(tmpctx, offerstr, strlen(offerstr), |
| 2194 | plugin_feature_set(cmd->plugin), chainparams, &err); |
| 2195 | /* Is it a valid offer? */ |
| 2196 | if (!b12offer) |
| 2197 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2198 | "Invalid bolt12 offer: %s", err); |
| 2199 | /* FIXME: add currency support */ |
| 2200 | if (b12offer->offer_currency) |
| 2201 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2202 | "Cannot pay offer in different currency %.*s", |
| 2203 | (int)tal_bytelen(b12offer->offer_currency), |
| 2204 | b12offer->offer_currency); |
| 2205 | /* Can only be applied to *any amount* offers. */ |
| 2206 | if (b12offer->offer_amount) |
| 2207 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2208 | "Expecting an offer with no amount."); |
| 2209 | |
| 2210 | /* Not recurrence, one time only. */ |
| 2211 | if (offer_recurrence(b12offer)) |
| 2212 | return command_fail(cmd, JSONRPC2_INVALID_PARAMS, |
| 2213 | "Cannot sendamount recurring offers"); |
| 2214 | return NULL; |
| 2215 | } |
| 2216 | |
| 2217 | struct xpay_params { |
| 2218 | struct amount_msat *msat, *maxfee, *partial, *includefees_msat; |
no test coverage detected