Handle LND down response to clients

This commit is contained in:
Reckless_Satoshi 2022-02-08 02:05:22 -08:00
parent 849ef0c4a7
commit 715d7ebf6d
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -532,10 +532,14 @@ class Logics():
description = f"RoboSats - Publishing '{str(order)}' - Maker bond - This payment WILL FREEZE IN YOUR WALLET, check on the website if it was successful. It will automatically return unless you cheat or cancel unilaterally." description = f"RoboSats - Publishing '{str(order)}' - Maker bond - This payment WILL FREEZE IN YOUR WALLET, check on the website if it was successful. It will automatically return unless you cheat or cancel unilaterally."
# Gen hold Invoice # Gen hold Invoice
hold_payment = LNNode.gen_hold_invoice(bond_satoshis, try:
description, hold_payment = LNNode.gen_hold_invoice(bond_satoshis,
invoice_expiry=Order.t_to_expire[Order.Status.WFB], description,
cltv_expiry_secs=BOND_EXPIRY*3600) invoice_expiry=Order.t_to_expire[Order.Status.WFB],
cltv_expiry_secs=BOND_EXPIRY*3600)
except Exception as e:
if 'status = StatusCode.UNAVAILABLE' in str(e):
return False, {'bad_request':'The Lightning Network Daemon (LND) is down. Write in the Telegram group to make sure staff is aware.'}
order.maker_bond = LNPayment.objects.create( order.maker_bond = LNPayment.objects.create(
concept = LNPayment.Concepts.MAKEBOND, concept = LNPayment.Concepts.MAKEBOND,
@ -613,10 +617,15 @@ class Logics():
+ " - Taker bond - This payment WILL FREEZE IN YOUR WALLET, check on the website if it was successful. It will automatically return unless you cheat or cancel unilaterally.") + " - Taker bond - This payment WILL FREEZE IN YOUR WALLET, check on the website if it was successful. It will automatically return unless you cheat or cancel unilaterally.")
# Gen hold Invoice # Gen hold Invoice
hold_payment = LNNode.gen_hold_invoice(bond_satoshis, try:
description, hold_payment = LNNode.gen_hold_invoice(bond_satoshis,
invoice_expiry=Order.t_to_expire[Order.Status.TAK], description,
cltv_expiry_secs=BOND_EXPIRY*3600) invoice_expiry=Order.t_to_expire[Order.Status.TAK],
cltv_expiry_secs=BOND_EXPIRY*3600)
except Exception as e:
if 'status = StatusCode.UNAVAILABLE' in str(e):
return False, {'bad_request':'The Lightning Network Daemon (LND) is down. Write in the Telegram group to make sure staff is aware.'}
order.taker_bond = LNPayment.objects.create( order.taker_bond = LNPayment.objects.create(
concept = LNPayment.Concepts.TAKEBOND, concept = LNPayment.Concepts.TAKEBOND,
@ -678,11 +687,17 @@ class Logics():
description = f"RoboSats - Escrow amount for '{str(order)}' - It WILL FREEZE IN YOUR WALLET. It will be released to the buyer once you confirm you received the fiat. It will automatically return if buyer does not confirm the payment." description = f"RoboSats - Escrow amount for '{str(order)}' - It WILL FREEZE IN YOUR WALLET. It will be released to the buyer once you confirm you received the fiat. It will automatically return if buyer does not confirm the payment."
# Gen hold Invoice # Gen hold Invoice
hold_payment = LNNode.gen_hold_invoice(escrow_satoshis, try:
description, hold_payment = LNNode.gen_hold_invoice(escrow_satoshis,
invoice_expiry=Order.t_to_expire[Order.Status.WF2], description,
cltv_expiry_secs=ESCROW_EXPIRY*3600) invoice_expiry=Order.t_to_expire[Order.Status.WF2],
cltv_expiry_secs=ESCROW_EXPIRY*3600)
except Exception as e:
if 'status = StatusCode.UNAVAILABLE' in str(e):
return False, {'bad_request':'The Lightning Network Daemon (LND). Write in the Telegram group to make sure staff is aware.'}
order.trade_escrow = LNPayment.objects.create( order.trade_escrow = LNPayment.objects.create(
concept = LNPayment.Concepts.TRESCROW, concept = LNPayment.Concepts.TRESCROW,
type = LNPayment.Types.HOLD, type = LNPayment.Types.HOLD,