| 741 | } |
| 742 | |
| 743 | struct wally_psbt *fromwire_wally_psbt(const tal_t *ctx, |
| 744 | const u8 **cursor, size_t *max) |
| 745 | { |
| 746 | struct wally_psbt *psbt; |
| 747 | u32 psbt_byte_len; |
| 748 | const u8 *psbt_buf; |
| 749 | |
| 750 | psbt_byte_len = fromwire_u32(cursor, max); |
| 751 | psbt_buf = fromwire(cursor, max, NULL, psbt_byte_len); |
| 752 | if (!psbt_buf || psbt_byte_len == 0) |
| 753 | return NULL; |
| 754 | |
| 755 | psbt = psbt_from_bytes(ctx, psbt_buf, psbt_byte_len); |
| 756 | if (!psbt) |
| 757 | return fromwire_fail(cursor, max); |
| 758 | |
| 759 | #if DEVELOPER |
| 760 | /* Re-marshall for sanity check! */ |
| 761 | u8 *tmpbuf = tal_arr(NULL, u8, psbt_byte_len); |
| 762 | size_t written; |
| 763 | if (wally_psbt_to_bytes(psbt, 0, tmpbuf, psbt_byte_len, &written) != WALLY_OK) { |
| 764 | tal_free(tmpbuf); |
| 765 | tal_free(psbt); |
| 766 | return fromwire_fail(cursor, max); |
| 767 | } |
| 768 | tal_free(tmpbuf); |
| 769 | #endif |
| 770 | |
| 771 | return psbt; |
| 772 | } |
| 773 | |
| 774 | /* This only works on a non-final psbt because we're ALL SEGWIT! */ |
| 775 | void psbt_txid(const tal_t *ctx, |
no test coverage detected