mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
Python 3 and Segwit fixes
This commit is contained in:
parent
b86619ee30
commit
e49e3d6673
2 changed files with 10 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
from binascii import hexlify, unhexlify
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from PyQt4.Qt import (QDialog, QInputDialog, QLineEdit, QTextEdit, QVBoxLayout, QLabel, SIGNAL)
|
from PyQt4.Qt import (QDialog, QInputDialog, QLineEdit, QTextEdit, QVBoxLayout, QLabel, SIGNAL)
|
||||||
|
@ -182,7 +183,7 @@ class LedgerAuthDialog(QDialog):
|
||||||
|
|
||||||
def do_pairing(self):
|
def do_pairing(self):
|
||||||
rng = os.urandom(16)
|
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.pairqr.setData(pairID)
|
||||||
self.modebox.setVisible(False)
|
self.modebox.setVisible(False)
|
||||||
self.helpmsg.setVisible(False)
|
self.helpmsg.setVisible(False)
|
||||||
|
@ -245,7 +246,7 @@ class LedgerWebSocket(QThread):
|
||||||
QThread.__init__(self)
|
QThread.__init__(self)
|
||||||
self.stopping = False
|
self.stopping = False
|
||||||
self.pairID = pairID
|
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.dlg = dlg
|
||||||
self.dongle = self.dlg.dongle
|
self.dongle = self.dlg.dongle
|
||||||
self.data = None
|
self.data = None
|
||||||
|
@ -269,10 +270,10 @@ class LedgerWebSocket(QThread):
|
||||||
if data['type'] == 'identify':
|
if data['type'] == 'identify':
|
||||||
debug_msg('Identify')
|
debug_msg('Identify')
|
||||||
apdu = [0xe0, 0x12, 0x01, 0x00, 0x41] # init pairing
|
apdu = [0xe0, 0x12, 0x01, 0x00, 0x41] # init pairing
|
||||||
apdu.extend(data['public_key'].decode('hex'))
|
apdu.extend(unhexlify(data['public_key']))
|
||||||
try:
|
try:
|
||||||
challenge = self.dongle.exchange( bytearray(apdu) )
|
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
|
self.data = data
|
||||||
except BTChipException as e:
|
except BTChipException as e:
|
||||||
debug_msg('Identify Failed')
|
debug_msg('Identify Failed')
|
||||||
|
@ -280,7 +281,7 @@ class LedgerWebSocket(QThread):
|
||||||
if data['type'] == 'challenge':
|
if data['type'] == 'challenge':
|
||||||
debug_msg('Challenge')
|
debug_msg('Challenge')
|
||||||
apdu = [0xe0, 0x12, 0x02, 0x00, 0x10] # confirm pairing
|
apdu = [0xe0, 0x12, 0x02, 0x00, 0x10] # confirm pairing
|
||||||
apdu.extend(data['data'].decode('hex'))
|
apdu.extend(unhexlify(data['data']))
|
||||||
try:
|
try:
|
||||||
self.dongle.exchange( bytearray(apdu) )
|
self.dongle.exchange( bytearray(apdu) )
|
||||||
debug_msg('Pairing Successful')
|
debug_msg('Pairing Successful')
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from binascii import hexlify
|
|
||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
|
@ -175,8 +174,8 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||||
self.cfg = d.get('cfg', {'mode':0,'pair':''})
|
self.cfg = d.get('cfg', {'mode':0,'pair':''})
|
||||||
|
|
||||||
def is_segwit(self):
|
def is_segwit(self):
|
||||||
return self.plugin.segwit
|
return self.derivation.startswith("m/49'/")
|
||||||
|
|
||||||
def dump(self):
|
def dump(self):
|
||||||
obj = Hardware_KeyStore.dump(self)
|
obj = Hardware_KeyStore.dump(self)
|
||||||
obj['cfg'] = self.cfg
|
obj['cfg'] = self.cfg
|
||||||
|
@ -341,10 +340,10 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||||
for utxo in inputs:
|
for utxo in inputs:
|
||||||
sequence = int_to_hex(utxo[5], 4)
|
sequence = int_to_hex(utxo[5], 4)
|
||||||
if segwitTransaction:
|
if segwitTransaction:
|
||||||
txtmp = bitcoinTransaction(bfh(utxo[0]))
|
txtmp = bitcoinTransaction(bfh(utxo[0]))
|
||||||
tmp = bfh(utxo[3])[::-1]
|
tmp = bfh(utxo[3])[::-1]
|
||||||
tmp += bfh(int_to_hex(utxo[1], 4))
|
tmp += bfh(int_to_hex(utxo[1], 4))
|
||||||
tmp += str(txtmp.outputs[utxo[1]].amount)
|
tmp += txtmp.outputs[utxo[1]].amount
|
||||||
chipInputs.append({'value' : tmp, 'witness' : True, 'sequence' : sequence})
|
chipInputs.append({'value' : tmp, 'witness' : True, 'sequence' : sequence})
|
||||||
redeemScripts.append(bfh(utxo[2]))
|
redeemScripts.append(bfh(utxo[2]))
|
||||||
elif not p2shTransaction:
|
elif not p2shTransaction:
|
||||||
|
|
Loading…
Add table
Reference in a new issue