MCPcopy Create free account
hub / github.com/ElementsProject/lightning / swap_wally_outputs

Function swap_wally_outputs

common/permute_tx.c:5–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <wally_psbt.h>
4
5static void swap_wally_outputs(struct wally_tx_output *outputs,
6 struct wally_tx_output *psbt_global_outs,
7 struct wally_psbt_output *psbt_outs,
8 const void **map, u32 *cltvs,
9 size_t i1, size_t i2)
10{
11 struct wally_tx_output tmpoutput;
12 struct wally_psbt_output tmppsbtout;
13
14 if (i1 == i2)
15 return;
16
17 tmpoutput = outputs[i1];
18 outputs[i1] = outputs[i2];
19 outputs[i2] = tmpoutput;
20
21 /* For the PSBT, we swap the psbt outputs and
22 * the global tx's outputs */
23 tmpoutput = psbt_global_outs[i1];
24 psbt_global_outs[i1] = psbt_global_outs[i2];
25 psbt_global_outs[i2] = tmpoutput;
26
27 tmppsbtout = psbt_outs[i1];
28 psbt_outs[i1] = psbt_outs[i2];
29 psbt_outs[i2] = tmppsbtout;
30
31 if (map) {
32 const void *tmp = map[i1];
33 map[i1] = map[i2];
34 map[i2] = tmp;
35 }
36
37 if (cltvs) {
38 u32 tmp = cltvs[i1];
39 cltvs[i1] = cltvs[i2];
40 cltvs[i2] = tmp;
41 }
42}
43
44static bool output_better(const struct wally_tx_output *a, u32 cltv_a,
45 const struct wally_tx_output *b, u32 cltv_b)

Callers 1

permute_outputsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected