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

Function check_offer_sendamount_payable

plugins/xpay/xpay.c:2188–2215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2186}
2187
2188static struct command_result *
2189check_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
2217struct xpay_params {
2218 struct amount_msat *msat, *maxfee, *partial, *includefees_msat;

Callers 2

bip353_fetchedFunction · 0.85
json_sendamountFunction · 0.85

Calls 5

offer_decodeFunction · 0.85
tal_bytelenFunction · 0.85
offer_recurrenceFunction · 0.85
plugin_feature_setFunction · 0.50
command_failFunction · 0.50

Tested by

no test coverage detected