| 3656 | } |
| 3657 | |
| 3658 | static void rbf_remote_start(struct state *state, const u8 *rbf_msg) |
| 3659 | { |
| 3660 | struct channel_id cid; |
| 3661 | struct tx_state *tx_state; |
| 3662 | char *err_reason; |
| 3663 | struct amount_sat total; |
| 3664 | enum dualopend_wire msg_type; |
| 3665 | struct tlv_tx_init_rbf_tlvs *init_rbf_tlvs; |
| 3666 | struct tlv_tx_ack_rbf_tlvs *ack_rbf_tlvs; |
| 3667 | |
| 3668 | u8 *msg; |
| 3669 | /* tmpctx gets cleaned midway, so we have a context for this fn */ |
| 3670 | char *rbf_ctx = notleak_with_children(tal(state, char)); |
| 3671 | |
| 3672 | /* We need a new tx_state! */ |
| 3673 | tx_state = new_tx_state(rbf_ctx); |
| 3674 | ack_rbf_tlvs = tlv_tx_ack_rbf_tlvs_new(tmpctx); |
| 3675 | |
| 3676 | if (!fromwire_tx_init_rbf(tmpctx, rbf_msg, &cid, |
| 3677 | &tx_state->tx_locktime, |
| 3678 | &tx_state->feerate_per_kw_funding, |
| 3679 | &init_rbf_tlvs)) |
| 3680 | open_err_fatal(state, "Parsing tx_init_rbf %s", |
| 3681 | tal_hex(tmpctx, rbf_msg)); |
| 3682 | |
| 3683 | /* Is this the correct channel? */ |
| 3684 | check_channel_id(state, &cid, &state->channel_id); |
| 3685 | peer_billboard(false, "channel rbf: init received from peer"); |
| 3686 | |
| 3687 | /* Have you sent us everything we need yet ? */ |
| 3688 | if (!state->tx_state->remote_funding_sigs_rcvd) |
| 3689 | open_err_warn(state, "%s", |
| 3690 | "Last funding attempt not complete:" |
| 3691 | " missing your funding tx_sigs"); |
| 3692 | |
| 3693 | if (state->our_role == TX_INITIATOR) { |
| 3694 | open_abort(state, "%s", |
| 3695 | "Only the channel initiator is allowed" |
| 3696 | " to initiate RBF"); |
| 3697 | goto free_rbf_ctx; |
| 3698 | } |
| 3699 | |
| 3700 | /* Maybe they want a different funding amount! */ |
| 3701 | if (init_rbf_tlvs && init_rbf_tlvs->funding_output_contribution) { |
| 3702 | tx_state->opener_funding = |
| 3703 | amount_sat(*init_rbf_tlvs->funding_output_contribution); |
| 3704 | |
| 3705 | if (!amount_sat_eq(tx_state->opener_funding, |
| 3706 | state->tx_state->opener_funding)) |
| 3707 | status_debug("RBF: opener amt changed %s->%s", |
| 3708 | fmt_amount_sat(tmpctx, |
| 3709 | state->tx_state->opener_funding), |
| 3710 | fmt_amount_sat(tmpctx, |
| 3711 | tx_state->opener_funding)); |
| 3712 | } else |
| 3713 | /* Otherwise we use the last known funding amount */ |
| 3714 | tx_state->opener_funding = state->tx_state->opener_funding; |
| 3715 |
no test coverage detected