Browse Source

common: disallow NULL channel_id to peer_failed_err.

No more sending "all-channel" errors; in particular, gossipd now only
sends warnings (which make us hang up), not errors, and peer_connected
rejections are warnings (and disconnect), not errors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `peer_connected` rejections now send a warning, not an error, to the peer.
master
Rusty Russell 4 years ago
parent
commit
6b11cc8b8c
  1. 1
      common/peer_failed.c
  2. 4
      common/read_peer_msg.c
  3. 8
      common/wire_error.c
  4. 8
      common/wire_error.h
  5. 6
      connectd/connectd.c
  6. 2
      connectd/peer_exchange_initmsg.c
  7. 6
      gossipd/gossipd.c
  8. 114
      gossipd/queries.c
  9. 146
      gossipd/routing.c
  10. 10
      gossipd/test/run-bench-find_route.c
  11. 10
      gossipd/test/run-crc32_of_update.c
  12. 10
      gossipd/test/run-extended-info.c
  13. 10
      gossipd/test/run-find_route-specific.c
  14. 10
      gossipd/test/run-find_route.c
  15. 10
      gossipd/test/run-overlong.c
  16. 10
      gossipd/test/run-txout_failure.c
  17. 9
      lightningd/peer_control.c
  18. 5
      lightningd/test/run-invoice-select-inchan.c
  19. 14
      openingd/dualopend.c
  20. 28
      openingd/openingd.c
  21. 2
      tests/test_plugin.py
  22. 2
      wallet/db_postgres_sqlgen.c
  23. 2
      wallet/db_sqlite3_sqlgen.c
  24. 4
      wallet/statements_gettextgen.po
  25. 5
      wallet/test/run-wallet.c

1
common/peer_failed.c

