使用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多个与主公钥相关的地址
创建钱包时,bitcoinlib仅生成主密钥和派生密钥地址
要创建新的付款和更改地址,您可以使用:
或获取10个新的未使用地址(无论是否创建):
注意:command wallet.addresslist(depth=-1)显示所有生成的地址,还有主密钥、支付/更改密钥以及两者之间的所有内容。通常,wallet.addresslist()应该足够了:它只返回用于更改和支付的密钥/地址
相关问题 更多 >
编程相关推荐