commit 01207316aa078264d79dcad0ff88b3fd1417b613
parent 53c6fc8cf14a914e961bd2f137540684244b461c
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 26 Mar 2020 06:32:12 +0100
storage upgrade: move "htlc_minimum_msat" to base channel config
Diffstat:
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
@@ -504,11 +504,12 @@ class Peer(Logger):
was_announced=False,
current_commitment_signature=None,
current_htlc_signatures=b'',
+ htlc_minimum_msat=1,
)
return local_config
@log_exceptions
- async def channel_establishment_flow(self, password: Optional[str], funding_tx: 'PartialTransaction', funding_sat: int,
+ async def channel_establishment_flow(self, password: Optional[str], funding_tx: 'PartialTransaction', funding_sat: int,
push_msat: int, temp_channel_id: bytes) -> Tuple[Channel, 'PartialTransaction']:
await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT)
feerate = self.lnworker.current_feerate_per_kw()
@@ -536,7 +537,7 @@ class Peer(Logger):
max_htlc_value_in_flight_msat=local_config.max_htlc_value_in_flight_msat,
channel_flags=0x00, # not willing to announce channel
channel_reserve_satoshis=local_config.reserve_sat,
- htlc_minimum_msat=1,
+ htlc_minimum_msat=local_config.htlc_minimum_msat,
)
payload = await self.wait_for_message('accept_channel', temp_channel_id)
remote_per_commitment_point = payload['first_per_commitment_point']
diff --git a/electrum/lnutil.py b/electrum/lnutil.py
@@ -69,6 +69,7 @@ class Config(StoredObject):
max_accepted_htlcs = attr.ib(type=int)
initial_msat = attr.ib(type=int)
reserve_sat = attr.ib(type=int)
+ htlc_minimum_msat = attr.ib(type=int)
@attr.s
class LocalConfig(Config):
@@ -80,7 +81,6 @@ class LocalConfig(Config):
@attr.s
class RemoteConfig(Config):
- htlc_minimum_msat = attr.ib(type=int)
next_per_commitment_point = attr.ib(type=bytes, converter=hex_to_bytes)
current_per_commitment_point = attr.ib(default=None, type=bytes, converter=hex_to_bytes)
diff --git a/electrum/tests/test_lnchannel.py b/electrum/tests/test_lnchannel.py
@@ -83,6 +83,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, is_initiator,
was_announced=False,
current_commitment_signature=None,
current_htlc_signatures=None,
+ htlc_minimum_msat=1,
),
"constraints":lnpeer.ChannelConstraints(
capacity=funding_sat,
diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py
@@ -50,7 +50,7 @@ if TYPE_CHECKING:
OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # electrum versions >= 2.0
-FINAL_SEED_VERSION = 26 # electrum >= 2.7 will set this to prevent
+FINAL_SEED_VERSION = 27 # electrum >= 2.7 will set this to prevent
# old versions from overwriting new format
@@ -172,6 +172,7 @@ class WalletDB(JsonDB):
self._convert_version_24()
self._convert_version_25()
self._convert_version_26()
+ self._convert_version_27()
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
self._after_upgrade_tasks()
@@ -587,6 +588,14 @@ class WalletDB(JsonDB):
c['closing_height'] = closing_txid, closing_height, closing_timestamp
self.data['seed_version'] = 26
+ def _convert_version_27(self):
+ if not self._is_upgrade_method_needed(26, 26):
+ return
+ channels = self.data.get('channels', {})
+ for channel_id, c in channels.items():
+ c['local_config']['htlc_minimum_msat'] = 1
+ self.data['seed_version'] = 27
+
def _convert_imported(self):
if not self._is_upgrade_method_needed(0, 13):
return