mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
channeld: simply exit if hsmd vanishes.
We currently die when gossipd vanishes, but our direct connection will go away. We then complain if the node is shutting down while we're talking to hsmd. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
1c71c9849b
commit
1abbc3d06a
@ -4,6 +4,7 @@ CHANNELD_HEADERS := \
|
|||||||
channeld/full_channel_error_names_gen.h \
|
channeld/full_channel_error_names_gen.h \
|
||||||
channeld/channeld_wiregen.h \
|
channeld/channeld_wiregen.h \
|
||||||
channeld/channeld_htlc.h \
|
channeld/channeld_htlc.h \
|
||||||
|
channeld/channeld.h \
|
||||||
channeld/commit_tx.h \
|
channeld/commit_tx.h \
|
||||||
channeld/full_channel.h \
|
channeld/full_channel.h \
|
||||||
channeld/full_channel_error.h \
|
channeld/full_channel_error.h \
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <ccan/cast/cast.h>
|
#include <ccan/cast/cast.h>
|
||||||
#include <ccan/mem/mem.h>
|
#include <ccan/mem/mem.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
|
#include <channeld/channeld.h>
|
||||||
#include <channeld/channeld_wiregen.h>
|
#include <channeld/channeld_wiregen.h>
|
||||||
#include <channeld/full_channel.h>
|
#include <channeld/full_channel.h>
|
||||||
#include <channeld/watchtower.h>
|
#include <channeld/watchtower.h>
|
||||||
@ -193,23 +194,17 @@ static void billboard_update(const struct peer *peer)
|
|||||||
peer_billboard(false, update);
|
peer_billboard(false, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES)
|
const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES)
|
||||||
{
|
{
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
int type = fromwire_peektype(req);
|
|
||||||
|
|
||||||
|
/* hsmd goes away at shutdown. That's OK. */
|
||||||
if (!wire_sync_write(HSM_FD, req))
|
if (!wire_sync_write(HSM_FD, req))
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
exit(0);
|
||||||
"Writing %s to HSM: %s",
|
|
||||||
hsmd_wire_name(type),
|
|
||||||
strerror(errno));
|
|
||||||
|
|
||||||
msg = wire_sync_read(ctx, HSM_FD);
|
msg = wire_sync_read(ctx, HSM_FD);
|
||||||
if (!msg)
|
if (!msg)
|
||||||
status_failed(STATUS_FAIL_HSM_IO,
|
exit(0);
|
||||||
"Reading resp to %s: %s",
|
|
||||||
hsmd_wire_name(type),
|
|
||||||
strerror(errno));
|
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
10
channeld/channeld.h
Normal file
10
channeld/channeld.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef LIGHTNING_CHANNELD_CHANNELD_H
|
||||||
|
#define LIGHTNING_CHANNELD_CHANNELD_H
|
||||||
|
#include "config.h"
|
||||||
|
#include <ccan/short_types/short_types.h>
|
||||||
|
#include <ccan/take/take.h>
|
||||||
|
#include <ccan/tal/tal.h>
|
||||||
|
|
||||||
|
const u8 *hsm_req(const tal_t *ctx, const u8 *req TAKES);
|
||||||
|
|
||||||
|
#endif /* LIGHTNING_CHANNELD_CHANNELD_H */
|
@ -1,6 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <bitcoin/feerate.h>
|
#include <bitcoin/feerate.h>
|
||||||
#include <bitcoin/script.h>
|
#include <bitcoin/script.h>
|
||||||
|
#include <channeld/channeld.h>
|
||||||
#include <channeld/watchtower.h>
|
#include <channeld/watchtower.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
#include <common/htlc_tx.h>
|
#include <common/htlc_tx.h>
|
||||||
@ -26,7 +27,7 @@ penalty_tx_create(const tal_t *ctx,
|
|||||||
struct bitcoin_tx *tx;
|
struct bitcoin_tx *tx;
|
||||||
struct keyset keyset;
|
struct keyset keyset;
|
||||||
size_t weight;
|
size_t weight;
|
||||||
u8 *msg;
|
const u8 *msg;
|
||||||
struct amount_sat fee, min_out, amt;
|
struct amount_sat fee, min_out, amt;
|
||||||
struct bitcoin_signature sig;
|
struct bitcoin_signature sig;
|
||||||
u32 locktime = 0;
|
u32 locktime = 0;
|
||||||
@ -105,16 +106,12 @@ penalty_tx_create(const tal_t *ctx,
|
|||||||
bitcoin_tx_finalize(tx);
|
bitcoin_tx_finalize(tx);
|
||||||
|
|
||||||
u8 *hsm_sign_msg =
|
u8 *hsm_sign_msg =
|
||||||
towire_hsmd_sign_penalty_to_us(ctx, &remote_per_commitment_secret,
|
towire_hsmd_sign_penalty_to_us(tmpctx, &remote_per_commitment_secret,
|
||||||
tx, wscript);
|
tx, wscript);
|
||||||
|
|
||||||
if (!wire_sync_write(hsm_fd, take(hsm_sign_msg)))
|
msg = hsm_req(tmpctx, hsm_sign_msg);
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
if (!fromwire_hsmd_sign_tx_reply(msg, &sig))
|
||||||
"Writing sign request to hsm");
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
|
||||||
msg = wire_sync_read(tmpctx, hsm_fd);
|
|
||||||
if (!msg || !fromwire_hsmd_sign_tx_reply(msg, &sig))
|
|
||||||
status_failed(STATUS_FAIL_INTERNAL_ERROR,
|
|
||||||
"Reading sign_tx_reply: %s", tal_hex(tmpctx, msg));
|
"Reading sign_tx_reply: %s", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
witness = bitcoin_witness_sig_and_element(tx, &sig, &ONE, sizeof(ONE),
|
witness = bitcoin_witness_sig_and_element(tx, &sig, &ONE, sizeof(ONE),
|
||||||
|
Loading…
Reference in New Issue
Block a user