Skip to content

Commit

Permalink
Limit waiting time to confirm a deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
aguillon committed Mar 13, 2024
1 parent 87959d7 commit f7fdb39
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/tezos.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,20 @@ def check_credits(db, estimated_fees):

async def confirm_deposit(tx_hash, payer, amount: Union[int, str]):
receiver = ptz.key.public_key_hash()
op_result = await find_transaction(tx_hash)
return any(
op
for op in op_result["contents"]
if op["kind"] == "transaction"
and op["source"] == payer
and op["destination"] == receiver
and int(op["amount"]) == int(amount)
)
block_time = int(constants["minimal_block_delay"])
try:
async with asyncio.timeout(2*block_time):
op_result = await find_transaction(tx_hash)
return any(
op
for op in op_result["contents"]
if op["kind"] == "transaction"
and op["source"] == payer
and op["destination"] == receiver
and int(op["amount"]) == int(amount)
)
except TimeoutError:
return False


async def confirm_withdraw(tx_hash, db, user_id, withdraw):
Expand Down

0 comments on commit f7fdb39

Please sign in to comment.