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

Function psbt_append_input

bitcoin/psbt.c:128–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128struct wally_psbt_input *psbt_append_input(struct wally_psbt *psbt,
129 const struct bitcoin_outpoint *outpoint,
130 u32 sequence,
131 const u8 *scriptSig,
132 const u8 *input_wscript,
133 const u8 *redeemscript)
134{
135 struct wally_tx_input *tx_in;
136 size_t input_num = psbt->num_inputs;
137 const u32 flags = WALLY_PSBT_FLAG_NON_FINAL; /* Skip script/witness */
138 int wally_err;
139
140 tal_wally_start();
141 if (chainparams->is_elements) {
142 if (wally_tx_elements_input_init_alloc(outpoint->txid.shad.sha.u.u8,
143 sizeof(outpoint->txid.shad.sha.u.u8),
144 outpoint->n,
145 sequence, NULL, 0,
146 NULL,
147 NULL, 0,
148 NULL, 0, NULL, 0,
149 NULL, 0, NULL, 0,
150 NULL, 0, NULL,
151 &tx_in) != WALLY_OK)
152 abort();
153 } else {
154 if (wally_tx_input_init_alloc(outpoint->txid.shad.sha.u.u8,
155 sizeof(outpoint->txid.shad.sha.u.u8),
156 outpoint->n,
157 sequence, NULL, 0, NULL,
158 &tx_in) != WALLY_OK)
159 abort();
160 }
161
162 wally_err = wally_psbt_add_input_at(psbt, input_num, flags, tx_in);
163 assert(wally_err == WALLY_OK);
164 wally_tx_input_free(tx_in);
165 tal_wally_end(psbt);
166
167 if (input_wscript) {
168 /* Add the prev output's data into the PSBT struct */
169 psbt_input_set_witscript(psbt, input_num, input_wscript);
170 }
171
172 if (redeemscript) {
173 tal_wally_start();
174 wally_err = wally_psbt_input_set_redeem_script(&psbt->inputs[input_num],
175 redeemscript,
176 tal_bytelen(redeemscript));
177 assert(wally_err == WALLY_OK);
178 tal_wally_end(psbt);
179 }
180
181 return &psbt->inputs[input_num];
182}
183
184void psbt_rm_input(struct wally_psbt *psbt,
185 size_t remove_at)

Callers 5

bitcoin_tx_add_inputFunction · 0.70
psbt_using_utxosFunction · 0.50
linearize_outputFunction · 0.50
add_in_out_with_serialFunction · 0.50
run_tx_interactiveFunction · 0.50

Calls 5

tal_wally_startFunction · 0.85
abortFunction · 0.85
tal_wally_endFunction · 0.85
psbt_input_set_witscriptFunction · 0.85
tal_bytelenFunction · 0.85

Tested by 1

add_in_out_with_serialFunction · 0.40