diff --git a/electrum/commands.py b/electrum/commands.py index 2efa0b648..08c942785 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -49,7 +49,7 @@ from .address_synchronizer import TX_HEIGHT_LOCAL from .import lightning from .mnemonic import Mnemonic from .lnutil import SENT, RECEIVED -from .lnbase import channel_id_from_funding_tx +from .lnpeer import channel_id_from_funding_tx if TYPE_CHECKING: from .network import Network diff --git a/electrum/gui/qt/channel_details.py b/electrum/gui/qt/channel_details.py index 8691f1ef8..bdbd52932 100644 --- a/electrum/gui/qt/channel_details.py +++ b/electrum/gui/qt/channel_details.py @@ -7,7 +7,7 @@ import PyQt5.QtCore as QtCore from electrum.i18n import _ from electrum.util import bh2u, format_time from electrum.lnutil import format_short_channel_id, LOCAL, REMOTE, UpdateAddHtlc, Direction -from electrum.lnchan import htlcsum +from electrum.lnchannel import htlcsum from electrum.lnaddr import LnAddr, lndecode from electrum.bitcoin import COIN diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py index 45eee6e8c..a546689f8 100644 --- a/electrum/gui/qt/channels_list.py +++ b/electrum/gui/qt/channels_list.py @@ -6,7 +6,7 @@ from PyQt5.QtWidgets import * from electrum.util import inv_dict, bh2u, bfh from electrum.i18n import _ -from electrum.lnchan import Channel +from electrum.lnchannel import Channel from electrum.lnutil import LOCAL, REMOTE, ConnStringFormatError from .util import MyTreeView, WindowModalDialog, Buttons, OkButton, CancelButton, EnterButton, WWLabel diff --git a/electrum/lnchan.py b/electrum/lnchannel.py similarity index 99% rename from electrum/lnchan.py rename to electrum/lnchannel.py index c8a53fa04..810b937b8 100644 --- a/electrum/lnchan.py +++ b/electrum/lnchannel.py @@ -115,7 +115,7 @@ class Channel(PrintError): if self.name: return str(self.name) try: - return f"lnchan_{bh2u(self.channel_id[-4:])}" + return f"lnchannel_{bh2u(self.channel_id[-4:])}" except: return super().diagnostic_name() diff --git a/electrum/lnbase.py b/electrum/lnpeer.py similarity index 99% rename from electrum/lnbase.py rename to electrum/lnpeer.py index abb065286..c9e9e1d61 100644 --- a/electrum/lnbase.py +++ b/electrum/lnpeer.py @@ -26,7 +26,7 @@ from .util import PrintError, bh2u, print_error, bfh, log_exceptions, list_enabl from .transaction import Transaction, TxOutput from .lnonion import (new_onion_packet, decode_onion_error, OnionFailureCode, calc_hops_data_for_payment, process_onion_packet, OnionPacket, construct_onion_error, OnionRoutingFailureMessage) -from .lnchan import Channel, RevokeAndAck, htlcsum +from .lnchannel import Channel, RevokeAndAck, htlcsum from .lnutil import (Outpoint, LocalConfig, RECEIVED, UpdateAddHtlc, RemoteConfig, OnlyPubkeyKeypair, ChannelConstraints, RevocationStore, funding_output_script, get_per_commitment_secret_from_seed, diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py index ba4b709c1..485d3fb64 100644 --- a/electrum/lnrouter.py +++ b/electrum/lnrouter.py @@ -36,14 +36,14 @@ import asyncio from . import constants from .util import PrintError, bh2u, profiler, get_headers_dir, bfh, is_ip_address, list_enabled_bits from .storage import JsonDB -from .lnchannelverifier import LNChannelVerifier, verify_sig_for_channel_update +from .lnverifier import LNChannelVerifier, verify_sig_for_channel_update from .crypto import sha256d from . import ecc from .lnutil import (LN_GLOBAL_FEATURES_KNOWN_SET, LNPeerAddr, NUM_MAX_EDGES_IN_PAYMENT_PATH, NotFoundChanAnnouncementForUpdate) if TYPE_CHECKING: - from .lnchan import Channel + from .lnchannel import Channel from .network import Network diff --git a/electrum/lnsweep.py b/electrum/lnsweep.py index d70ca6b02..12abcc366 100644 --- a/electrum/lnsweep.py +++ b/electrum/lnsweep.py @@ -17,7 +17,7 @@ from .transaction import Transaction, TxOutput, construct_witness from .simple_config import SimpleConfig, FEERATE_FALLBACK_STATIC_FEE if TYPE_CHECKING: - from .lnchan import Channel + from .lnchannel import Channel def maybe_create_sweeptx_for_their_ctx_to_remote(ctx: Transaction, sweep_address: str, @@ -203,7 +203,7 @@ def create_sweeptxs_for_their_latest_ctx(chan: 'Channel', ctx: Transaction, Regardless of it is a breach or not, construct sweep tx for 'to_remote'. If it is a breach, also construct sweep tx for 'to_local'. Sweep txns for HTLCs are only constructed if it is NOT a breach, as - lnchan does not store old HTLCs. + lnchannel does not store old HTLCs. """ this_conf, other_conf = get_ordered_channel_configs(chan=chan, for_us=False) ctn = extract_ctn_from_tx_and_chan(ctx, chan) diff --git a/electrum/lnutil.py b/electrum/lnutil.py index 596e5d700..5dec78e46 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -21,7 +21,7 @@ from .lnaddr import lndecode from .keystore import BIP32_KeyStore if TYPE_CHECKING: - from .lnchan import Channel + from .lnchannel import Channel HTLC_TIMEOUT_WEIGHT = 663 @@ -114,7 +114,7 @@ MAXIMUM_HTLC_MINIMUM_MSAT_ACCEPTED = 1000 MAXIMUM_REMOTE_TO_SELF_DELAY_ACCEPTED = 2016 class RevocationStore: - """ Taken from LND, see license in lnchan.py. """ + """ Taken from LND, see license in lnchannel.py. """ START_INDEX = 2 ** 48 - 1 diff --git a/electrum/lnchannelverifier.py b/electrum/lnverifier.py similarity index 99% rename from electrum/lnchannelverifier.py rename to electrum/lnverifier.py index 21c74ff15..e340f49c9 100644 --- a/electrum/lnchannelverifier.py +++ b/electrum/lnverifier.py @@ -29,7 +29,6 @@ from typing import TYPE_CHECKING import aiorpcx -from . import lnbase from . import bitcoin from . import ecc from . import constants diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 5e1b09cef..6c25a1a39 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -28,10 +28,10 @@ from .bip32 import bip32_root from .util import bh2u, bfh, PrintError, InvoiceError, resolve_dns_srv, is_ip_address, log_exceptions from .util import timestamp_to_datetime from .lntransport import LNTransport, LNResponderTransport -from .lnbase import Peer +from .lnpeer import Peer from .lnaddr import lnencode, LnAddr, lndecode from .ecc import der_sig_from_sig_string -from .lnchan import Channel, ChannelJsonEncoder +from .lnchannel import Channel, ChannelJsonEncoder from .lnutil import (Outpoint, calc_short_channel_id, LNPeerAddr, get_compressed_pubkey_from_bech32, extract_nodeid, PaymentFailure, split_host_port, ConnStringFormatError, diff --git a/electrum/tests/test_lnchan.py b/electrum/tests/test_lnchannel.py similarity index 98% rename from electrum/tests/test_lnchan.py rename to electrum/tests/test_lnchannel.py index ab21d92d3..582a853b6 100644 --- a/electrum/tests/test_lnchan.py +++ b/electrum/tests/test_lnchannel.py @@ -25,8 +25,8 @@ import binascii from pprint import pformat from electrum import bitcoin -from electrum import lnbase -from electrum import lnchan +from electrum import lnpeer +from electrum import lnchannel from electrum import lnutil from electrum import bip32 as bip32_utils from electrum.lnutil import SENT, LOCAL, REMOTE, RECEIVED @@ -38,14 +38,14 @@ one_bitcoin_in_msat = bitcoin.COIN * 1000 def create_channel_state(funding_txid, funding_index, funding_sat, local_feerate, is_initiator, local_amount, remote_amount, privkeys, other_pubkeys, seed, cur, nex, other_node_id, l_dust, r_dust, l_csv, r_csv): assert local_amount > 0 assert remote_amount > 0 - channel_id, _ = lnbase.channel_id_from_funding_tx(funding_txid, funding_index) - their_revocation_store = lnbase.RevocationStore() + channel_id, _ = lnpeer.channel_id_from_funding_tx(funding_txid, funding_index) + their_revocation_store = lnpeer.RevocationStore() return { "channel_id":channel_id, "short_channel_id":channel_id[:8], - "funding_outpoint":lnbase.Outpoint(funding_txid, funding_index), - "remote_config":lnbase.RemoteConfig( + "funding_outpoint":lnpeer.Outpoint(funding_txid, funding_index), + "remote_config":lnpeer.RemoteConfig( payment_basepoint=other_pubkeys[0], multisig_key=other_pubkeys[1], htlc_basepoint=other_pubkeys[2], @@ -65,7 +65,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, local_feerate current_per_commitment_point=cur, revocation_store=their_revocation_store, ), - "local_config":lnbase.LocalConfig( + "local_config":lnpeer.LocalConfig( payment_basepoint=privkeys[0], multisig_key=privkeys[1], htlc_basepoint=privkeys[2], @@ -87,7 +87,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, local_feerate current_htlc_signatures=None, got_sig_for_next=False, ), - "constraints":lnbase.ChannelConstraints( + "constraints":lnpeer.ChannelConstraints( capacity=funding_sat, is_initiator=is_initiator, funding_txn_minimum_depth=3, @@ -126,9 +126,9 @@ def create_test_channels(feerate=6000, local=None, remote=None): bob_first = lnutil.secret_to_pubkey(int.from_bytes(lnutil.get_per_commitment_secret_from_seed(bob_seed, lnutil.RevocationStore.START_INDEX), "big")) alice, bob = \ - lnchan.Channel( + lnchannel.Channel( create_channel_state(funding_txid, funding_index, funding_sat, feerate, True, local_amount, remote_amount, alice_privkeys, bob_pubkeys, alice_seed, None, bob_first, b"\x02"*33, l_dust=200, r_dust=1300, l_csv=5, r_csv=4), name="alice"), \ - lnchan.Channel( + lnchannel.Channel( create_channel_state(funding_txid, funding_index, funding_sat, feerate, False, remote_amount, local_amount, bob_privkeys, alice_pubkeys, bob_seed, None, alice_first, b"\x01"*33, l_dust=1300, r_dust=200, l_csv=4, r_csv=5), name="bob") alice.set_state('OPEN') @@ -692,9 +692,9 @@ class TestChanReserve(unittest.TestCase): force_state_transition(self.alice_channel, self.bob_channel) aliceSelfBalance = self.alice_channel.balance(LOCAL)\ - - lnchan.htlcsum(self.alice_channel.hm.htlcs_by_direction(LOCAL, SENT)) + - lnchannel.htlcsum(self.alice_channel.hm.htlcs_by_direction(LOCAL, SENT)) bobBalance = self.bob_channel.balance(REMOTE)\ - - lnchan.htlcsum(self.alice_channel.hm.htlcs_by_direction(REMOTE, SENT)) + - lnchannel.htlcsum(self.alice_channel.hm.htlcs_by_direction(REMOTE, SENT)) self.assertEqual(aliceSelfBalance, one_bitcoin_in_msat*4.5) self.assertEqual(bobBalance, one_bitcoin_in_msat*5) # Now let Bob try to add an HTLC. This should fail, since it will diff --git a/electrum/tests/test_lnbase.py b/electrum/tests/test_lnpeer.py similarity index 98% rename from electrum/tests/test_lnbase.py rename to electrum/tests/test_lnpeer.py index 406ab5665..312aaf7e5 100644 --- a/electrum/tests/test_lnbase.py +++ b/electrum/tests/test_lnpeer.py @@ -13,7 +13,7 @@ from electrum.lnaddr import lnencode, LnAddr, lndecode from electrum.bitcoin import COIN, sha256 from electrum.util import bh2u -from electrum.lnbase import Peer +from electrum.lnpeer import Peer from electrum.lnutil import LNPeerAddr, Keypair, privkey_to_pubkey from electrum.lnutil import LightningPeerConnectionClosed, RemoteMisbehaving from electrum.lnutil import PaymentFailure @@ -21,7 +21,7 @@ from electrum.lnrouter import ChannelDB, LNPathFinder from electrum.lnworker import LNWorker from electrum.lnmsg import encode_msg, decode_msg -from .test_lnchan import create_test_channels +from .test_lnchannel import create_test_channels def keypair(): priv = ECPrivkey.generate_random_key().get_secret_bytes() @@ -39,7 +39,7 @@ class MockNetwork: self.callbacks = defaultdict(list) self.lnwatcher = None user_config = {} - user_dir = tempfile.mkdtemp(prefix="electrum-lnbase-test-") + user_dir = tempfile.mkdtemp(prefix="electrum-lnpeer-test-") self.config = simple_config.SimpleConfig(user_config, read_user_dir_function=lambda: user_dir) self.asyncio_loop = asyncio.get_event_loop() self.channel_db = ChannelDB(self)