Skip to content

Commit d96a492

Browse files
Merge pull request #1463 from TheBlueMatt/2022-05-lol-more-underflow
Reject outbound channels if the total reserve is larger than funding
2 parents 132b072 + f2de2f3 commit d96a492

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lightning/src/ln/channel.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,10 @@ impl<Signer: Sign> Channel<Signer> {
19461946
if msg.dust_limit_satoshis > self.holder_selected_channel_reserve_satoshis {
19471947
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.dust_limit_satoshis, self.holder_selected_channel_reserve_satoshis)));
19481948
}
1949+
if msg.channel_reserve_satoshis > self.channel_value_satoshis - self.holder_selected_channel_reserve_satoshis {
1950+
return Err(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must not be greater than channel value minus our reserve ({})",
1951+
msg.channel_reserve_satoshis, self.channel_value_satoshis - self.holder_selected_channel_reserve_satoshis)));
1952+
}
19491953
let full_channel_value_msat = (self.channel_value_satoshis - msg.channel_reserve_satoshis) * 1000;
19501954
if msg.htlc_minimum_msat >= full_channel_value_msat {
19511955
return Err(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));

0 commit comments

Comments
 (0)