1200wd / bitcoinlib

Bitcoin and other Cryptocurrencies Library for Python. Includes a fully functional wallet, Mnemonic key generation and management and connection with various service providers to receive and send blockchain and transaction information.
http://bitcoinlib.readthedocs.io/
GNU General Public License v3.0
596 stars 199 forks source link

Error creating wallet from wif #380

Closed esmerlinp closed 5 months ago

esmerlinp commented 6 months ago
from bitcoinlib.wallets import Wallet
from bitcoinlib.keys import HDKey

wif ='vprv9QaUG9asejK249oLzs7...'
hdkey = HDKey().from_wif(wif=wif, network="testnet")

w = wallet_create_or_open('tempWallet', hdkey)

in _create raise WalletError("Depth of provided public master key %d does not correspond with key path " bitcoinlib.wallets.WalletError: Depth of provided public master key 5 does not correspond with key path ['m', "purpose'", "coin_type'", "account'", 'change', 'address_index']. Did you provide correct witness_type and multisig attribute?

mccwdev commented 5 months ago

I could not reproduce your error, this code works for me:

wif = 'vprv9DMUxX4ShgxML7PEzp5pFKW79iGxExn8aRt6ScVsnXFCo9cHoBwHLajKtMfMX75dPzcW4x7EouLCyWi1oJQejkV6K5Ksm9jx5K2rxzK7qCX'
hdkey = HDKey().from_wif(wif=wif, network="testnet")
w = wallet_create_or_open('tempWallet', hdkey)

But you can also directly use the wif code to create a wallet

wif = 'vprv9DMUxX4ShgxML7PEzp5pFKW79iGxExn8aRt6ScVsnXFCo9cHoBwHLajKtMfMX75dPzcW4x7EouLCyWi1oJQejkV6K5Ksm9jx5K2rxzK7qCX'
w = wallet_create_or_open('tempWallet', wif)