コード例 #1
0
def main() :
    parser = argparse.ArgumentParser(description='Construct a paperwallet and return svg content')
    parser.add_argument('filename', type=str, help='Output file name to store SVG in')
    parser.add_argument('--amount', type=str, help='Text (amount) to be placed on the paper wallet')
    parser.add_argument('--asset', type=str, help='Asset label to be placed on the paper wallet')
    parser.add_argument('--design', type=str, help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument('-encrypt', help='Encrypt private key with BIP38!', action='store_true')
    parser.add_argument('--back_qr', help='Content of the QR-code on the back of the paper wallet', action='store_true')
    parser.add_argument('--back_text1', help='Text field 1 on the back of the paper wallet', action='store_true')
    parser.add_argument('--back_text2', help='Text field 2 on the back of the paper wallet', action='store_true')
    parser.add_argument('--back_text3', help='Text field 3 on the back of the paper wallet', action='store_true')
    parser.set_defaults(design="cass")
    parser.set_defaults(back_text1="Install the BitShares App.", back_text2="Load your funds from the wallet", back_text3="Buy the BitShares 101 Book for $1", back_qr="http://cryptofresh.com/products/8?r=xeroc")
    args = parser.parse_args()

    ''' Generate new wif and address '''
    wif = Address.newwif()
    add = Address.wif2btsaddr(wif)

    ''' Verify that the private keys gives access to address in add '''
    assert Address.priv2btsaddr(Address.wif2hex(wif)) is not add, "private key for address %s is different from given address %s" %(Address.priv2btsaddr(Address.wif2hex(wif)), add) 

    pw = ""
    if args.encrypt :
        import getpass
        while True :
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if(pw == pwck) : 
                break
            else :
                print("Given Passphrases do not match!")

    front,back = Paper.paperwallet(wif, add, args.amount, args.asset, encrypt=pw, design=args.design, backtext1=args.back_text1, backtext2=args.back_text2, backtext3=args.back_text3, backQRcode=args.back_qr)

    extension = os.path.splitext(args.filename)[1]
    if extension == ".svg" :
        open(args.filename, 'wb').write(front)
        open(args.filename.replace('.svg','-back.svg'), 'wb').write(back)
    elif extension == ".pdf" :
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader
        merger = PdfFileMerger()
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        merger.write(args.filename)
    else :
        print("unknown extension %s" % extension)
        return
コード例 #2
0
def main() :
    parser = argparse.ArgumentParser(description='Tool to update the voter key of a coldstorage address')
    parser.add_argument('--voteaddress', type=str, help='address that will be allowed to vote with cold funds instead')
    parser.add_argument('--account', type=str, help='account that will be allowed to vote with cold funds instead')
    parser.add_argument('--rpcurl', type=str, help='')
    parser.add_argument('--rpcuser', type=str, help='')
    parser.add_argument('--rpcpasswd', type=str, help='')
    parser.add_argument('--output', type=str, help='filename into which the signed output is stored')
    parser.set_defaults(rpcurl=config.url, rpcuser=config.user, rpcpasswd=config.passwd)
    parser.set_defaults(output="signedtx.txt")
    args = parser.parse_args()
    slate_id = None

    ''' Connect to bitshares client via RPC '''
    rpc = bitsharesrpc.client(args.rpcurl, args.rpcuser, args.rpcpasswd)

    if not args.voteaddress and not args.account :
        print("No voteaddress given! Please specify!")
        args.voteaddress  = ask_for_address() 
    if args.account :
        args.voteaddress  = rpc.wallet_address_create(args.account)[ "result" ]
        print("Using %s from account %s" %(args.voteaddress, args.account))

    ''' Ask for the private key '''
    privkey  = ask_for_privkey()
    address  = Address.priv2btsaddr(Address.wif2hex(privkey))

    ''' balance ids '''
    balances = rpc.blockchain_list_address_balances(address)["result"]
    print("This address holds the following BTS funds (ignoring other assets):")
    ops      = []
    for balance in balances :
        balanceId = balance[0]
        asset_id  = balance[1]["condition"]["asset_id"]
        asset    = rpc.blockchain_get_asset(asset_id)["result"]
        if asset_id == 0 :
            if balance[1]["balance"] == 0: continue
            print("- %f BTS" % ((balance[1]["balance"])/float(asset["precision"])))
            votekeyop      = Transaction.UpdateBalanceVote(balanceId, args.voteaddress, slate_id)
            ops.append(Transaction.Operation( "update_balance_vote_op_type", votekeyop ))

    tx             = Transaction.Transaction( 60*60*12, None, ops )
    sigtx          = Transaction.SignedTransaction(tx, [privkey])

    ''' Store signed transaction '''
    with open(args.output,"wb") as fp :
        fp.write(json.dumps(sigtx.tojson()))
    print("\n%d transaction successfully signed and output written to file '%s'" % (len(ops), args.output) )
    print("To broadcast transaction copy the file and run ./broadcast_signed_tx.py on online computer")
コード例 #3
0
def ask_for_privkey(address=None) :
    while True :
        try :
            print("1) Type in WIF private key")
            print("2) Use QR scanner")
            choice = raw_input("Select option: ")
            if choice == "1" :
                privkey_raw = raw_input("Please provide private key (WIF): ")
            elif choice == "2" :
                print("Press any key if the green rectangle appears!")
                privkey_raw = readtextfromQR()
            else :
                continue

            if privkey_raw[0] == "6" :
                privkey = ask_for_decryption(privkey_raw)
            elif privkey_raw[0] == "5" :
                privkey = privkey_raw
            else :
                raise Exception("Expecting WIF/BIP38 private key!")

            ''' Verify that the given private key gives access to the cold storage address '''
            addressraw = Address.priv2btsaddr(Address.wif2hex(privkey))
            print("This private key gives access to funds in address %s" % addressraw)
            if address : 
                if str(address).strip() == str(addressraw).strip() :
                    return str(privkey).strip()
                else :
                    print("The private key is wrong! It gives access to %s but access to %s is required to sign this tx" % (addressraw, address))
                    raise
            else :
                return str(privkey).strip()

        except Exception, e:
            print("Error: %s" % str(e))
            print("Try again!")
            continue
        except (EOFError, KeyboardInterrupt):
            print
            sys.exit(1)
コード例 #4
0
def main():
    parser = argparse.ArgumentParser(description="Construct paperwallets according to file")
    parser.add_argument("--design", type=str, help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument("-svg", help="Store as SVG instead of PDF", action="store_true")
    parser.add_argument("--amount", type=str, help="Text (amount) to be placed on the paper wallet")
    parser.add_argument("--asset", type=str, help="Asset label to be placed on the paper wallet")
    parser.add_argument("-encrypt", help="Encrypt private key with BIP38!", action="store_true")
    parser.add_argument("--back_qr", help="Content of the QR-code on the back of the paper wallet", action="store_true")
    parser.add_argument("--back_text1", help="Text field 1 on the back of the paper wallet", action="store_true")
    parser.add_argument("--back_text2", help="Text field 2 on the back of the paper wallet", action="store_true")
    parser.add_argument("--back_text3", help="Text field 3 on the back of the paper wallet", action="store_true")
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument("--wallet", type=str, help="wallet csv file (i.e. generated by sharedrop.py)")
    group.add_argument("--number", type=int, help="Number of wallets to create randomly")
    parser.set_defaults(design="cass", amount="", asset=None)
    parser.set_defaults(
        back_text1="Install the BitShares App.",
        back_text2="Load your funds from the wallet",
        back_text3="Buy the BitShares 101 Book for $1",
        back_qr="http://cryptofresh.com/products/8?r=xeroc",
    )
    args = parser.parse_args()

    """
    Optionally encrypt with BIP38
    """
    pw = ""
    if args.encrypt:
        import getpass

        while True:
            pw = getpass.getpass("Passphrase: ")
            pwck = getpass.getpass("Retype passphrase: ")
            if pw == pwck:
                break
            else:
                print("Given Passphrases do not match!")

    """
    Construct data or read data from file
    """
    wallet = []
    if args.wallet:
        with open(args.wallet, "r") as csvfile:
            spamwriter = csv.reader(csvfile, delimiter=";")
            for wif, add, amount, asset in spamwriter:
                """ Verify that the private keys gives access to address in add """
                assert Address.priv2btsaddr(Address.wif2hex(wif)) is not add, (
                    "private key for address %s is different from given address %s"
                    % (Address.priv2btsaddr(Address.wif2hex(wif)), add)
                )
                wallet.append([wif, add, amount, asset])
    else:
        for i in xrange(0, args.number):
            wif = Address.newwif()
            add = Address.wif2btsaddr(wif)
            wallet.append([wif, add, args.amount, args.asset])

    """
    Construct paper wallets
    """
    print("Constructing paper wallets")
    if not args.svg:
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader

        mergerfront = PdfFileMerger()
        mergerback = PdfFileMerger()
        for w in wallet:
            wif, add, amount, asset = w
            print("Creating Paperwallet for %s" % (add))
            front, back = Paper.paperwallet(
                wif,
                add,
                amount,
                asset,
                encrypt=pw,
                design=args.design,
                backtext1=args.back_text1,
                backtext2=args.back_text2,
                backtext3=args.back_text3,
                backQRcode=args.back_qr,
            )

            if args.svg:
                filename = "paperwallets/%s.svg" % add
                open(filename.replace(".svg", "-front.svg"), "wb").write(front)
                open(filename.replace(".svg", "-back.svg"), "wb").write(back)
            else:
                mergerfront.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
                mergerback.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        mergerfront.write("paperwallets-front.pdf")
        mergerback.write("paperwallets-back.pdf")
    else:
        for w in wallet:
            wif, add, amount, asset = w
            print("Creating Paperwallet for %s" % (add))
            front, back = Paper.paperwallet(
                wif,
                add,
                amount,
                asset,
                encrypt=pw,
                design=args.design,
                backtext1=args.back_text1,
                backtext2=args.back_text2,
                backtext3=args.back_text3,
                backQRcode=args.back_qr,
            )

            filename = "paperwallets/%s.svg" % add
            open(filename.replace(".svg", "-front.svg"), "wb").write(front)
            open(filename.replace(".svg", "-back.svg"), "wb").write(back)
    print("Done.")
コード例 #5
0
def main():
    parser = argparse.ArgumentParser(
        description='Construct a paperwallet and return svg content')
    parser.add_argument('filename',
                        type=str,
                        help='Output file name to store SVG in')
    parser.add_argument('--amount',
                        type=str,
                        help='Text (amount) to be placed on the paper wallet')
    parser.add_argument('--asset',
                        type=str,
                        help='Asset label to be placed on the paper wallet')
    parser.add_argument('--design',
                        type=str,
                        help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument('-encrypt',
                        help='Encrypt private key with BIP38!',
                        action='store_true')
    parser.add_argument(
        '--back_qr',
        help='Content of the QR-code on the back of the paper wallet',
        action='store_true')
    parser.add_argument('--back_text1',
                        help='Text field 1 on the back of the paper wallet',
                        action='store_true')
    parser.add_argument('--back_text2',
                        help='Text field 2 on the back of the paper wallet',
                        action='store_true')
    parser.add_argument('--back_text3',
                        help='Text field 3 on the back of the paper wallet',
                        action='store_true')
    parser.set_defaults(design="cass")
    parser.set_defaults(back_text1="Install the BitShares App.",
                        back_text2="Load your funds from the wallet",
                        back_text3="Buy the BitShares 101 Book for $1",
                        back_qr="http://cryptofresh.com/products/8?r=xeroc")
    args = parser.parse_args()
    ''' Generate new wif and address '''
    wif = Address.newwif()
    add = Address.wif2btsaddr(wif)
    ''' Verify that the private keys gives access to address in add '''
    assert Address.priv2btsaddr(
        Address.wif2hex(wif)
    ) is not add, "private key for address %s is different from given address %s" % (
        Address.priv2btsaddr(Address.wif2hex(wif)), add)

    pw = ""
    if args.encrypt:
        import getpass
        while True:
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if (pw == pwck):
                break
            else:
                print("Given Passphrases do not match!")

    front, back = Paper.paperwallet(wif,
                                    add,
                                    args.amount,
                                    args.asset,
                                    encrypt=pw,
                                    design=args.design,
                                    backtext1=args.back_text1,
                                    backtext2=args.back_text2,
                                    backtext3=args.back_text3,
                                    backQRcode=args.back_qr)

    extension = os.path.splitext(args.filename)[1]
    if extension == ".svg":
        open(args.filename, 'wb').write(front)
        open(args.filename.replace('.svg', '-back.svg'), 'wb').write(back)
    elif extension == ".pdf":
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader
        merger = PdfFileMerger()
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        merger.write(args.filename)
    else:
        print("unknown extension %s" % extension)
        return
コード例 #6
0
def main() :
    parser = argparse.ArgumentParser(description='Construct a paperwallet and store svg file')
    parser.add_argument('filename', type=str, help='Output file name to store SVG in')
    parser.add_argument('--amount', type=str, help='Text (amount) to be placed on the paper wallet')
    parser.add_argument('--asset', type=str, help='Asset label to be placed on the paper wallet')
    parser.add_argument('--design', type=str, help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument('-encrypt', help='Encrypt private key with BIP38!', action='store_true')
    parser.set_defaults(design="cass")
    args = parser.parse_args()

    while True : 
        lines = ""
        try : 
            for line in sys.stdin :
                lines += line
        except (EOFError, KeyboardInterrupt):
            print # end in newline
            sys.exit(1)
            print( lines )
        try :
            j = json.loads(lines)
        except :
            print( "Error parsing JSON!" )
            continue
        break

        if  not "wif_private_key" in j or \
            not "native_address" in j :
            print( "invalid JSON format! Missing native_address and private_key!" )
            continue

    wif = j[ "wif_private_key" ]
    add = j[ "native_address" ]
    ''' Verify that the private keys gives access to address in add '''
    assert Address.priv2btsaddr(Address.wif2hex(wif)) is not add, "private key for address %s is different from given address %s" %(Address.priv2btsaddr(Address.wif2hex(wif)), add) 

    pw = ""
    if args.encrypt :
        import getpass
        while True :
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if(pw == pwck) : 
                break
            else :
                print("Given Passphrases do not match!")

    front,back = Paper.paperwallet(wif, add, args.amount, args.asset, encrypt=pw, design=args.design)

    extension = os.path.splitext(args.filename)[1]
    if extension == ".svg" :
        open(args.filename, 'wb').write(front)
        open(args.filename.replace('.svg','-back.svg'), 'wb').write(back)
    elif extension == ".pdf" :
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader
        merger = PdfFileMerger()
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        merger.write(args.filename)
    else :
        print("unknown extension %s" % extension)
        return
コード例 #7
0
def main():
    parser = argparse.ArgumentParser(
        description='Construct a paperwallet and store svg file')
    parser.add_argument('filename',
                        type=str,
                        help='Output file name to store SVG in')
    parser.add_argument('--amount',
                        type=str,
                        help='Text (amount) to be placed on the paper wallet')
    parser.add_argument('--asset',
                        type=str,
                        help='Asset label to be placed on the paper wallet')
    parser.add_argument('--design',
                        type=str,
                        help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument('-encrypt',
                        help='Encrypt private key with BIP38!',
                        action='store_true')
    parser.set_defaults(design="cass")
    args = parser.parse_args()

    while True:
        lines = ""
        try:
            for line in sys.stdin:
                lines += line
        except (EOFError, KeyboardInterrupt):
            print  # end in newline
            sys.exit(1)
            print(lines)
        try:
            j = json.loads(lines)
        except:
            print("Error parsing JSON!")
            continue
        break

        if  not "wif_private_key" in j or \
            not "native_address" in j :
            print(
                "invalid JSON format! Missing native_address and private_key!")
            continue

    wif = j["wif_private_key"]
    add = j["native_address"]
    ''' Verify that the private keys gives access to address in add '''
    assert Address.priv2btsaddr(
        Address.wif2hex(wif)
    ) is not add, "private key for address %s is different from given address %s" % (
        Address.priv2btsaddr(Address.wif2hex(wif)), add)

    pw = ""
    if args.encrypt:
        import getpass
        while True:
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if (pw == pwck):
                break
            else:
                print("Given Passphrases do not match!")

    front, back = Paper.paperwallet(wif,
                                    add,
                                    args.amount,
                                    args.asset,
                                    encrypt=pw,
                                    design=args.design)

    extension = os.path.splitext(args.filename)[1]
    if extension == ".svg":
        open(args.filename, 'wb').write(front)
        open(args.filename.replace('.svg', '-back.svg'), 'wb').write(back)
    elif extension == ".pdf":
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader
        merger = PdfFileMerger()
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
        merger.append(PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        merger.write(args.filename)
    else:
        print("unknown extension %s" % extension)
        return
コード例 #8
0
def main():
    parser = argparse.ArgumentParser(
        description='Construct paperwallets according to file')
    parser.add_argument('--design',
                        type=str,
                        help='Design of the paperwallet (defaults to "cass")')
    parser.add_argument('-svg',
                        help='Store as SVG instead of PDF',
                        action='store_true')
    parser.add_argument('--amount',
                        type=str,
                        help='Text (amount) to be placed on the paper wallet')
    parser.add_argument('--asset',
                        type=str,
                        help='Asset label to be placed on the paper wallet')
    parser.add_argument('-encrypt',
                        help='Encrypt private key with BIP38!',
                        action='store_true')
    parser.add_argument(
        '--back_qr',
        help='Content of the QR-code on the back of the paper wallet',
        action='store_true')
    parser.add_argument('--back_text1',
                        help='Text field 1 on the back of the paper wallet',
                        action='store_true')
    parser.add_argument('--back_text2',
                        help='Text field 2 on the back of the paper wallet',
                        action='store_true')
    parser.add_argument('--back_text3',
                        help='Text field 3 on the back of the paper wallet',
                        action='store_true')
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--wallet',
                       type=str,
                       help='wallet csv file (i.e. generated by sharedrop.py)')
    group.add_argument('--number',
                       type=int,
                       help='Number of wallets to create randomly')
    parser.set_defaults(design="cass", amount="", asset=None)
    parser.set_defaults(back_text1="Install the BitShares App.",
                        back_text2="Load your funds from the wallet",
                        back_text3="Buy the BitShares 101 Book for $1",
                        back_qr="http://cryptofresh.com/products/8?r=xeroc")
    args = parser.parse_args()
    '''
    Optionally encrypt with BIP38
    '''
    pw = ""
    if args.encrypt:
        import getpass
        while True:
            pw = getpass.getpass('Passphrase: ')
            pwck = getpass.getpass('Retype passphrase: ')
            if (pw == pwck):
                break
            else:
                print("Given Passphrases do not match!")
    '''
    Construct data or read data from file
    '''
    wallet = []
    if args.wallet:
        with open(args.wallet, 'r') as csvfile:
            spamwriter = csv.reader(csvfile, delimiter=';')
            for wif, add, amount, asset in spamwriter:
                ''' Verify that the private keys gives access to address in add '''
                assert Address.priv2btsaddr(
                    Address.wif2hex(wif)
                ) is not add, "private key for address %s is different from given address %s" % (
                    Address.priv2btsaddr(Address.wif2hex(wif)), add)
                wallet.append([wif, add, amount, asset])
    else:
        for i in xrange(0, args.number):
            wif = Address.newwif()
            add = Address.wif2btsaddr(wif)
            wallet.append([wif, add, args.amount, args.asset])
    '''
    Construct paper wallets
    '''
    print("Constructing paper wallets")
    if not args.svg:
        import svg2pdf
        import io
        from PyPDF2 import PdfFileMerger, PdfFileReader
        mergerfront = PdfFileMerger()
        mergerback = PdfFileMerger()
        for w in wallet:
            wif, add, amount, asset = w
            print("Creating Paperwallet for %s" % (add))
            front, back = Paper.paperwallet(wif,
                                            add,
                                            amount,
                                            asset,
                                            encrypt=pw,
                                            design=args.design,
                                            backtext1=args.back_text1,
                                            backtext2=args.back_text2,
                                            backtext3=args.back_text3,
                                            backQRcode=args.back_qr)

            if args.svg:
                filename = "paperwallets/%s.svg" % add
                open(filename.replace('.svg', '-front.svg'), 'wb').write(front)
                open(filename.replace('.svg', '-back.svg'), 'wb').write(back)
            else:
                mergerfront.append(
                    PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(front)))))
                mergerback.append(
                    PdfFileReader(io.BytesIO(bytes(svg2pdf.svg2pdf(back)))))
        mergerfront.write("paperwallets-front.pdf")
        mergerback.write("paperwallets-back.pdf")
    else:
        for w in wallet:
            wif, add, amount, asset = w
            print("Creating Paperwallet for %s" % (add))
            front, back = Paper.paperwallet(wif,
                                            add,
                                            amount,
                                            asset,
                                            encrypt=pw,
                                            design=args.design,
                                            backtext1=args.back_text1,
                                            backtext2=args.back_text2,
                                            backtext3=args.back_text3,
                                            backQRcode=args.back_qr)

            filename = "paperwallets/%s.svg" % add
            open(filename.replace('.svg', '-front.svg'), 'wb').write(front)
            open(filename.replace('.svg', '-back.svg'), 'wb').write(back)
    print("Done.")
コード例 #9
0
def main():
    parser = argparse.ArgumentParser(
        description='Tool to update the voter key of a coldstorage address')
    parser.add_argument(
        '--voteaddress',
        type=str,
        help='address that will be allowed to vote with cold funds instead')
    parser.add_argument(
        '--account',
        type=str,
        help='account that will be allowed to vote with cold funds instead')
    parser.add_argument('--rpcurl', type=str, help='')
    parser.add_argument('--rpcuser', type=str, help='')
    parser.add_argument('--rpcpasswd', type=str, help='')
    parser.add_argument('--output',
                        type=str,
                        help='filename into which the signed output is stored')
    parser.set_defaults(rpcurl=config.url,
                        rpcuser=config.user,
                        rpcpasswd=config.passwd)
    parser.set_defaults(output="signedtx.txt")
    args = parser.parse_args()
    slate_id = None
    ''' Connect to bitshares client via RPC '''
    rpc = bitsharesrpc.client(args.rpcurl, args.rpcuser, args.rpcpasswd)

    if not args.voteaddress and not args.account:
        print("No voteaddress given! Please specify!")
        args.voteaddress = ask_for_address()
    if args.account:
        args.voteaddress = rpc.wallet_address_create(args.account)["result"]
        print("Using %s from account %s" % (args.voteaddress, args.account))
    ''' Ask for the private key '''
    privkey = ask_for_privkey()
    address = Address.priv2btsaddr(Address.wif2hex(privkey))
    ''' balance ids '''
    balances = rpc.blockchain_list_address_balances(address)["result"]
    print(
        "This address holds the following BTS funds (ignoring other assets):")
    ops = []
    for balance in balances:
        balanceId = balance[0]
        asset_id = balance[1]["condition"]["asset_id"]
        asset = rpc.blockchain_get_asset(asset_id)["result"]
        if asset_id == 0:
            if balance[1]["balance"] == 0: continue
            print("- %f BTS" %
                  ((balance[1]["balance"]) / float(asset["precision"])))
            votekeyop = Transaction.UpdateBalanceVote(balanceId,
                                                      args.voteaddress,
                                                      slate_id)
            ops.append(
                Transaction.Operation("update_balance_vote_op_type",
                                      votekeyop))

    tx = Transaction.Transaction(60 * 60 * 12, None, ops)
    sigtx = Transaction.SignedTransaction(tx, [privkey])
    ''' Store signed transaction '''
    with open(args.output, "wb") as fp:
        fp.write(json.dumps(sigtx.tojson()))
    print(
        "\n%d transaction successfully signed and output written to file '%s'"
        % (len(ops), args.output))
    print(
        "To broadcast transaction copy the file and run ./broadcast_signed_tx.py on online computer"
    )