| 100 | } |
| 101 | |
| 102 | static const u8 *linearize_output(const tal_t *ctx, |
| 103 | const struct wally_psbt *parent, |
| 104 | size_t index) |
| 105 | { |
| 106 | struct wally_psbt *copy = clone_psbt(NULL, parent); |
| 107 | struct wally_psbt *psbt = create_psbt(NULL, 0, 1, 0); |
| 108 | struct wally_psbt_output dummy_out; |
| 109 | size_t byte_len; |
| 110 | struct bitcoin_outpoint outpoint; |
| 111 | |
| 112 | /* Add a 'fake' non-zero input so libwally will agree to linearize the tx */ |
| 113 | memset(&outpoint, 1, sizeof(outpoint)); |
| 114 | psbt_append_input(psbt, &outpoint, 0, NULL, NULL, NULL); |
| 115 | |
| 116 | dummy_out = psbt->outputs[0]; |
| 117 | psbt->outputs[0] = copy->outputs[index]; |
| 118 | psbt->num_outputs = 1; |
| 119 | |
| 120 | /* Sort the outputs, so serializing them is ok */ |
| 121 | wally_map_sort(&psbt->outputs[0].unknowns, 0); |
| 122 | |
| 123 | /* We don't care if the keypaths change */ |
| 124 | psbt->outputs[0].keypaths.num_items = 0; |
| 125 | psbt->outputs[0].taproot_leaf_hashes.num_items = 0; |
| 126 | psbt->outputs[0].taproot_leaf_paths.num_items = 0; |
| 127 | /* And you can add scripts, no problem */ |
| 128 | wally_psbt_output_set_witness_script(&psbt->outputs[0], NULL, 0); |
| 129 | wally_psbt_output_set_redeem_script(&psbt->outputs[0], NULL, 0); |
| 130 | |
| 131 | const u8 *bytes = psbt_get_bytes(ctx, psbt, &byte_len); |
| 132 | |
| 133 | psbt->outputs[0] = dummy_out; |
| 134 | psbt->num_outputs = 0; |
| 135 | |
| 136 | tal_free(psbt); |
| 137 | tal_free(copy); |
| 138 | |
| 139 | return bytes; |
| 140 | } |
| 141 | |
| 142 | static bool input_identical(const struct wally_psbt *a, |
| 143 | size_t a_index, |
no test coverage detected