Browse Source

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 <rusty@rustcorp.com.au>
nifty/pset-pre
Rusty Russell 5 years ago
committed by Christian Decker
parent
commit
66fb7d6026
  1. 3
      channeld/channeld.c
  2. 8
      channeld/watchtower.c
  3. 3
      channeld/watchtower.h

3
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,

8
channeld/watchtower.c

@ -13,7 +13,6 @@
#include <wire/wire_sync.h>
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));

3
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 */

Loading…
Cancel
Save