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

Function param_offer

plugins/fetchinvoice.c:499–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499static struct command_result *param_offer(struct command *cmd,
500 const char *name,
501 const char *buffer,
502 const jsmntok_t *tok,
503 struct tlv_offer **offer)
504{
505 char *fail;
506
507 /* BOLT-offers #12:
508 * - if `features` contains unknown _odd_ bits that are non-zero:
509 * - MUST ignore the bit.
510 * - if `features` contains unknown _even_ bits that are non-zero:
511 * - MUST NOT respond to the offer.
512 * - SHOULD indicate the unknown bit to the user.
513 */
514 /* BOLT-offers #12:
515 * - MUST NOT set or imply any `chain_hash` not set or implied by
516 * the offer.
517 */
518 *offer = offer_decode(cmd, buffer + tok->start, tok->end - tok->start,
519 plugin_feature_set(cmd->plugin), chainparams,
520 &fail);
521 if (!*offer)
522 return command_fail_badparam(cmd, name, buffer, tok,
523 tal_fmt(cmd,
524 "Unparsable offer: %s",
525 fail));
526
527 /* BOLT-offers #12:
528 *
529 * - if `node_id` or `description` is not set:
530 * - MUST NOT respond to the offer.
531 */
532 if (!(*offer)->node_id)
533 return command_fail_badparam(cmd, name, buffer, tok,
534 "Offer does not contain a node_id");
535
536 if (!(*offer)->description)
537 return command_fail_badparam(cmd, name, buffer, tok,
538 "Offer does not contain a description");
539 return NULL;
540}
541
542static bool can_carry_onionmsg(const struct gossmap *map,
543 const struct gossmap_chan *c,

Callers

nothing calls this directly

Calls 3

offer_decodeFunction · 0.85
plugin_feature_setFunction · 0.85
command_fail_badparamFunction · 0.85

Tested by

no test coverage detected