MCPcopy Create free account
hub / github.com/ElementsProject/lightning / rbf_remote_start

Function rbf_remote_start

openingd/dualopend.c:3234–3375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3232}
3233
3234static void rbf_remote_start(struct state *state, const u8 *rbf_msg)
3235{
3236 struct channel_id cid;
3237 struct tx_state *tx_state;
3238 char *err_reason;
3239 struct amount_sat total;
3240 enum dualopend_wire msg_type;
3241 u8 *msg;
3242 /* tmpctx gets cleaned midway, so we have a context for this fn */
3243 char *rbf_ctx = notleak_with_children(tal(state, char));
3244
3245 /* We need a new tx_state! */
3246 tx_state = new_tx_state(rbf_ctx);
3247
3248 if (!fromwire_init_rbf(rbf_msg, &cid,
3249 state->our_role == TX_INITIATOR ?
3250 &tx_state->accepter_funding :
3251 &tx_state->opener_funding,
3252 &tx_state->tx_locktime,
3253 &tx_state->feerate_per_kw_funding))
3254 open_err_fatal(state, "Parsing init_rbf %s",
3255 tal_hex(tmpctx, rbf_msg));
3256
3257 /* Is this the correct channel? */
3258 check_channel_id(state, &cid, &state->channel_id);
3259 peer_billboard(false, "channel rbf: init received from peer");
3260
3261 if (state->our_role == TX_INITIATOR)
3262 open_err_warn(state, "%s",
3263 "Only the channel initiator is allowed"
3264 " to initiate RBF");
3265
3266 /* Have you sent us everything we need yet ? */
3267 if (!state->tx_state->remote_funding_sigs_rcvd)
3268 open_err_warn(state, "%s",
3269 "Last funding attempt not complete:"
3270 " missing your funding tx_sigs");
3271
3272 /* FIXME: should we check for currently in progress? */
3273
3274 /* Copy over the channel config info -- everything except
3275 * the reserve will be the same */
3276 tx_state->localconf = state->tx_state->localconf;
3277 tx_state->remoteconf = state->tx_state->remoteconf;
3278
3279 if (!check_funding_feerate(tx_state->feerate_per_kw_funding,
3280 state->tx_state->feerate_per_kw_funding)) {
3281 open_err_warn(state, "Funding feerate not greater than last."
3282 "Proposed %u, last feerate %u",
3283 tx_state->feerate_per_kw_funding,
3284 state->tx_state->feerate_per_kw_funding);
3285 goto free_rbf_ctx;
3286 }
3287
3288 /* We ask master if this is ok */
3289 msg = towire_dualopend_got_rbf_offer(NULL,
3290 &state->channel_id,
3291 state->our_role == TX_INITIATOR ?

Callers 1

handle_peer_inFunction · 0.85

Calls 15

new_tx_stateFunction · 0.85
open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
check_channel_idFunction · 0.85
open_err_warnFunction · 0.85
check_funding_feerateFunction · 0.85
create_psbtFunction · 0.85
amount_sat_greaterFunction · 0.85
check_config_boundsFunction · 0.85
peer_writeFunction · 0.85
rbf_wrap_upFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected