mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
Integrate Decred with wallet encryption.
dcrwallet requires the password to be entered at the first startup when encrypted. basicswap-run with --startonlycoin=decred and the WALLET_ENCRYPTION_PWD environment var set can be used for the initial sync.
This commit is contained in:
@@ -1379,7 +1379,7 @@ class BTCInterface(Secp256k1Interface):
|
||||
return True
|
||||
return False
|
||||
|
||||
def isWalletEncryptedLocked(self):
|
||||
def isWalletEncryptedLocked(self) -> (bool, bool):
|
||||
wallet_info = self.rpc_wallet('getwalletinfo')
|
||||
encrypted = 'unlocked_until' in wallet_info
|
||||
locked = encrypted and wallet_info['unlocked_until'] <= 0
|
||||
|
||||
@@ -320,6 +320,44 @@ class DCRInterface(Secp256k1Interface):
|
||||
# Load with --create
|
||||
pass
|
||||
|
||||
def isWalletEncrypted(self) -> bool:
|
||||
return True
|
||||
|
||||
def isWalletLocked(self) -> bool:
|
||||
walletislocked = self.rpc_wallet('walletislocked')
|
||||
return walletislocked
|
||||
|
||||
def isWalletEncryptedLocked(self) -> (bool, bool):
|
||||
walletislocked = self.rpc_wallet('walletislocked')
|
||||
return True, walletislocked
|
||||
|
||||
def changeWalletPassword(self, old_password: str, new_password: str):
|
||||
self._log.info('changeWalletPassword - {}'.format(self.ticker()))
|
||||
if old_password == '':
|
||||
# Read initial pwd from settings
|
||||
settings = self._sc.getChainClientSettings(self.coin_type())
|
||||
old_password = settings['wallet_pwd']
|
||||
self.rpc_wallet('walletpassphrasechange', [old_password, new_password])
|
||||
|
||||
# Lock wallet to match other coins
|
||||
self.rpc_wallet('walletlock')
|
||||
|
||||
# Clear initial password
|
||||
self._sc.editSettings(self.coin_name().lower(), {'wallet_pwd': ''})
|
||||
|
||||
def unlockWallet(self, password: str):
|
||||
if password == '':
|
||||
return
|
||||
self._log.info('unlockWallet - {}'.format(self.ticker()))
|
||||
|
||||
# Max timeout value, ~3 years
|
||||
self.rpc_wallet('walletpassphrase', [password, 100000000])
|
||||
self._sc.checkWalletSeed(self.coin_type())
|
||||
|
||||
def lockWallet(self):
|
||||
self._log.info('lockWallet - {}'.format(self.ticker()))
|
||||
self.rpc_wallet('walletlock')
|
||||
|
||||
def getWalletSeedID(self):
|
||||
masterpubkey = self.rpc_wallet('getmasterpubkey')
|
||||
masterpubkey_data = self.decode_address(masterpubkey)[4:]
|
||||
|
||||
Reference in New Issue
Block a user