Browse Source

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 <darosior@protonmail.com>
ppa-prep
Antoine Poinsot 4 years ago
committed by neil saitug
parent
commit
8846c35ac6
  1. 22
      channeld/channeld.c
  2. 2
      lightningd/dual_open_control.c

22
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, 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 wally_psbt *psbt)
{ {
const struct witness_stack **ws = const struct witness_stack **ws;
psbt_to_witness_stacks(tmpctx, psbt,
channel->opener); ws = psbt_to_witness_stacks(tmpctx, psbt,
our_tx_role(peer));
return towire_tx_signatures(ctx, &channel->cid, return towire_tx_signatures(ctx, &peer->channel->cid,
&channel->funding_txid, &peer->channel->funding_txid,
ws); ws);
} }
#endif /* EXPERIMENTAL_FEATURES */ #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)); tal_wally_end(tal_steal(peer, peer->psbt));
#if EXPERIMENTAL_FEATURES #if EXPERIMENTAL_FEATURES
sync_crypto_write(peer->pps, sync_crypto_write(peer->pps,
take(psbt_to_tx_sigs_msg(NULL, peer->channel, take(psbt_to_tx_sigs_msg(NULL, peer, psbt)));
psbt)));
#endif /* EXPERIMENTAL_FEATURES */ #endif /* EXPERIMENTAL_FEATURES */
} }
@ -2803,8 +2803,7 @@ static void peer_reconnect(struct peer *peer,
our_tx_role(peer)) our_tx_role(peer))
&& !peer->funding_locked[REMOTE]) && !peer->funding_locked[REMOTE])
sync_crypto_write(peer->pps, sync_crypto_write(peer->pps,
take(psbt_to_tx_sigs_msg(NULL, peer->channel, take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt)));
peer->psbt)));
#endif /* EXPERIMENTAL_FEATURES */ #endif /* EXPERIMENTAL_FEATURES */
/* BOLT #2: /* BOLT #2:
@ -3605,8 +3604,7 @@ static void init_channel(struct peer *peer)
if (!reconnected && peer->psbt && if (!reconnected && peer->psbt &&
psbt_side_finalized(peer->psbt, our_tx_role(peer))) psbt_side_finalized(peer->psbt, our_tx_role(peer)))
sync_crypto_write(peer->pps, sync_crypto_write(peer->pps,
take(psbt_to_tx_sigs_msg(NULL, peer->channel, take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt)));
peer->psbt)));
#endif /* EXPERIMENTAL_FEATURES */ #endif /* EXPERIMENTAL_FEATURES */
/* Reenable channel */ /* Reenable channel */

2
lightningd/dual_open_control.c

@ -468,7 +468,7 @@ openchannel2_changed_deserialize(struct openchannel2_psbt_payload *payload,
return false; return false;
/* Add serials to PSBT, before checking for required fields */ /* 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)) if (!psbt_has_required_fields(psbt))
fatal("Plugin supplied PSBT that's missing required fields. %s", fatal("Plugin supplied PSBT that's missing required fields. %s",

Loading…
Cancel
Save