| 568 | } |
| 569 | |
| 570 | static bool funder_finalize_channel_setup(struct state *state, |
| 571 | struct amount_msat local_msat, |
| 572 | struct bitcoin_signature *sig, |
| 573 | struct bitcoin_tx **tx, |
| 574 | struct penalty_base **pbase) |
| 575 | { |
| 576 | u8 *msg; |
| 577 | struct channel_id id_in; |
| 578 | const u8 *wscript; |
| 579 | struct channel_id cid; |
| 580 | char *err_reason; |
| 581 | struct wally_tx_output *direct_outputs[NUM_SIDES]; |
| 582 | |
| 583 | /*~ Channel is ready; Report the channel parameters to the signer. */ |
| 584 | msg = towire_hsmd_ready_channel(NULL, |
| 585 | true, /* is_outbound */ |
| 586 | state->funding_sats, |
| 587 | state->push_msat, |
| 588 | &state->funding.txid, |
| 589 | state->funding.n, |
| 590 | state->localconf.to_self_delay, |
| 591 | state->upfront_shutdown_script[LOCAL], |
| 592 | state->local_upfront_shutdown_wallet_index, |
| 593 | &state->their_points, |
| 594 | &state->their_funding_pubkey, |
| 595 | state->remoteconf.to_self_delay, |
| 596 | state->upfront_shutdown_script[REMOTE], |
| 597 | state->channel_type); |
| 598 | wire_sync_write(HSM_FD, take(msg)); |
| 599 | msg = wire_sync_read(tmpctx, HSM_FD); |
| 600 | if (!fromwire_hsmd_ready_channel_reply(msg)) |
| 601 | status_failed(STATUS_FAIL_HSM_IO, "Bad ready_channel_reply %s", |
| 602 | tal_hex(tmpctx, msg)); |
| 603 | |
| 604 | /*~ Now we can initialize the `struct channel`. This represents |
| 605 | * the current channel state and is how we can generate the current |
| 606 | * commitment transaction. |
| 607 | * |
| 608 | * The routines to support `struct channel` are split into a common |
| 609 | * part (common/initial_channel) which doesn't support HTLCs and is |
| 610 | * enough for us here, and the complete channel support required by |
| 611 | * `channeld` which lives in channeld/full_channel. */ |
| 612 | derive_channel_id(&cid, &state->funding); |
| 613 | |
| 614 | state->channel = new_initial_channel(state, |
| 615 | &cid, |
| 616 | &state->funding, |
| 617 | state->minimum_depth, |
| 618 | NULL, 0, /* No channel lease */ |
| 619 | state->funding_sats, |
| 620 | local_msat, |
| 621 | take(new_fee_states(NULL, LOCAL, |
| 622 | &state->feerate_per_kw)), |
| 623 | &state->localconf, |
| 624 | &state->remoteconf, |
| 625 | &state->our_points, |
| 626 | &state->their_points, |
| 627 | &state->our_funding_pubkey, |
no test coverage detected