@ -71,6 +71,7 @@ void peer_failed_err(struct per_peer_state *pps,
va_list ap;
const char *desc;
assert(channel_id);
va_start(ap, fmt);
desc = tal_vfmt(tmpctx, fmt, ap);
va_end(ap);

4
common/read_peer_msg.c

@ -126,8 +126,8 @@ void handle_gossip_msg(struct per_peer_state *pps, const u8 *msg TAKES)
/* It's a raw gossip msg: this copies or takes() */
gossip = tal_dup_talarr(tmpctx, u8, msg);
/* Gossipd can send us gossip messages, OR errors */
if (fromwire_peektype(gossip) == WIRE_ERROR) {
/* Gossipd can send us gossip messages, OR warnings */
if (fromwire_peektype(gossip) == WIRE_WARNING) {
sync_crypto_write(pps, gossip);
peer_failed_connection_lost();
} else {

8
common/wire_error.c

@ -10,18 +10,12 @@ u8 *towire_errorfmtv(const tal_t *ctx,
const char *fmt,
va_list ap)
{
/* BOLT #1:
*
* The channel is referred to by `channel_id`, unless `channel_id` is
* 0 (i.e. all bytes are 0), in which case it refers to all
* channels. */
static const struct channel_id all_channels;
char *estr;
u8 *msg;
estr = tal_vfmt(ctx, fmt, ap);
/* We need tal_len to work, so we use copy. */
msg = towire_error(ctx, channel ? channel : &all_channels,
msg = towire_error(ctx, channel,
(u8 *)tal_dup_arr(estr, char, estr, strlen(estr), 0));
tal_free(estr);

8
common/wire_error.h

@ -12,25 +12,25 @@ struct channel_id;
* towire_errorfmt - helper to turn string into WIRE_ERROR.
*
* @ctx: context to allocate from
* @channel: specific channel to complain about, or NULL for all.
* @channel: specific channel to complain about
* @fmt: format for error.
*/
u8 *towire_errorfmt(const tal_t *ctx,
const struct channel_id *channel,
const char *fmt, ...) PRINTF_FMT(3,4);
const char *fmt, ...) PRINTF_FMT(3,4) NON_NULL_ARGS(2);
/**
* towire_errorfmtv - helper to turn string into WIRE_ERROR.
*
* @ctx: context to allocate from
* @channel: specific channel to complain about, or NULL for all.
* @channel: specific channel to complain about
* @fmt: format for error.
* @ap: accumulated varargs.
*/
u8 *towire_errorfmtv(const tal_t *ctx,
const struct channel_id *channel,
const char *fmt,
va_list ap);
va_list ap) NON_NULL_ARGS(2);
/**
* towire_warningfmt - helper to turn string into WIRE_WARNING.

6
connectd/connectd.c

@ -463,14 +463,14 @@ struct io_plan *peer_connected(struct io_conn *conn,
unsup = features_unsupported(daemon->our_features, their_features,
INIT_FEATURE);
if (unsup != -1) {
msg = towire_errorfmt(NULL, NULL, "Unsupported feature %u",
unsup);
msg = towire_warningfmt(NULL, NULL, "Unsupported feature %u",
unsup);
msg = cryptomsg_encrypt_msg(tmpctx, cs, take(msg));
return io_write(conn, msg, tal_count(msg), io_close_cb, NULL);
}
if (!feature_check_depends(their_features, &depender, &missing)) {
msg = towire_errorfmt(NULL, NULL,
msg = towire_warningfmt(NULL, NULL,
"Feature %zu requires feature %zu",
depender, missing);
msg = cryptomsg_encrypt_msg(tmpctx, cs, take(msg));

2
connectd/peer_exchange_initmsg.c

@ -79,7 +79,7 @@ static struct io_plan *peer_init_received(struct io_conn *conn,
status_peer_debug(&peer->id,
"No common chain with this peer '%s', closing",
tal_hex(tmpctx, msg));
msg = towire_errorfmt(NULL, NULL, "No common network");
msg = towire_warningfmt(NULL, NULL, "No common network");
msg = cryptomsg_encrypt_msg(NULL, &peer->cs, take(msg));
return io_write(conn, msg, tal_count(msg), io_close_cb, NULL);
}

6
gossipd/gossipd.c

@ -319,7 +319,7 @@ static u8 *handle_ping(struct peer *peer, const u8 *ping)
/* This checks the ping packet and makes a pong reply if needed; peer
* can specify it doesn't want a response, to simulate traffic. */
if (!check_ping_make_pong(NULL, ping, &pong))
return towire_errorfmt(peer, NULL, "Bad ping");
return towire_warningfmt(peer, NULL, "Bad ping");
if (pong)
queue_peer_msg(peer, take(pong));
@ -333,7 +333,7 @@ static const u8 *handle_pong(struct peer *peer, const u8 *pong)
const char *err = got_pong(pong, &peer->num_pings_outstanding);
if (err)
return towire_errorfmt(peer, NULL, "%s", err);
return towire_warningfmt(peer, NULL, "%s", err);
daemon_conn_send(peer->daemon->master,
take(towire_gossipd_ping_reply(NULL, &peer->id, true,
@ -454,7 +454,7 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg)
/* FIXME: ratelimit! */
if (!fromwire_onion_message(msg, msg, &onion, tlvs))
return towire_errorfmt(peer, NULL, "Bad onion_message");
return towire_warningfmt(peer, NULL, "Bad onion_message");
/* We unwrap the onion now. */
op = parse_onionpacket(tmpctx, onion, tal_bytelen(onion), &badreason);

114
gossipd/queries.c

@ -250,9 +250,9 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
if (!fromwire_query_short_channel_ids(tmpctx, msg, &chain, &encoded,
tlvs)) {
return towire_errorfmt(peer, NULL,
"Bad query_short_channel_ids w/tlvs %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"Bad query_short_channel_ids w/tlvs %s",
tal_hex(tmpctx, msg));
}
if (tlvs->query_flags) {
/* BOLT #7:
@ -266,9 +266,9 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
*/
flags = decode_scid_query_flags(tmpctx, tlvs->query_flags);
if (!flags) {
return towire_errorfmt(peer, NULL,
"Bad query_short_channel_ids query_flags %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"Bad query_short_channel_ids query_flags %s",
tal_hex(tmpctx, msg));
}
} else
flags = NULL;
@ -295,15 +295,15 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
* - MAY fail the connection.
*/
if (peer->scid_queries || peer->scid_query_nodes) {
return towire_errorfmt(peer, NULL,
"Bad concurrent query_short_channel_ids");
return towire_warningfmt(peer, NULL,
"Bad concurrent query_short_channel_ids");
}
scids = decode_short_ids(tmpctx, encoded);
if (!scids) {
return towire_errorfmt(peer, NULL,
"Bad query_short_channel_ids encoding %s",
tal_hex(tmpctx, encoded));
return towire_warningfmt(peer, NULL,
"Bad query_short_channel_ids encoding %s",
tal_hex(tmpctx, encoded));
}
/* BOLT #7:
@ -320,9 +320,9 @@ const u8 *handle_query_short_channel_ids(struct peer *peer, const u8 *msg)
memset(flags, 0xFF, tal_bytelen(flags));
} else {
if (tal_count(flags) != tal_count(scids)) {
return towire_errorfmt(peer, NULL,
"Bad query_short_channel_ids flags count %zu scids %zu",
tal_count(flags), tal_count(scids));
return towire_warningfmt(peer, NULL,
"Bad query_short_channel_ids flags count %zu scids %zu",
tal_count(flags), tal_count(scids));
}
}
@ -652,9 +652,9 @@ const u8 *handle_query_channel_range(struct peer *peer, const u8 *msg)
if (!fromwire_query_channel_range(msg, &chain_hash,
&first_blocknum, &number_of_blocks,
tlvs)) {
return towire_errorfmt(peer, NULL,
"Bad query_channel_range w/tlvs %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"Bad query_channel_range w/tlvs %s",
tal_hex(tmpctx, msg));
}
if (tlvs->query_option)
query_option_flags = *tlvs->query_option;
@ -703,13 +703,13 @@ static u8 *append_range_reply(struct peer *peer,
ts = decode_channel_update_timestamps(tmpctx,
timestamps_tlv);
if (!ts)
return towire_errorfmt(peer, NULL,
"reply_channel_range can't decode timestamps.");
return towire_warningfmt(peer, NULL,
"reply_channel_range can't decode timestamps.");
if (tal_count(ts) != tal_count(scids)) {
return towire_errorfmt(peer, NULL,
"reply_channel_range %zu timestamps when %zu scids?",
tal_count(ts),
tal_count(scids));
return towire_warningfmt(peer, NULL,
"reply_channel_range %zu timestamps when %zu scids?",
tal_count(ts),
tal_count(scids));
}
} else
ts = NULL;
@ -749,35 +749,35 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
if (!fromwire_reply_channel_range(tmpctx, msg, &chain, &first_blocknum,
&number_of_blocks, &complete,
&encoded, tlvs)) {
return towire_errorfmt(peer, NULL,
"Bad reply_channel_range w/tlvs %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"Bad reply_channel_range w/tlvs %s",
tal_hex(tmpctx, msg));
}
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
return towire_errorfmt(peer, NULL,
"reply_channel_range for bad chain: %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"reply_channel_range for bad chain: %s",
tal_hex(tmpctx, msg));
}
if (!peer->range_replies) {
return towire_errorfmt(peer, NULL,
"reply_channel_range without query: %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"reply_channel_range without query: %s",
tal_hex(tmpctx, msg));
}
/* Beware overflow! */
if (first_blocknum + number_of_blocks < first_blocknum) {
return towire_errorfmt(peer, NULL,
"reply_channel_range invalid %u+%u",
first_blocknum, number_of_blocks);
return towire_warningfmt(peer, NULL,
"reply_channel_range invalid %u+%u",
first_blocknum, number_of_blocks);
}
scids = decode_short_ids(tmpctx, encoded);
if (!scids) {
return towire_errorfmt(peer, NULL,
"Bad reply_channel_range encoding %s",
tal_hex(tmpctx, encoded));
return towire_warningfmt(peer, NULL,
"Bad reply_channel_range encoding %s",
tal_hex(tmpctx, encoded));
}
status_peer_debug(&peer->id,
@ -807,12 +807,12 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
/* ie. They can be outside range we asked, but they must overlap! */
if (first_blocknum + number_of_blocks <= peer->range_first_blocknum
|| first_blocknum >= peer->range_end_blocknum) {
return towire_errorfmt(peer, NULL,
"reply_channel_range invalid %u+%u for query %u+%u",
first_blocknum, number_of_blocks,
peer->range_first_blocknum,
peer->range_end_blocknum
- peer->range_first_blocknum);
return towire_warningfmt(peer, NULL,
"reply_channel_range invalid %u+%u for query %u+%u",
first_blocknum, number_of_blocks,
peer->range_first_blocknum,
peer->range_end_blocknum
- peer->range_first_blocknum);
}
start = first_blocknum;
@ -838,10 +838,10 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
* can overlap. */
if (first_blocknum != peer->range_prev_end_blocknum + 1
&& first_blocknum != peer->range_prev_end_blocknum) {
return towire_errorfmt(peer, NULL,
"reply_channel_range %u+%u previous end was block %u",
first_blocknum, number_of_blocks,
peer->range_prev_end_blocknum);
return towire_warningfmt(peer, NULL,
"reply_channel_range %u+%u previous end was block %u",
first_blocknum, number_of_blocks,
peer->range_prev_end_blocknum);
}
peer->range_prev_end_blocknum = end;
@ -878,21 +878,21 @@ const u8 *handle_reply_short_channel_ids_end(struct peer *peer, const u8 *msg)
u8 complete;
if (!fromwire_reply_short_channel_ids_end(msg, &chain, &complete)) {
return towire_errorfmt(peer, NULL,
"Bad reply_short_channel_ids_end %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"Bad reply_short_channel_ids_end %s",
tal_hex(tmpctx, msg));
}
if (!bitcoin_blkid_eq(&chainparams->genesis_blockhash, &chain)) {
return towire_errorfmt(peer, NULL,
"reply_short_channel_ids_end for bad chain: %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"reply_short_channel_ids_end for bad chain: %s",
tal_hex(tmpctx, msg));
}
if (!peer->scid_query_outstanding) {
return towire_errorfmt(peer, NULL,
"unexpected reply_short_channel_ids_end: %s",
tal_hex(tmpctx, msg));
return towire_warningfmt(peer, NULL,
"unexpected reply_short_channel_ids_end: %s",
tal_hex(tmpctx, msg));
}
peer->scid_query_outstanding = false;

146
gossipd/routing.c

@ -1391,16 +1391,16 @@ static u8 *check_channel_update(const tal_t *ctx,
sha256_double(&hash, update + offset, tal_count(update) - offset);
if (!check_signed_hash_nodeid(&hash, node_sig, node_id))
return towire_errorfmt(ctx, NULL,
"Bad signature for %s hash %s"
" on channel_update %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, update));
return towire_warningfmt(ctx, NULL,
"Bad signature for %s hash %s"
" on channel_update %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, update));
return NULL;
}
@ -1419,52 +1419,52 @@ static u8 *check_channel_announcement(const tal_t *ctx,
tal_count(announcement) - offset);
if (!check_signed_hash_nodeid(&hash, node1_sig, node1_id)) {
return towire_errorfmt(ctx, NULL,
"Bad node_signature_1 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node1_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
return towire_warningfmt(ctx, NULL,
"Bad node_signature_1 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node1_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
}
if (!check_signed_hash_nodeid(&hash, node2_sig, node2_id)) {
return towire_errorfmt(ctx, NULL,
"Bad node_signature_2 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node2_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
return towire_warningfmt(ctx, NULL,
"Bad node_signature_2 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
node2_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
}
if (!check_signed_hash(&hash, bitcoin1_sig, bitcoin1_key)) {
return towire_errorfmt(ctx, NULL,
"Bad bitcoin_signature_1 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
bitcoin1_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
return towire_warningfmt(ctx, NULL,
"Bad bitcoin_signature_1 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
bitcoin1_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
}
if (!check_signed_hash(&hash, bitcoin2_sig, bitcoin2_key)) {
return towire_errorfmt(ctx, NULL,
"Bad bitcoin_signature_2 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
bitcoin2_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
return towire_warningfmt(ctx, NULL,
"Bad bitcoin_signature_2 %s hash %s"
" on channel_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
bitcoin2_sig),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, announcement));
}
return NULL;
}
@ -1715,9 +1715,9 @@ u8 *handle_channel_announcement(struct routing_state *rstate,
&pending->node_id_2,
&pending->bitcoin_key_1,
&pending->bitcoin_key_2)) {
err = towire_errorfmt(rstate, NULL,
"Malformed channel_announcement %s",
tal_hex(pending, pending->announce));
err = towire_warningfmt(rstate, NULL,
"Malformed channel_announcement %s",
tal_hex(pending, pending->announce));
goto malformed;
}
@ -2309,9 +2309,9 @@ u8 *handle_channel_update(struct routing_state *rstate, const u8 *update TAKES,
&channel_flags, &expiry,
&htlc_minimum, &fee_base_msat,
&fee_proportional_millionths)) {
err = towire_errorfmt(rstate, NULL,
"Malformed channel_update %s",
tal_hex(tmpctx, serialized));
err = towire_warningfmt(rstate, NULL,
"Malformed channel_update %s",
tal_hex(tmpctx, serialized));
return err;
}
direction = channel_flags & 0x1;
@ -2587,9 +2587,9 @@ u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann,
* - SHOULD fail the connection.
* - MUST NOT process the message further.
*/
u8 *err = towire_errorfmt(rstate, NULL,
"Malformed node_announcement %s",
tal_hex(tmpctx, node_ann));
u8 *err = towire_warningfmt(rstate, NULL,
"Malformed node_announcement %s",
tal_hex(tmpctx, node_ann));
return err;
}
@ -2606,16 +2606,16 @@ u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann,
* - MUST NOT process the message further.
* - SHOULD fail the connection.
*/
u8 *err = towire_errorfmt(rstate, NULL,
"Bad signature for %s hash %s"
" on node_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
&signature),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, node_ann));
u8 *err = towire_warningfmt(rstate, NULL,
"Bad signature for %s hash %s"
" on node_announcement %s",
type_to_string(tmpctx,
secp256k1_ecdsa_signature,
&signature),
type_to_string(tmpctx,
struct sha256_double,
&hash),
tal_hex(tmpctx, node_ann));
return err;
}
@ -2627,10 +2627,10 @@ u8 *handle_node_announcement(struct routing_state *rstate, const u8 *node_ann,
* descriptors of the known types:
* - SHOULD fail the connection.
*/
u8 *err = towire_errorfmt(rstate, NULL,
"Malformed wireaddrs %s in %s.",
tal_hex(tmpctx, wireaddrs),
tal_hex(tmpctx, node_ann));
u8 *err = towire_warningfmt(rstate, NULL,
"Malformed wireaddrs %s in %s.",
tal_hex(tmpctx, wireaddrs),
tal_hex(tmpctx, node_ann));
return err;
}

10
gossipd/test/run-bench-find_route.c

@ -99,11 +99,6 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_amount */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
@ -116,6 +111,11 @@ u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }

10
gossipd/test/run-crc32_of_update.c

@ -113,17 +113,17 @@ void status_fmt(enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_hsmd_cupdate_sig_req */
u8 *towire_hsmd_cupdate_sig_req(const tal_t *ctx UNNEEDED, const u8 *cu UNNEEDED)
{ fprintf(stderr, "towire_hsmd_cupdate_sig_req called!\n"); abort(); }
/* Generated stub for towire_hsmd_node_announcement_sig_req */
u8 *towire_hsmd_node_announcement_sig_req(const tal_t *ctx UNNEEDED, const u8 *announcement UNNEEDED)
{ fprintf(stderr, "towire_hsmd_node_announcement_sig_req called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for towire_wireaddr */
void towire_wireaddr(u8 **pptr UNNEEDED, const struct wireaddr *addr UNNEEDED)
{ fprintf(stderr, "towire_wireaddr called!\n"); abort(); }

10
gossipd/test/run-extended-info.c

@ -82,11 +82,11 @@ void queue_peer_from_store(struct peer *peer UNNEEDED,
/* Generated stub for queue_peer_msg */
void queue_peer_msg(struct peer *peer UNNEEDED, const u8 *msg TAKES UNNEEDED)
{ fprintf(stderr, "queue_peer_msg called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
void status_fmt(enum log_level level UNNEEDED,

10
gossipd/test/run-find_route-specific.c

@ -85,11 +85,6 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_amount */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
@ -102,6 +97,11 @@ u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }

10
gossipd/test/run-find_route.c

@ -85,11 +85,6 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_amount */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
@ -102,6 +97,11 @@ u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }

10
gossipd/test/run-overlong.c

@ -85,11 +85,6 @@ char *sanitize_error(const tal_t *ctx UNNEEDED, const u8 *errmsg UNNEEDED,
void status_failed(enum status_failreason code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_failed called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_amount */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
@ -102,6 +97,11 @@ u8 *towire_gossip_store_private_channel(const tal_t *ctx UNNEEDED, struct amount
/* Generated stub for towire_gossip_store_private_update */
u8 *towire_gossip_store_private_update(const tal_t *ctx UNNEEDED, const u8 *update UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_private_update called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for update_peers_broadcast_index */
void update_peers_broadcast_index(struct list_head *peers UNNEEDED, u32 offset UNNEEDED)
{ fprintf(stderr, "update_peers_broadcast_index called!\n"); abort(); }

10
gossipd/test/run-txout_failure.c

@ -91,14 +91,14 @@ void status_fmt(enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "status_fmt called!\n"); abort(); }
/* Generated stub for towire_errorfmt */
u8 *towire_errorfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_errorfmt called!\n"); abort(); }
/* Generated stub for towire_gossip_store_channel_amount */
u8 *towire_gossip_store_channel_amount(const tal_t *ctx UNNEEDED, struct amount_sat satoshis UNNEEDED)
{ fprintf(stderr, "towire_gossip_store_channel_amount called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
/* NOOP stub for gossip_store_new */

9
lightningd/peer_control.c

@ -1083,9 +1083,9 @@ peer_connected_hook_deserialize(struct peer_connected_hook_payload *payload,
if (json_tok_streq(buffer, t_res, "disconnect")) {
payload->error = (u8*)"";
if (t_err) {
payload->error = towire_errorfmt(tmpctx, NULL, "%.*s",
t_err->end - t_err->start,
buffer + t_err->start);
payload->error = towire_warningfmt(tmpctx, NULL, "%.*s",
t_err->end - t_err->start,
buffer + t_err->start);
}
log_debug(ld->log, "peer_connected hook rejects and says '%s'",
payload->error);
@ -2238,7 +2238,8 @@ static void process_dev_forget_channel(struct bitcoind *bitcoind UNUSED,
json_add_txid(response, "funding_txid", &forget->channel->funding_txid);
/* Set error so we don't try to reconnect. */
forget->channel->error = towire_errorfmt(forget->channel, NULL,
forget->channel->error = towire_errorfmt(forget->channel,
&forget->channel->cid,
"dev_forget_channel");
delete_channel(forget->channel);

5
lightningd/test/run-invoice-select-inchan.c

@ -615,6 +615,11 @@ void towire_node_id(u8 **pptr UNNEEDED, const struct node_id *id UNNEEDED)
/* Generated stub for towire_onchaind_dev_memleak */
u8 *towire_onchaind_dev_memleak(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_onchaind_dev_memleak called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for version */
const char *version(void)
{ fprintf(stderr, "version called!\n"); abort(); }

14
openingd/dualopend.c

@ -2694,13 +2694,13 @@ static u8 *handle_peer_in(struct state *state)
return NULL;
sync_crypto_write(state->pps,
take(towire_errorfmt(NULL,
extract_channel_id(msg,
&channel_id) ?
&channel_id : NULL,
"Unexpected message %s: %s",
peer_wire_name(t),
tal_hex(tmpctx, msg))));
take(towire_warningfmt(NULL,
extract_channel_id(msg,
&channel_id) ?
&channel_id : NULL,
"Unexpected message %s: %s",
peer_wire_name(t),
tal_hex(tmpctx, msg))));
/* FIXME: We don't actually want master to try to send an
* error, since peer is transient. This is a hack.

28
openingd/openingd.c

@ -1153,11 +1153,11 @@ static u8 *handle_peer_in(struct state *state)
return NULL;
sync_crypto_write(state->pps,
take(towire_errorfmt(NULL,
extract_channel_id(msg, &channel_id) ? &channel_id : NULL,
"Unexpected message %s: %s",
peer_wire_name(t),
tal_hex(tmpctx, msg))));
take(towire_warningfmt(NULL,
extract_channel_id(msg, &channel_id) ? &channel_id : NULL,
"Unexpected message %s: %s",
peer_wire_name(t),
tal_hex(tmpctx, msg))));
/* FIXME: We don't actually want master to try to send an
* error, since peer is transient. This is a hack.
@ -1179,20 +1179,18 @@ static void handle_gossip_in(struct state *state)
handle_gossip_msg(state->pps, take(msg));
}
/*~ Is this message of type `error` with the special zero-id
* "fail-everything"? If lightningd asked us to send such a thing, we're
* done. */
static void fail_if_all_error(const u8 *inner)
/*~ Is this message of a `warning` or `error`? If lightningd asked us to send
* such a thing, it wants to close the connection. */
static void fail_if_warning_or_error(const u8 *inner)
{
struct channel_id channel_id;
u8 *data;
if (!fromwire_error(tmpctx, inner, &channel_id, &data)
|| !channel_id_is_all(&channel_id)) {
if (!fromwire_warning(tmpctx, inner, &channel_id, &data)
&& !fromwire_error(tmpctx, inner, &channel_id, &data))
return;
}
status_info("Master said send err: %s",
status_info("Master said send %s",
sanitize_error(tmpctx, inner, NULL));
exit(0);
}
@ -1358,10 +1356,10 @@ int main(int argc, char *argv[])
per_peer_state_set_fds(state->pps, 3, 4, 5);
/*~ If lightningd wanted us to send a msg, do so before we waste time
* doing work. If it's a global error, we'll close immediately. */
* doing work. If it's a warning, we'll close immediately. */
if (inner != NULL) {
sync_crypto_write(state->pps, inner);
fail_if_all_error(inner);
fail_if_warning_or_error(inner);
tal_free(inner);
}

2
tests/test_plugin.py

@ -424,7 +424,7 @@ def test_plugin_connected_hook_chaining(node_factory):
])
# FIXME: this error occurs *after* connection, so we connect then drop.
l3.daemon.wait_for_log(r"chan#1: peer_in WIRE_ERROR")
l3.daemon.wait_for_log(r"chan#1: peer_in WIRE_WARNING")
l3.daemon.wait_for_log(r"You are in reject list")
def check_disconnect():

2
wallet/db_postgres_sqlgen.c

@ -1786,4 +1786,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:e7f5fdbc96b1e28c14a395767b8c9a29ccf9a9773c69e2bf24b77b31f11ee4b6
// SHA256STAMP:d99c7d86df2c57de4dad0ae207bb71ac7245e1beb3bee1066ab5d947db9b1e5c

2
wallet/db_sqlite3_sqlgen.c

@ -1786,4 +1786,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:e7f5fdbc96b1e28c14a395767b8c9a29ccf9a9773c69e2bf24b77b31f11ee4b6
// SHA256STAMP:d99c7d86df2c57de4dad0ae207bb71ac7245e1beb3bee1066ab5d947db9b1e5c

4
wallet/statements_gettextgen.po

@ -1174,7 +1174,7 @@ msgstr ""
msgid "not a valid SQL statement"
msgstr ""
#: wallet/test/run-wallet.c:1390
#: wallet/test/run-wallet.c:1395
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:95ea4c16d30a6f6bc7c6f9651cc2312a0e3b299ecd58f3a4ed48d89f2bebacce
# SHA256STAMP:878611b064230015bd80f43f4d7acde6bbf1c468da09bc8621898ff6718308e6

5
wallet/test/run-wallet.c

@ -792,6 +792,11 @@ u8 *towire_temporary_node_failure(const tal_t *ctx UNNEEDED)
/* Generated stub for towire_unknown_next_peer */
u8 *towire_unknown_next_peer(const tal_t *ctx UNNEEDED)
{ fprintf(stderr, "towire_unknown_next_peer called!\n"); abort(); }
/* Generated stub for towire_warningfmt */
u8 *towire_warningfmt(const tal_t *ctx UNNEEDED,
const struct channel_id *channel UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "towire_warningfmt called!\n"); abort(); }
/* Generated stub for watch_txid */
struct txwatch *watch_txid(const tal_t *ctx UNNEEDED,
struct chain_topology *topo UNNEEDED,

Loading…
Cancel
Save