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

Function permute_outputs

common/permute_tx.c:84–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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