Skip to content

Commit

Permalink
WORKAROUND: Use explicit txid and vout instead of OutPoint ([vls#409])
Browse files Browse the repository at this point in the history
Trouble with u32 endian swapping between CLN's `bitcoin_outpoint` and
our `OutPoint`.  See ([vls#409])
  • Loading branch information
ksedgwic committed Sep 27, 2023
1 parent f3aa64d commit ae30195
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,9 @@ static void check_mutual_channel_ready(struct peer *peer)
if (peer->channel_ready[LOCAL] && peer->channel_ready[REMOTE]) {
/* Make sure the hsmd agrees that this outpoint is
* sufficiently buried. */
msg = towire_hsmd_sync_outpoint(NULL, &peer->channel->funding);
msg = towire_hsmd_sync_outpoint(NULL,
&peer->channel->funding.txid,
peer->channel->funding.n);
msg = hsm_req(tmpctx, take(msg));
if (!fromwire_hsmd_sync_outpoint_reply(msg))
status_failed(STATUS_FAIL_HSM_IO,
Expand Down Expand Up @@ -770,7 +772,7 @@ static void check_mutual_splice_locked(struct peer *peer)
/* Make sure the hsmd agrees that this outpoint is
* sufficiently buried. */
const u8 *msg2;
msg2 = towire_hsmd_sync_outpoint(NULL, &inflight->outpoint);
msg2 = towire_hsmd_sync_outpoint(NULL, &inflight->outpoint.txid, inflight->outpoint.n);
msg2 = hsm_req(tmpctx, take(msg2));
if (!fromwire_hsmd_sync_outpoint_reply(msg2))
status_failed(STATUS_FAIL_HSM_IO,
Expand Down
3 changes: 2 additions & 1 deletion hsmd/hsmd_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ msgtype,hsmd_setup_channel_reply,131
# Sent when channel_ready or splice_locked are mutual.
# Ensures that hsmd sees outpoint buried.
msgtype,hsmd_sync_outpoint,32
msgdata,hsmd_sync_outpoint,funding_outpoint,bitcoin_outpoint,
msgdata,hsmd_sync_outpoint,funding_txid,bitcoin_txid,
msgdata,hsmd_sync_outpoint,funding_txout,u16,

# No value returned
msgtype,hsmd_sync_outpoint_reply,132
Expand Down
5 changes: 3 additions & 2 deletions hsmd/libhsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ static u8 *handle_setup_channel(struct hsmd_client *c, const u8 *msg_in)
* to ensure they are caught up when outpoints are freshly buried */
static u8 *handle_sync_outpoint(struct hsmd_client *c, const u8 *msg_in)
{
struct bitcoin_outpoint outpoint;
struct bitcoin_txid funding_txid;
u16 funding_txout;

if (!fromwire_hsmd_sync_outpoint(msg_in, &outpoint))
if (!fromwire_hsmd_sync_outpoint(msg_in, &funding_txid, &funding_txout))
return hsmd_status_malformed_request(c, msg_in);

/* Stub implementation */
Expand Down
4 changes: 3 additions & 1 deletion openingd/dualopend.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ static void check_mutual_channel_ready(struct state *state)
if (state->channel_ready[LOCAL] && state->channel_ready[REMOTE]) {
/* Make sure the hsmd agrees that this outpoint is
* sufficiently buried. */
msg = towire_hsmd_sync_outpoint(NULL, &state->channel->funding);
msg = towire_hsmd_sync_outpoint(NULL,
&state->channel->funding.txid,
state->channel->funding.n);
wire_sync_write(HSM_FD, take(msg));
msg = wire_sync_read(tmpctx, HSM_FD);
if (!fromwire_hsmd_sync_outpoint_reply(msg))
Expand Down

0 comments on commit ae30195

Please sign in to comment.