Пример #1
0
def unlock_wallet(display_enabled=False):

    try:
        password = raw_input("Enter wallet password: "******"Incorrect password."
        else:
            print "Unlocked wallet."
            wallet = HDWallet(hex_privkey)
            child = wallet.get_child_keypairs(count=2, include_privkey=True)
            payment_keypair = child[0]
            owner_keypair = child[1]
            save_keys_to_memory(payment_keypair, owner_keypair)
            if display_enabled:
                display_wallet_info(payment_keypair[0], owner_keypair[0])
    except KeyboardInterrupt:
        print "\nExited."
Пример #2
0
def unlock_wallet(display_enabled=False):

    if walletUnlocked():
        if display_enabled:
            payment_address, owner_address = get_addresses_from_file()
            display_wallet_info(payment_address, owner_address)
    else:

        try:
            password = getpass("Enter wallet password: "******"Incorrect password.")
            else:
                print "Unlocked wallet."
                wallet = HDWallet(hex_privkey)
                child = wallet.get_child_keypairs(count=2,
                                                  include_privkey=True)
                payment_keypair = child[0]
                owner_keypair = child[1]
                save_keys_to_memory(payment_keypair, owner_keypair)

                if display_enabled:
                    display_wallet_info(payment_keypair[0], owner_keypair[0])
        except KeyboardInterrupt:
            print "\nExited."
Пример #3
0
def initialize_wallet():

    result = {}
    print "Initializing new wallet ..."
    password = "******"

    try:
        while len(password) < WALLET_PASSWORD_LENGTH:
            password = getpass("Enter new password: "******"Password is too short. Please make it at"
                msg += " least %s characters long" % WALLET_PASSWORD_LENGTH
                print msg
            else:

                confirm_password = getpass("Confirm new password: "******"Passwords don't match.")

                temp_wallet = HDWallet()
                hex_privkey = temp_wallet.get_master_privkey()

                hex_password = hexlify(password)

                wallet = HDWallet(hex_privkey)
                child = wallet.get_child_keypairs(count=2)

                encrypted_key = aes_encrypt(hex_privkey, hex_password)
                wallet_file_data = {}
                wallet_file_data[
                    'encrypted_master_private_key'] = encrypted_key
                wallet_file_data['payment_addresses'] = [child[0]]
                wallet_file_data['owner_addresses'] = [child[1]]

                print "\nWallet created! Make sure to...\n", \
                      "  1. Remember your password and write it down in a safe place\n", \
                      "  2. Back up your encrypted master private key:\n\n", \
                      "     " + encrypted_key + "\n"

                input_prompt = "Have you backed up your private key? (y/n): "
                user_input = raw_input(input_prompt)
                user_input = user_input.lower()

                if user_input == 'y':
                    file = open(WALLET_PATH, 'w')
                    file.write(json.dumps(wallet_file_data))
                    file.close()
                    print ""
                else:
                    exit_with_error(
                        "Wallet could not be created. Try again and make sure to complete the backup process."
                    )

    except KeyboardInterrupt:
        exit_with_error("\nExited.")

    return result