| 184 | } |
| 185 | |
| 186 | int 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 | |
| 228 | bool bitcoin_tx_check(const struct bitcoin_tx *tx) |
| 229 | { |
no test coverage detected