cln/common/read_peer_msg.c
Rusty Russell 9b85a247aa common: add tal_free_if_taken() helper for common case.
Uses found and changed by Claude.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-03-29 14:35:54 +10:30

27 lines
589 B
C

#include "config.h"
#include <bitcoin/chainparams.h>
#include <common/peer_failed.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
#include <common/utils.h>
#include <common/wire_error.h>
bool handle_peer_error_or_warning(struct per_peer_state *pps,
const u8 *msg TAKES)
{
const char *err;
err = is_peer_error(tmpctx, msg);
if (err)
peer_failed_received_errmsg(pps, true, err);
/* Simply log incoming warnings */
err = is_peer_warning(tmpctx, msg);
if (err) {
tal_free_if_taken(msg);
status_info("Received %s", err);
return true;
}
return false;
}