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

Function param_decodable

plugins/offers.c:646–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644}
645
646static struct command_result *param_decodable(struct command *cmd,
647 const char *name,
648 const char *buffer,
649 const jsmntok_t *token,
650 struct decodable *decodable)
651{
652 const char *likely_fail = NULL, *fail;
653 jsmntok_t tok;
654 enum likely_type type;
655
656 /* BOLT #11:
657 *
658 * If a URI scheme is desired, the current recommendation is to either
659 * use 'lightning:' as a prefix before the BOLT-11 encoding
660 */
661 tok = *token;
662 /* Note: either case! */
663 tok_pull(buffer, &tok, "lightning:");
664
665 type = guess_type(buffer, &tok);
666 decodable->offer = offer_decode(cmd, buffer + tok.start,
667 tok.end - tok.start,
668 plugin_feature_set(cmd->plugin), NULL,
669 type == LIKELY_BOLT12_OFFER
670 ? &likely_fail : &fail);
671 if (decodable->offer) {
672 decodable->type = "bolt12 offer";
673 return NULL;
674 }
675
676 decodable->invoice = invoice_decode(cmd, buffer + tok.start,
677 tok.end - tok.start,
678 plugin_feature_set(cmd->plugin),
679 NULL,
680 type == LIKELY_BOLT12_INV
681 ? &likely_fail : &fail);
682 if (decodable->invoice) {
683 decodable->type = "bolt12 invoice";
684 return NULL;
685 }
686
687 decodable->invreq = invrequest_decode(cmd, buffer + tok.start,
688 tok.end - tok.start,
689 plugin_feature_set(cmd->plugin),
690 NULL,
691 type == LIKELY_BOLT12_INVREQ
692 ? &likely_fail : &fail);
693 if (decodable->invreq) {
694 decodable->type = "bolt12 invoice_request";
695 return NULL;
696 }
697
698 decodable->payer_proof = payer_proof_decode(cmd, buffer + tok.start,
699 tok.end - tok.start,
700 type == LIKELY_BOLT12_PAYER_PROOF
701 ? &likely_fail : &fail);
702 if (decodable->payer_proof) {
703 decodable->type = "bolt12 payer_proof";

Callers

nothing calls this directly

Calls 13

tok_pullFunction · 0.85
guess_typeFunction · 0.85
offer_decodeFunction · 0.85
invoice_decodeFunction · 0.85
invrequest_decodeFunction · 0.85
payer_proof_decodeFunction · 0.85
encrypted_decodeFunction · 0.85
bolt11_decodeFunction · 0.85
rune_from_base64nFunction · 0.85
rune_to_stringFunction · 0.85
plugin_feature_setFunction · 0.70
utf8_checkFunction · 0.50

Tested by

no test coverage detected