コード例 #1
0
def wallet_generate_recover(method, walletspath,
                            default_wallet_name='wallet.json'):
    if jm_single().config.get("POLICY", "segwit") == "true":
        #Here using default callbacks for scripts (not used in Qt)
        return wallet_generate_recover_bip39(method, walletspath,
                                             default_wallet_name)
    if method == 'generate':
        seed = btc.sha256(os.urandom(64))[:32]
        words = mn_encode(seed)
        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.')
            return False
        seed = mn_decode(words)
        print(seed)
    password = cli_get_wallet_passphrase_check()
    if not password:
        return False
    password_key = btc.bin_dbl_sha256(password)
    encrypted_seed = encryptData(password_key, seed.decode('hex'))
    return persist_walletfile(walletspath, default_wallet_name, encrypted_seed)
コード例 #2
0
def wallet_showseed(wallet):
    if isinstance(wallet, Bip39Wallet):
        if not wallet.entropy:
            return "Entropy is not initialized."
        m = Mnemonic("english")
        return "Wallet recovery seed\n\n" + m.to_mnemonic(
            wallet.entropy) + "\n"
    hexseed = wallet.seed
    print("hexseed = " + hexseed)
    words = mn_encode(hexseed)
    return "Wallet recovery seed\n\n" + " ".join(words) + "\n"
コード例 #3
0
def wallet_showseed(wallet):
    if isinstance(wallet, Bip39Wallet):
        if not wallet.entropy:
            return "Entropy is not initialized."
        m = Mnemonic("english")
        text = "Wallet mnemonic recovery phrase:\n\n" + m.to_mnemonic(wallet.entropy) + "\n"
        if wallet.mnemonic_extension:
            text += '\nWallet mnemonic extension: ' + wallet.mnemonic_extension + '\n'
        return text
    hexseed = wallet.seed
    print("hexseed = " + hexseed)
    words = mn_encode(hexseed)
    return "Wallet mnemonic seed phrase:\n\n" + " ".join(words) + "\n"
コード例 #4
0
ファイル: wallet-tool.py プロジェクト: fivepiece/CoinSwapCS
                used = (' used' if balance > 0.0 else 'empty')
                balance_depth += balance
                if options.showprivkey:
                    wip_privkey = btc.wif_compressed_privkey(
                    privkey, get_p2pk_vbyte())
                else:
                    wip_privkey = ''
                cus_print(' ' * 13 + '%-35s%s %.8f btc %s' % (
                    addr, used, balance / 1e8, wip_privkey))
        total_balance += balance_depth
        print('for mixdepth=%d balance=%.8fbtc' % (m, balance_depth / 1e8))
    print('total balance = %.8fbtc' % (total_balance / 1e8))
elif method == 'generate' or method == 'recover':
    if method == 'generate':
        seed = btc.sha256(os.urandom(64))[:32]
        words = mn_encode(seed)
        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)