diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 75fe33866..f5296e4c6 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -458,8 +458,6 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS) } } - /* If there's no plugin, the psbt will be NULL. We should pass an empty - * PSBT over, in this case */ msg = towire_dualopend_got_offer_reply(NULL, payload->accepter_funding, payload->funding_feerate_per_kw, payload->psbt, @@ -1877,18 +1875,17 @@ void peer_start_dualopend(struct peer *peer, const u8 *msg; assert(!peer->uncommitted_channel); - uc = peer->uncommitted_channel = new_uncommitted_channel(peer); - hsmfd = hsm_get_client_fd(peer->ld, &uc->peer->id, uc->dbid, + hsmfd = hsm_get_client_fd(peer->ld, &peer->id, uc->dbid, HSM_CAP_COMMITMENT_POINT | HSM_CAP_SIGN_REMOTE_TX); uc->open_daemon = new_channel_subd(peer->ld, "lightning_dualopend", uc, UNCOMMITTED, &peer->id, - uc->log, - true, dualopend_wire_name, + uc->log, true, + dualopend_wire_name, dual_opend_msg, opend_channel_errmsg, opend_channel_set_billboard, @@ -1896,11 +1893,13 @@ void peer_start_dualopend(struct peer *peer, take(&pps->gossip_fd), take(&pps->gossip_store_fd), take(&hsmfd), NULL); + if (!uc->open_daemon) { - uncommitted_channel_disconnect(uc, LOG_BROKEN, - tal_fmt(tmpctx, - "Running lightning_dualopend: %s", - strerror(errno))); + char *errmsg; + errmsg = tal_fmt(tmpctx, + "Running lightning_dualopend: %s", + strerror(errno)); + uncommitted_channel_disconnect(uc, LOG_BROKEN, errmsg); tal_free(uc); return; } @@ -1912,23 +1911,23 @@ void peer_start_dualopend(struct peer *peer, /* BOLT #2: * * The sender: - * - SHOULD set `minimum_depth` to a number of blocks it considers - * reasonable to avoid double-spending of the funding transaction. + * - SHOULD set `minimum_depth` to a number of blocks it + * considers reasonable to avoid double-spending of the + * funding transaction. */ uc->minimum_depth = peer->ld->config.anchor_confirms; - msg = towire_dualopend_init(NULL, - chainparams, - peer->ld->our_features, - peer->their_features, - &uc->our_config, - max_to_self_delay, - min_effective_htlc_capacity, - pps, &uc->local_basepoints, - &uc->local_funding_pubkey, - uc->minimum_depth, - feerate_min(peer->ld, NULL), - feerate_max(peer->ld, NULL), - send_msg); + msg = towire_dualopend_init(NULL, chainparams, + peer->ld->our_features, + peer->their_features, + &uc->our_config, + max_to_self_delay, + min_effective_htlc_capacity, + pps, &uc->local_basepoints, + &uc->local_funding_pubkey, + uc->minimum_depth, + feerate_min(peer->ld, NULL), + feerate_max(peer->ld, NULL), + send_msg); subd_send_msg(uc->open_daemon, take(msg)); } diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 83687cce4..569c94408 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -735,8 +735,8 @@ static void dualopend_send_custommsg(struct state *state, const u8 *msg) #endif static u8 *psbt_to_tx_sigs_msg(const tal_t *ctx, - struct state *state, - const struct wally_psbt *psbt) + struct state *state, + const struct wally_psbt *psbt) { const struct witness_stack **ws = psbt_to_witness_stacks(tmpctx, psbt, @@ -1674,7 +1674,8 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) &state->feerate_per_kw_commitment)), &state->localconf, &state->remoteconf, - &state->our_points, &state->their_points, + &state->our_points, + &state->their_points, &state->our_funding_pubkey, &state->their_funding_pubkey, true, true, @@ -1894,7 +1895,8 @@ static void opener_start(struct state *state, u8 *msg) sync_crypto_write(state->pps, take(msg)); /* This is usually a very transient state... */ - peer_billboard(false, "channel open: offered, waiting for accept_channel2"); + peer_billboard(false, "channel open: offered, waiting for" + " accept_channel2"); /* ... since their reply should be immediate. */ msg = opening_negotiate_msg(tmpctx, state, true); @@ -1925,8 +1927,10 @@ static void opener_start(struct state *state, u8 *msg) "Parsing accept_channel2 %s", tal_hex(msg, msg)); if (a_tlv->option_upfront_shutdown_script) { - state->upfront_shutdown_script[REMOTE] = tal_steal(state, - a_tlv->option_upfront_shutdown_script->shutdown_scriptpubkey); + state->upfront_shutdown_script[REMOTE] + = tal_steal(state, + a_tlv->option_upfront_shutdown_script + ->shutdown_scriptpubkey); } else state->upfront_shutdown_script[REMOTE] = NULL;