| 3612 | } |
| 3613 | |
| 3614 | static void handle_commit_received(struct subd *dualopend, |
| 3615 | struct channel *channel, |
| 3616 | const u8 *msg) |
| 3617 | { |
| 3618 | struct lightningd *ld = dualopend->ld; |
| 3619 | struct bitcoin_tx *remote_commit; |
| 3620 | struct bitcoin_signature remote_commit_sig; |
| 3621 | struct penalty_base *pbase; |
| 3622 | struct json_stream *response; |
| 3623 | struct openchannel2_psbt_payload *payload; |
| 3624 | struct channel_inflight *inflight; |
| 3625 | struct command *cmd; |
| 3626 | bool updated; |
| 3627 | |
| 3628 | if (!fromwire_dualopend_commit_rcvd(tmpctx, msg, |
| 3629 | &remote_commit, |
| 3630 | &remote_commit_sig, |
| 3631 | &pbase)) { |
| 3632 | channel_internal_error(channel, |
| 3633 | "Bad WIRE_DUALOPEND_COMMIT_RCVD: %s", |
| 3634 | tal_hex(msg, msg)); |
| 3635 | channel->open_attempt = tal_free(channel->open_attempt); |
| 3636 | notify_channel_open_failed(channel->peer->ld, &channel->cid); |
| 3637 | return; |
| 3638 | } |
| 3639 | |
| 3640 | inflight = channel_current_inflight(channel); |
| 3641 | if (!inflight) { |
| 3642 | channel_internal_error(channel, |
| 3643 | "No inflight found for channel"); |
| 3644 | return; |
| 3645 | } |
| 3646 | |
| 3647 | updated = wallet_update_channel_commit(ld, channel, inflight, |
| 3648 | remote_commit, |
| 3649 | &remote_commit_sig); |
| 3650 | |
| 3651 | /* FIXME: handle RBF pbases */ |
| 3652 | if (pbase && channel->state != DUALOPEND_AWAITING_LOCKIN) { |
| 3653 | wallet_penalty_base_add(ld->wallet, |
| 3654 | channel->dbid, |
| 3655 | pbase); |
| 3656 | } |
| 3657 | |
| 3658 | switch (channel->opener) { |
| 3659 | case LOCAL: |
| 3660 | if (!channel->open_attempt || !channel->open_attempt->cmd) { |
| 3661 | log_info(channel->log, "No channel open attempt/command!"); |
| 3662 | channel->open_attempt |
| 3663 | = tal_free(channel->open_attempt); |
| 3664 | return; |
| 3665 | } |
| 3666 | cmd = channel->open_attempt->cmd; |
| 3667 | response = build_commit_response(cmd, channel, inflight); |
| 3668 | channel->open_attempt |
| 3669 | = tal_free(channel->open_attempt); |
| 3670 | was_pending(command_success(cmd, response)); |
| 3671 | return; |
no test coverage detected