Answer the question
In order to leave comments, you need to log in
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'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question