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
606 stars 201 forks source link

Not able to make transaction using seedphrase. "No UXTO's found" #232

Closed anthonybudd closed 2 years ago

anthonybudd commented 2 years ago

I have a wallet that has ~$100 of BTC on it. I'm trying to make a programmatic transaction using Bitcoinlib but I am getting this error:

bitcoinlib.wallets.WalletError: Create transaction: No unspent transaction outputs found or no key available for UTXO's

In the code I am loading the seedphrase for the wallet with the $100 wallet (line 7, mainKey...). As per the docs I am using the scan() method to Update all UTXO’s and balances. I would have thought the scan method would find that there is a balance however the error would suggest that it is not.

Can anyone point out something obvious I'm doing wrong or is this an issue with the library?.

CODE:

from bitcoinlib.wallets import Wallet
from bitcoinlib.keys import HDKey
import random
import string

walletName = 'MAIN-'+''.join(random.choices(string.ascii_lowercase, k=10))
mainKey = HDKey().from_seed("SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE")
mainWallet = Wallet.create(name=walletName, keys=mainKey)
mainWallet.scan()
mainWallet.info()

anotherWallet = "SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE SEED PHRASE"
anotherWalletName = ''.join(random.choices(string.ascii_lowercase, k=10))
k = HDKey().from_seed(anotherWallet)
w = Wallet.create(name=anotherWalletName, keys=k)
address = w.get_key().address
print(address)
tx = mainWallet.send_to(address, '0.00001958 BTC')
tx.info()
mccwdev commented 2 years ago

The code looks correct to me.

Does mainWallet.info() show the utxo? Do you see any warnings or errors in the logs? I assume there is a problem with one of the service providers.

Another thing could be that you probably create many wallets with a different name, but same masterkey. There could be some conflict there. I will run some tests.

mccwdev commented 2 years ago

I could not reproduce the error using the same code. Are you using the latest version of the library?

If so please let me know if you found any errors in the logs.

0xBLCKLPTN commented 1 year ago

Hey, I have the same problem. shot