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

Function bitcoin_tx_add_input

bitcoin/tx.c:225–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225int bitcoin_tx_add_input(struct bitcoin_tx *tx,
226 const struct bitcoin_outpoint *outpoint,
227 u32 sequence, const u8 *scriptSig,
228 struct amount_sat amount, const u8 *scriptPubkey,
229 const u8 *input_wscript)
230{
231 int wally_err;
232 int input_num = tx->wtx->num_inputs;
233 struct wally_tx_input *tx_input;
234
235 psbt_append_input(tx->psbt, outpoint,
236 sequence, scriptSig,
237 input_wscript, NULL);
238
239 if (input_wscript) {
240 scriptPubkey = scriptpubkey_p2wsh(tmpctx, input_wscript);
241 }
242
243 assert(scriptPubkey);
244 psbt_input_set_wit_utxo(tx->psbt, input_num,
245 scriptPubkey, amount);
246
247 tal_wally_start();
248 tx_input = wally_tx_input_from_outpoint_sequence(outpoint, sequence);
249 wally_err = wally_tx_add_input(tx->wtx,
250 tx_input);
251 assert(wally_err == WALLY_OK);
252 wally_tx_input_free(tx_input);
253
254 /* scriptsig isn't actually stored in psbt input, so add that now */
255 wally_tx_set_input_script(tx->wtx, input_num,
256 scriptSig, tal_bytelen(scriptSig));
257 tal_wally_end(tx->wtx);
258
259 if (is_elements(chainparams)) {
260 /* FIXME: persist asset tags */
261 amount_sat_to_asset(&amount,
262 chainparams->fee_asset_tag);
263 /* FIXME: persist nonces */
264 }
265 return input_num;
266}
267
268bool bitcoin_tx_check(const struct bitcoin_tx *tx)
269{

Callers 8

commit_txFunction · 0.85
penalty_tx_createFunction · 0.85
onchaind_tx_unsignedFunction · 0.85
initial_commit_txFunction · 0.85
htlc_txFunction · 0.85
create_close_txFunction · 0.85
tx_spending_utxoFunction · 0.85
mainFunction · 0.85

Calls 9

psbt_append_inputFunction · 0.85
scriptpubkey_p2wshFunction · 0.85
psbt_input_set_wit_utxoFunction · 0.85
tal_wally_startFunction · 0.85
tal_bytelenFunction · 0.85
tal_wally_endFunction · 0.85
is_elementsFunction · 0.85
amount_sat_to_assetFunction · 0.50

Tested by

no test coverage detected