S
S
SashaN692021-04-02 12:14:10
Python
SashaN69, 2021-04-02 12:14:10

Error Transaction broadcast failed, or Unspents were already used.?

I'm trying to accept bitcoin with this

from bit import Key
from bb import Order
owner_btc_address = '' # Установить биткоин кошелек владельца

def create_payment(order_id, amount):
    key = Key()
    thereis_order = Order.get_or_none(order_id=str(order_id))

    if not thereis_order:
        o = Order.create(
            key=key.to_hex(),
            order_id=str(order_id),
            order_amount=amount
        )

        address = key.address
        return address

def check_payment(order_id):
    o = Order.get(order_id=str(order_id))
    if not o.is_paid:
        address = Key.from_hex(o.key)

        balance = address.get_balance('btc')
        print(balance)
        utxos = address.get_unspents()
        print(utxos)

        if float(balance)>=o.order_amount:
            address.send([(owner_btc_address, 0.000155, 'btc')], unspents=utxos, fee=1)
            return True
    else:
        return True
    return False



#create_payment()
print(check_payment('123'))

The address was successfully generated for the test, sent $10 worth of bitcoins there, print(balance) shows that the bitcoin is there, but when I call check_payment, I get an error raise ConnectionError('Transaction broadcast failed, or Unspents were already used.')
ConnectionError: Transaction broadcast failed, or Unspents were already used and the money does not arrive on the wallet in the pool, there are no new transactions either. What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SashaN69, 2021-04-02
@SashaN69

The problem was solved by increasing the fee

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question