Browse Source

digitalbitbox: make constant strings

3.3.3.1
Janus 6 years ago
parent
commit
0169ec880c
  1. 19
      electrum/plugins/digitalbitbox/digitalbitbox.py

19
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:

Loading…
Cancel
Save