| 469 | } |
| 470 | |
| 471 | struct tlv_payer_proof *payer_proof_decode(const tal_t *ctx, |
| 472 | const char *b12, size_t b12len, |
| 473 | const char **fail) |
| 474 | { |
| 475 | struct tlv_payer_proof *tlvpp; |
| 476 | const u8 *data; |
| 477 | size_t dlen; |
| 478 | |
| 479 | data = b12_string_to_data(tmpctx, b12, b12len, "lnp", &dlen, fail); |
| 480 | if (!data) { |
| 481 | tal_steal(ctx, *fail); |
| 482 | return NULL; |
| 483 | } |
| 484 | |
| 485 | tlvpp = fromwire_tlv_payer_proof(ctx, &data, &dlen); |
| 486 | if (!tlvpp) { |
| 487 | *fail = tal_fmt(ctx, "invalid payer_proof data"); |
| 488 | return NULL; |
| 489 | } |
| 490 | |
| 491 | *fail = check_payer_proof(ctx, tlvpp); |
| 492 | if (*fail) |
| 493 | return tal_free(tlvpp); |
| 494 | |
| 495 | return tlvpp; |
| 496 | } |