electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 0169ec880ca69efe78bc23b40dfcbef82edc0155
parent 9a3f2e8fcca74595289b99a1f3b1b569ad568503
Author: Janus <ysangkok@gmail.com>
Date:   Fri,  7 Dec 2018 19:18:33 +0100

digitalbitbox: make constant strings

Diffstat:
Melectrum/plugins/digitalbitbox/digitalbitbox.py | 19+++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/electrum/plugins/digitalbitbox/digitalbitbox.py b/electrum/plugins/digitalbitbox/digitalbitbox.py @@ -53,6 +53,9 @@ def derive_keys(x): MIN_MAJOR_VERSION = 5 +ENCRYPTION_PRIVKEY_KEY = 'encryptionprivkey' +CHANNEL_ID_KEY = 'comserverchannelid' + class DigitalBitbox_Client(): def __init__(self, plugin, hidDevice): @@ -280,7 +283,7 @@ class DigitalBitbox_Client(): except (FileNotFoundError, jsonDecodeError): return - if 'encryptionprivkey' not in dbb_config or 'comserverchannelid' not in dbb_config: + if ENCRYPTION_PRIVKEY_KEY not in dbb_config or CHANNEL_ID_KEY not in dbb_config: return choices = [ @@ -294,12 +297,12 @@ class DigitalBitbox_Client(): if reply == 0: if self.plugin.is_mobile_paired(): - del self.plugin.digitalbitbox_config['encryptionprivkey'] - del self.plugin.digitalbitbox_config['comserverchannelid'] + del self.plugin.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY] + del self.plugin.digitalbitbox_config[CHANNEL_ID_KEY] elif reply == 1: # import pairing from dbb app - self.plugin.digitalbitbox_config['encryptionprivkey'] = dbb_config['encryptionprivkey'] - self.plugin.digitalbitbox_config['comserverchannelid'] = dbb_config['comserverchannelid'] + self.plugin.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY] = dbb_config[ENCRYPTION_PRIVKEY_KEY] + self.plugin.digitalbitbox_config[CHANNEL_ID_KEY] = dbb_config[CHANNEL_ID_KEY] self.plugin.config.set_key('digitalbitbox', self.plugin.digitalbitbox_config) def dbb_generate_wallet(self): @@ -729,15 +732,15 @@ class DigitalBitboxPlugin(HW_PluginBase): def is_mobile_paired(self): - return 'encryptionprivkey' in self.digitalbitbox_config + return ENCRYPTION_PRIVKEY_KEY in self.digitalbitbox_config def comserver_post_notification(self, payload): assert self.is_mobile_paired(), "unexpected mobile pairing error" url = 'https://digitalbitbox.com/smartverification/index.php' - key_s = base64.b64decode(self.digitalbitbox_config['encryptionprivkey']) + key_s = base64.b64decode(self.digitalbitbox_config[ENCRYPTION_PRIVKEY_KEY]) args = 'c=data&s=0&dt=0&uuid=%s&pl=%s' % ( - self.digitalbitbox_config['comserverchannelid'], + self.digitalbitbox_config[CHANNEL_ID_KEY], EncodeAES_base64(key_s, json.dumps(payload).encode('ascii')).decode('ascii'), ) try: