def parse_tx(self, json_response): # https://api.etherscan.io/ signing_key = json_response['result']['from'] script = json_response['result']['input'] block_no = json_response['result']['blockNumber'] if not script: logging.error('transaction response is missing input: %s', json_response) raise InvalidTransactionError( 'transaction response is missing input') if not block_no: logging.error('transaction is not yet confirmed: %s', json_response) raise InvalidTransactionError('transaction is not yet confirmed') ts_url = self.timestamp_url % str(int(block_no, 16)) r = requests.get(ts_url, headers=headers) if r.status_code != 200: logging.error( 'Error looking up block timestamp with url=%s, status_code=%d', ts_url, r.status_code) raise InvalidTransactionError( 'error looking up block timestamp=%s' % block_no) date_time = r.json()['result']['timeStamp'] return TransactionData(signing_key, script, date_time_utc=int(date_time), revoked_addresses=None)
def parse_tx(self, json_response): revoked = set() script = None time = json_response['time'] signing_key = json_response['inputs'][0]['prev_out']['addr'] for o in json_response['out']: if int(o.get('value', 1)) == 0: script = o['script'][4:] else: if o.get('spent'): revoked.add(o.get('addr')) if not script: logging.error('transaction response is missing op_return script: %s', json_response) raise InvalidTransactionError('transaction response is missing op_return script' % json_response) return TransactionData(signing_key, script, time, revoked)
def parse_tx(self, json_response): revoked = set() script = None time = json_response['received'] signing_key = json_response['inputs'][0]['addresses'][0] for o in json_response['outputs']: if float(o.get('value', 1)) == 0: script = o['data_hex'] else: if o.get('spent_by'): revoked.add(o.get('addresses')[0]) if not script: logging.error('transaction response is missing op_return script: %s', json_response) raise InvalidTransactionError('transaction response is missing op_return script' % json_response) return TransactionData(signing_key, script, time, revoked)
def parse_tx(self, json_response): revoked = set() script = None # note: time is tx time (received), while blocktime is block time(confirmed) ??? time = json_response['time'] signing_key = json_response['vout'][0]['scriptPubKey']['addresses'][0] for o in json_response['vout']: if float(o.get('value', 1)) - float('0E-8') < float('0.0001'): script = o.get('scriptPubKey').get('hex') else: if o.get('scriptPubKey').get('hex'): revoked.add(o.get('scriptPubKey').get('addresses')[0]) if not script: logging.error( 'transaction response is missing op_return script: %s', json_response) raise InvalidTransactionError( 'transaction response is missing op_return script' % json_response) return TransactionData(signing_key, script, time, revoked)
def parse_tx(self, json_response): revoked = set() script = None time = json_response['data']['time_utc'] signing_key = json_response['data']['vins'][0]['address'] for o in json_response['data']['vouts']: if float(o.get('amount', 1)) == 0: if not 'extras' in o: script = None else: script = o['extras']['script'][4:] else: if o.get('is_spent') and float(o.get('is_spent', 1)) == 49: revoked.add(o.get('address')) if not script: logging.error( 'transaction response is missing op_return script: %s', json_response) raise InvalidTransactionError( 'transaction response is missing op_return script') return TransactionData(signing_key, script, time, revoked)