Python 3 and Segwit fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from binascii import hexlify, unhexlify
|
||||
import threading
|
||||
|
||||
from PyQt4.Qt import (QDialog, QInputDialog, QLineEdit, QTextEdit, QVBoxLayout, QLabel, SIGNAL)
|
||||
@@ -182,7 +183,7 @@ class LedgerAuthDialog(QDialog):
|
||||
|
||||
def do_pairing(self):
|
||||
rng = os.urandom(16)
|
||||
pairID = rng.encode('hex') + hashlib.sha256(rng).digest()[0].encode('hex')
|
||||
pairID = (hexlify(rng) + hexlify(hashlib.sha256(rng).digest()[0:1])).decode('utf-8')
|
||||
self.pairqr.setData(pairID)
|
||||
self.modebox.setVisible(False)
|
||||
self.helpmsg.setVisible(False)
|
||||
@@ -245,7 +246,7 @@ class LedgerWebSocket(QThread):
|
||||
QThread.__init__(self)
|
||||
self.stopping = False
|
||||
self.pairID = pairID
|
||||
self.txreq = '{"type":"request","second_factor_data":"' + str(txdata['secureScreenData']).encode('hex') + '"}' if txdata else None
|
||||
self.txreq = '{"type":"request","second_factor_data":"' + hexlify(txdata['secureScreenData']).decode('utf-8') + '"}' if txdata else None
|
||||
self.dlg = dlg
|
||||
self.dongle = self.dlg.dongle
|
||||
self.data = None
|
||||
@@ -269,10 +270,10 @@ class LedgerWebSocket(QThread):
|
||||
if data['type'] == 'identify':
|
||||
debug_msg('Identify')
|
||||
apdu = [0xe0, 0x12, 0x01, 0x00, 0x41] # init pairing
|
||||
apdu.extend(data['public_key'].decode('hex'))
|
||||
apdu.extend(unhexlify(data['public_key']))
|
||||
try:
|
||||
challenge = self.dongle.exchange( bytearray(apdu) )
|
||||
ws.send( '{"type":"challenge","data":"%s" }' % str(challenge).encode('hex') )
|
||||
ws.send( '{"type":"challenge","data":"%s" }' % hexlify(challenge).decode('utf-8') )
|
||||
self.data = data
|
||||
except BTChipException as e:
|
||||
debug_msg('Identify Failed')
|
||||
@@ -280,7 +281,7 @@ class LedgerWebSocket(QThread):
|
||||
if data['type'] == 'challenge':
|
||||
debug_msg('Challenge')
|
||||
apdu = [0xe0, 0x12, 0x02, 0x00, 0x10] # confirm pairing
|
||||
apdu.extend(data['data'].decode('hex'))
|
||||
apdu.extend(unhexlify(data['data']))
|
||||
try:
|
||||
self.dongle.exchange( bytearray(apdu) )
|
||||
debug_msg('Pairing Successful')
|
||||
|
||||
Reference in New Issue
Block a user