swaps: server_update_pairs: add named constant for MAX_SWAP_AMT
What changed, and why it matters
This commit is a minor code cleanup: it replaces a hard-coded number (10,000,000 satoshis) with a named constant called MAX_SWAP_AMT. The value is exactly the same as before, and the developer's own comment says it is only there to reduce accidental damage and is not enforced by the client. There is no security fix here.
No action required. This is a non-functional refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In electrum/submarine_swaps.py, the literal 10000000 used as a cap in server_update_pairs() is replaced by bitcoin.COIN // 10 (which equals 0.1 BTC = 10,000,000 satoshis). The behavior is unchanged; it is purely a readability/maintainability refactor. The added comment explicitly states the cap is ‘just to minimise accidental damage. not enforced client-side’.
Changed components
electrum/submarine_swaps.pyInspect captured patch +3 / −2
diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py
index 37d8d2a..d5e69fb 100644
--- a/electrum/submarine_swaps.py
+++ b/electrum/submarine_swaps.py
@@ -1196,8 +1196,9 @@ class SwapManager(Logger):
self.percentage = Decimal(self.config.SWAPSERVER_FEE_MILLIONTHS) / 10000 # type: ignore
self._min_amount = MIN_SWAP_AMOUNT_SAT
oc_balance_sat: int = self.wallet.get_spendable_balance_sat()
- max_forward: int = min(int(self.lnworker.num_sats_can_receive()), oc_balance_sat, 10000000)
- max_reverse: int = min(int(self.lnworker.num_sats_can_send()), 10000000)
+ MAX_SWAP_AMT = bitcoin.COIN // 10 # just to minimise accidental damage. not enforced client-side
+ max_forward: int = min(int(self.lnworker.num_sats_can_receive()), oc_balance_sat, MAX_SWAP_AMT)
+ max_reverse: int = min(int(self.lnworker.num_sats_can_send()), MAX_SWAP_AMT)
self._max_forward: int = self._keep_leading_digits(max_forward, 2)
self._max_reverse: int = self._keep_leading_digits(max_reverse, 2)
new_mining_fee = self.get_fee_for_txbatcher()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.