From 2bc2502b23bc8ff41770e08a34ff95f0a7044c36 Mon Sep 17 00:00:00 2001 From: Rusty Russell <rusty@rustcorp.com.au> Date: Wed, 10 Jan 2018 15:17:22 +1030 Subject: [PATCH] wire: move extract_channel_id to here. It can be useful for other daemons. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> --- lightningd/peer_control.c | 27 --------------------------- wire/peer_wire.c | 27 +++++++++++++++++++++++++++ wire/peer_wire.h | 3 +++ 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 43198117f..6ad027435 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -445,33 +445,6 @@ bool unsupported_features(const u8 *gfeatures, const u8 *lfeatures) sizeof(supported_local_features)); } -/* Extract channel_id from various packets, return true if possible. */ -static bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id) -{ - u64 ignored_u64; - u32 ignored_u32; - u16 ignored_u16; - u8 ignored_u8; - struct pubkey ignored_pubkey; - struct bitcoin_blkid ignored_chainhash; - - if (fromwire_channel_reestablish(in_pkt, NULL, channel_id, - &ignored_u64, &ignored_u64)) - return true; - if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash, - channel_id, &ignored_u64, - &ignored_u64, &ignored_u64, - &ignored_u64, &ignored_u64, - &ignored_u64, &ignored_u32, - &ignored_u16, &ignored_u16, - &ignored_pubkey, &ignored_pubkey, - &ignored_pubkey, &ignored_pubkey, - &ignored_pubkey, &ignored_pubkey, - &ignored_u8)) - return true; - return false; -} - /** * peer_channel_new -- Instantiate a new channel for the given peer and save it * diff --git a/wire/peer_wire.c b/wire/peer_wire.c index 09d994b3a..ff1ac56cf 100644 --- a/wire/peer_wire.c +++ b/wire/peer_wire.c @@ -73,3 +73,30 @@ bool is_unknown_msg_discardable(const u8 *cursor) enum wire_type t = fromwire_peektype(cursor); return unknown_type(t) && (t & 1); } + +/* Extract channel_id from various packets, return true if possible. */ +bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id) +{ + u64 ignored_u64; + u32 ignored_u32; + u16 ignored_u16; + u8 ignored_u8; + struct pubkey ignored_pubkey; + struct bitcoin_blkid ignored_chainhash; + + if (fromwire_channel_reestablish(in_pkt, NULL, channel_id, + &ignored_u64, &ignored_u64)) + return true; + if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash, + channel_id, &ignored_u64, + &ignored_u64, &ignored_u64, + &ignored_u64, &ignored_u64, + &ignored_u64, &ignored_u32, + &ignored_u16, &ignored_u16, + &ignored_pubkey, &ignored_pubkey, + &ignored_pubkey, &ignored_pubkey, + &ignored_pubkey, &ignored_pubkey, + &ignored_u8)) + return true; + return false; +} diff --git a/wire/peer_wire.h b/wire/peer_wire.h index b9160ff59..ada42520b 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -19,6 +19,9 @@ bool is_unknown_msg_discardable(const u8 *cursor); /* Return true if it's a gossip message. */ bool is_gossip_msg(const u8 *cursor); +/* Extract channel_id from various packets, return true if possible. */ +bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id); + /* BOLT #2: * * Only the least-significant bit of `channel_flags` is currently