Skip to content

Commit ae30195

Browse files
committed
WORKAROUND: Use explicit txid and vout instead of OutPoint ([vls#409])
Trouble with u32 endian swapping between CLN's `bitcoin_outpoint` and our `OutPoint`. See ([vls#409])
1 parent f3aa64d commit ae30195

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

channeld/channeld.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,9 @@ static void check_mutual_channel_ready(struct peer *peer)
688688
if (peer->channel_ready[LOCAL] && peer->channel_ready[REMOTE]) {
689689
/* Make sure the hsmd agrees that this outpoint is
690690
* sufficiently buried. */
691-
msg = towire_hsmd_sync_outpoint(NULL, &peer->channel->funding);
691+
msg = towire_hsmd_sync_outpoint(NULL,
692+
&peer->channel->funding.txid,
693+
peer->channel->funding.n);
692694
msg = hsm_req(tmpctx, take(msg));
693695
if (!fromwire_hsmd_sync_outpoint_reply(msg))
694696
status_failed(STATUS_FAIL_HSM_IO,
@@ -770,7 +772,7 @@ static void check_mutual_splice_locked(struct peer *peer)
770772
/* Make sure the hsmd agrees that this outpoint is
771773
* sufficiently buried. */
772774
const u8 *msg2;
773-
msg2 = towire_hsmd_sync_outpoint(NULL, &inflight->outpoint);
775+
msg2 = towire_hsmd_sync_outpoint(NULL, &inflight->outpoint.txid, inflight->outpoint.n);
774776
msg2 = hsm_req(tmpctx, take(msg2));
775777
if (!fromwire_hsmd_sync_outpoint_reply(msg2))
776778
status_failed(STATUS_FAIL_HSM_IO,

hsmd/hsmd_wire.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ msgtype,hsmd_setup_channel_reply,131
9292
# Sent when channel_ready or splice_locked are mutual.
9393
# Ensures that hsmd sees outpoint buried.
9494
msgtype,hsmd_sync_outpoint,32
95-
msgdata,hsmd_sync_outpoint,funding_outpoint,bitcoin_outpoint,
95+
msgdata,hsmd_sync_outpoint,funding_txid,bitcoin_txid,
96+
msgdata,hsmd_sync_outpoint,funding_txout,u16,
9697

9798
# No value returned
9899
msgtype,hsmd_sync_outpoint_reply,132

hsmd/libhsmd.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,10 @@ static u8 *handle_setup_channel(struct hsmd_client *c, const u8 *msg_in)
389389
* to ensure they are caught up when outpoints are freshly buried */
390390
static u8 *handle_sync_outpoint(struct hsmd_client *c, const u8 *msg_in)
391391
{
392-
struct bitcoin_outpoint outpoint;
392+
struct bitcoin_txid funding_txid;
393+
u16 funding_txout;
393394

394-
if (!fromwire_hsmd_sync_outpoint(msg_in, &outpoint))
395+
if (!fromwire_hsmd_sync_outpoint(msg_in, &funding_txid, &funding_txout))
395396
return hsmd_status_malformed_request(c, msg_in);
396397

397398
/* Stub implementation */

openingd/dualopend.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ static void check_mutual_channel_ready(struct state *state)
431431
if (state->channel_ready[LOCAL] && state->channel_ready[REMOTE]) {
432432
/* Make sure the hsmd agrees that this outpoint is
433433
* sufficiently buried. */
434-
msg = towire_hsmd_sync_outpoint(NULL, &state->channel->funding);
434+
msg = towire_hsmd_sync_outpoint(NULL,
435+
&state->channel->funding.txid,
436+
state->channel->funding.n);
435437
wire_sync_write(HSM_FD, take(msg));
436438
msg = wire_sync_read(tmpctx, HSM_FD);
437439
if (!fromwire_hsmd_sync_outpoint_reply(msg))

0 commit comments

Comments
 (0)