Skip to content

Commit 8846c35

Browse files
darosiorniftynei
authored andcommitted
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 <[email protected]>
1 parent e99335e commit 8846c35

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

channeld/channeld.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,16 @@ static enum tx_role our_tx_role(const struct peer *peer)
273273
}
274274

275275
static const u8 *psbt_to_tx_sigs_msg(const tal_t *ctx,
276-
struct channel *channel,
276+
const struct peer *peer,
277277
const struct wally_psbt *psbt)
278278
{
279-
const struct witness_stack **ws =
280-
psbt_to_witness_stacks(tmpctx, psbt,
281-
channel->opener);
279+
const struct witness_stack **ws;
280+
281+
ws = psbt_to_witness_stacks(tmpctx, psbt,
282+
our_tx_role(peer));
282283

283-
return towire_tx_signatures(ctx, &channel->cid,
284-
&channel->funding_txid,
284+
return towire_tx_signatures(ctx, &peer->channel->cid,
285+
&peer->channel->funding_txid,
285286
ws);
286287
}
287288
#endif /* EXPERIMENTAL_FEATURES */
@@ -2051,8 +2052,7 @@ static void handle_send_tx_sigs(struct peer *peer, const u8 *msg)
20512052
tal_wally_end(tal_steal(peer, peer->psbt));
20522053
#if EXPERIMENTAL_FEATURES
20532054
sync_crypto_write(peer->pps,
2054-
take(psbt_to_tx_sigs_msg(NULL, peer->channel,
2055-
psbt)));
2055+
take(psbt_to_tx_sigs_msg(NULL, peer, psbt)));
20562056
#endif /* EXPERIMENTAL_FEATURES */
20572057
}
20582058

@@ -2803,8 +2803,7 @@ static void peer_reconnect(struct peer *peer,
28032803
our_tx_role(peer))
28042804
&& !peer->funding_locked[REMOTE])
28052805
sync_crypto_write(peer->pps,
2806-
take(psbt_to_tx_sigs_msg(NULL, peer->channel,
2807-
peer->psbt)));
2806+
take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt)));
28082807
#endif /* EXPERIMENTAL_FEATURES */
28092808

28102809
/* BOLT #2:
@@ -3605,8 +3604,7 @@ static void init_channel(struct peer *peer)
36053604
if (!reconnected && peer->psbt &&
36063605
psbt_side_finalized(peer->psbt, our_tx_role(peer)))
36073606
sync_crypto_write(peer->pps,
3608-
take(psbt_to_tx_sigs_msg(NULL, peer->channel,
3609-
peer->psbt)));
3607+
take(psbt_to_tx_sigs_msg(NULL, peer, peer->psbt)));
36103608
#endif /* EXPERIMENTAL_FEATURES */
36113609

36123610
/* Reenable channel */

lightningd/dual_open_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ openchannel2_changed_deserialize(struct openchannel2_psbt_payload *payload,
468468
return false;
469469

470470
/* Add serials to PSBT, before checking for required fields */
471-
psbt_add_serials(psbt, REMOTE);
471+
psbt_add_serials(psbt, TX_ACCEPTER);
472472

473473
if (!psbt_has_required_fields(psbt))
474474
fatal("Plugin supplied PSBT that's missing required fields. %s",

0 commit comments

Comments
 (0)