| 318 | } |
| 319 | |
| 320 | struct command_result *handle_invoice(struct command *cmd, |
| 321 | const u8 *invbin, |
| 322 | struct tlv_onionmsg_payload_reply_path *reply_path STEALS) |
| 323 | { |
| 324 | size_t len = tal_count(invbin); |
| 325 | struct inv *inv = tal(cmd, struct inv); |
| 326 | struct out_req *req; |
| 327 | struct command_result *err; |
| 328 | int bad_feature; |
| 329 | struct sha256 m, shash; |
| 330 | |
| 331 | inv->reply_path = tal_steal(inv, reply_path); |
| 332 | |
| 333 | inv->inv = fromwire_tlv_invoice(cmd, &invbin, &len); |
| 334 | if (!inv->inv) { |
| 335 | return fail_inv(cmd, inv, |
| 336 | "Invalid invoice %s", |
| 337 | tal_hex(tmpctx, invbin)); |
| 338 | } |
| 339 | |
| 340 | /* BOLT-offers #12: |
| 341 | * |
| 342 | * The reader of an invoice_request: |
| 343 | *... |
| 344 | * - MUST fail the request if `features` contains unknown even bits. |
| 345 | */ |
| 346 | bad_feature = features_unsupported(plugin_feature_set(cmd->plugin), |
| 347 | inv->inv->features, |
| 348 | BOLT11_FEATURE); |
| 349 | if (bad_feature != -1) { |
| 350 | return fail_inv(cmd, inv, |
| 351 | "Unsupported inv feature %i", |
| 352 | bad_feature); |
| 353 | } |
| 354 | |
| 355 | /* BOLT-offers #12: |
| 356 | * |
| 357 | * The reader of an invoice_request: |
| 358 | *... |
| 359 | * - if `chain` is not present: |
| 360 | * - MUST fail the request if bitcoin is not a supported chain. |
| 361 | * - otherwise: |
| 362 | * - MUST fail the request if `chain` is not a supported chain. |
| 363 | */ |
| 364 | if (!bolt12_chain_matches(inv->inv->chain, chainparams)) { |
| 365 | return fail_inv(cmd, inv, |
| 366 | "Wrong chain %s", |
| 367 | tal_hex(tmpctx, inv->inv->chain)); |
| 368 | } |
| 369 | |
| 370 | /* BOLT-offers #12: |
| 371 | * - MUST reject the invoice if `signature` is not a valid signature |
| 372 | * using `node_id` as described in |
| 373 | * [Signature Calculation](#signature-calculation). |
| 374 | */ |
| 375 | err = inv_must_have(cmd, inv, node_id); |
| 376 | if (err) |
| 377 | return err; |
no test coverage detected