@@ -45,7 +45,7 @@ use util::errors::APIError;
45
45
46
46
use std:: { cmp, mem} ;
47
47
use std:: collections:: { HashMap , hash_map, HashSet } ;
48
- use std:: io:: { Cursor , Read } ;
48
+ use std:: io:: { Cursor , Read , Error } ;
49
49
use std:: sync:: { Arc , Mutex , MutexGuard , RwLock } ;
50
50
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
51
51
use std:: time:: Duration ;
@@ -485,6 +485,39 @@ pub struct ChannelDetails {
485
485
pub is_live : bool ,
486
486
}
487
487
488
+ impl Writeable for ChannelDetails {
489
+ fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , Error > {
490
+ self . channel_id . write ( writer) ?;
491
+ self . short_channel_id . write ( writer) ?;
492
+ self . remote_network_id . write ( writer) ?;
493
+ self . counterparty_features . write ( writer) ?;
494
+ self . channel_value_satoshis . write ( writer) ?;
495
+ self . user_id . write ( writer) ?;
496
+ self . outbound_capacity_msat . write ( writer) ?;
497
+ self . inbound_capacity_msat . write ( writer) ?;
498
+ self . is_live . write ( writer) ?;
499
+ Ok ( ( ) )
500
+ }
501
+ }
502
+
503
+ impl Readable for ChannelDetails {
504
+ fn read < R : Read > ( reader : & mut R ) -> Result < Self , DecodeError > {
505
+ let channel_id: [ u8 ; 32 ] = Readable :: read ( reader) ?;
506
+ let short_channel_id: Option < u64 > = Readable :: read ( reader) ?;
507
+ let remote_network_id: PublicKey = Readable :: read ( reader) ?;
508
+ let counterparty_features: InitFeatures = Readable :: read ( reader) ?;
509
+ let channel_value_satoshis: u64 = Readable :: read ( reader) ?;
510
+ let user_id: u64 = Readable :: read ( reader) ?;
511
+ let outbound_capacity_msat: u64 = Readable :: read ( reader) ?;
512
+ let inbound_capacity_msat: u64 = Readable :: read ( reader) ?;
513
+ let is_live: bool = Readable :: read ( reader) ?;
514
+ Ok ( ChannelDetails {
515
+ channel_id, short_channel_id, remote_network_id, counterparty_features,
516
+ channel_value_satoshis, user_id, outbound_capacity_msat, inbound_capacity_msat, is_live
517
+ } )
518
+ }
519
+ }
520
+
488
521
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
489
522
/// Err() type describing which state the payment is in, see the description of individual enum
490
523
/// states for more.
0 commit comments