| 515 | } |
| 516 | |
| 517 | struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, |
| 518 | const struct chainparams *chainparams, |
| 519 | varint_t input_count, varint_t output_count, |
| 520 | u32 nlocktime) |
| 521 | { |
| 522 | struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx); |
| 523 | assert(chainparams); |
| 524 | |
| 525 | /* If we are constructing an elements transaction we need to |
| 526 | * explicitly add the fee as an extra output. So allocate one more |
| 527 | * than the outputs we need internally. */ |
| 528 | if (chainparams->is_elements) |
| 529 | output_count += 1; |
| 530 | |
| 531 | tal_wally_start(); |
| 532 | wally_tx_init_alloc(WALLY_TX_VERSION_2, nlocktime, input_count, output_count, |
| 533 | &tx->wtx); |
| 534 | tal_add_destructor(tx, bitcoin_tx_destroy); |
| 535 | tal_wally_end_onto(tx, tx->wtx, struct wally_tx); |
| 536 | |
| 537 | tx->chainparams = chainparams; |
| 538 | tx->psbt = new_psbt(tx, tx->wtx); |
| 539 | |
| 540 | return tx; |
| 541 | } |
| 542 | |
| 543 | void bitcoin_tx_finalize(struct bitcoin_tx *tx) |
| 544 | { |
no test coverage detected