@@ -1719,6 +1719,86 @@ impl_writeable!(AcceptChannel, {
1719
1719
shutdown_scriptpubkey
1720
1720
} ) ;
1721
1721
1722
+ impl_writeable ! ( AnnouncementSignatures , {
1723
+ channel_id,
1724
+ short_channel_id,
1725
+ node_signature,
1726
+ bitcoin_signature
1727
+ } ) ;
1728
+
1729
+ impl < W : :: std:: io:: Write > Writeable < W > for ChannelReestablish {
1730
+ fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1731
+ self . channel_id . write ( w) ?;
1732
+ self . next_local_commitment_number . write ( w) ?;
1733
+ self . next_remote_commitment_number . write ( w) ?;
1734
+ if let Some ( ref data_loss_protect) = self . data_loss_protect {
1735
+ data_loss_protect. your_last_per_commitment_secret . write ( w) ?;
1736
+ data_loss_protect. my_current_per_commitment_point . write ( w) ?;
1737
+ }
1738
+ Ok ( ( ) )
1739
+ }
1740
+ }
1741
+
1742
+ impl < R : :: std:: io:: Read > Readable < R > for ChannelReestablish {
1743
+ fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1744
+ Ok ( Self {
1745
+ channel_id : Readable :: read ( r) ?,
1746
+ next_local_commitment_number : Readable :: read ( r) ?,
1747
+ next_remote_commitment_number : Readable :: read ( r) ?,
1748
+ data_loss_protect : {
1749
+ let mut buf = [ 0 ; 32 +33 ] ;
1750
+ match r. read_exact ( & mut buf) {
1751
+ Ok ( ( ) ) => Some ( DataLossProtect {
1752
+ your_last_per_commitment_secret : {
1753
+ let mut a: [ u8 ; 32 ] = Default :: default ( ) ;
1754
+ a. copy_from_slice ( & buf[ ..32 ] ) ;
1755
+ a
1756
+ } ,
1757
+ my_current_per_commitment_point : secp_pubkey ! ( & Secp256k1 :: without_caps( ) , & buf[ 32 ..] ) ,
1758
+ } ) ,
1759
+ Err ( DecodeError :: ShortRead ) => None ,
1760
+ Err ( e) => return Err ( e)
1761
+ }
1762
+ }
1763
+ } )
1764
+ }
1765
+ }
1766
+
1767
+ impl_writeable ! ( ClosingSigned , {
1768
+ channel_id,
1769
+ fee_satoshis,
1770
+ signature
1771
+ } ) ;
1772
+
1773
+ impl_writeable ! ( CommitmentSigned , {
1774
+ channel_id,
1775
+ signature,
1776
+ htlc_signatures
1777
+ } ) ;
1778
+
1779
+ impl_writeable ! ( DecodedOnionErrorPacket , {
1780
+ hmac,
1781
+ failuremsg,
1782
+ pad
1783
+ } ) ;
1784
+
1785
+ impl_writeable ! ( FundingCreated , {
1786
+ temporary_channel_id,
1787
+ funding_txid,
1788
+ funding_output_index,
1789
+ signature
1790
+ } ) ;
1791
+
1792
+ impl_writeable ! ( FundingSigned , {
1793
+ channel_id,
1794
+ signature
1795
+ } ) ;
1796
+
1797
+ impl_writeable ! ( FundingLocked , {
1798
+ channel_id,
1799
+ next_per_commitment_point
1800
+ } ) ;
1801
+
1722
1802
impl_writeable ! ( OpenChannel , {
1723
1803
chain_hash,
1724
1804
temporary_channel_id,
@@ -1741,20 +1821,9 @@ impl_writeable!(OpenChannel, {
1741
1821
shutdown_scriptpubkey
1742
1822
} ) ;
1743
1823
1744
- impl_writeable ! ( FundingCreated , {
1745
- temporary_channel_id,
1746
- funding_txid,
1747
- funding_output_index,
1748
- signature
1749
- } ) ;
1750
-
1751
- impl_writeable ! ( FundingSigned , {
1752
- channel_id,
1753
- signature
1754
- } ) ;
1755
-
1756
- impl_writeable ! ( FundingLocked , {
1824
+ impl_writeable ! ( RevokeAndACK , {
1757
1825
channel_id,
1826
+ per_commitment_secret,
1758
1827
next_per_commitment_point
1759
1828
} ) ;
1760
1829
@@ -1763,16 +1832,10 @@ impl_writeable!(Shutdown, {
1763
1832
scriptpubkey
1764
1833
} ) ;
1765
1834
1766
- impl_writeable ! ( ClosingSigned , {
1767
- channel_id,
1768
- fee_satoshis,
1769
- signature
1770
- } ) ;
1771
-
1772
- impl_writeable ! ( UpdateFulfillHTLC , {
1835
+ impl_writeable ! ( UpdateFailHTLC , {
1773
1836
channel_id,
1774
1837
htlc_id,
1775
- payment_preimage
1838
+ reason
1776
1839
} ) ;
1777
1840
1778
1841
impl_writeable ! ( UpdateFailMalformedHTLC , {
@@ -1782,40 +1845,21 @@ impl_writeable!(UpdateFailMalformedHTLC, {
1782
1845
failure_code
1783
1846
} ) ;
1784
1847
1785
- impl_writeable ! ( CommitmentSigned , {
1786
- channel_id,
1787
- signature,
1788
- htlc_signatures
1789
- } ) ;
1790
-
1791
- impl_writeable ! ( RevokeAndACK , {
1792
- channel_id,
1793
- per_commitment_secret,
1794
- next_per_commitment_point
1795
- } ) ;
1796
-
1797
1848
impl_writeable ! ( UpdateFee , {
1798
1849
channel_id,
1799
1850
feerate_per_kw
1800
1851
} ) ;
1801
1852
1802
- impl_writeable ! ( AnnouncementSignatures , {
1853
+ impl_writeable ! ( UpdateFulfillHTLC , {
1803
1854
channel_id,
1804
- short_channel_id,
1805
- node_signature,
1806
- bitcoin_signature
1855
+ htlc_id,
1856
+ payment_preimage
1807
1857
} ) ;
1808
1858
1809
1859
impl_writeable ! ( OnionErrorPacket , {
1810
1860
data
1811
1861
} ) ;
1812
1862
1813
- impl_writeable ! ( UpdateFailHTLC , {
1814
- channel_id,
1815
- htlc_id,
1816
- reason
1817
- } ) ;
1818
-
1819
1863
impl < W : :: std:: io:: Write > Writeable < W > for OnionPacket {
1820
1864
fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1821
1865
self . version . write ( w) ?;
@@ -1897,43 +1941,6 @@ impl<R: ::std::io::Read> Readable<R> for Pong {
1897
1941
}
1898
1942
}
1899
1943
1900
- impl < W : :: std:: io:: Write > Writeable < W > for ChannelReestablish {
1901
- fn write ( & self , w : & mut Writer < W > ) -> Result < ( ) , DecodeError > {
1902
- self . channel_id . write ( w) ?;
1903
- self . next_local_commitment_number . write ( w) ?;
1904
- self . next_remote_commitment_number . write ( w) ?;
1905
- if let Some ( ref data_loss_protect) = self . data_loss_protect {
1906
- data_loss_protect. your_last_per_commitment_secret . write ( w) ?;
1907
- data_loss_protect. my_current_per_commitment_point . write ( w) ?;
1908
- }
1909
- Ok ( ( ) )
1910
- }
1911
- }
1912
-
1913
- impl < R : :: std:: io:: Read > Readable < R > for ChannelReestablish {
1914
- fn read ( r : & mut Reader < R > ) -> Result < Self , DecodeError > {
1915
- Ok ( Self {
1916
- channel_id : Readable :: read ( r) ?,
1917
- next_local_commitment_number : Readable :: read ( r) ?,
1918
- next_remote_commitment_number : Readable :: read ( r) ?,
1919
- data_loss_protect : {
1920
- let mut buf = [ 0 ; 32 +33 ] ;
1921
- match r. read_exact ( & mut buf) {
1922
- Ok ( ( ) ) => Some ( DataLossProtect {
1923
- your_last_per_commitment_secret : {
1924
- let mut a: [ u8 ; 32 ] = Default :: default ( ) ;
1925
- a. copy_from_slice ( & buf[ ..32 ] ) ;
1926
- a
1927
- } ,
1928
- my_current_per_commitment_point : secp_pubkey ! ( & Secp256k1 :: without_caps( ) , & buf[ 32 ..] ) ,
1929
- } ) ,
1930
- Err ( DecodeError :: ShortRead ) => None ,
1931
- Err ( e) => return Err ( e)
1932
- }
1933
- }
1934
- } )
1935
- }
1936
- }
1937
1944
1938
1945
#[ cfg( test) ]
1939
1946
mod tests {
0 commit comments