mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-28 08:11:02 +00:00
Merge branch 'master' of github.com:trezor/python-trezor
This commit is contained in:
commit
c47065fb11
@ -57,7 +57,7 @@ How to install (Windows)
|
||||
|
||||
How to install (Debian-Ubuntu)
|
||||
------------------------------
|
||||
* sudo apt-get install python-dev python-setuptools cython libusb-1.0-0-dev libudev-dev
|
||||
* sudo apt-get install python-dev python-setuptools cython libusb-1.0-0-dev libudev-dev git
|
||||
* git clone https://github.com/trezor/python-trezor.git
|
||||
* cd python-trezor
|
||||
* python setup.py install (or develop)
|
||||
|
@ -7,7 +7,7 @@ import mapping
|
||||
from transport import Transport
|
||||
import messages_pb2 as proto
|
||||
|
||||
TREZORD_HOST = 'http://localhost:21324'
|
||||
TREZORD_HOST = 'https://localback.net:21324'
|
||||
CONFIG_URL = 'https://mytrezor.com/data/plugin/config_signed.bin'
|
||||
|
||||
def get_error(resp):
|
||||
@ -22,11 +22,13 @@ class BridgeTransport(Transport):
|
||||
|
||||
config = r.text
|
||||
|
||||
r = requests.post(TREZORD_HOST + '/configure', data=config)
|
||||
self.conn = requests.Session();
|
||||
|
||||
r = self.conn.post(TREZORD_HOST + '/configure', data=config)
|
||||
if r.status_code != 200:
|
||||
raise Exception('trezord: Could not configure' + get_error(r))
|
||||
|
||||
r = requests.get(TREZORD_HOST + '/enumerate')
|
||||
r = self.conn.get(TREZORD_HOST + '/enumerate')
|
||||
if r.status_code != 200:
|
||||
raise Exception('trezord: Could not enumerate devices' + get_error(r))
|
||||
enum = r.json()
|
||||
@ -41,14 +43,14 @@ class BridgeTransport(Transport):
|
||||
super(BridgeTransport, self).__init__(device, *args, **kwargs)
|
||||
|
||||
def _open(self):
|
||||
r = requests.post(TREZORD_HOST + '/acquire/%s' % self.path)
|
||||
r = self.conn.post(TREZORD_HOST + '/acquire/%s' % self.path)
|
||||
if r.status_code != 200:
|
||||
raise Exception('trezord: Could not acquire session' + get_error(r))
|
||||
resp = r.json()
|
||||
self.session = resp['session']
|
||||
|
||||
def _close(self):
|
||||
r = requests.post(TREZORD_HOST + '/release/%s' % self.session)
|
||||
r = self.conn.post(TREZORD_HOST + '/release/%s' % self.session)
|
||||
if r.status_code != 200:
|
||||
raise Exception('trezord: Could not release session' + get_error(r))
|
||||
else:
|
||||
@ -61,7 +63,7 @@ class BridgeTransport(Transport):
|
||||
cls = protobuf_msg.__class__.__name__
|
||||
msg = protobuf_json.pb2json(protobuf_msg)
|
||||
payload = '{"type": "%s", "message": %s}' % (cls, json.dumps(msg))
|
||||
r = requests.post(TREZORD_HOST + '/call/%s' % self.session, data=payload)
|
||||
r = self.conn.post(TREZORD_HOST + '/call/%s' % self.session, data=payload)
|
||||
if r.status_code != 200:
|
||||
raise Exception('trezord: Could not write message' + get_error(r))
|
||||
else:
|
||||
|
@ -52,12 +52,15 @@ def opcode_serialize(opcode):
|
||||
except:
|
||||
raise Exception('Unknown script opcode: %s' % opcode)
|
||||
|
||||
def insight_tx(url):
|
||||
try:
|
||||
f = urllib2.urlopen(url)
|
||||
except:
|
||||
raise Exception('URL error: %s' % url)
|
||||
data = json.load(f)
|
||||
def insight_tx(url, rawdata=False):
|
||||
if not rawdata:
|
||||
try:
|
||||
f = urllib2.urlopen(url)
|
||||
data = json.load(f)
|
||||
except:
|
||||
raise Exception('URL error: %s' % url)
|
||||
else:
|
||||
data = url
|
||||
|
||||
t = proto_types.TransactionType()
|
||||
t.version = data['version']
|
||||
@ -81,7 +84,7 @@ def insight_tx(url):
|
||||
|
||||
for vout in data['vout']:
|
||||
o = t.bin_outputs.add()
|
||||
o.amount = int(Decimal(vout['value']) * 100000000)
|
||||
o.amount = int(Decimal(str(vout['value'])) * 100000000)
|
||||
asm = vout['scriptPubKey']['asm'].split(' ')
|
||||
asm = [ opcode_serialize(x) for x in asm ]
|
||||
o.script_pubkey = ''.join(asm)
|
||||
|
Loading…
Reference in New Issue
Block a user