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

Function rbf_wrap_up

openingd/dualopend.c:3388–3479  ·  view source on GitHub ↗

Takes ownership of tx_state if successful */

Source from the content-addressed store, hash-verified

3386
3387/* Takes ownership of tx_state if successful */
3388static void rbf_wrap_up(struct state *state,
3389 struct tx_state *tx_state,
3390 struct amount_sat total)
3391{
3392 enum dualopend_wire msg_type;
3393 char *err_reason;
3394 bool aborted;
3395 u8 *msg;
3396
3397 /* BOLT #2:
3398 * The sending node:
3399 * - if is the *opener*:
3400 * - MUST send at least one `tx_add_output`, which contains the
3401 * channel's funding output */
3402 if (state->our_role == TX_INITIATOR)
3403 add_funding_output(tx_state, state, total);
3404 else
3405 /* if accepter, set to an invalid number, 1 (odd is invalid) */
3406 tx_state->funding_serial = 1;
3407
3408 /* Add all of our inputs/outputs to the changeset */
3409 init_changeset(tx_state, tx_state->psbt);
3410
3411 if (state->our_role == TX_INITIATOR) {
3412 /* Send our first message; opener initiates */
3413 if (!send_next(state, tx_state, &tx_state->psbt, &aborted)) {
3414 if (!aborted)
3415 open_abort(state, "Peer error, has no tx updates.");
3416 return;
3417 }
3418 }
3419
3420 if (!run_tx_interactive(state, tx_state,
3421 &tx_state->psbt,
3422 state->our_role)) {
3423 return;
3424 }
3425
3426 if (state->require_confirmed_inputs[LOCAL]) {
3427 err_reason = validate_inputs(state, tx_state,
3428 state->our_role == TX_INITIATOR ?
3429 TX_ACCEPTER : TX_INITIATOR);
3430 if (err_reason) {
3431 open_abort(state, "%s", err_reason);
3432 return;
3433 }
3434 }
3435
3436 /* Is this an eligible RBF (at least one overlapping input) */
3437 msg = towire_dualopend_rbf_validate(NULL, tx_state->psbt);
3438 wire_sync_write(REQ_FD, take(msg));
3439 msg = wire_sync_read(tmpctx, REQ_FD);
3440
3441 while (state->developer && fromwire_dualopend_dev_memleak(msg)) {
3442 handle_dev_memleak(state, msg);
3443 msg = wire_sync_read(tmpctx, REQ_FD);
3444 }
3445

Callers 2

rbf_local_startFunction · 0.85
rbf_remote_startFunction · 0.85

Calls 15

add_funding_outputFunction · 0.85
init_changesetFunction · 0.85
open_abortFunction · 0.85
run_tx_interactiveFunction · 0.85
validate_inputsFunction · 0.85
fromwire_peektypeFunction · 0.85
psbt_txidFunction · 0.85
accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85
handle_send_tx_sigsFunction · 0.85
send_nextFunction · 0.70
handle_dev_memleakFunction · 0.70

Tested by

no test coverage detected