From f3995350e8ad588f0ac788dc9cd59d7aac6ca5c3 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Mon, 6 Apr 2020 16:53:48 +0200 Subject: [PATCH] localconfig: rename seed to channel_seed --- electrum/lnpeer.py | 12 +++--------- electrum/lnutil.py | 6 +++--- electrum/tests/test_lnchannel.py | 2 +- electrum/wallet_db.py | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index 950e941ee..70e182c66 100644 --- a/electrum/lnpeer.py +++ b/electrum/lnpeer.py @@ -483,13 +483,8 @@ class Peer(Logger): return bool(self.features & LnFeatures.OPTION_STATIC_REMOTEKEY_OPT) def make_local_config(self, funding_sat: int, push_msat: int, initiator: HTLCOwner) -> LocalConfig: - - random_seed = os.urandom(32) - if initiator == LOCAL: - initial_msat = funding_sat * 1000 - push_msat - else: - initial_msat = push_msat - + channel_seed = os.urandom(32) + initial_msat = funding_sat * 1000 - push_msat if initiator == LOCAL else push_msat if self.is_static_remotekey(): # Note: in the future, if a CSV delay is added, # we will want to derive that key @@ -499,9 +494,8 @@ class Peer(Logger): static_remotekey = bfh(wallet.get_public_key(addr)) else: static_remotekey = None - local_config = LocalConfig.from_seed( - seed=random_seed, + channel_seed=channel_seed, static_remotekey=static_remotekey, to_self_delay=DEFAULT_TO_SELF_DELAY, dust_limit_sat=546, diff --git a/electrum/lnutil.py b/electrum/lnutil.py index ac02eb223..c99c80a07 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -77,7 +77,7 @@ class Config(StoredObject): @attr.s class LocalConfig(Config): - seed = attr.ib(type=bytes, converter=hex_to_bytes) # type: Optional[bytes] + channel_seed = attr.ib(type=bytes, converter=hex_to_bytes) # type: Optional[bytes] funding_locked_received = attr.ib(type=bool) was_announced = attr.ib(type=bool) current_commitment_signature = attr.ib(type=bytes, converter=hex_to_bytes) @@ -86,9 +86,9 @@ class LocalConfig(Config): @classmethod def from_seed(self, **kwargs): - seed = kwargs['seed'] + channel_seed = kwargs['channel_seed'] static_remotekey = kwargs.pop('static_remotekey') - node = BIP32Node.from_rootseed(seed, xtype='standard') + node = BIP32Node.from_rootseed(channel_seed, xtype='standard') keypair_generator = lambda family: generate_keypair(node, family) kwargs['per_commitment_secret_seed'] = keypair_generator(LnKeyFamily.REVOCATION_ROOT).privkey kwargs['multisig_key'] = keypair_generator(LnKeyFamily.MULTISIG) diff --git a/electrum/tests/test_lnchannel.py b/electrum/tests/test_lnchannel.py index 6e28e28e0..fe1163c29 100644 --- a/electrum/tests/test_lnchannel.py +++ b/electrum/tests/test_lnchannel.py @@ -70,7 +70,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, is_initiator, current_per_commitment_point=cur, ), "local_config":lnpeer.LocalConfig( - seed = None, + channel_seed = None, payment_basepoint=privkeys[0], multisig_key=privkeys[1], htlc_basepoint=privkeys[2], diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py index 77c76d43e..e439b0dcc 100644 --- a/electrum/wallet_db.py +++ b/electrum/wallet_db.py @@ -602,7 +602,7 @@ class WalletDB(JsonDB): return channels = self.data.get('channels', {}) for channel_id, c in channels.items(): - c['local_config']['seed'] = None + c['local_config']['channel_seed'] = None self.data['seed_version'] = 28 def _convert_imported(self):