| 3795 | } |
| 3796 | |
| 3797 | static void rbf_remote_start(struct state *state, const u8 *rbf_msg) |
| 3798 | { |
| 3799 | struct channel_id cid; |
| 3800 | struct tx_state *tx_state; |
| 3801 | char *err_reason; |
| 3802 | struct amount_sat total; |
| 3803 | enum dualopend_wire msg_type; |
| 3804 | struct tlv_tx_init_rbf_tlvs *init_rbf_tlvs; |
| 3805 | struct tlv_tx_ack_rbf_tlvs *ack_rbf_tlvs; |
| 3806 | |
| 3807 | u8 *msg; |
| 3808 | /* tmpctx gets cleaned midway, so we have a context for this fn */ |
| 3809 | char *rbf_ctx = notleak_with_children(tal(state, char)); |
| 3810 | |
| 3811 | /* We need a new tx_state! */ |
| 3812 | tx_state = new_tx_state(rbf_ctx); |
| 3813 | ack_rbf_tlvs = tlv_tx_ack_rbf_tlvs_new(tmpctx); |
| 3814 | |
| 3815 | if (!fromwire_tx_init_rbf(tmpctx, rbf_msg, &cid, |
| 3816 | &tx_state->tx_locktime, |
| 3817 | &tx_state->feerate_per_kw_funding, |
| 3818 | &init_rbf_tlvs)) |
| 3819 | open_err_fatal(state, "Parsing tx_init_rbf %s", |
| 3820 | tal_hex(tmpctx, rbf_msg)); |
| 3821 | |
| 3822 | /* Is this the correct channel? */ |
| 3823 | check_channel_id(state, &cid, &state->channel_id); |
| 3824 | peer_billboard(false, "channel rbf: init received from peer"); |
| 3825 | |
| 3826 | /* Have you sent us everything we need yet ? */ |
| 3827 | if (!state->tx_state->remote_funding_sigs_rcvd) |
| 3828 | open_err_warn(state, "%s", |
| 3829 | "Last funding attempt not complete:" |
| 3830 | " missing your funding tx_sigs"); |
| 3831 | |
| 3832 | if (state->our_role == TX_INITIATOR) { |
| 3833 | open_abort(state, "%s", |
| 3834 | "Only the channel initiator is allowed" |
| 3835 | " to initiate RBF"); |
| 3836 | goto free_rbf_ctx; |
| 3837 | } |
| 3838 | |
| 3839 | /* Maybe they want a different funding amount! */ |
| 3840 | if (init_rbf_tlvs && init_rbf_tlvs->funding_output_contribution) { |
| 3841 | tx_state->opener_funding = |
| 3842 | amount_sat(*init_rbf_tlvs->funding_output_contribution); |
| 3843 | |
| 3844 | if (!amount_sat_eq(tx_state->opener_funding, |
| 3845 | state->tx_state->opener_funding)) |
| 3846 | status_debug("RBF: opener amt changed %s->%s", |
| 3847 | fmt_amount_sat(tmpctx, |
| 3848 | state->tx_state->opener_funding), |
| 3849 | fmt_amount_sat(tmpctx, |
| 3850 | tx_state->opener_funding)); |
| 3851 | } else |
| 3852 | /* Otherwise we use the last known funding amount */ |
| 3853 | tx_state->opener_funding = state->tx_state->opener_funding; |
| 3854 |
no test coverage detected