Mels Hakobyan
Mels Hakobyan

Reputation: 45

Python bit for bitcoin transactions send() method doesn't work

I am trying to create and broadcast a transaction with help of bit library in python, here is the code -

from bit import PrivateKeyTestnet

main_key = PrivateKeyTestnet('MyWalletWIF')
tx_hash = main_key.send([("RecievingAddress", 67000, 'satoshi')], fee=200, absolute_fee=True, leftover="MyWalletAddress")

My wallet has 3605376 satoshi on it's balance (btc testnet) as a single UTXO. The code throws the following error -

/usr/local/lib/python3.7/dist-packages/bit/network/services.py in broadcast_tx_testnet(cls, tx_hex)


   1248 
   1249         if success is False:
-> 1250             raise ConnectionError('Transaction broadcast failed, or Unspents were already used.')
   1251 
   1252         raise ConnectionError('All APIs are unreachable.')

ConnectionError: Transaction broadcast failed, or Unspents were already used.

Upvotes: -1

Views: 771

Answers (1)

Mels Hakobyan
Mels Hakobyan

Reputation: 45

Still don't understand what was the issue but I solved it by removing fee related part of the code, and it worked

tx_hash = main_key.send([("RecievingAddress", 67000, 'satoshi')], leftover="MyWalletAddress")

Upvotes: 0

Related Questions