lnchannel: rm HTLC value upper limit of ~42 mBTC
closes #7328 closes #7100 see https://github.com/lightningnetwork/lightning-rfc/pull/877#issuecomment-857577075
This commit is contained in:
@@ -51,7 +51,7 @@ from .lnutil import (Outpoint, LocalConfig, RemoteConfig, Keypair, OnlyPubkeyKey
|
||||
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 @@ class Channel(AbstractChannel):
|
||||
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 @@ class Channel(AbstractChannel):
|
||||
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)
|
||||
|
||||
@@ -40,7 +40,6 @@ COMMITMENT_TX_WEIGHT = 724
|
||||
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():
|
||||
|
||||
@@ -14,7 +14,7 @@ from .bitcoin import (script_to_p2wsh, opcodes, p2wsh_nested_script, push_script
|
||||
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 @@ class SwapManager(Logger):
|
||||
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
|
||||
|
||||
@@ -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 @@ class TestAvailableToSpend(ElectrumTestCase):
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user