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

Function linearize_input

common/psbt_open.c:60–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60static const u8 *linearize_input(const tal_t *ctx,
61 const struct wally_psbt_input *in,
62 const struct wally_tx_input *tx_in)
63{
64 struct wally_psbt *psbt = create_psbt(NULL, 1, 0, 0);
65 size_t byte_len;
66
67 tal_wally_start();
68 if (wally_tx_add_input(psbt->tx, tx_in) != WALLY_OK)
69 abort();
70 tal_wally_end(psbt->tx);
71
72 psbt->inputs[0] = *in;
73 psbt->num_inputs++;
74
75
76 /* Sort the inputs, so serializing them is ok */
77 wally_map_sort(&psbt->inputs[0].unknowns, 0);
78
79 /* signatures, keypaths, etc - we dont care if they change */
80 psbt->inputs[0].final_witness = NULL;
81 psbt->inputs[0].final_scriptsig_len = 0;
82 psbt->inputs[0].witness_script = NULL;
83 psbt->inputs[0].witness_script_len = 0;
84 psbt->inputs[0].redeem_script_len = 0;
85 psbt->inputs[0].keypaths.num_items = 0;
86 psbt->inputs[0].signatures.num_items = 0;
87
88 const u8 *bytes = psbt_get_bytes(ctx, psbt, &byte_len);
89
90 /* Hide the inputs we added, so it doesn't get freed */
91 psbt->num_inputs--;
92 tal_free(psbt);
93 return bytes;
94}
95
96static const u8 *linearize_output(const tal_t *ctx,
97 const struct wally_psbt_output *out,

Callers 1

input_identicalFunction · 0.85

Calls 6

create_psbtFunction · 0.85
tal_wally_startFunction · 0.85
abortFunction · 0.85
tal_wally_endFunction · 0.85
psbt_get_bytesFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected