@@ -1222,48 +1222,43 @@ impl Channel {
1222
1222
1223
1223
// Message handlers:
1224
1224
1225
- pub fn accept_channel ( & mut self , msg : & msgs:: AcceptChannel ) -> Result < ( ) , HandleError > {
1226
- macro_rules! return_error_message {
1227
- ( $msg: expr ) => {
1228
- return Err ( HandleError { err: $msg, action: Some ( msgs:: ErrorAction :: SendErrorMessage { msg: msgs:: ErrorMessage { channel_id: msg. temporary_channel_id, data: $msg. to_string( ) } } ) } ) ;
1229
- }
1230
- }
1225
+ pub fn accept_channel ( & mut self , msg : & msgs:: AcceptChannel ) -> Result < ( ) , ChannelError > {
1231
1226
// Check sanity of message fields:
1232
1227
if !self . channel_outbound {
1233
- return_error_message ! ( "Got an accept_channel message from an inbound peer" ) ;
1228
+ return Err ( ChannelError :: Close ( "Got an accept_channel message from an inbound peer" ) ) ;
1234
1229
}
1235
1230
if self . channel_state != ChannelState :: OurInitSent as u32 {
1236
- return_error_message ! ( "Got an accept_channel message at a strange time" ) ;
1231
+ return Err ( ChannelError :: Close ( "Got an accept_channel message at a strange time" ) ) ;
1237
1232
}
1238
1233
if msg. dust_limit_satoshis > 21000000 * 100000000 {
1239
- return_error_message ! ( "Peer never wants payout outputs?" ) ;
1234
+ return Err ( ChannelError :: Close ( "Peer never wants payout outputs?" ) ) ;
1240
1235
}
1241
1236
if msg. channel_reserve_satoshis > self . channel_value_satoshis {
1242
- return_error_message ! ( "Bogus channel_reserve_satoshis" ) ;
1237
+ return Err ( ChannelError :: Close ( "Bogus channel_reserve_satoshis" ) ) ;
1243
1238
}
1244
1239
if msg. dust_limit_satoshis > msg. channel_reserve_satoshis {
1245
- return_error_message ! ( "Bogus channel_reserve and dust_limit" ) ;
1240
+ return Err ( ChannelError :: Close ( "Bogus channel_reserve and dust_limit" ) ) ;
1246
1241
}
1247
1242
if msg. channel_reserve_satoshis < self . our_dust_limit_satoshis {
1248
- return_error_message ! ( "Peer never wants payout outputs?" ) ;
1243
+ return Err ( ChannelError :: Close ( "Peer never wants payout outputs?" ) ) ;
1249
1244
}
1250
1245
if msg. dust_limit_satoshis > Channel :: get_our_channel_reserve_satoshis ( self . channel_value_satoshis ) {
1251
- return_error_message ! ( "Dust limit is bigger than our channel reverse" ) ;
1246
+ return Err ( ChannelError :: Close ( "Dust limit is bigger than our channel reverse" ) ) ;
1252
1247
}
1253
1248
if msg. htlc_minimum_msat >= ( self . channel_value_satoshis - msg. channel_reserve_satoshis ) * 1000 {
1254
- return_error_message ! ( "Minimum htlc value is full channel value" ) ;
1249
+ return Err ( ChannelError :: Close ( "Minimum htlc value is full channel value" ) ) ;
1255
1250
}
1256
1251
if msg. minimum_depth > Channel :: derive_maximum_minimum_depth ( self . channel_value_satoshis * 1000 , self . value_to_self_msat ) {
1257
- return_error_message ! ( "minimum_depth too large" ) ;
1252
+ return Err ( ChannelError :: Close ( "minimum_depth too large" ) ) ;
1258
1253
}
1259
1254
if msg. to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
1260
- return_error_message ! ( "They wanted our payments to be delayed by a needlessly long period" ) ;
1255
+ return Err ( ChannelError :: Close ( "They wanted our payments to be delayed by a needlessly long period" ) ) ;
1261
1256
}
1262
1257
if msg. max_accepted_htlcs < 1 {
1263
- return_error_message ! ( "0 max_accpted_htlcs makes for a useless channel" ) ;
1258
+ return Err ( ChannelError :: Close ( "0 max_accpted_htlcs makes for a useless channel" ) ) ;
1264
1259
}
1265
1260
if msg. max_accepted_htlcs > 483 {
1266
- return_error_message ! ( "max_accpted_htlcs > 483" ) ;
1261
+ return Err ( ChannelError :: Close ( "max_accpted_htlcs > 483" ) ) ;
1267
1262
}
1268
1263
1269
1264
// TODO: Optional additional constraints mentioned in the spec
0 commit comments