URI: 
       tMerge pull request #6857 from SomberNight/202012_walletdb_v33 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 9fcfa709e097f71a85f5e6c73596ad3b0327814e
   DIR parent b80978c8db013b71754107bcabceaf9f545975a9
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 17 Dec 2020 17:37:41 +0100
       
       Merge pull request #6857 from SomberNight/202012_walletdb_v33
       
       wallet_db: impl convert_version_33: put 'height' field into invoices
       Diffstat:
         M electrum/invoices.py                |       2 +-
         M electrum/wallet_db.py               |      17 ++++++++++++++++-
       
       2 files changed, 17 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/electrum/invoices.py b/electrum/invoices.py
       t@@ -118,7 +118,7 @@ class OnchainInvoice(Invoice):
            outputs = attr.ib(kw_only=True, converter=_decode_outputs)  # type: List[PartialTxOutput]
            bip70 = attr.ib(type=str, kw_only=True)  # type: Optional[str]
            requestor = attr.ib(type=str, kw_only=True)  # type: Optional[str]
       -    height = attr.ib(type=int, default=0, kw_only=True, validator=attr.validators.instance_of(int))
       +    height = attr.ib(type=int, kw_only=True, validator=attr.validators.instance_of(int))
        
            def get_address(self) -> str:
                """returns the first address, to be displayed in GUI"""
   DIR diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py
       t@@ -52,7 +52,7 @@ if TYPE_CHECKING:
        
        OLD_SEED_VERSION = 4        # electrum versions < 2.0
        NEW_SEED_VERSION = 11       # electrum versions >= 2.0
       -FINAL_SEED_VERSION = 32     # electrum >= 2.7 will set this to prevent
       +FINAL_SEED_VERSION = 33     # electrum >= 2.7 will set this to prevent
                                    # old versions from overwriting new format
        
        
       t@@ -180,6 +180,7 @@ class WalletDB(JsonDB):
                self._convert_version_30()
                self._convert_version_31()
                self._convert_version_32()
       +        self._convert_version_33()
                self.put('seed_version', FINAL_SEED_VERSION)  # just to be sure
        
                self._after_upgrade_tasks()
       t@@ -695,6 +696,20 @@ class WalletDB(JsonDB):
                self.data['invoices'] = invoices_new
                self.data['seed_version'] = 32
        
       +    def _convert_version_33(self):
       +        if not self._is_upgrade_method_needed(32, 32):
       +            return
       +
       +        from .invoices import PR_TYPE_ONCHAIN
       +        requests = self.data.get('payment_requests', {})
       +        invoices = self.data.get('invoices', {})
       +        for d in [invoices, requests]:
       +            for key, item in list(d.items()):
       +                if item['type'] == PR_TYPE_ONCHAIN:
       +                    item['height'] = item.get('height') or 0
       +
       +        self.data['seed_version'] = 33
       +
            def _convert_imported(self):
                if not self._is_upgrade_method_needed(0, 13):
                    return