diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py index 8a490ad001e1..1d710a5ec8a9 100644 --- a/electrum/lnchannel.py +++ b/electrum/lnchannel.py @@ -51,7 +51,7 @@ funding_output_script, SENT, RECEIVED, LOCAL, REMOTE, HTLCOwner, make_commitment_outputs, ScriptHtlc, PaymentFailure, calc_fees_for_commitment_tx, RemoteMisbehaving, make_htlc_output_witness_script, ShortChannelID, map_htlcs_to_ctx_output_idxs, LNPeerAddr, - LN_MAX_HTLC_VALUE_MSAT, fee_for_htlc_output, offered_htlc_trim_threshold_sat, + fee_for_htlc_output, offered_htlc_trim_threshold_sat, received_htlc_trim_threshold_sat, make_commitment_output_to_remote_address) from .lnsweep import create_sweeptxs_for_our_ctx, create_sweeptxs_for_their_ctx from .lnsweep import create_sweeptx_for_their_revoked_htlc, SweepInfo @@ -564,7 +564,6 @@ def __init__(self, state: 'StoredDict', *, sweep_address=None, name=None, lnwork self.revocation_store = RevocationStore(state["revocation_store"]) self._can_send_ctx_updates = True # type: bool self._receive_fail_reasons = {} # type: Dict[int, (bytes, OnionRoutingFailure)] - self._ignore_max_htlc_value = False # used in tests self.should_request_force_close = False self.unconfirmed_closing_txid = None # not a state, only for GUI @@ -815,8 +814,6 @@ def _assert_can_add_htlc(self, *, htlc_proposer: HTLCOwner, amount_msat: int, raise PaymentFailure("HTLC value must be positive") if amount_msat < chan_config.htlc_minimum_msat: raise PaymentFailure(f'HTLC value too small: {amount_msat} msat') - if amount_msat > LN_MAX_HTLC_VALUE_MSAT and not self._ignore_max_htlc_value: - raise PaymentFailure(f"HTLC value over protocol maximum: {amount_msat} > {LN_MAX_HTLC_VALUE_MSAT} msat") # check proposer can afford htlc max_can_send_msat = self.available_to_spend(htlc_proposer, strict=strict) diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 9cfda25b3b7f..50c35c2fe300 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -40,7 +40,6 @@ HTLC_OUTPUT_WEIGHT = 172 LN_MAX_FUNDING_SAT = pow(2, 24) - 1 -LN_MAX_HTLC_VALUE_MSAT = pow(2, 32) - 1 # dummy address for fee estimation of funding tx def ln_dummy_address(): diff --git a/electrum/submarine_swaps.py b/electrum/submarine_swaps.py index e5ad617d2b6b..dd7d38327ccb 100644 --- a/electrum/submarine_swaps.py +++ b/electrum/submarine_swaps.py @@ -14,7 +14,7 @@ from .transaction import PartialTxInput, PartialTxOutput, PartialTransaction from .transaction import script_GetOp, match_script_against_template, OPPushDataGeneric, OPPushDataPubkey from .util import log_exceptions -from .lnutil import REDEEM_AFTER_DOUBLE_SPENT_DELAY, ln_dummy_address, LN_MAX_HTLC_VALUE_MSAT +from .lnutil import REDEEM_AFTER_DOUBLE_SPENT_DELAY, ln_dummy_address from .bitcoin import dust_threshold from .logging import Logger from .lnutil import hex_to_bytes @@ -450,7 +450,7 @@ async def get_pairs(self) -> None: self._max_amount = limits['maximal'] def get_max_amount(self): - return min(self._max_amount, LN_MAX_HTLC_VALUE_MSAT // 1000) + return self._max_amount def check_invoice_amount(self, x): return x >= self.min_amount and x <= self._max_amount diff --git a/electrum/tests/test_lnchannel.py b/electrum/tests/test_lnchannel.py index e29c9b88dde6..e4d0e2bf8d6b 100644 --- a/electrum/tests/test_lnchannel.py +++ b/electrum/tests/test_lnchannel.py @@ -193,9 +193,6 @@ def create_test_channels(*, feerate=6000, local_msat=None, remote_msat=None, alice._fallback_sweep_address = bitcoin.pubkey_to_address('p2wpkh', alice.config[LOCAL].payment_basepoint.pubkey.hex()) bob._fallback_sweep_address = bitcoin.pubkey_to_address('p2wpkh', bob.config[LOCAL].payment_basepoint.pubkey.hex()) - alice._ignore_max_htlc_value = True - bob._ignore_max_htlc_value = True - return alice, bob class TestFee(ElectrumTestCase): @@ -683,29 +680,6 @@ def test_DesyncHTLCs(self): self.assertEqual(500000000000, bob_channel.available_to_spend(LOCAL)) alice_channel.add_htlc(htlc_dict) - def test_max_htlc_value(self): - alice_channel, bob_channel = create_test_channels() - paymentPreimage = b"\x01" * 32 - paymentHash = bitcoin.sha256(paymentPreimage) - htlc_dict = { - 'payment_hash' : paymentHash, - 'amount_msat' : one_bitcoin_in_msat * 41 // 10, - 'cltv_expiry' : 5, - 'timestamp' : 0, - } - - alice_channel._ignore_max_htlc_value = False - bob_channel._ignore_max_htlc_value = False - with self.assertRaises(lnutil.PaymentFailure): - alice_channel.add_htlc(htlc_dict) - with self.assertRaises(lnutil.RemoteMisbehaving): - bob_channel.receive_htlc(htlc_dict) - - alice_channel._ignore_max_htlc_value = True - bob_channel._ignore_max_htlc_value = True - alice_channel.add_htlc(htlc_dict) - bob_channel.receive_htlc(htlc_dict) - class TestChanReserve(ElectrumTestCase): def setUp(self):