adding new management commands for viewing sales and wallet balances
parent
5142d3ee1d
commit
059da3bcf6
@ -0,0 +1,36 @@
|
|||||||
|
import json
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from core.monero import AuctionWallet
|
||||||
|
from sales.models import ItemSale
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Shows mempool'
|
||||||
|
|
||||||
|
def handle(self, *args, **kwargs):
|
||||||
|
aw = AuctionWallet()
|
||||||
|
if aw.connected is False:
|
||||||
|
raise Exception('Unable to connect to auction wallet RPC endpoint.')
|
||||||
|
|
||||||
|
msg = {'sales': []}
|
||||||
|
item_sales = ItemSale.objects.all()
|
||||||
|
for sale in item_sales:
|
||||||
|
ew = aw.wallet.accounts[sale.escrow_account_index]
|
||||||
|
msg['sales'].append({
|
||||||
|
'account_index': sale.escrow_account_index,
|
||||||
|
'sale_id': sale.id,
|
||||||
|
'platform_paid': sale.platform_paid,
|
||||||
|
'expected_payment_xmr': sale.expected_payment_xmr,
|
||||||
|
'received_payment_xmr': sale.received_payment_xmr,
|
||||||
|
'item_shipped': sale.item_shipped,
|
||||||
|
'item_received': sale.item_received,
|
||||||
|
'escrow_complete': sale.escrow_complete,
|
||||||
|
'sale_finalized': sale.sale_finalized,
|
||||||
|
'escrow_wallet_balances': {
|
||||||
|
'locked': float(ew.balances()[0]),
|
||||||
|
'unlocked': float(ew.balances()[1])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
self.stdout.write(json.dumps(msg))
|
Reference in New Issue