Skip to content

Commit e9b1af2

Browse files
committed
Check validity of dust_limit_satoshis in remote messages
1 parent 1bb4f44 commit e9b1af2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ln/channel.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ impl Channel {
366366
if msg.push_msat > (msg.funding_satoshis - msg.channel_reserve_satoshis) * 1000 {
367367
return Err(HandleError{err: "push_msat more than highest possible value", msg: None});
368368
}
369-
//TODO Check if dust_limit is sane?
369+
if msg.dust_limit_satoshis > 21000000 * 100000000 {
370+
return Err(HandleError{err: "Peer never wants payout outputs?", msg: None});
371+
}
370372
if msg.max_htlc_value_in_flight_msat > msg.funding_satoshis * 1000 {
371373
return Err(HandleError{err: "Bogus max_htlc_value_in_flight_satoshis", msg: None});
372374
}
@@ -826,13 +828,15 @@ impl Channel {
826828

827829
pub fn accept_channel(&mut self, msg: &msgs::AcceptChannel) -> Result<(), HandleError> {
828830
// Check sanity of message fields:
829-
//TODO Check if dust_limit is sane?
830831
if !self.channel_outbound {
831832
return Err(HandleError{err: "Got an accept_channel message from an inbound peer", msg: None});
832833
}
833834
if self.channel_state != ChannelState::OurInitSent as u32 {
834835
return Err(HandleError{err: "Got an accept_channel message at a strange time", msg: None});
835836
}
837+
if msg.dust_limit_satoshis > 21000000 * 100000000 {
838+
return Err(HandleError{err: "Peer never wants payout outputs?", msg: None});
839+
}
836840
if msg.max_htlc_value_in_flight_msat > self.channel_value_satoshis * 1000 {
837841
return Err(HandleError{err: "Bogus max_htlc_value_in_flight_satoshis", msg: None});
838842
}

0 commit comments

Comments
 (0)