@@ -7,10 +7,11 @@ use bitcoin::blockdata::script::Script;
7
7
8
8
use std:: error:: Error ;
9
9
use std:: { cmp, fmt} ;
10
+ use std:: io:: Read ;
10
11
use std:: result:: Result ;
11
12
12
13
use util:: { byte_utils, internal_traits, events} ;
13
- use util:: ser:: { Readable , Reader , Writeable , Writer } ;
14
+ use util:: ser:: { Readable , Writeable , Writer } ;
14
15
15
16
pub trait MsgEncodable {
16
17
fn encode ( & self ) -> Vec < u8 > ;
@@ -1728,8 +1729,8 @@ impl_writeable!(AnnouncementSignatures, {
1728
1729
bitcoin_signature
1729
1730
} ) ;
1730
1731
1731
- impl < W : :: std :: io :: Write > Writeable < W > for ChannelReestablish {
1732
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1732
+ impl < W : Writer > Writeable < W > for ChannelReestablish {
1733
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1733
1734
self . channel_id . write ( w) ?;
1734
1735
self . next_local_commitment_number . write ( w) ?;
1735
1736
self . next_remote_commitment_number . write ( w) ?;
@@ -1741,8 +1742,8 @@ impl<W: ::std::io::Write> Writeable<W> for ChannelReestablish {
1741
1742
}
1742
1743
}
1743
1744
1744
- impl < R : :: std :: io :: Read > Readable < R > for ChannelReestablish {
1745
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1745
+ impl < R : Read > Readable < R > for ChannelReestablish {
1746
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1746
1747
Ok ( Self {
1747
1748
channel_id : Readable :: read ( r) ?,
1748
1749
next_local_commitment_number : Readable :: read ( r) ?,
@@ -1871,8 +1872,8 @@ impl_writeable!(OnionErrorPacket, {
1871
1872
data
1872
1873
} ) ;
1873
1874
1874
- impl < W : :: std :: io :: Write > Writeable < W > for OnionPacket {
1875
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1875
+ impl < W : Writer > Writeable < W > for OnionPacket {
1876
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1876
1877
self . version . write ( w) ?;
1877
1878
match self . public_key {
1878
1879
Ok ( pubkey) => pubkey. write ( w) ?,
@@ -1884,8 +1885,8 @@ impl<W: ::std::io::Write> Writeable<W> for OnionPacket {
1884
1885
}
1885
1886
}
1886
1887
1887
- impl < R : :: std :: io :: Read > Readable < R > for OnionPacket {
1888
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1888
+ impl < R : Read > Readable < R > for OnionPacket {
1889
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1889
1890
Ok ( OnionPacket {
1890
1891
version : Readable :: read ( r) ?,
1891
1892
public_key : {
@@ -1908,8 +1909,8 @@ impl_writeable!(UpdateAddHTLC, {
1908
1909
onion_routing_packet
1909
1910
} ) ;
1910
1911
1911
- impl < W : :: std :: io :: Write > Writeable < W > for OnionRealm0HopData {
1912
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1912
+ impl < W : Writer > Writeable < W > for OnionRealm0HopData {
1913
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1913
1914
self . short_channel_id . write ( w) ?;
1914
1915
self . amt_to_forward . write ( w) ?;
1915
1916
self . outgoing_cltv_value . write ( w) ?;
@@ -1918,8 +1919,8 @@ impl<W: ::std::io::Write> Writeable<W> for OnionRealm0HopData {
1918
1919
}
1919
1920
}
1920
1921
1921
- impl < R : :: std :: io :: Read > Readable < R > for OnionRealm0HopData {
1922
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1922
+ impl < R : Read > Readable < R > for OnionRealm0HopData {
1923
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1923
1924
Ok ( OnionRealm0HopData {
1924
1925
short_channel_id : Readable :: read ( r) ?,
1925
1926
amt_to_forward : Readable :: read ( r) ?,
@@ -1932,17 +1933,17 @@ impl<R: ::std::io::Read> Readable<R> for OnionRealm0HopData {
1932
1933
}
1933
1934
}
1934
1935
1935
- impl < W : :: std :: io :: Write > Writeable < W > for OnionHopData {
1936
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1936
+ impl < W : Writer > Writeable < W > for OnionHopData {
1937
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1937
1938
self . realm . write ( w) ?;
1938
1939
self . data . write ( w) ?;
1939
1940
self . hmac . write ( w) ?;
1940
1941
Ok ( ( ) )
1941
1942
}
1942
1943
}
1943
1944
1944
- impl < R : :: std :: io :: Read > Readable < R > for OnionHopData {
1945
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1945
+ impl < R : Read > Readable < R > for OnionHopData {
1946
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1946
1947
Ok ( OnionHopData {
1947
1948
realm : {
1948
1949
let r: u8 = Readable :: read ( r) ?;
@@ -1957,16 +1958,16 @@ impl<R: ::std::io::Read> Readable<R> for OnionHopData {
1957
1958
}
1958
1959
}
1959
1960
1960
- impl < W : :: std :: io :: Write > Writeable < W > for Ping {
1961
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1961
+ impl < W : Writer > Writeable < W > for Ping {
1962
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1962
1963
self . ponglen . write ( w) ?;
1963
1964
vec ! [ 0u8 ; self . byteslen as usize ] . write ( w) ?; // size-unchecked write
1964
1965
Ok ( ( ) )
1965
1966
}
1966
1967
}
1967
1968
1968
- impl < R : :: std :: io :: Read > Readable < R > for Ping {
1969
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1969
+ impl < R : Read > Readable < R > for Ping {
1970
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1970
1971
Ok ( Ping {
1971
1972
ponglen : Readable :: read ( r) ?,
1972
1973
byteslen : {
@@ -1978,15 +1979,15 @@ impl<R: ::std::io::Read> Readable<R> for Ping {
1978
1979
}
1979
1980
}
1980
1981
1981
- impl < W : :: std :: io :: Write > Writeable < W > for Pong {
1982
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1982
+ impl < W : Writer > Writeable < W > for Pong {
1983
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
1983
1984
vec ! [ 0u8 ; self . byteslen as usize ] . write ( w) ?; // size-unchecked write
1984
1985
Ok ( ( ) )
1985
1986
}
1986
1987
}
1987
1988
1988
- impl < R : :: std :: io :: Read > Readable < R > for Pong {
1989
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1989
+ impl < R : Read > Readable < R > for Pong {
1990
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
1990
1991
Ok ( Pong {
1991
1992
byteslen : {
1992
1993
let byteslen = Readable :: read ( r) ?;
@@ -1997,8 +1998,8 @@ impl<R: ::std::io::Read> Readable<R> for Pong {
1997
1998
}
1998
1999
}
1999
2000
2000
- impl < W : :: std :: io :: Write > Writeable < W > for UnsignedChannelAnnouncement {
2001
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
2001
+ impl < W : Writer > Writeable < W > for UnsignedChannelAnnouncement {
2002
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
2002
2003
self . features . write ( w) ?;
2003
2004
self . chain_hash . write ( w) ?;
2004
2005
self . short_channel_id . write ( w) ?;
@@ -2011,8 +2012,8 @@ impl<W: ::std::io::Write> Writeable<W> for UnsignedChannelAnnouncement {
2011
2012
}
2012
2013
}
2013
2014
2014
- impl < R : :: std :: io :: Read > Readable < R > for UnsignedChannelAnnouncement {
2015
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
2015
+ impl < R : Read > Readable < R > for UnsignedChannelAnnouncement {
2016
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
2016
2017
Ok ( Self {
2017
2018
features : {
2018
2019
let f: GlobalFeatures = Readable :: read ( r) ?;
@@ -2044,8 +2045,8 @@ impl_writeable!(ChannelAnnouncement,{
2044
2045
contents
2045
2046
} ) ;
2046
2047
2047
- impl < W : :: std :: io :: Write > Writeable < W > for UnsignedChannelUpdate {
2048
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
2048
+ impl < W : Writer > Writeable < W > for UnsignedChannelUpdate {
2049
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
2049
2050
self . chain_hash . write ( w) ?;
2050
2051
self . short_channel_id . write ( w) ?;
2051
2052
self . timestamp . write ( w) ?;
@@ -2059,8 +2060,8 @@ impl<W: ::std::io::Write> Writeable<W> for UnsignedChannelUpdate {
2059
2060
}
2060
2061
}
2061
2062
2062
- impl < R : :: std :: io :: Read > Readable < R > for UnsignedChannelUpdate {
2063
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
2063
+ impl < R : Read > Readable < R > for UnsignedChannelUpdate {
2064
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
2064
2065
Ok ( Self {
2065
2066
chain_hash : Readable :: read ( r) ?,
2066
2067
short_channel_id : Readable :: read ( r) ?,
@@ -2084,16 +2085,16 @@ impl_writeable!(ChannelUpdate, {
2084
2085
contents
2085
2086
} ) ;
2086
2087
2087
- impl < W : :: std :: io :: Write > Writeable < W > for ErrorMessage {
2088
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
2088
+ impl < W : Writer > Writeable < W > for ErrorMessage {
2089
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
2089
2090
self . channel_id . write ( w) ?;
2090
2091
self . data . as_bytes ( ) . to_vec ( ) . write ( w) ?; // write with size prefix
2091
2092
Ok ( ( ) )
2092
2093
}
2093
2094
}
2094
2095
2095
- impl < R : :: std :: io :: Read > Readable < R > for ErrorMessage {
2096
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
2096
+ impl < R : Read > Readable < R > for ErrorMessage {
2097
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
2097
2098
Ok ( Self {
2098
2099
channel_id : Readable :: read ( r) ?,
2099
2100
data : {
@@ -2110,8 +2111,8 @@ impl<R: ::std::io::Read> Readable<R> for ErrorMessage {
2110
2111
}
2111
2112
}
2112
2113
2113
- impl < W : :: std :: io :: Write > Writeable < W > for UnsignedNodeAnnouncement {
2114
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
2114
+ impl < W : Writer > Writeable < W > for UnsignedNodeAnnouncement {
2115
+ fn write ( & self , w : & mut W ) -> Result < ( ) , DecodeError > {
2115
2116
self . features . write ( w) ?;
2116
2117
self . timestamp . write ( w) ?;
2117
2118
self . node_id . write ( w) ?;
@@ -2156,8 +2157,8 @@ impl<W: ::std::io::Write> Writeable<W> for UnsignedNodeAnnouncement {
2156
2157
}
2157
2158
}
2158
2159
2159
- impl < R : :: std :: io :: Read > Readable < R > for UnsignedNodeAnnouncement {
2160
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
2160
+ impl < R : Read > Readable < R > for UnsignedNodeAnnouncement {
2161
+ fn read ( r : & mut R ) -> Result < Self , DecodeError > {
2161
2162
let features: GlobalFeatures = Readable :: read ( r) ?;
2162
2163
if features. requires_unknown_bits ( ) {
2163
2164
return Err ( DecodeError :: UnknownRequiredFeature ) ;
0 commit comments