@@ -2419,10 +2419,9 @@ impl FundingScope {
2419
2419
their_funding_contribution.to_sat(),
2420
2420
);
2421
2421
2422
- let post_value_to_self_msat = AddSigned::checked_add_signed(
2423
- prev_funding.value_to_self_msat,
2424
- our_funding_contribution.to_sat() * 1000,
2425
- );
2422
+ let post_value_to_self_msat = prev_funding
2423
+ .value_to_self_msat
2424
+ .checked_add_signed(our_funding_contribution.to_sat() * 1000);
2426
2425
debug_assert!(post_value_to_self_msat.is_some());
2427
2426
let post_value_to_self_msat = post_value_to_self_msat.unwrap();
2428
2427
@@ -2488,8 +2487,7 @@ impl FundingScope {
2488
2487
pub(super) fn compute_post_splice_value(
2489
2488
&self, our_funding_contribution: i64, their_funding_contribution: i64,
2490
2489
) -> u64 {
2491
- AddSigned::saturating_add_signed(
2492
- self.get_value_satoshis(),
2490
+ self.get_value_satoshis().saturating_add_signed(
2493
2491
our_funding_contribution.saturating_add(their_funding_contribution),
2494
2492
)
2495
2493
}
@@ -2523,30 +2521,6 @@ impl FundingScope {
2523
2521
}
2524
2522
}
2525
2523
2526
- // TODO: Remove once MSRV is at least 1.66
2527
- trait AddSigned {
2528
- fn checked_add_signed(self, rhs: i64) -> Option<u64>;
2529
- fn saturating_add_signed(self, rhs: i64) -> u64;
2530
- }
2531
-
2532
- impl AddSigned for u64 {
2533
- fn checked_add_signed(self, rhs: i64) -> Option<u64> {
2534
- if rhs >= 0 {
2535
- self.checked_add(rhs as u64)
2536
- } else {
2537
- self.checked_sub(rhs.unsigned_abs())
2538
- }
2539
- }
2540
-
2541
- fn saturating_add_signed(self, rhs: i64) -> u64 {
2542
- if rhs >= 0 {
2543
- self.saturating_add(rhs as u64)
2544
- } else {
2545
- self.saturating_sub(rhs.unsigned_abs())
2546
- }
2547
- }
2548
- }
2549
-
2550
2524
/// Info about a pending splice
2551
2525
struct PendingSplice {
2552
2526
funding_negotiation: Option<FundingNegotiation>,
@@ -11629,10 +11603,8 @@ where
11629
11603
11630
11604
if our_funding_contribution != SignedAmount::ZERO {
11631
11605
let post_splice_holder_balance = Amount::from_sat(
11632
- AddSigned::checked_add_signed(
11633
- holder_balance_remaining.to_sat(),
11634
- our_funding_contribution.to_sat(),
11635
- )
11606
+ holder_balance_remaining.to_sat()
11607
+ .checked_add_signed(our_funding_contribution.to_sat())
11636
11608
.ok_or(format!(
11637
11609
"Channel {} cannot be spliced out; our remaining balance {} does not cover our negative funding contribution {}",
11638
11610
self.context.channel_id(),
@@ -11653,10 +11625,8 @@ where
11653
11625
11654
11626
if their_funding_contribution != SignedAmount::ZERO {
11655
11627
let post_splice_counterparty_balance = Amount::from_sat(
11656
- AddSigned::checked_add_signed(
11657
- counterparty_balance_remaining.to_sat(),
11658
- their_funding_contribution.to_sat(),
11659
- )
11628
+ counterparty_balance_remaining.to_sat()
11629
+ .checked_add_signed(their_funding_contribution.to_sat())
11660
11630
.ok_or(format!(
11661
11631
"Channel {} cannot be spliced out; their remaining balance {} does not cover their negative funding contribution {}",
11662
11632
self.context.channel_id(),
0 commit comments