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

Function bitcoin_tx_add_input

bitcoin/tx.c:186–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186int bitcoin_tx_add_input(struct bitcoin_tx *tx,
187 const struct bitcoin_outpoint *outpoint,
188 u32 sequence, const u8 *scriptSig,
189 struct amount_sat amount, const u8 *scriptPubkey,
190 const u8 *input_wscript)
191{
192 int wally_err;
193 int input_num = tx->wtx->num_inputs;
194
195 psbt_append_input(tx->psbt, outpoint,
196 sequence, scriptSig,
197 input_wscript, NULL);
198
199 if (input_wscript) {
200 scriptPubkey = scriptpubkey_p2wsh(tmpctx, input_wscript);
201 }
202
203 assert(scriptPubkey);
204 psbt_input_set_wit_utxo(tx->psbt, input_num,
205 scriptPubkey, amount);
206
207 tal_wally_start();
208 wally_err = wally_tx_add_input(tx->wtx,
209 &tx->psbt->tx->inputs[input_num]);
210 assert(wally_err == WALLY_OK);
211
212 /* scriptsig isn't actually stored in psbt input, so add that now */
213 wally_tx_set_input_script(tx->wtx, input_num,
214 scriptSig, tal_bytelen(scriptSig));
215 tal_wally_end(tx->wtx);
216
217 if (is_elements(chainparams)) {
218 struct amount_asset asset;
219 /* FIXME: persist asset tags */
220 asset = amount_sat_to_asset(&amount,
221 chainparams->fee_asset_tag);
222 /* FIXME: persist nonces */
223 psbt_elements_input_set_asset(tx->psbt, input_num, &asset);
224 }
225 return input_num;
226}
227
228bool bitcoin_tx_check(const struct bitcoin_tx *tx)
229{

Callers 9

tx_to_usFunction · 0.85
replace_penalty_tx_to_usFunction · 0.85
commit_txFunction · 0.85
penalty_tx_createFunction · 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

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

Tested by

no test coverage detected