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

Function psbt_append_input

bitcoin/psbt.c:198–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198struct wally_psbt_input *psbt_append_input(struct wally_psbt *psbt,
199 const struct bitcoin_outpoint *outpoint,
200 u32 sequence,
201 const u8 *scriptSig,
202 const u8 *input_wscript,
203 const u8 *redeemscript)
204{
205 struct wally_tx_input *tx_in;
206 size_t input_num = psbt->num_inputs;
207 const u32 flags = WALLY_PSBT_FLAG_NON_FINAL; /* Skip script/witness */
208 int wally_err;
209
210 tal_wally_start();
211 if (chainparams->is_elements) {
212 if (wally_tx_elements_input_init_alloc(outpoint->txid.shad.sha.u.u8,
213 sizeof(outpoint->txid.shad.sha.u.u8),
214 outpoint->n,
215 sequence, NULL, 0,
216 NULL,
217 NULL, 0,
218 NULL, 0, NULL, 0,
219 NULL, 0, NULL, 0,
220 NULL, 0, NULL,
221 &tx_in) != WALLY_OK)
222 abort();
223 } else {
224 if (wally_tx_input_init_alloc(outpoint->txid.shad.sha.u.u8,
225 sizeof(outpoint->txid.shad.sha.u.u8),
226 outpoint->n,
227 sequence, NULL, 0, NULL,
228 &tx_in) != WALLY_OK)
229 abort();
230 }
231
232 wally_err = wally_psbt_add_tx_input_at(psbt, input_num, flags, tx_in);
233 assert(wally_err == WALLY_OK);
234 wally_tx_input_free(tx_in);
235 tal_wally_end(psbt);
236
237 if (input_wscript) {
238 /* Add the prev output's data into the PSBT struct */
239 psbt_input_set_witscript(psbt, input_num, input_wscript);
240 }
241
242 if (redeemscript) {
243 tal_wally_start();
244 wally_err = wally_psbt_input_set_redeem_script(&psbt->inputs[input_num],
245 redeemscript,
246 tal_bytelen(redeemscript));
247 assert(wally_err == WALLY_OK);
248 tal_wally_end(psbt);
249 }
250
251 return &psbt->inputs[input_num];
252}
253
254void psbt_rm_input(struct wally_psbt *psbt,
255 size_t remove_at)

Callers 9

bitcoin_tx_add_inputFunction · 0.85
psbt_using_utxosFunction · 0.85
splice_initiatorFunction · 0.85
anchor_psbtFunction · 0.85
linearize_outputFunction · 0.85
add_in_out_with_serialFunction · 0.85
update_parent_psbtFunction · 0.85
run_tx_interactiveFunction · 0.85

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.68