diff --git a/core/monero.py b/core/monero.py index 93a8807..f16dc85 100644 --- a/core/monero.py +++ b/core/monero.py @@ -1,9 +1,12 @@ +from logging import getLogger from django.conf import settings from monero.daemon import Daemon from monero.wallet import Wallet from monero.backends.jsonrpc import JSONRPCDaemon, JSONRPCWallet +logger = getLogger('django.server') + class AuctionDaemon(object): def __init__(self): self.host = settings.DAEMON_HOST @@ -50,3 +53,17 @@ class AuctionWallet(object): self.connected = False except: self.connected = False + + +def connect_rpc(rpc_type): + if rpc_type == "daemon": + rpc = AuctionDaemon() + elif rpc_type == "wallet": + rpc = AuctionWallet() + else: + logger.error('[ERROR] Invalid RPC type specified. Use "daemon" or "wallet"') + return False + if rpc.connected is False: + logger.error(f'[ERROR] Auction {rpc_type} is not connected. Stopping task.') + return False + return rpc \ No newline at end of file diff --git a/sales/tasks/payments.py b/sales/tasks/payments.py index a9a5894..69db8be 100644 --- a/sales/tasks/payments.py +++ b/sales/tasks/payments.py @@ -4,25 +4,12 @@ from huey import crontab from huey.contrib.djhuey import periodic_task from django.conf import settings from django.core.cache import cache -from core.monero import AuctionWallet, AuctionDaemon +from core.monero import connect_rpc from sales.models import ItemSale logger = logging.getLogger('django.server') -def connect_rpc(rpc_type): - if rpc_type == "daemon": - rpc = AuctionDaemon() - elif rpc_type == "wallet": - rpc = AuctionWallet() - else: - logger.error('[ERROR] Invalid RPC type specified. Use "daemon" or "wallet"') - return False - if rpc.connected is False: - logging.error(f'[ERROR] Auction {rpc_type} is not connected. Stopping task.') - return False - return rpc - @periodic_task(crontab(minute='*/2')) def poll_for_buyer_escrow_payments(): wallet_rpc = connect_rpc("wallet") diff --git a/sales/templatetags/search_block_explorer.py b/sales/templatetags/search_block_explorer.py index d6eef3b..f127f86 100644 --- a/sales/templatetags/search_block_explorer.py +++ b/sales/templatetags/search_block_explorer.py @@ -1,10 +1,17 @@ from django import template from django.conf import settings +from core.monero import connect_rpc register = template.Library() @register.filter(is_safe=True) def search_block_explorer(param): - search_url = f'{settings.BLOCK_EXPLORER}search?value={param}' - return search_url + daemon_rpc = connect_rpc('daemon') + if daemon_rpc: + net_type = daemon_rpc.daemon.info()['nettype'] + explorer_url = settings.BLOCK_EXPLORER % net_type + search_url = f'{explorer_url}/tx/{param}/autorefresh' + return search_url + else: + return '#' diff --git a/web/templates/sales/get_sale/item_received.html b/web/templates/sales/get_sale/item_received.html index 28e2093..d147678 100644 --- a/web/templates/sales/get_sale/item_received.html +++ b/web/templates/sales/get_sale/item_received.html @@ -22,7 +22,7 @@

Network Fee (XMR): {{ sale.network_fee_xmr }}

Total Payout (XMR): {{ total_seller_payout }}

Payout Address: {{ sale.item.payout_address }}

-

Payout Transaction ID: {{ sale.seller_payout_transaction }}

+

Payout Transaction ID: {{ sale.seller_payout_transaction }}


If you found the site useful and had a good experience, please consider sending a tip to the developer address provided at the bottom of the page.

Thanks for using {{ site_meta.name }}!

diff --git a/xmrauctions/settings.py b/xmrauctions/settings.py index 5828bd4..de1b10f 100644 --- a/xmrauctions/settings.py +++ b/xmrauctions/settings.py @@ -28,11 +28,7 @@ ALLOWED_HOSTS = str(os.environ['ALLOWED_HOSTS']).split(',') ESCROW_PERIOD_DAYS = os.environ.get('ESCROW_PERIOD_DAYS', 30) PLATFORM_FEE_PERCENT = os.environ.get('PLATFORM_FEE_PERCENT', 0) BLOCK_CONFIRMATIONS_RCV = os.environ.get('BLOCK_CONFIRMATIONS_RCV', 3) - -if DEBUG: - BLOCK_EXPLORER = 'https://community.xmr.to/explorer/stagenet/' -else: - BLOCK_EXPLORER = 'https://community.xmr.to/explorer/mainnet/' +BLOCK_EXPLORER = 'https://community.xmr.to/explorer/%s' # Application definition