用 Bitcoinlib 制作了一个钱包,将key
参数设置为我的主公钥。但是,当尝试使用他们的depth=-1
标志打印我所有地址的列表时,应该显示与我的密钥关联的所有地址,但是它只返回一个包含 3 个地址的列表。
代码
# Creation of the wallet was done before like so:
# Wallet.create("Ledger", keys=xpub)
# However after creating a wallet Bitcoinlib stores it locally so you don't make one everytime.
from bitcoinlib.wallets import Wallet
import base64, secrets
def base64_encode(string: str):
b64 = base64.b64encode(string.encode('ascii'))
return b64.decode('ascii')
def base64_decode(string: str):
b64 = base64.b64decode(string.encode('ascii'))
return b64.decode('ascii')
xpub = base64_decode(secrets.xpub)
wallet = Wallet("Ledger")
print(wallet.addresslist(depth=-1))
输出:['bc1qg2rl6fjutq4knttna2cqlssjp3vlmr9g0wxvk5', 'bc1qw84m5u94tt8xujesl78yq5tnswm58r309nrmus', 'bc1qlu5yuz0vsm7r867mslgkf2v89976y8qtfflvps']
编辑:我知道主公钥有更多相关的地址,因为在 Electrum 它已经显示了与这个主公钥相关的 30 多个地址