From e4429242aacb9c7e6de68e3fe8d9e18854d21c42 Mon Sep 17 00:00:00 2001 From: nelisky Date: Tue, 3 Mar 2015 23:36:51 +0000 Subject: [PATCH] Allow insight_tx to be passed a dict object instead of an url --- trezorlib/tx_api.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/trezorlib/tx_api.py b/trezorlib/tx_api.py index 5816411..62a7867 100644 --- a/trezorlib/tx_api.py +++ b/trezorlib/tx_api.py @@ -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']