You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
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 balances of all sale items'
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument('-a', '--all', action='store_true', help='Whether or not to scan whole wallet vs item sales', default=False)
|
|
|
|
def handle(self, *args, **kwargs):
|
|
aw = AuctionWallet()
|
|
if aw.connected is False:
|
|
raise Exception('Unable to connect to auction wallet RPC endpoint.')
|
|
|
|
msg = {'balances': []}
|
|
if kwargs.get('all', False):
|
|
for index,account in enumerate(aw.wallet.accounts):
|
|
msg['balances'].append({
|
|
"index": index,
|
|
"address": str(account.address()),
|
|
"outgoing": [str(i) for i in account.outgoing()],
|
|
"incoming": [str(i) for i in account.incoming()],
|
|
})
|
|
else:
|
|
item_sales = ItemSale.objects.all()
|
|
for sale in item_sales:
|
|
w = aw.wallet.accounts[sale.escrow_account_index]
|
|
msg['balances'].append({
|
|
"sale_id": sale.id,
|
|
"address": str(w.address()),
|
|
"outgoing": [str(i) for i in w.outgoing()],
|
|
"incoming": [str(i) for i in w.incoming()],
|
|
})
|
|
|
|
self.stdout.write(json.dumps(msg))
|