From 66fb7d6026ae80a5ac83354d52ed75e98f611105 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 7 May 2020 15:07:39 +0930 Subject: [PATCH] channeld: pass in HSM_FD as an argument to watchtower code. It's weird to reproduce this #define in another file. Signed-off-by: Rusty Russell --- channeld/channeld.c | 3 ++- channeld/watchtower.c | 8 ++++---- channeld/watchtower.h | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index 873dde7f1..2bd331a4a 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -1416,7 +1416,8 @@ static u8 *got_revoke_msg(struct peer *peer, u64 revoke_num, ptx = penalty_tx_create( NULL, peer->channel, peer->feerate_penalty, peer->final_scriptpubkey, per_commitment_secret, - &pbase->txid, pbase->outnum, pbase->amount); + &pbase->txid, pbase->outnum, pbase->amount, + HSM_FD); } msg = towire_channel_got_revoke(peer, revoke_num, per_commitment_secret, diff --git a/channeld/watchtower.c b/channeld/watchtower.c index 9e5e47e25..7fbc5a9c4 100644 --- a/channeld/watchtower.c +++ b/channeld/watchtower.c @@ -13,7 +13,6 @@ #include static const u8 ONE = 0x1; -#define HSM_FD 6 const struct bitcoin_tx * penalty_tx_create(const tal_t *ctx, @@ -22,7 +21,8 @@ penalty_tx_create(const tal_t *ctx, u8 *final_scriptpubkey, const struct secret *revocation_preimage, const struct bitcoin_txid *commitment_txid, - s16 to_them_outnum, struct amount_sat to_them_sats) + s16 to_them_outnum, struct amount_sat to_them_sats, + int hsm_fd) { u8 *wscript; struct bitcoin_tx *tx; @@ -105,11 +105,11 @@ penalty_tx_create(const tal_t *ctx, towire_hsm_sign_penalty_to_us(ctx, &remote_per_commitment_secret, tx, wscript, *tx->input_amounts[0]); - if (!wire_sync_write(HSM_FD, take(hsm_sign_msg))) + if (!wire_sync_write(hsm_fd, take(hsm_sign_msg))) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Writing sign request to hsm"); - msg = wire_sync_read(tmpctx, HSM_FD); + msg = wire_sync_read(tmpctx, hsm_fd); if (!msg || !fromwire_hsm_sign_tx_reply(msg, &sig)) status_failed(STATUS_FAIL_INTERNAL_ERROR, "Reading sign_tx_reply: %s", tal_hex(tmpctx, msg)); diff --git a/channeld/watchtower.h b/channeld/watchtower.h index 9e197f0d3..456e3a37d 100644 --- a/channeld/watchtower.h +++ b/channeld/watchtower.h @@ -13,6 +13,7 @@ penalty_tx_create(const tal_t *ctx, u8 *final_scriptpubkey, const struct secret *revocation_preimage, const struct bitcoin_txid *commitment_txid, - s16 to_them_outnum, struct amount_sat to_them_sats); + s16 to_them_outnum, struct amount_sat to_them_sats, + int hsm_fd); #endif /* LIGHTNING_CHANNELD_WATCHTOWER_H */