| 503 | } |
| 504 | |
| 505 | struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, |
| 506 | const struct chainparams *chainparams, |
| 507 | varint_t input_count, varint_t output_count, |
| 508 | u32 nlocktime) |
| 509 | { |
| 510 | struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx); |
| 511 | assert(chainparams); |
| 512 | |
| 513 | /* If we are constructing an elements transaction we need to |
| 514 | * explicitly add the fee as an extra output. So allocate one more |
| 515 | * than the outputs we need internally. */ |
| 516 | if (chainparams->is_elements) |
| 517 | output_count += 1; |
| 518 | |
| 519 | tal_wally_start(); |
| 520 | wally_tx_init_alloc(WALLY_TX_VERSION_2, nlocktime, input_count, output_count, |
| 521 | &tx->wtx); |
| 522 | tal_add_destructor(tx, bitcoin_tx_destroy); |
| 523 | tal_wally_end_onto(tx, tx->wtx, struct wally_tx); |
| 524 | |
| 525 | tx->chainparams = chainparams; |
| 526 | tx->psbt = new_psbt(tx, tx->wtx); |
| 527 | |
| 528 | return tx; |
| 529 | } |
| 530 | |
| 531 | void bitcoin_tx_finalize(struct bitcoin_tx *tx) |
| 532 | { |
no test coverage detected