使用 bip-utils 重新生成 BRD 钱包创建的 4 年历史的比特币地址

问题描述 投票:0回答:1

我有一个比特币钱包,最初是我 4 年前使用 BRD 钱包应用程序创建的,后来成为了 Coinbase 钱包应用程序。我出于教育目的而玩弄这个钱包,它不包含大量资金,所以我不怕犯错误。

我有这个钱包的恢复密码,并已成功重新生成(在 python 脚本中;使用 bip-utils)与我当前在 Coinbase 钱包应用程序中看到的完全相同的 Bech32 地址(以“bc1”开头)。这证实了我的恢复短语是正确的。

但是,我正在努力重新生成当时用于接收交易的旧 P2PKH 地址(以“1”开头)。尽管跨多个帐户生成了数千个地址(1000 个不同帐户的 1000 个地址),但我无法重现这个特定的 P2PKH 地址。

from bip_utils import Bip39SeedGenerator, Bip44, Bip44Coins, Bip44Changes

def explore_addresses(mnemonic, account=0, num_addresses=20):
    # Generate seed from mnemonic
    seed = Bip39SeedGenerator(mnemonic).Generate()

    # Generate wallet
    bip44_mst = Bip44.FromSeed(seed, Bip44Coins.BITCOIN)
    bip44_acc = bip44_mst.Purpose().Coin().Account(account)
    bip44_ext = bip44_acc.Change(Bip44Changes.CHAIN_EXT)

    # Interate addresses within the specified account
    addresses = []
    for i in range(num_addresses):
        address = bip44_ext.AddressIndex(i).PublicKey().ToAddress()
        addresses.append((i, address))

    return addresses


mnemonic = '<my recovery phrase from coinbasewallet>'
for account in range(1000):
    addresses = explore_addresses(mnemonic, account, num_addresses=1000)
    for index, address in addresses:
        if address.startswith('12vHA'):
            print(f"Index {index}: {address}")

重新生成旧的 P2PKH 地址时可能会遗漏什么? BRD 使用的特定派生路径或钱包配置是否与标准 BIP44 路径不同?

我很感激任何有关如何成功重新生成特定 P2PKH 地址的见解。

cryptography blockchain bitcoin
1个回答
0
投票

您的旧版P2PKH钱包可能不是分层确定性钱包(HD Wallt)。您需要做的就是

print('0x' + seed.hex())
,然后将种子直接导入您的钱包作为WIF格式的私钥。

$ git clone https://github.com/mohanson/pybtc
$ cd pybtc
import btc

prikey = btc.core.PriKey(int.fromhex('YOUR SEED', 16))
print('WIFs', prikey.wif())
p2pkh_address = btc.core.address_p2pkh(prikey.pubkey())
print('Addr', p2pkh_address)
© www.soinside.com 2019 - 2024. All rights reserved.