# Path: utils.py
# def h2h(h):
#     return h[::-1].encode("hex")
# 
# def hash2addr(h160):
#     vh160 = "\x00"+h160  # \x00 is version 0
#     addr=vh160+checksum(vh160)
#     return b58encode(addr)


import transactions
import logging
import msgs
import json
    import sys
    import time
from utils import h2h, hash2addr

def load_tx(filename):
    txdata = "".join(open(filename,"r").read().split("\n")).decode("hex")
    return msgs.Tx.frombinary(txdata)[0]
    
def save_tx(filename, tx):
    bintx = tx.tobinary().encode("hex")
    open(filename,"w").write("\n".join([bintx[i:i+80] for i in range(0, len(bintx), 80)]))

def getaddress(script):
    sc = script.decode("hex")

# Path: utils.py
# def h2h(h):
#     return h[::-1].encode("hex")
# 
# def hash2addr(h160):
#     vh160 = "\x00"+h160  # \x00 is version 0
#     addr=vh160+checksum(vh160)
#     return b58encode(addr)


# Path: txutil.py
import transactions
import logging
import msgs
import json
    import sys
    import time
from utils import h2h, hash2addr


def load_tx(filename):
    txdata = "".join(open(filename,"r").read().split("\n")).decode("hex")
    return msgs.Tx.frombinary(txdata)[0]
    
def save_tx(filename, tx):
    bintx = tx.tobinary().encode("hex")
    open(filename,"w").write("\n".join([bintx[i:i+80] for i in range(0, len(bintx), 80)]))

def getaddress(script):
    sc = script.decode("hex")

    if sc[:2] == "\x76\xa9" and sc[-2:] == "\x88\xac":