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

Function permute_outputs

common/permute_tx.c:91–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void permute_outputs(struct bitcoin_tx *tx, u32 *cltvs, const void **map)
92{
93 size_t i, best_pos;
94 struct wally_tx_output *outputs = tx->wtx->outputs;
95 size_t num_outputs = tx->wtx->num_outputs;
96
97 /* We can't permute nothing! */
98 if (num_outputs == 0)
99 return;
100
101 /* Now do a dumb sort (num_outputs is small). */
102 for (i = 0; i < num_outputs - 1; i++) {
103 best_pos =
104 i + find_best_out(outputs + i, cltvs ? cltvs + i : NULL,
105 num_outputs - i);
106
107 /* Swap best into first place. */
108 swap_wally_outputs(tx->wtx->outputs,
109 tx->psbt->tx->outputs,
110 tx->psbt->outputs,
111 map, cltvs, i, best_pos);
112 }
113}

Callers 3

commit_txFunction · 0.85
initial_commit_txFunction · 0.85
create_close_txFunction · 0.85

Calls 2

find_best_outFunction · 0.85
swap_wally_outputsFunction · 0.85

Tested by

no test coverage detected