| 142 | }; |
| 143 | |
| 144 | static struct command_result *param_decodable(struct command *cmd, |
| 145 | const char *name, |
| 146 | const char *buffer, |
| 147 | const jsmntok_t *token, |
| 148 | struct decodable *decodable) |
| 149 | { |
| 150 | char *likely_fail = NULL, *fail; |
| 151 | jsmntok_t tok; |
| 152 | |
| 153 | /* BOLT #11: |
| 154 | * |
| 155 | * If a URI scheme is desired, the current recommendation is to either |
| 156 | * use 'lightning:' as a prefix before the BOLT-11 encoding |
| 157 | */ |
| 158 | tok = *token; |
| 159 | if (json_tok_startswith(buffer, &tok, "lightning:") |
| 160 | || json_tok_startswith(buffer, &tok, "LIGHTNING:")) |
| 161 | tok.start += strlen("lightning:"); |
| 162 | |
| 163 | decodable->offer = offer_decode(cmd, buffer + tok.start, |
| 164 | tok.end - tok.start, |
| 165 | plugin_feature_set(cmd->plugin), NULL, |
| 166 | json_tok_startswith(buffer, &tok, "lno1") |
| 167 | ? &likely_fail : &fail); |
| 168 | if (decodable->offer) { |
| 169 | decodable->type = "bolt12 offer"; |
| 170 | return NULL; |
| 171 | } |
| 172 | |
| 173 | decodable->invoice = invoice_decode(cmd, buffer + tok.start, |
| 174 | tok.end - tok.start, |
| 175 | plugin_feature_set(cmd->plugin), |
| 176 | NULL, |
| 177 | json_tok_startswith(buffer, &tok, |
| 178 | "lni1") |
| 179 | ? &likely_fail : &fail); |
| 180 | if (decodable->invoice) { |
| 181 | decodable->type = "bolt12 invoice"; |
| 182 | return NULL; |
| 183 | } |
| 184 | |
| 185 | decodable->invreq = invrequest_decode(cmd, buffer + tok.start, |
| 186 | tok.end - tok.start, |
| 187 | plugin_feature_set(cmd->plugin), |
| 188 | NULL, |
| 189 | json_tok_startswith(buffer, &tok, |
| 190 | "lnr1") |
| 191 | ? &likely_fail : &fail); |
| 192 | if (decodable->invreq) { |
| 193 | decodable->type = "bolt12 invoice_request"; |
| 194 | return NULL; |
| 195 | } |
| 196 | |
| 197 | /* If no other was likely, bolt11 decoder gives us failure string. */ |
| 198 | decodable->b11 = bolt11_decode(cmd, |
| 199 | tal_strndup(tmpctx, buffer + tok.start, |
| 200 | tok.end - tok.start), |
| 201 | plugin_feature_set(cmd->plugin), |
nothing calls this directly
no test coverage detected