def tx_from_str(txt):
 import json
 txt = txt.strip()
 try:
  txt.decode('hex')
  is_hex = True
 except:
  is_hex = False
 if is_hex:
  return txt
 tx_dict = json.loads(str(txt))
 assert ('hex' in tx_dict.keys())
 return tx_dict['hex']

def tx_from_str ( txt ) : import json txt = txt . strip ( ) try : txt . decode ( 'hex' ) is_hex = True except : is_hex = False if is_hex : return txt tx_dict = json . loads ( str ( txt ) ) assert ( 'hex' in tx_dict . keys ( ) ) return tx_dict [ 'hex' ]
json or raw hexadecimal .