| 94 | } |
| 95 | |
| 96 | static const u8 *linearize_output(const tal_t *ctx, |
| 97 | const struct wally_psbt_output *out, |
| 98 | const struct wally_tx_output *tx_out) |
| 99 | { |
| 100 | struct wally_psbt *psbt = create_psbt(NULL, 1, 1, 0); |
| 101 | size_t byte_len; |
| 102 | struct bitcoin_outpoint outpoint; |
| 103 | |
| 104 | /* Add a 'fake' input so this will linearize the tx */ |
| 105 | memset(&outpoint, 0, sizeof(outpoint)); |
| 106 | psbt_append_input(psbt, &outpoint, 0, NULL, NULL, NULL); |
| 107 | |
| 108 | tal_wally_start(); |
| 109 | if (wally_tx_add_output(psbt->tx, tx_out) != WALLY_OK) |
| 110 | abort(); |
| 111 | tal_wally_end(psbt->tx); |
| 112 | |
| 113 | psbt->outputs[0] = *out; |
| 114 | psbt->num_outputs++; |
| 115 | /* Sort the outputs, so serializing them is ok */ |
| 116 | wally_map_sort(&psbt->outputs[0].unknowns, 0); |
| 117 | |
| 118 | /* We don't care if the keypaths change */ |
| 119 | psbt->outputs[0].keypaths.num_items = 0; |
| 120 | /* And you can add scripts, no problem */ |
| 121 | psbt->outputs[0].witness_script_len = 0; |
| 122 | psbt->outputs[0].redeem_script_len = 0; |
| 123 | |
| 124 | const u8 *bytes = psbt_get_bytes(ctx, psbt, &byte_len); |
| 125 | |
| 126 | /* Hide the outputs we added, so it doesn't get freed */ |
| 127 | psbt->num_outputs--; |
| 128 | tal_free(psbt); |
| 129 | return bytes; |
| 130 | } |
| 131 | |
| 132 | static bool input_identical(const struct wally_psbt *a, |
| 133 | size_t a_index, |
no test coverage detected