@@ -1053,7 +1053,7 @@ impl Readable for OptionalField<u64> {
1053
1053
}
1054
1054
1055
1055
1056
- impl_writeable ! ( AcceptChannel , {
1056
+ impl_writeable_msg ! ( AcceptChannel , {
1057
1057
temporary_channel_id,
1058
1058
dust_limit_satoshis,
1059
1059
max_htlc_value_in_flight_msat,
@@ -1069,14 +1069,14 @@ impl_writeable!(AcceptChannel, {
1069
1069
htlc_basepoint,
1070
1070
first_per_commitment_point,
1071
1071
shutdown_scriptpubkey
1072
- } ) ;
1072
+ } , { } ) ;
1073
1073
1074
- impl_writeable ! ( AnnouncementSignatures , {
1074
+ impl_writeable_msg ! ( AnnouncementSignatures , {
1075
1075
channel_id,
1076
1076
short_channel_id,
1077
1077
node_signature,
1078
1078
bitcoin_signature
1079
- } ) ;
1079
+ } , { } ) ;
1080
1080
1081
1081
impl Writeable for ChannelReestablish {
1082
1082
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -1115,64 +1115,44 @@ impl Readable for ChannelReestablish{
1115
1115
}
1116
1116
}
1117
1117
1118
- impl Writeable for ClosingSigned {
1119
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1120
- self . channel_id . write ( w) ?;
1121
- self . fee_satoshis . write ( w) ?;
1122
- self . signature . write ( w) ?;
1123
- encode_tlv_stream ! ( w, {
1124
- ( 1 , self . fee_range, option) ,
1125
- } ) ;
1126
- Ok ( ( ) )
1127
- }
1128
- }
1129
-
1130
- impl Readable for ClosingSigned {
1131
- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1132
- let channel_id = Readable :: read ( r) ?;
1133
- let fee_satoshis = Readable :: read ( r) ?;
1134
- let signature = Readable :: read ( r) ?;
1135
- let mut fee_range = None ;
1136
- decode_tlv_stream ! ( r, {
1137
- ( 1 , fee_range, option) ,
1138
- } ) ;
1139
- Ok ( Self { channel_id, fee_satoshis, signature, fee_range } )
1140
- }
1141
- }
1118
+ impl_writeable_msg ! ( ClosingSigned ,
1119
+ { channel_id, fee_satoshis, signature } ,
1120
+ { ( 1 , fee_range, option) }
1121
+ ) ;
1142
1122
1143
1123
impl_writeable ! ( ClosingSignedFeeRange , {
1144
1124
min_fee_satoshis,
1145
1125
max_fee_satoshis
1146
1126
} ) ;
1147
1127
1148
- impl_writeable ! ( CommitmentSigned , {
1128
+ impl_writeable_msg ! ( CommitmentSigned , {
1149
1129
channel_id,
1150
1130
signature,
1151
1131
htlc_signatures
1152
- } ) ;
1132
+ } , { } ) ;
1153
1133
1154
1134
impl_writeable ! ( DecodedOnionErrorPacket , {
1155
1135
hmac,
1156
1136
failuremsg,
1157
1137
pad
1158
1138
} ) ;
1159
1139
1160
- impl_writeable ! ( FundingCreated , {
1140
+ impl_writeable_msg ! ( FundingCreated , {
1161
1141
temporary_channel_id,
1162
1142
funding_txid,
1163
1143
funding_output_index,
1164
1144
signature
1165
- } ) ;
1145
+ } , { } ) ;
1166
1146
1167
- impl_writeable ! ( FundingSigned , {
1147
+ impl_writeable_msg ! ( FundingSigned , {
1168
1148
channel_id,
1169
1149
signature
1170
- } ) ;
1150
+ } , { } ) ;
1171
1151
1172
- impl_writeable ! ( FundingLocked , {
1152
+ impl_writeable_msg ! ( FundingLocked , {
1173
1153
channel_id,
1174
- next_per_commitment_point
1175
- } ) ;
1154
+ next_per_commitment_point,
1155
+ } , { } ) ;
1176
1156
1177
1157
impl Writeable for Init {
1178
1158
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -1193,7 +1173,7 @@ impl Readable for Init {
1193
1173
}
1194
1174
}
1195
1175
1196
- impl_writeable ! ( OpenChannel , {
1176
+ impl_writeable_msg ! ( OpenChannel , {
1197
1177
chain_hash,
1198
1178
temporary_channel_id,
1199
1179
funding_satoshis,
@@ -1213,47 +1193,53 @@ impl_writeable!(OpenChannel, {
1213
1193
first_per_commitment_point,
1214
1194
channel_flags,
1215
1195
shutdown_scriptpubkey
1216
- } ) ;
1196
+ } , { } ) ;
1217
1197
1218
- impl_writeable ! ( RevokeAndACK , {
1198
+ impl_writeable_msg ! ( RevokeAndACK , {
1219
1199
channel_id,
1220
1200
per_commitment_secret,
1221
1201
next_per_commitment_point
1222
- } ) ;
1202
+ } , { } ) ;
1223
1203
1224
- impl_writeable ! ( Shutdown , {
1204
+ impl_writeable_msg ! ( Shutdown , {
1225
1205
channel_id,
1226
1206
scriptpubkey
1227
- } ) ;
1207
+ } , { } ) ;
1228
1208
1229
- impl_writeable ! ( UpdateFailHTLC , {
1209
+ impl_writeable_msg ! ( UpdateFailHTLC , {
1230
1210
channel_id,
1231
1211
htlc_id,
1232
1212
reason
1233
- } ) ;
1213
+ } , { } ) ;
1234
1214
1235
- impl_writeable ! ( UpdateFailMalformedHTLC , {
1215
+ impl_writeable_msg ! ( UpdateFailMalformedHTLC , {
1236
1216
channel_id,
1237
1217
htlc_id,
1238
1218
sha256_of_onion,
1239
1219
failure_code
1240
- } ) ;
1220
+ } , { } ) ;
1241
1221
1242
- impl_writeable ! ( UpdateFee , {
1222
+ impl_writeable_msg ! ( UpdateFee , {
1243
1223
channel_id,
1244
1224
feerate_per_kw
1245
- } ) ;
1225
+ } , { } ) ;
1246
1226
1247
- impl_writeable ! ( UpdateFulfillHTLC , {
1227
+ impl_writeable_msg ! ( UpdateFulfillHTLC , {
1248
1228
channel_id,
1249
1229
htlc_id,
1250
1230
payment_preimage
1251
- } ) ;
1231
+ } , { } ) ;
1252
1232
1233
+ // Note that this is written as a part of ChannelManager objects, and thus cannot change its
1234
+ // serialization format in a way which assumes we know the total serialized length/message end
1235
+ // position.
1253
1236
impl_writeable ! ( OnionErrorPacket , {
1254
1237
data
1255
1238
} ) ;
1256
1239
1240
+ // Note that this is written as a part of ChannelManager objects, and thus cannot change its
1241
+ // serialization format in a way which assumes we know the total serialized length/message end
1242
+ // position.
1257
1243
impl Writeable for OnionPacket {
1258
1244
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1259
1245
self . version . write ( w) ?;
@@ -1282,14 +1268,14 @@ impl Readable for OnionPacket {
1282
1268
}
1283
1269
}
1284
1270
1285
- impl_writeable ! ( UpdateAddHTLC , {
1271
+ impl_writeable_msg ! ( UpdateAddHTLC , {
1286
1272
channel_id,
1287
1273
htlc_id,
1288
1274
amount_msat,
1289
1275
payment_hash,
1290
1276
cltv_expiry,
1291
1277
onion_routing_packet
1292
- } ) ;
1278
+ } , { } ) ;
1293
1279
1294
1280
impl Writeable for FinalOnionHopData {
1295
1281
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -1700,24 +1686,10 @@ impl Writeable for QueryShortChannelIds {
1700
1686
}
1701
1687
}
1702
1688
1703
- impl Readable for ReplyShortChannelIdsEnd {
1704
- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1705
- let chain_hash: BlockHash = Readable :: read ( r) ?;
1706
- let full_information: bool = Readable :: read ( r) ?;
1707
- Ok ( ReplyShortChannelIdsEnd {
1708
- chain_hash,
1709
- full_information,
1710
- } )
1711
- }
1712
- }
1713
-
1714
- impl Writeable for ReplyShortChannelIdsEnd {
1715
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1716
- self . chain_hash . write ( w) ?;
1717
- self . full_information . write ( w) ?;
1718
- Ok ( ( ) )
1719
- }
1720
- }
1689
+ impl_writeable_msg ! ( ReplyShortChannelIdsEnd , {
1690
+ chain_hash,
1691
+ full_information,
1692
+ } , { } ) ;
1721
1693
1722
1694
impl QueryChannelRange {
1723
1695
/**
@@ -1732,27 +1704,11 @@ impl QueryChannelRange {
1732
1704
}
1733
1705
}
1734
1706
1735
- impl Readable for QueryChannelRange {
1736
- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1737
- let chain_hash: BlockHash = Readable :: read ( r) ?;
1738
- let first_blocknum: u32 = Readable :: read ( r) ?;
1739
- let number_of_blocks: u32 = Readable :: read ( r) ?;
1740
- Ok ( QueryChannelRange {
1741
- chain_hash,
1742
- first_blocknum,
1743
- number_of_blocks
1744
- } )
1745
- }
1746
- }
1747
-
1748
- impl Writeable for QueryChannelRange {
1749
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1750
- self . chain_hash . write ( w) ?;
1751
- self . first_blocknum . write ( w) ?;
1752
- self . number_of_blocks . write ( w) ?;
1753
- Ok ( ( ) )
1754
- }
1755
- }
1707
+ impl_writeable_msg ! ( QueryChannelRange , {
1708
+ chain_hash,
1709
+ first_blocknum,
1710
+ number_of_blocks
1711
+ } , { } ) ;
1756
1712
1757
1713
impl Readable for ReplyChannelRange {
1758
1714
fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
@@ -1812,28 +1768,11 @@ impl Writeable for ReplyChannelRange {
1812
1768
}
1813
1769
}
1814
1770
1815
- impl Readable for GossipTimestampFilter {
1816
- fn read < R : Read > ( r : & mut R ) -> Result < Self , DecodeError > {
1817
- let chain_hash: BlockHash = Readable :: read ( r) ?;
1818
- let first_timestamp: u32 = Readable :: read ( r) ?;
1819
- let timestamp_range: u32 = Readable :: read ( r) ?;
1820
- Ok ( GossipTimestampFilter {
1821
- chain_hash,
1822
- first_timestamp,
1823
- timestamp_range,
1824
- } )
1825
- }
1826
- }
1827
-
1828
- impl Writeable for GossipTimestampFilter {
1829
- fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
1830
- self . chain_hash . write ( w) ?;
1831
- self . first_timestamp . write ( w) ?;
1832
- self . timestamp_range . write ( w) ?;
1833
- Ok ( ( ) )
1834
- }
1835
- }
1836
-
1771
+ impl_writeable_msg ! ( GossipTimestampFilter , {
1772
+ chain_hash,
1773
+ first_timestamp,
1774
+ timestamp_range,
1775
+ } , { } ) ;
1837
1776
1838
1777
#[ cfg( test) ]
1839
1778
mod tests {
0 commit comments