This commit is contained in:
Reckless_Satoshi 2022-01-06 15:33:55 -08:00
parent 31b19ce18c
commit 6a1a906bea
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 6 additions and 3 deletions

View File

@ -131,7 +131,6 @@ class Logics():
order.save()
return True, None
# 2) When maker cancels after bond
'''The order dissapears from book and goes to cancelled.
Maker is charged a small amount of sats, to prevent DDOS
@ -171,7 +170,7 @@ class Logics():
order.satoshis_now = cls.satoshis_now(order)
bond_satoshis = int(order.satoshis_now * BOND_SIZE)
description = f'RoboSats - Maker bond for order ID {order.id}. These sats will return to you if you do not cheat!'
description = f'RoboSats - Publishing {str(order)} - This bond will return to you if you do not cheat.'
# Gen HODL Invoice
invoice, payment_hash, expires_at = LNNode.gen_hodl_invoice(bond_satoshis, description, BOND_EXPIRY*3600)
@ -205,7 +204,7 @@ class Logics():
order.satoshis_now = cls.satoshis_now(order)
bond_satoshis = int(order.satoshis_now * BOND_SIZE)
description = f'RoboSats - Taker bond for order ID {order.id}. These sats will return to you if you do not cheat!'
description = f'RoboSats - Taking {str(order)} - This bond will return to you if you do not cheat.'
# Gen HODL Invoice
invoice, payment_hash, expires_at = LNNode.gen_hodl_invoice(bond_satoshis, description, BOND_EXPIRY*3600)

View File

@ -128,6 +128,10 @@ class Order(models.Model):
# buyer payment LN invoice
buyer_invoice = models.ForeignKey(LNPayment, related_name='buyer_invoice', on_delete=models.SET_NULL, null=True, default=None, blank=True)
def __str__(self):
# Make relational back to ORDER
return (f'Order {self.id}: {self.Types(self.type).label} {"{:,}".format(self.t0_satoshis)} Sats for {self.Currencies(self.currency).label}')
@receiver(pre_delete, sender=Order)
def delelete_HTLCs_at_order_deletion(sender, instance, **kwargs):
to_delete = (instance.maker_bond, instance.buyer_invoice, instance.taker_bond, instance.trade_escrow)