Esempio n. 1
0
        seed = mn_decode(words)
        print(seed)
    password = getpass.getpass('Enter wallet encryption passphrase: ')
    password2 = getpass.getpass('Reenter wallet encryption passphrase: ')
    if password != password2:
        print('ERROR. Passwords did not match')
        sys.exit(0)
    if password == "":
        print('============= WARNING =============')
        print('Using no password is very dangerous')
        print('===================================')
        abort = query_yes_no('Abort?')
        if abort:
            sys.exit(0)
    password_key = btc.bin_dbl_sha256(password)
    encrypted_seed = encryptData(password_key, seed.decode('hex'))
    timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
    walletfile = json.dumps({
        'creator': 'joinmarket project',
        'creation_time': timestamp,
        'encrypted_seed': encrypted_seed.encode('hex'),
        'network': get_network()
    })

    default_walletname = 'wallet.json'
    walletpath = os.path.join('wallets', default_walletname)
    input_greeting = 'Input wallet file name (default: wallet.json): '
    i = 1
    while os.path.isfile(walletpath):
        temp_walletname = default_walletname
        default_walletname = 'wallet{0}.json'.format(i)
Esempio n. 2
0
     print("Write down this wallet recovery seed\n\n" + " ".join(words) + "\n")
 elif method == "recover":
     words = raw_input("Input 12 word recovery seed: ")
     words = words.split()  # default for split is 1 or more whitespace chars
     if len(words) != 12:
         print("ERROR: Recovery seed phrase must be exactly 12 words.")
         sys.exit(0)
     seed = mn_decode(words)
     print(seed)
 password = getpass.getpass("Enter wallet encryption passphrase: ")
 password2 = getpass.getpass("Reenter wallet encryption passphrase: ")
 if password != password2:
     print("ERROR. Passwords did not match")
     sys.exit(0)
 password_key = btc.bin_dbl_sha256(password)
 encrypted_seed = encryptData(password_key, seed.decode("hex"))
 timestamp = datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S")
 walletfile = json.dumps(
     {
         "creator": "joinmarket project",
         "creation_time": timestamp,
         "encrypted_seed": encrypted_seed.encode("hex"),
         "network": get_network(),
     }
 )
 walletname = raw_input("Input wallet file name (default: wallet.json): ")
 if len(walletname) == 0:
     walletname = "wallet.json"
 walletpath = os.path.join("wallets", walletname)
 # Does a wallet with the same name exist?
 if os.path.isfile(walletpath):
Esempio n. 3
0
                # address is used

                # r = raw_input('WARNING: Using uncompressed private key, the vast ' +
                #   'majority of JoinMarket transactions use compressed keys\n' +
                #       'being so unusual is bad for privacy. Continue? (y/n):')
                # if r != 'y':
                #   sys.exit(0)
                print('Uncompressed privkeys not supported (yet)')
                print(privkey, 'skipped')
                continue
        if btc.secp_present:
            privkey_bin = btc.from_wif_privkey(privkey,
                                        vbyte=get_p2pk_vbyte()).decode('hex')[:-1]
        else:
            privkey_bin = btc.encode_privkey(privkey, 'hex').decode('hex')
        encrypted_privkey = encryptData(wallet.password_key, privkey_bin)
        if 'imported_keys' not in wallet.walletdata:
            wallet.walletdata['imported_keys'] = []
        wallet.walletdata['imported_keys'].append(
            {'encrypted_privkey': encrypted_privkey.encode('hex'),
             'mixdepth': options.mixdepth})
    if wallet.walletdata['imported_keys']:
        fd = open(wallet.path, 'w')
        fd.write(json.dumps(wallet.walletdata))
        fd.close()
        print('Private key(s) successfully imported')
elif method == 'listwallets':
    # Fetch list of wallets
    possible_wallets = []
    for (dirpath, dirnames, filenames) in os.walk('wallets'):
        possible_wallets.extend(filenames)