Python Code :

from bitcoinlib.wallets import Wallet

# Set up sender and recipient wallet addresses
sender_wallet = Wallet('L3ZoqFs7WYDUdCrzeNgY6ThKP8hEY2ozrpHgk4auDLpNbfeTaxyi')
recipient_wallet = 'bc1q98p7r9uqsg3xjwaj6e04d99c5u5rue6kvfl3yu'

# Set up transaction details
fee = 0.0001  # transaction fee
amount = 0.1  # amount to send
change = 0.0  # amount to send back to sender
data = None  # transaction data
message = "This is a test transaction"  # transaction message

# Create transaction and sign with sender's private key
tx = sender_wallet.send_to(recipient_wallet, amount, fee, change, data, message)
tx.sign(sender_wallet)

# Broadcast transaction to Bitcoin network
tx.broadcast()

I installed "bitcoinlib" module already. And when I run code I got error

Traceback (most recent call last):
  File "C:\Users\Admin\Desktop\BTC Flashing\sendcrypto.py", line 4, in <module>
    sender_wallet = Wallet('L3ZoqFs7WYDUdCrzeNgY6ThKP8hEY2ozrpHgk4auDLpNbfeTaxyi')
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Admin\AppData\Roaming\Python\Python311\site-packages\bitcoinlib\wallets.py", line 1408, in __init__
    raise WalletError("Wallet '%s' not found, please specify correct wallet ID or name." % wallet)
bitcoinlib.wallets.WalletError: Wallet 'L3ZoqFs7WYDUdCrzeNgY6ThKP8hEY2ozrpHgk4auDLpNbfeTaxyi' not found, please specify correct wallet ID or name.

I am aware of sharing my private key here. I have no issue.

I didn't find anything properly. Or may be I lost in space.

1

There are 1 answers

0
StasFQ On

You need to create a wallet first:

sender_wallet = Wallet.create('wallet name')

It should works