From 8846c35ac6a72c5cee11eb9be67bdbe59bb5f184 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Thu, 22 Oct 2020 14:19:02 +0200 Subject: [PATCH] dual_open: correct silent enum conversions We were silently converting a side enum (3 variants) to a tx_role enum (2 variants). Signed-off-by: Antoine Poinsot --- channeld/channeld.c | 22 ++++++++++------------ lightningd/dual_open_control.c | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index 69bc133ab..c8662ae37 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -273,15 +273,16 @@ static enum tx_role our_tx_role(const struct peer *peer) } static const u8 *psbt_to_tx_sigs_msg(const tal_t *ctx, - struct channel *channel, + const struct peer *peer, const struct wally_psbt *psbt) { - const struct witness_stack **ws = - psbt_to_witness_stacks(tmpctx, psbt, - channel->opener); + const struct witness_stack **ws; + + ws = psbt_to_witness_stacks(tmpctx, psbt, + our_tx_role(peer)); - return towire_tx_signatures(ctx, &channel->cid, - &channel->funding_txid, + return towire_tx_signatures(ctx, &peer->channel->cid, + &peer->channel->funding_txid, ws); } #endif /* EXPERIMENTAL_FEATURES */ @@ -2051,8 +2052,7 @@ static void handle_send_tx_sigs(struct peer *peer, const u8 *msg) tal_wally_end(tal_steal(peer, peer->psbt)); #if EXPERIMENTAL_FEATURES sync_crypto_write(peer->pps, - take(psbt_to_tx_sigs_msg(NULL, peer->channel, - psbt))); + take(psbt_to_tx_sigs_msg(NULL, peer, psbt))); #endif /* EXPERIMENTAL_FEATURES */ } @@ -2803,8 +2803,7 @@ static void peer_reconnect(struct peer *peer, our_tx_role(peer)) && !peer->funding_locked[REMOTE]) sync_crypto_write(peer->pps, - take(psbt_to_tx_sigs_msg(NULL, peer->channel, - peer->psbt))); + take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt))); #endif /* EXPERIMENTAL_FEATURES */ /* BOLT #2: @@ -3605,8 +3604,7 @@ static void init_channel(struct peer *peer) if (!reconnected && peer->psbt && psbt_side_finalized(peer->psbt, our_tx_role(peer))) sync_crypto_write(peer->pps, - take(psbt_to_tx_sigs_msg(NULL, peer->channel, - peer->psbt))); + take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt))); #endif /* EXPERIMENTAL_FEATURES */ /* Reenable channel */ diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index ce60058b2..04bf71e84 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -468,7 +468,7 @@ openchannel2_changed_deserialize(struct openchannel2_psbt_payload *payload, return false; /* Add serials to PSBT, before checking for required fields */ - psbt_add_serials(psbt, REMOTE); + psbt_add_serials(psbt, TX_ACCEPTER); if (!psbt_has_required_fields(psbt)) fatal("Plugin supplied PSBT that's missing required fields. %s",