Takes ownership of tx_state if successful */
| 3023 | |
| 3024 | /* Takes ownership of tx_state if successful */ |
| 3025 | static void rbf_wrap_up(struct state *state, |
| 3026 | struct tx_state *tx_state, |
| 3027 | struct amount_sat total) |
| 3028 | { |
| 3029 | enum dualopend_wire msg_type; |
| 3030 | char *err_reason; |
| 3031 | u8 *msg; |
| 3032 | |
| 3033 | /* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2: |
| 3034 | * The sending node: |
| 3035 | * - if is the *opener*: |
| 3036 | * - MUST send at least one `tx_add_output`, which contains the |
| 3037 | * channel's funding output */ |
| 3038 | if (state->our_role == TX_INITIATOR) |
| 3039 | add_funding_output(tx_state, state, total); |
| 3040 | else |
| 3041 | /* if accepter, set to an invalid number, 1 (odd is invalid) */ |
| 3042 | tx_state->funding_serial = 1; |
| 3043 | |
| 3044 | /* Add all of our inputs/outputs to the changeset */ |
| 3045 | init_changeset(tx_state, tx_state->psbt); |
| 3046 | |
| 3047 | if (state->our_role == TX_INITIATOR) { |
| 3048 | /* Send our first message; opener initiates */ |
| 3049 | if (!send_next(state, tx_state, &tx_state->psbt)) { |
| 3050 | open_err_warn(state, |
| 3051 | "Peer error, has no tx updates."); |
| 3052 | return; |
| 3053 | } |
| 3054 | } |
| 3055 | |
| 3056 | if (!run_tx_interactive(state, tx_state, |
| 3057 | &tx_state->psbt, |
| 3058 | state->our_role)) { |
| 3059 | return; |
| 3060 | } |
| 3061 | |
| 3062 | /* Is this an eligible RBF (at least one overlapping input) */ |
| 3063 | msg = towire_dualopend_rbf_validate(NULL, tx_state->psbt); |
| 3064 | wire_sync_write(REQ_FD, take(msg)); |
| 3065 | msg = wire_sync_read(tmpctx, REQ_FD); |
| 3066 | |
| 3067 | #if DEVELOPER |
| 3068 | while (fromwire_dualopend_dev_memleak(msg)) { |
| 3069 | handle_dev_memleak(state, msg); |
| 3070 | msg = wire_sync_read(tmpctx, REQ_FD); |
| 3071 | } |
| 3072 | #endif |
| 3073 | |
| 3074 | if ((msg_type = fromwire_peektype(msg)) == WIRE_DUALOPEND_FAIL) { |
| 3075 | if (!fromwire_dualopend_fail(msg, msg, &err_reason)) |
| 3076 | master_badmsg(msg_type, msg); |
| 3077 | open_err_warn(state, "%s", err_reason); |
| 3078 | return; |
| 3079 | } |
| 3080 | |
| 3081 | if (!fromwire_dualopend_rbf_valid(msg)) |
| 3082 | master_badmsg(WIRE_DUALOPEND_RBF_VALID, msg); |
no test coverage detected