0

I am trying to build a Bitcoin wallet that receives bitcoins and can transfer them to another wallet, I am using PYTHON.

step 1 ( create private_key, public_key and public_ address ):

        from bitcoin import *

        private_key=random_key()  #this is may private key to use in steep 3
        public_key=privtopub(private_key)
        address=pubtoaddr(public_key)    #1DgUiJ6v5Wd7uMQGsGSdiTNP4q1JKc1D5P 

This works and I get those public keys and the address to receive funds.

Steep 2 (send funds to public address)

I send funds to the newly created public address and verify them in the bitcoin explorer.

steep 3: (transfer funds to another wallet)

from bitcoinlib.wallets import Wallet
from bitcoinlib.wallets import wallet_create_or_open


private_key = private_key #this is a private key create in steep 1

w =wallet_create_or_open("Wallet 2025", keys=private_key, network= 'bitcoin', scheme='single')
         
address = w.get_key() #this address is the same address created in step 1 #1DgUiJ6v5Wd7uMQGsGSdiTNP4q1JKc1D5P 
           
w.utxos()
w.utxos_update()
w.scan()
w.info()

# here we try to send the funds, but it does not work
#Funds are not sent.
res = w.send_to(3LtQxpPR2W9MNzYeekaApmD8wzTSzCQjda, '0.0001 BTC', offline=False)
res.info()

this is the response of res.info()

Transaction 3c91e849a9f6832c602d32fdbae662d67e091091c8983911987c73444b3f8bc1 Date: None Network: bitcoin Version: 1 Witness type: legacy Status: new Verified: False Inputs

  • 1DgUiJ6v5Wd7uMQGsGSdiTNP4q1JKc1D5P 0.00015854 BTC 9d665e80adf9ea26cab104a6027ab37902c0a23874740fd6438519bb6b4c59ff 6 legacy sig_pubkey; sigs: 0 (1-of-1) not validated Outputs
  • 1DgUiJ6v5Wd7uMQGsGSdiTNP4q1JKc1D5P 0.00004739 BTC p2pkh U
  • 3LtQxpPR2W9MNzYeekaApmD8wzTSzCQjda 0.00010000 BTC p2sh U Size: 117 Vsize: 117 Fee: 1115 Confirmations: None Block: None Pushed to network: False Wallet: Wallet 2025 Errors: Cannot verify transaction

what is the error, because I can not send the funds.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.