Skip to content

Commit 2bc2502

Browse files
rustyrussellcdecker
authored andcommitted
wire: move extract_channel_id to here.
It can be useful for other daemons. Signed-off-by: Rusty Russell <[email protected]>
1 parent e34ec8d commit 2bc2502

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

lightningd/peer_control.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -445,33 +445,6 @@ bool unsupported_features(const u8 *gfeatures, const u8 *lfeatures)
445445
sizeof(supported_local_features));
446446
}
447447

448-
/* Extract channel_id from various packets, return true if possible. */
449-
static bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
450-
{
451-
u64 ignored_u64;
452-
u32 ignored_u32;
453-
u16 ignored_u16;
454-
u8 ignored_u8;
455-
struct pubkey ignored_pubkey;
456-
struct bitcoin_blkid ignored_chainhash;
457-
458-
if (fromwire_channel_reestablish(in_pkt, NULL, channel_id,
459-
&ignored_u64, &ignored_u64))
460-
return true;
461-
if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash,
462-
channel_id, &ignored_u64,
463-
&ignored_u64, &ignored_u64,
464-
&ignored_u64, &ignored_u64,
465-
&ignored_u64, &ignored_u32,
466-
&ignored_u16, &ignored_u16,
467-
&ignored_pubkey, &ignored_pubkey,
468-
&ignored_pubkey, &ignored_pubkey,
469-
&ignored_pubkey, &ignored_pubkey,
470-
&ignored_u8))
471-
return true;
472-
return false;
473-
}
474-
475448
/**
476449
* peer_channel_new -- Instantiate a new channel for the given peer and save it
477450
*

wire/peer_wire.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,30 @@ bool is_unknown_msg_discardable(const u8 *cursor)
7373
enum wire_type t = fromwire_peektype(cursor);
7474
return unknown_type(t) && (t & 1);
7575
}
76+
77+
/* Extract channel_id from various packets, return true if possible. */
78+
bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id)
79+
{
80+
u64 ignored_u64;
81+
u32 ignored_u32;
82+
u16 ignored_u16;
83+
u8 ignored_u8;
84+
struct pubkey ignored_pubkey;
85+
struct bitcoin_blkid ignored_chainhash;
86+
87+
if (fromwire_channel_reestablish(in_pkt, NULL, channel_id,
88+
&ignored_u64, &ignored_u64))
89+
return true;
90+
if (fromwire_open_channel(in_pkt, NULL, &ignored_chainhash,
91+
channel_id, &ignored_u64,
92+
&ignored_u64, &ignored_u64,
93+
&ignored_u64, &ignored_u64,
94+
&ignored_u64, &ignored_u32,
95+
&ignored_u16, &ignored_u16,
96+
&ignored_pubkey, &ignored_pubkey,
97+
&ignored_pubkey, &ignored_pubkey,
98+
&ignored_pubkey, &ignored_pubkey,
99+
&ignored_u8))
100+
return true;
101+
return false;
102+
}

wire/peer_wire.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ bool is_unknown_msg_discardable(const u8 *cursor);
1919
/* Return true if it's a gossip message. */
2020
bool is_gossip_msg(const u8 *cursor);
2121

22+
/* Extract channel_id from various packets, return true if possible. */
23+
bool extract_channel_id(const u8 *in_pkt, struct channel_id *channel_id);
24+
2225
/* BOLT #2:
2326
*
2427
* Only the least-significant bit of `channel_flags` is currently

0 commit comments

Comments
 (0)