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

Function linearize_input

common/psbt_open.c:61–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static const u8 *linearize_input(const tal_t *ctx,
62 const struct wally_psbt *parent,
63 size_t index)
64{
65 struct wally_psbt *copy = clone_psbt(NULL, parent);
66 struct wally_psbt *psbt = create_psbt(NULL, 1, 0, 0);
67 struct wally_psbt_input dummy_in;
68 size_t byte_len;
69
70 dummy_in = psbt->inputs[0];
71 psbt->inputs[0] = copy->inputs[index];
72 psbt->num_inputs = 1;
73
74 /* Sort the inputs, so serializing them is ok */
75 wally_map_sort(&psbt->inputs[0].unknowns, 0);
76
77 /* signatures, keypaths, etc - we dont care if they change */
78 wally_psbt_input_set_final_witness(&psbt->inputs[0], NULL);
79 wally_psbt_input_set_final_scriptsig(&psbt->inputs[0], NULL, 0);
80 wally_psbt_input_set_witness_script(&psbt->inputs[0], NULL, 0);
81 wally_psbt_input_set_redeem_script(&psbt->inputs[0], NULL, 0);
82 wally_psbt_input_set_taproot_signature(&psbt->inputs[0], NULL, 0);
83 wally_psbt_input_set_sighash(&psbt->inputs[0], 0);
84 psbt->inputs[0].taproot_leaf_hashes.num_items = 0;
85 psbt->inputs[0].taproot_leaf_paths.num_items = 0;
86 psbt->inputs[0].keypaths.num_items = 0;
87 psbt->inputs[0].signatures.num_items = 0;
88 psbt->inputs[0].utxo = NULL;
89 psbt->inputs[0].witness_utxo = NULL;
90
91 const u8 *bytes = psbt_get_bytes(ctx, psbt, &byte_len);
92
93 psbt->inputs[0] = dummy_in;
94 psbt->num_inputs = 0;
95
96 tal_free(psbt);
97 tal_free(copy);
98
99 return bytes;
100}
101
102static const u8 *linearize_output(const tal_t *ctx,
103 const struct wally_psbt *parent,

Callers 1

input_identicalFunction · 0.85

Calls 4

clone_psbtFunction · 0.85
create_psbtFunction · 0.85
psbt_get_bytesFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected