| 223 | } |
| 224 | |
| 225 | int 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 | |
| 268 | bool bitcoin_tx_check(const struct bitcoin_tx *tx) |
| 269 | { |
no test coverage detected