Browse Source

storage upgrade: move "htlc_minimum_msat" to base channel config

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
01207316aa
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/lnpeer.py
  2. 2
      electrum/lnutil.py
  3. 1
      electrum/tests/test_lnchannel.py
  4. 11
      electrum/wallet_db.py

5
electrum/lnpeer.py

@ -504,11 +504,12 @@ class Peer(Logger):
was_announced=False, was_announced=False,
current_commitment_signature=None, current_commitment_signature=None,
current_htlc_signatures=b'', current_htlc_signatures=b'',
htlc_minimum_msat=1,
) )
return local_config return local_config
@log_exceptions @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']: push_msat: int, temp_channel_id: bytes) -> Tuple[Channel, 'PartialTransaction']:
await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT) await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT)
feerate = self.lnworker.current_feerate_per_kw() 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, max_htlc_value_in_flight_msat=local_config.max_htlc_value_in_flight_msat,
channel_flags=0x00, # not willing to announce channel channel_flags=0x00, # not willing to announce channel
channel_reserve_satoshis=local_config.reserve_sat, 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) payload = await self.wait_for_message('accept_channel', temp_channel_id)
remote_per_commitment_point = payload['first_per_commitment_point'] remote_per_commitment_point = payload['first_per_commitment_point']

2
electrum/lnutil.py

@ -69,6 +69,7 @@ class Config(StoredObject):
max_accepted_htlcs = attr.ib(type=int) max_accepted_htlcs = attr.ib(type=int)
initial_msat = attr.ib(type=int) initial_msat = attr.ib(type=int)
reserve_sat = attr.ib(type=int) reserve_sat = attr.ib(type=int)
htlc_minimum_msat = attr.ib(type=int)
@attr.s @attr.s
class LocalConfig(Config): class LocalConfig(Config):
@ -80,7 +81,6 @@ class LocalConfig(Config):
@attr.s @attr.s
class RemoteConfig(Config): class RemoteConfig(Config):
htlc_minimum_msat = attr.ib(type=int)
next_per_commitment_point = attr.ib(type=bytes, converter=hex_to_bytes) 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) current_per_commitment_point = attr.ib(default=None, type=bytes, converter=hex_to_bytes)

1
electrum/tests/test_lnchannel.py

@ -83,6 +83,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, is_initiator,
was_announced=False, was_announced=False,
current_commitment_signature=None, current_commitment_signature=None,
current_htlc_signatures=None, current_htlc_signatures=None,
htlc_minimum_msat=1,
), ),
"constraints":lnpeer.ChannelConstraints( "constraints":lnpeer.ChannelConstraints(
capacity=funding_sat, capacity=funding_sat,

11
electrum/wallet_db.py

@ -50,7 +50,7 @@ if TYPE_CHECKING:
OLD_SEED_VERSION = 4 # electrum versions < 2.0 OLD_SEED_VERSION = 4 # electrum versions < 2.0
NEW_SEED_VERSION = 11 # 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 # old versions from overwriting new format
@ -172,6 +172,7 @@ class WalletDB(JsonDB):
self._convert_version_24() self._convert_version_24()
self._convert_version_25() self._convert_version_25()
self._convert_version_26() self._convert_version_26()
self._convert_version_27()
self.put('seed_version', FINAL_SEED_VERSION) # just to be sure self.put('seed_version', FINAL_SEED_VERSION) # just to be sure
self._after_upgrade_tasks() self._after_upgrade_tasks()
@ -587,6 +588,14 @@ class WalletDB(JsonDB):
c['closing_height'] = closing_txid, closing_height, closing_timestamp c['closing_height'] = closing_txid, closing_height, closing_timestamp
self.data['seed_version'] = 26 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): def _convert_imported(self):
if not self._is_upgrade_method_needed(0, 13): if not self._is_upgrade_method_needed(0, 13):
return return

Loading…
Cancel
Save