Skip to content

Commit 7fcfb39

Browse files
authored
Merge pull request lightningdevkit#4383 from jkczyz/2026-02-unsigned-abs
Use `SignedAmount::unsigned_abs` to avoid overflow
2 parents f43803d + 2d948fd commit 7fcfb39

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,8 +2664,8 @@ impl FundingScope {
26642664
their_funding_contribution: SignedAmount, counterparty_funding_pubkey: PublicKey,
26652665
our_new_holder_keys: ChannelPublicKeys,
26662666
) -> Self {
2667-
debug_assert!(our_funding_contribution.abs() <= SignedAmount::MAX_MONEY);
2668-
debug_assert!(their_funding_contribution.abs() <= SignedAmount::MAX_MONEY);
2667+
debug_assert!(our_funding_contribution.unsigned_abs() <= Amount::MAX_MONEY);
2668+
debug_assert!(their_funding_contribution.unsigned_abs() <= Amount::MAX_MONEY);
26692669

26702670
let post_channel_value = prev_funding.compute_post_splice_value(
26712671
our_funding_contribution.to_sat(),
@@ -12155,15 +12155,15 @@ where
1215512155
fn validate_splice_contributions(
1215612156
&self, our_funding_contribution: SignedAmount, their_funding_contribution: SignedAmount,
1215712157
) -> Result<(), String> {
12158-
if our_funding_contribution.abs() > SignedAmount::MAX_MONEY {
12158+
if our_funding_contribution.unsigned_abs() > Amount::MAX_MONEY {
1215912159
return Err(format!(
1216012160
"Channel {} cannot be spliced; our {} contribution exceeds the total bitcoin supply",
1216112161
self.context.channel_id(),
1216212162
our_funding_contribution,
1216312163
));
1216412164
}
1216512165

12166-
if their_funding_contribution.abs() > SignedAmount::MAX_MONEY {
12166+
if their_funding_contribution.unsigned_abs() > Amount::MAX_MONEY {
1216712167
return Err(format!(
1216812168
"Channel {} cannot be spliced; their {} contribution exceeds the total bitcoin supply",
1216912169
self.context.channel_id(),

0 commit comments

Comments
 (0)