Browse Source

Give user feedback when importaddress fails due to conflict with Core wallet.

This fails (sys.exit) when importaddress throws the error corresponding to
Core wallet already owning the key corresponding to an address, and gives
brief advice how the error can be fixed.
It is not considered safe to simply ignore this error in case address reuse
or coins being sent to an address the user doesn't control, occurs.
master
AdamISZ 8 years ago
parent
commit
20e8bf6c92
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 14
      jmclient/jmclient/blockchaininterface.py

14
jmclient/jmclient/blockchaininterface.py

@ -350,7 +350,19 @@ class BitcoinCoreInterface(BlockchainInterface):
log.debug('importing ' + str(len(addr_list)) +
' addresses into account ' + wallet_name)
for addr in addr_list:
self.rpc('importaddress', [addr, wallet_name, False])
try:
self.rpc('importaddress', [addr, wallet_name, False])
except JsonRpcError as e:
if e.code == -4 and e.message == "The wallet already " + \
"contains the private key for this address or script":
log.warn("Fatal sync error: import of address: " + addr +
" failed, since it's already owned by this Bitcoin Core "
"wallet in another account. To prevent coin or privacy "
"loss, Joinmarket will not load a wallet in this conflicted "
"state. To fix: use a new Bitcoin Core wallet to sync this "
"Joinmarket wallet, or use a new Joinmarket wallet.")
sys.exit(1)
raise
def add_watchonly_addresses(self, addr_list, wallet_name, restart_cb=None):
"""For backwards compatibility, this fn name is preserved

Loading…
Cancel
Save