From 6922d81a1e92a98a89972178ca8b957002fa7aa2 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Tue, 16 Jun 2020 11:08:52 +0200 Subject: [PATCH] channel backups: add another version number, for the backup itself --- electrum/lnutil.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/electrum/lnutil.py b/electrum/lnutil.py index cca35ae7e..2225ad85c 100644 --- a/electrum/lnutil.py +++ b/electrum/lnutil.py @@ -154,6 +154,8 @@ class ChannelConstraints(StoredObject): is_initiator = attr.ib(type=bool) # note: sometimes also called "funder" funding_txn_minimum_depth = attr.ib(type=int) + +CHANNEL_BACKUP_VERSION = 0 @attr.s class ChannelBackupStorage(StoredObject): node_id = attr.ib(type=bytes, converter=hex_to_bytes) @@ -179,6 +181,7 @@ class ChannelBackupStorage(StoredObject): def to_bytes(self): vds = BCDataStream() + vds.write_int16(CHANNEL_BACKUP_VERSION) vds.write_boolean(self.is_initiator) vds.write_bytes(self.privkey, 32) vds.write_bytes(self.channel_seed, 32) @@ -198,6 +201,8 @@ class ChannelBackupStorage(StoredObject): def from_bytes(s): vds = BCDataStream() vds.write(s) + version = vds.read_int16() + assert version == CHANNEL_BACKUP_VERSION return ChannelBackupStorage( is_initiator = bool(vds.read_bytes(1)), privkey = vds.read_bytes(32).hex(),