(txhash, network='btc')
| 326 | |
| 327 | |
| 328 | def blockr_fetchtx(txhash, network='btc'): |
| 329 | if network == 'testnet': |
| 330 | blockr_url = 'http://tbtc.blockr.io/api/v1/tx/raw/' |
| 331 | elif network == 'btc': |
| 332 | blockr_url = 'http://btc.blockr.io/api/v1/tx/raw/' |
| 333 | else: |
| 334 | raise Exception( |
| 335 | 'Unsupported network {0} for blockr_fetchtx'.format(network)) |
| 336 | if isinstance(txhash, list): |
| 337 | txhash = ','.join([x.encode('hex') if not re.match('^[0-9a-fA-F]*$', x) |
| 338 | else x for x in txhash]) |
| 339 | jsondata = json.loads(make_request(blockr_url+txhash).decode("utf-8")) |
| 340 | return [d['tx']['hex'] for d in jsondata['data']] |
| 341 | else: |
| 342 | if not re.match('^[0-9a-fA-F]*$', txhash): |
| 343 | txhash = txhash.encode('hex') |
| 344 | jsondata = json.loads(make_request(blockr_url+txhash).decode("utf-8")) |
| 345 | return jsondata['data']['tx']['hex'] |
| 346 | |
| 347 | |
| 348 | def helloblock_fetchtx(txhash, network='btc'): |
nothing calls this directly
no test coverage detected