Skip to content

Commit

Permalink
FIx getting send address
Browse files Browse the repository at this point in the history
Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
  • Loading branch information
r4rdsn committed Nov 22, 2019
1 parent 9e4fa24 commit 5e1c30c
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/handlers/escrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ async def set_counter_send_address(
}
)
escrow_user = offer.init
from_address = offer.init["send_address"]
send_reply = True
elif offer.type == "sell":
memo = template.format(
Expand All @@ -678,19 +679,17 @@ async def set_counter_send_address(
}
)
escrow_user = offer.counter
from_address = address
send_reply = False

update = {
"counter.send_address": address,
"transaction_time": time(),
"memo": memo,
}
await offer.update_document(
{"$set": update, "$unset": {"pending_input_from": True}}
await get_escrow_instance(offer[offer.type]).check_transaction(
offer._id,
from_address,
offer["sum_fee_up"].to_decimal(),
offer[f"sum_{offer.type}"].to_decimal(),
offer[offer.type],
memo,
)
counter = dict(offer.counter)
counter.update({"send_address": address})
offer = replace(offer, counter=counter)
keyboard = InlineKeyboardMarkup()
keyboard.add(
InlineKeyboardButton(
Expand All @@ -699,15 +698,6 @@ async def set_counter_send_address(
)
)
escrow_address = markdown.bold(get_escrow_instance(offer[offer.type]).address)
await state.finish()
await get_escrow_instance(offer[offer.type]).check_transaction(
offer._id,
escrow_user["send_address"],
offer["sum_fee_up"].to_decimal(),
offer[f"sum_{offer.type}"].to_decimal(),
offer[offer.type],
memo,
)
answer = _("Send {} {} to address {}", locale=escrow_user["locale"]).format(
offer.sum_fee_up, offer[offer.type], escrow_address
)
Expand All @@ -731,6 +721,15 @@ async def set_counter_send_address(
reply_markup=keyboard,
parse_mode=ParseMode.MARKDOWN,
)
update = {
"counter.send_address": address,
"transaction_time": time(),
"memo": memo,
}
await offer.update_document(
{"$set": update, "$unset": {"pending_input_from": True}}
)
await state.finish()


@escrow_callback_handler(lambda call: call.data.startswith("escrow_cancel "))
Expand Down

0 comments on commit 5e1c30c

Please sign in to comment.