@@ -66,16 +66,14 @@ pub enum DecodeError {
66
66
}
67
67
68
68
/// An init message to be sent or received from a peer
69
- #[ derive( Clone ) ]
69
+ #[ derive( Clone , Debug , PartialEq ) ]
70
70
pub struct Init {
71
- #[ cfg( not( feature = "fuzztarget" ) ) ]
72
- pub ( crate ) features : InitFeatures ,
73
- #[ cfg( feature = "fuzztarget" ) ]
71
+ /// The relevant features which the sender supports
74
72
pub features : InitFeatures ,
75
73
}
76
74
77
75
/// An error message to be sent or received from a peer
78
- #[ derive( Clone ) ]
76
+ #[ derive( Clone , Debug , PartialEq ) ]
79
77
pub struct ErrorMessage {
80
78
/// The channel ID involved in the error
81
79
pub channel_id : [ u8 ; 32 ] ,
@@ -87,7 +85,7 @@ pub struct ErrorMessage {
87
85
}
88
86
89
87
/// A ping message to be sent or received from a peer
90
- #[ derive( Clone ) ]
88
+ #[ derive( Clone , Debug , PartialEq ) ]
91
89
pub struct Ping {
92
90
/// The desired response length
93
91
pub ponglen : u16 ,
@@ -97,15 +95,15 @@ pub struct Ping {
97
95
}
98
96
99
97
/// A pong message to be sent or received from a peer
100
- #[ derive( Clone ) ]
98
+ #[ derive( Clone , Debug , PartialEq ) ]
101
99
pub struct Pong {
102
100
/// The pong packet size.
103
101
/// This field is not sent on the wire. byteslen zeros are sent.
104
102
pub byteslen : u16 ,
105
103
}
106
104
107
105
/// An open_channel message to be sent or received from a peer
108
- #[ derive( Clone ) ]
106
+ #[ derive( Clone , Debug , PartialEq ) ]
109
107
pub struct OpenChannel {
110
108
/// The genesis hash of the blockchain where the channel is to be opened
111
109
pub chain_hash : BlockHash ,
@@ -148,7 +146,7 @@ pub struct OpenChannel {
148
146
}
149
147
150
148
/// An accept_channel message to be sent or received from a peer
151
- #[ derive( Clone ) ]
149
+ #[ derive( Clone , Debug , PartialEq ) ]
152
150
pub struct AcceptChannel {
153
151
/// A temporary channel ID, until the funding outpoint is announced
154
152
pub temporary_channel_id : [ u8 ; 32 ] ,
@@ -183,7 +181,7 @@ pub struct AcceptChannel {
183
181
}
184
182
185
183
/// A funding_created message to be sent or received from a peer
186
- #[ derive( Clone ) ]
184
+ #[ derive( Clone , Debug , PartialEq ) ]
187
185
pub struct FundingCreated {
188
186
/// A temporary channel ID, until the funding is established
189
187
pub temporary_channel_id : [ u8 ; 32 ] ,
@@ -196,7 +194,7 @@ pub struct FundingCreated {
196
194
}
197
195
198
196
/// A funding_signed message to be sent or received from a peer
199
- #[ derive( Clone ) ]
197
+ #[ derive( Clone , Debug , PartialEq ) ]
200
198
pub struct FundingSigned {
201
199
/// The channel ID
202
200
pub channel_id : [ u8 ; 32 ] ,
@@ -205,7 +203,7 @@ pub struct FundingSigned {
205
203
}
206
204
207
205
/// A funding_locked message to be sent or received from a peer
208
- #[ derive( Clone , PartialEq ) ]
206
+ #[ derive( Clone , Debug , PartialEq ) ]
209
207
pub struct FundingLocked {
210
208
/// The channel ID
211
209
pub channel_id : [ u8 ; 32 ] ,
@@ -214,7 +212,7 @@ pub struct FundingLocked {
214
212
}
215
213
216
214
/// A shutdown message to be sent or received from a peer
217
- #[ derive( Clone , PartialEq ) ]
215
+ #[ derive( Clone , Debug , PartialEq ) ]
218
216
pub struct Shutdown {
219
217
/// The channel ID
220
218
pub channel_id : [ u8 ; 32 ] ,
@@ -224,7 +222,7 @@ pub struct Shutdown {
224
222
}
225
223
226
224
/// A closing_signed message to be sent or received from a peer
227
- #[ derive( Clone , PartialEq ) ]
225
+ #[ derive( Clone , Debug , PartialEq ) ]
228
226
pub struct ClosingSigned {
229
227
/// The channel ID
230
228
pub channel_id : [ u8 ; 32 ] ,
@@ -235,7 +233,7 @@ pub struct ClosingSigned {
235
233
}
236
234
237
235
/// An update_add_htlc message to be sent or received from a peer
238
- #[ derive( Clone , PartialEq ) ]
236
+ #[ derive( Clone , Debug , PartialEq ) ]
239
237
pub struct UpdateAddHTLC {
240
238
/// The channel ID
241
239
pub channel_id : [ u8 ; 32 ] ,
@@ -251,7 +249,7 @@ pub struct UpdateAddHTLC {
251
249
}
252
250
253
251
/// An update_fulfill_htlc message to be sent or received from a peer
254
- #[ derive( Clone , PartialEq ) ]
252
+ #[ derive( Clone , Debug , PartialEq ) ]
255
253
pub struct UpdateFulfillHTLC {
256
254
/// The channel ID
257
255
pub channel_id : [ u8 ; 32 ] ,
@@ -262,7 +260,7 @@ pub struct UpdateFulfillHTLC {
262
260
}
263
261
264
262
/// An update_fail_htlc message to be sent or received from a peer
265
- #[ derive( Clone , PartialEq ) ]
263
+ #[ derive( Clone , Debug , PartialEq ) ]
266
264
pub struct UpdateFailHTLC {
267
265
/// The channel ID
268
266
pub channel_id : [ u8 ; 32 ] ,
@@ -272,7 +270,7 @@ pub struct UpdateFailHTLC {
272
270
}
273
271
274
272
/// An update_fail_malformed_htlc message to be sent or received from a peer
275
- #[ derive( Clone , PartialEq ) ]
273
+ #[ derive( Clone , Debug , PartialEq ) ]
276
274
pub struct UpdateFailMalformedHTLC {
277
275
/// The channel ID
278
276
pub channel_id : [ u8 ; 32 ] ,
@@ -284,7 +282,7 @@ pub struct UpdateFailMalformedHTLC {
284
282
}
285
283
286
284
/// A commitment_signed message to be sent or received from a peer
287
- #[ derive( Clone , PartialEq ) ]
285
+ #[ derive( Clone , Debug , PartialEq ) ]
288
286
pub struct CommitmentSigned {
289
287
/// The channel ID
290
288
pub channel_id : [ u8 ; 32 ] ,
@@ -295,7 +293,7 @@ pub struct CommitmentSigned {
295
293
}
296
294
297
295
/// A revoke_and_ack message to be sent or received from a peer
298
- #[ derive( Clone , PartialEq ) ]
296
+ #[ derive( Clone , Debug , PartialEq ) ]
299
297
pub struct RevokeAndACK {
300
298
/// The channel ID
301
299
pub channel_id : [ u8 ; 32 ] ,
@@ -306,15 +304,15 @@ pub struct RevokeAndACK {
306
304
}
307
305
308
306
/// An update_fee message to be sent or received from a peer
309
- #[ derive( PartialEq , Clone ) ]
307
+ #[ derive( Clone , Debug , PartialEq ) ]
310
308
pub struct UpdateFee {
311
309
/// The channel ID
312
310
pub channel_id : [ u8 ; 32 ] ,
313
311
/// Fee rate per 1000-weight of the transaction
314
312
pub feerate_per_kw : u32 ,
315
313
}
316
314
317
- #[ derive( PartialEq , Clone ) ]
315
+ #[ derive( Clone , Debug , PartialEq ) ]
318
316
/// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
319
317
/// This is used to convince the recipient that the channel is at a certain commitment
320
318
/// number even if they lost that data due to a local failure. Of course, the peer may lie
@@ -328,7 +326,7 @@ pub struct DataLossProtect {
328
326
}
329
327
330
328
/// A channel_reestablish message to be sent or received from a peer
331
- #[ derive( PartialEq , Clone ) ]
329
+ #[ derive( Clone , Debug , PartialEq ) ]
332
330
pub struct ChannelReestablish {
333
331
/// The channel ID
334
332
pub channel_id : [ u8 ; 32 ] ,
@@ -341,7 +339,7 @@ pub struct ChannelReestablish {
341
339
}
342
340
343
341
/// An announcement_signatures message to be sent or received from a peer
344
- #[ derive( PartialEq , Clone , Debug ) ]
342
+ #[ derive( Clone , Debug , PartialEq ) ]
345
343
pub struct AnnouncementSignatures {
346
344
/// The channel ID
347
345
pub channel_id : [ u8 ; 32 ] ,
@@ -354,7 +352,7 @@ pub struct AnnouncementSignatures {
354
352
}
355
353
356
354
/// An address which can be used to connect to a remote peer
357
- #[ derive( Clone , PartialEq , Debug ) ]
355
+ #[ derive( Clone , Debug , PartialEq ) ]
358
356
pub enum NetAddress {
359
357
/// An IPv4 address/port on which the peer is listening.
360
358
IPv4 {
@@ -472,7 +470,7 @@ impl Readable for Result<NetAddress, u8> {
472
470
}
473
471
474
472
/// The unsigned part of a node_announcement
475
- #[ derive( PartialEq , Clone , Debug ) ]
473
+ #[ derive( Clone , Debug , PartialEq ) ]
476
474
pub struct UnsignedNodeAnnouncement {
477
475
/// The advertised features
478
476
pub features : NodeFeatures ,
@@ -491,7 +489,7 @@ pub struct UnsignedNodeAnnouncement {
491
489
pub ( crate ) excess_address_data : Vec < u8 > ,
492
490
pub ( crate ) excess_data : Vec < u8 > ,
493
491
}
494
- #[ derive( PartialEq , Clone , Debug ) ]
492
+ #[ derive( Clone , Debug , PartialEq ) ]
495
493
/// A node_announcement message to be sent or received from a peer
496
494
pub struct NodeAnnouncement {
497
495
/// The signature by the node key
@@ -501,7 +499,7 @@ pub struct NodeAnnouncement {
501
499
}
502
500
503
501
/// The unsigned part of a channel_announcement
504
- #[ derive( PartialEq , Clone , Debug ) ]
502
+ #[ derive( Clone , Debug , PartialEq ) ]
505
503
pub struct UnsignedChannelAnnouncement {
506
504
/// The advertised channel features
507
505
pub features : ChannelFeatures ,
@@ -520,7 +518,7 @@ pub struct UnsignedChannelAnnouncement {
520
518
pub ( crate ) excess_data : Vec < u8 > ,
521
519
}
522
520
/// A channel_announcement message to be sent or received from a peer
523
- #[ derive( PartialEq , Clone , Debug ) ]
521
+ #[ derive( Clone , Debug , PartialEq ) ]
524
522
pub struct ChannelAnnouncement {
525
523
/// Authentication of the announcement by the first public node
526
524
pub node_signature_1 : Signature ,
@@ -535,7 +533,7 @@ pub struct ChannelAnnouncement {
535
533
}
536
534
537
535
/// The unsigned part of a channel_update
538
- #[ derive( PartialEq , Clone , Debug ) ]
536
+ #[ derive( Clone , Debug , PartialEq ) ]
539
537
pub struct UnsignedChannelUpdate {
540
538
/// The genesis hash of the blockchain where the channel is to be opened
541
539
pub chain_hash : BlockHash ,
@@ -558,7 +556,7 @@ pub struct UnsignedChannelUpdate {
558
556
pub ( crate ) excess_data : Vec < u8 > ,
559
557
}
560
558
/// A channel_update message to be sent or received from a peer
561
- #[ derive( PartialEq , Clone , Debug ) ]
559
+ #[ derive( Clone , Debug , PartialEq ) ]
562
560
pub struct ChannelUpdate {
563
561
/// A signature of the channel update
564
562
pub signature : Signature ,
@@ -570,7 +568,7 @@ pub struct ChannelUpdate {
570
568
/// UTXOs in a range of blocks. The recipient of a query makes a best
571
569
/// effort to reply to the query using one or more reply_channel_range
572
570
/// messages.
573
- #[ derive( Clone , Debug ) ]
571
+ #[ derive( Clone , Debug , PartialEq ) ]
574
572
pub struct QueryChannelRange {
575
573
/// The genesis hash of the blockchain being queried
576
574
pub chain_hash : BlockHash ,
@@ -587,7 +585,7 @@ pub struct QueryChannelRange {
587
585
/// not be a perfect view of the network. The short_channel_ids in the
588
586
/// reply are encoded. We only support encoding_type=0 uncompressed
589
587
/// serialization and do not support encoding_type=1 zlib serialization.
590
- #[ derive( Clone , Debug ) ]
588
+ #[ derive( Clone , Debug , PartialEq ) ]
591
589
pub struct ReplyChannelRange {
592
590
/// The genesis hash of the blockchain being queried
593
591
pub chain_hash : BlockHash ,
@@ -609,7 +607,7 @@ pub struct ReplyChannelRange {
609
607
/// reply_short_channel_ids_end message. The short_channel_ids sent in
610
608
/// this query are encoded. We only support encoding_type=0 uncompressed
611
609
/// serialization and do not support encoding_type=1 zlib serialization.
612
- #[ derive( Clone , Debug ) ]
610
+ #[ derive( Clone , Debug , PartialEq ) ]
613
611
pub struct QueryShortChannelIds {
614
612
/// The genesis hash of the blockchain being queried
615
613
pub chain_hash : BlockHash ,
@@ -621,7 +619,7 @@ pub struct QueryShortChannelIds {
621
619
/// query_short_channel_ids message. The query recipient makes a best
622
620
/// effort to respond based on their local network view which may not be
623
621
/// a perfect view of the network.
624
- #[ derive( Clone , Debug ) ]
622
+ #[ derive( Clone , Debug , PartialEq ) ]
625
623
pub struct ReplyShortChannelIdsEnd {
626
624
/// The genesis hash of the blockchain that was queried
627
625
pub chain_hash : BlockHash ,
@@ -633,7 +631,7 @@ pub struct ReplyShortChannelIdsEnd {
633
631
/// A gossip_timestamp_filter message is used by a node to request
634
632
/// gossip relay for messages in the requested time range when the
635
633
/// gossip_queries feature has been negotiated.
636
- #[ derive( Clone , Debug ) ]
634
+ #[ derive( Clone , Debug , PartialEq ) ]
637
635
pub struct GossipTimestampFilter {
638
636
/// The genesis hash of the blockchain for channel and node information
639
637
pub chain_hash : BlockHash ,
@@ -650,7 +648,7 @@ enum EncodingType {
650
648
}
651
649
652
650
/// Used to put an error message in a LightningError
653
- #[ derive( Clone ) ]
651
+ #[ derive( Clone , Debug ) ]
654
652
pub enum ErrorAction {
655
653
/// The peer took some action which made us think they were useless. Disconnect them.
656
654
DisconnectPeer {
@@ -667,7 +665,7 @@ pub enum ErrorAction {
667
665
}
668
666
669
667
/// An Err type for failure to process messages.
670
- #[ derive( Clone ) ]
668
+ #[ derive( Clone , Debug ) ]
671
669
pub struct LightningError {
672
670
/// A human-readable message describing the error
673
671
pub err : String ,
@@ -677,7 +675,7 @@ pub struct LightningError {
677
675
678
676
/// Struct used to return values from revoke_and_ack messages, containing a bunch of commitment
679
677
/// transaction updates if they were pending.
680
- #[ derive( PartialEq , Clone ) ]
678
+ #[ derive( Clone , Debug , PartialEq ) ]
681
679
pub struct CommitmentUpdate {
682
680
/// update_add_htlc messages which should be sent
683
681
pub update_add_htlcs : Vec < UpdateAddHTLC > ,
@@ -696,7 +694,7 @@ pub struct CommitmentUpdate {
696
694
/// The information we received from a peer along the route of a payment we originated. This is
697
695
/// returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
698
696
/// RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
699
- #[ derive( Clone ) ]
697
+ #[ derive( Clone , Debug , PartialEq ) ]
700
698
pub enum HTLCFailChannelUpdate {
701
699
/// We received an error which included a full ChannelUpdate message.
702
700
ChannelUpdateMessage {
@@ -727,7 +725,7 @@ pub enum HTLCFailChannelUpdate {
727
725
/// OptionalFeild simply gets Present if there are enough bytes to read into it), we have a
728
726
/// separate enum type for them.
729
727
/// (C-not exported) due to a free generic in T
730
- #[ derive( Clone , PartialEq , Debug ) ]
728
+ #[ derive( Clone , Debug , PartialEq ) ]
731
729
pub enum OptionalField < T > {
732
730
/// Optional field is included in message
733
731
Present ( T ) ,
@@ -890,7 +888,7 @@ pub use self::fuzzy_internal_msgs::*;
890
888
#[ cfg( not( feature = "fuzztarget" ) ) ]
891
889
pub ( crate ) use self :: fuzzy_internal_msgs:: * ;
892
890
893
- #[ derive( Clone ) ]
891
+ #[ derive( Clone , PartialEq ) ]
894
892
pub ( crate ) struct OnionPacket {
895
893
pub ( crate ) version : u8 ,
896
894
/// In order to ensure we always return an error on Onion decode in compliance with BOLT 4, we
@@ -900,19 +898,13 @@ pub(crate) struct OnionPacket {
900
898
pub ( crate ) hop_data : [ u8 ; 20 * 65 ] ,
901
899
pub ( crate ) hmac : [ u8 ; 32 ] ,
902
900
}
903
-
904
- impl PartialEq for OnionPacket {
905
- fn eq ( & self , other : & OnionPacket ) -> bool {
906
- for ( i, j) in self . hop_data . iter ( ) . zip ( other. hop_data . iter ( ) ) {
907
- if i != j { return false ; }
908
- }
909
- self . version == other. version &&
910
- self . public_key == other. public_key &&
911
- self . hmac == other. hmac
901
+ impl fmt:: Debug for OnionPacket {
902
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
903
+ f. write_fmt ( format_args ! ( "OnionPacket version {} with hmac {:?}" , self . version, & self . hmac[ ..] ) )
912
904
}
913
905
}
914
906
915
- #[ derive( Clone , PartialEq ) ]
907
+ #[ derive( Clone , Debug , PartialEq ) ]
916
908
pub ( crate ) struct OnionErrorPacket {
917
909
// This really should be a constant size slice, but the spec lets these things be up to 128KB?
918
910
// (TODO) We limit it in decode to much lower...
@@ -932,12 +924,6 @@ impl fmt::Display for DecodeError {
932
924
}
933
925
}
934
926
935
- impl fmt:: Debug for LightningError {
936
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
937
- f. write_str ( self . err . as_str ( ) )
938
- }
939
- }
940
-
941
927
impl From < :: std:: io:: Error > for DecodeError {
942
928
fn from ( e : :: std:: io:: Error ) -> Self {
943
929
if e. kind ( ) == :: std:: io:: ErrorKind :: UnexpectedEof {
0 commit comments