| 3111 | } |
| 3112 | |
| 3113 | static void rbf_local_start(struct state *state, u8 *msg) |
| 3114 | { |
| 3115 | struct tx_state *tx_state; |
| 3116 | struct channel_id cid; |
| 3117 | struct amount_sat total; |
| 3118 | char *err_reason; |
| 3119 | /* tmpctx gets cleaned midway, so we have a context for this fn */ |
| 3120 | char *rbf_ctx = notleak_with_children(tal(state, char)); |
| 3121 | |
| 3122 | /* We need a new tx_state! */ |
| 3123 | tx_state = new_tx_state(rbf_ctx); |
| 3124 | /* Copy over the channel config info -- everything except |
| 3125 | * the reserve will be the same */ |
| 3126 | tx_state->localconf = state->tx_state->localconf; |
| 3127 | tx_state->remoteconf = state->tx_state->remoteconf; |
| 3128 | |
| 3129 | if (!fromwire_dualopend_rbf_init(tx_state, msg, |
| 3130 | state->our_role == TX_INITIATOR ? |
| 3131 | &tx_state->opener_funding : |
| 3132 | &tx_state->accepter_funding, |
| 3133 | &tx_state->feerate_per_kw_funding, |
| 3134 | &tx_state->psbt)) |
| 3135 | master_badmsg(WIRE_DUALOPEND_RBF_INIT, msg); |
| 3136 | |
| 3137 | peer_billboard(false, "channel rbf: init received from master"); |
| 3138 | |
| 3139 | if (!check_funding_feerate(tx_state->feerate_per_kw_funding, |
| 3140 | state->tx_state->feerate_per_kw_funding)) { |
| 3141 | open_err_warn(state, "Proposed funding feerate (%u) invalid", |
| 3142 | tx_state->feerate_per_kw_funding); |
| 3143 | goto free_rbf_ctx; |
| 3144 | } |
| 3145 | |
| 3146 | /* Have you sent us everything we need yet ? */ |
| 3147 | if (!state->tx_state->remote_funding_sigs_rcvd) { |
| 3148 | /* we're still waiting for the last sigs, master |
| 3149 | * should know better. Tell them no! */ |
| 3150 | open_err_warn(state, "%s", |
| 3151 | "Still waiting for remote funding sigs" |
| 3152 | " for last open attempt"); |
| 3153 | goto free_rbf_ctx; |
| 3154 | } |
| 3155 | |
| 3156 | tx_state->tx_locktime = tx_state->psbt->tx->locktime; |
| 3157 | msg = towire_init_rbf(tmpctx, &state->channel_id, |
| 3158 | state->our_role == TX_INITIATOR ? |
| 3159 | tx_state->opener_funding : |
| 3160 | tx_state->accepter_funding, |
| 3161 | tx_state->tx_locktime, |
| 3162 | tx_state->feerate_per_kw_funding); |
| 3163 | |
| 3164 | peer_write(state->pps, take(msg)); |
| 3165 | |
| 3166 | /* ... since their reply should be immediate. */ |
| 3167 | msg = opening_negotiate_msg(tmpctx, state); |
| 3168 | if (!msg) { |
| 3169 | open_err_warn(state, "%s", "Unable to init rbf"); |
| 3170 | goto free_rbf_ctx; |
no test coverage detected