From 780b620cb182395dfebfbd70236de0cc5795b8ec Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 8 Feb 2018 11:55:12 +1030 Subject: [PATCH] openingd: use wirestring instead of u8 array for why negotiation failed. Signed-off-by: Rusty Russell --- lightningd/peer_control.c | 6 ++---- openingd/opening.c | 2 +- openingd/opening_wire.csv | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 1e7292453..5161a3ad6 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2412,15 +2412,14 @@ static unsigned int opening_negotiation_failed(struct subd *openingd, struct crypto_state cs; u64 gossip_index; struct peer *peer = openingd->peer; - u8 *err; - const char *why; + char *why; /* We need the peer fd and gossip fd. */ if (tal_count(fds) == 0) return 2; if (!fromwire_opening_negotiation_failed(msg, msg, NULL, - &cs, &gossip_index, &err)) { + &cs, &gossip_index, &why)) { peer_internal_error(peer, "bad OPENING_NEGOTIATION_FAILED %s", tal_hex(msg, msg)); @@ -2433,7 +2432,6 @@ static unsigned int opening_negotiation_failed(struct subd *openingd, subd_send_fd(openingd->ld->gossip, fds[0]); subd_send_fd(openingd->ld->gossip, fds[1]); - why = tal_strndup(peer, (const char *)err, tal_len(err)); log_unusual(peer->log, "Opening negotiation failed: %s", why); /* This will free openingd, since that's peer->owner */ diff --git a/openingd/opening.c b/openingd/opening.c index d53ae219a..b2079f33e 100644 --- a/openingd/opening.c +++ b/openingd/opening.c @@ -91,7 +91,7 @@ static void negotiation_failed(struct state *state, bool send_error, /* Tell master we should return to gossiping. */ msg = towire_opening_negotiation_failed(state, &state->cs, state->gossip_index, - (const u8 *)errmsg); + errmsg); wire_sync_write(REQ_FD, msg); fdpass_send(REQ_FD, PEER_FD); fdpass_send(REQ_FD, GOSSIP_FD); diff --git a/openingd/opening_wire.csv b/openingd/opening_wire.csv index 306d6b7fd..2e1401bee 100644 --- a/openingd/opening_wire.csv +++ b/openingd/opening_wire.csv @@ -81,7 +81,5 @@ opening_fundee_reply,,funding_signed_msg,msglen*u8 opening_negotiation_failed,6010 opening_negotiation_failed,,crypto_state,struct crypto_state opening_negotiation_failed,,gossip_index,u64 -opening_negotiation_failed,,len,u16 -# FIXME: string support! -opening_negotiation_failed,,msg,len*u8 +opening_negotiation_failed,,msg,wirestring