From 2f5eeb066a4cfd8d3368b364a5035a4e3377e14e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 1 Dec 2022 12:32:33 +0000 Subject: [PATCH] TwJSON.Import: add blockchain rescan warning --- mmgen/proto/btc/tw/json.py | 10 ++++++++++ mmgen/tw/json.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/mmgen/proto/btc/tw/json.py b/mmgen/proto/btc/tw/json.py index 193b2324..20918f83 100755 --- a/mmgen/proto/btc/tw/json.py +++ b/mmgen/proto/btc/tw/json.py @@ -36,6 +36,16 @@ class BitcoinTwJSON(TwJSON): few minutes. """ + blockchain_rescan_warning = """ + Balances have been updated in the new tracking wallet. However, the wallet + is unaware of the used state of any spent addresses without balances, which + creates the danger of address reuse, especially when automatic change address + selection is in effect. + + To avoid this danger and restore full tracking wallet functionality, rescan + the blockchain for used addresses by running ‘mmgen-tool rescan_blockchain’. + """ + @property async def tracking_wallet_exists(self): return await self.twctl.rpc.check_or_create_daemon_wallet(wallet_create=False) diff --git a/mmgen/tw/json.py b/mmgen/tw/json.py index 8285dde2..21028066 100755 --- a/mmgen/tw/json.py +++ b/mmgen/tw/json.py @@ -62,6 +62,8 @@ class TwJSON: class Import(Base,metaclass=AsyncInit): + blockchain_rescan_warning = None + async def __init__(self,proto,filename,ignore_checksum=False,batch=False): super().__init__(proto) @@ -104,6 +106,9 @@ class TwJSON: await self.twctl.rescan_addresses(addrs) + if self.blockchain_rescan_warning: + ymsg('\n' + fmt(self.blockchain_rescan_warning.strip(),indent=' ')) + async def check_and_create_wallet(self): if await self.tracking_wallet_exists: