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