Compare commits
35 Commits
50164e9d5d
...
v1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
a56ffef656
|
|||
|
f1828d39a7
|
|||
|
2e743528d4
|
|||
|
3db0ba46d0
|
|||
|
80a4628d77
|
|||
|
47f210e51b
|
|||
|
2d574c0d46
|
|||
|
01d820368a
|
|||
|
71e59a9a95
|
|||
|
7a4300066f
|
|||
|
b5c3075fba
|
|||
|
3844acdaf8
|
|||
|
a1d1a6337e
|
|||
|
9507bc17a8
|
|||
|
c236cb964d
|
|||
|
08e6d5834d
|
|||
|
c568668b39
|
|||
|
a877b5bf9e
|
|||
|
22d301581b
|
|||
|
a888a3bd55
|
|||
|
c247aef2d5
|
|||
|
0118200098
|
|||
|
7e861534a6
|
|||
|
4b15a1aa0c
|
|||
|
fb9cb50a90
|
|||
|
209c3794fc
|
|||
|
8099320673
|
|||
|
aa92220756
|
|||
|
2595503dc0
|
|||
|
d516e91592
|
|||
|
b24a3147dd
|
|||
|
f8e03aca73
|
|||
|
38f08c069c
|
|||
|
16ac6c7d2b
|
|||
|
b0c7fcf779
|
@@ -10,7 +10,7 @@ COPY . /app
|
||||
|
||||
# Add mount point for data volume
|
||||
# VOLUME /data
|
||||
RUN apk add git
|
||||
RUN apk add git openssl
|
||||
|
||||
ENTRYPOINT ["python3"]
|
||||
CMD ["server.py"]
|
||||
|
||||
Binary file not shown.
18
README.md
18
README.md
@@ -1,6 +1,8 @@
|
||||
# FireWalletBrowser
|
||||
## Installation
|
||||
|
||||
See [here](https://firewallet.au/setup) for instructions on how to setup a FireWallet
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Nathanwoodburn/firewalletbrowser.git
|
||||
cd firewalletbrowser
|
||||
@@ -35,13 +37,13 @@ Also available as a docker image:
|
||||
To run using a HSD running directly on the host:
|
||||
|
||||
```bash
|
||||
sudo docker run --network=host -e hsd_api=yourapikeyhere git.woodburn.au/nathanwoodburn/firewallet:latest
|
||||
sudo docker run --network=host -e HSD_API=yourapikeyhere git.woodburn.au/nathanwoodburn/firewallet:latest
|
||||
```
|
||||
|
||||
If you have HSD running on a different IP/container
|
||||
|
||||
```bash
|
||||
sudo docker run -p 5000:5000 -e hsd_api=yourapikeyhere -e hsd_ip=hsdcontainer git.woodburn.au/nathanwoodburn/firewallet:latest
|
||||
sudo docker run -p 5000:5000 -e HSD_API=yourapikeyhere -e HSD_IP=hsdcontainer git.woodburn.au/nathanwoodburn/firewallet:latest
|
||||
```
|
||||
|
||||
For Docker you can mount a volume to persist the user data (/app/user_data)
|
||||
@@ -115,11 +117,13 @@ Auction page
|
||||
## Environment variables
|
||||
|
||||
```yaml
|
||||
hsd_api: HSD API key
|
||||
hsd_ip: HSD IP address
|
||||
theme: Theme to use (dark-purple, black)
|
||||
show_expired: Show expired domains (true/false)
|
||||
exclude: Comma separated list of wallets to exclude from the wallet list
|
||||
HSD_API: HSD API key
|
||||
HSD_IP: HSD IP address
|
||||
THEME: Theme to use (dark-purple, black)
|
||||
SHOW_EXPIRED: Show expired domains (true/false)
|
||||
EXCLUDE: Comma separated list of wallets to exclude from the wallet list (default primary)
|
||||
EXPLORER_TX: URL for exploring transactions (default https://niami.io/tx/)
|
||||
HSD_NETWORK: Network to connect to (main, regtest, simnet)
|
||||
```
|
||||
|
||||
|
||||
|
||||
157
account.py
157
account.py
@@ -10,12 +10,12 @@ import time
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
HSD_API = os.getenv("hsd_api")
|
||||
HSD_IP = os.getenv("hsd_ip")
|
||||
HSD_API = os.getenv("HSD_API")
|
||||
HSD_IP = os.getenv("HSD_IP")
|
||||
if HSD_IP is None:
|
||||
HSD_IP = "localhost"
|
||||
|
||||
HSD_NETWORK = os.getenv("hsd_network")
|
||||
HSD_NETWORK = os.getenv("HSD_NETWORK")
|
||||
HSD_WALLET_PORT = 12039
|
||||
HSD_NODE_PORT = 12037
|
||||
|
||||
@@ -35,9 +35,9 @@ elif HSD_NETWORK == "regtest":
|
||||
HSD_NODE_PORT = 14037
|
||||
|
||||
|
||||
show_expired = os.getenv("show_expired")
|
||||
if show_expired is None:
|
||||
show_expired = False
|
||||
SHOW_EXPIRED = os.getenv("SHOW_EXPIRED")
|
||||
if SHOW_EXPIRED is None:
|
||||
SHOW_EXPIRED = False
|
||||
|
||||
hsd = api.hsd(HSD_API,HSD_IP,HSD_NODE_PORT)
|
||||
hsw = api.hsw(HSD_API,HSD_IP,HSD_WALLET_PORT)
|
||||
@@ -47,9 +47,9 @@ cacheTime = 3600
|
||||
# Verify the connection
|
||||
response = hsd.getInfo()
|
||||
|
||||
exclude = ["primary"]
|
||||
if os.getenv("exclude") is not None:
|
||||
exclude = os.getenv("exclude").split(",")
|
||||
EXCLUDE = ["primary"]
|
||||
if os.getenv("EXCLUDE") is not None:
|
||||
EXCLUDE = os.getenv("EXCLUDE").split(",")
|
||||
|
||||
def hsdConnected():
|
||||
if hsdVersion() == -1:
|
||||
@@ -163,7 +163,7 @@ def listWallets():
|
||||
# Check if response is json or an array
|
||||
if isinstance(response, list):
|
||||
# Remove excluded wallets
|
||||
response = [wallet for wallet in response if wallet not in exclude]
|
||||
response = [wallet for wallet in response if wallet not in EXCLUDE]
|
||||
|
||||
return response
|
||||
return ['Wallet not connected']
|
||||
@@ -244,7 +244,7 @@ def getDomains(account,own=True):
|
||||
response = requests.get(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/name")
|
||||
info = response.json()
|
||||
|
||||
if show_expired:
|
||||
if SHOW_EXPIRED:
|
||||
return info
|
||||
|
||||
# Remove any expired domains
|
||||
@@ -388,7 +388,7 @@ def check_hip2(domain: str):
|
||||
domain = domain.lower()
|
||||
|
||||
if re.match(r'^[a-zA-Z0-9\-\.]{1,63}$', domain) is None:
|
||||
return 'Invalid address'
|
||||
return 'Invalid domain'
|
||||
|
||||
address = domainLookup.hip2(domain)
|
||||
if address.startswith("Hip2: "):
|
||||
@@ -433,6 +433,15 @@ def send(account,address,amount):
|
||||
"tx": response['result']
|
||||
}
|
||||
|
||||
def isOwnDomain(account,name: str):
|
||||
domains = getDomains(account)
|
||||
for domain in domains:
|
||||
print(domain)
|
||||
if domain['name'] == name:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def getDomain(domain: str):
|
||||
# Get the domain
|
||||
response = hsd.rpc_getNameInfo(domain)
|
||||
@@ -476,7 +485,6 @@ def getDNS(domain: str):
|
||||
return []
|
||||
return response['result']['records']
|
||||
|
||||
|
||||
def setDNS(account,domain,records):
|
||||
account_name = check_account(account)
|
||||
password = ":".join(account.split(":")[1:])
|
||||
@@ -521,6 +529,9 @@ def setDNS(account,domain,records):
|
||||
response = hsw.sendUPDATE(account_name,password,domain,data)
|
||||
return response
|
||||
|
||||
def register(account,domain):
|
||||
# Maybe add default dns records?
|
||||
return setDNS(account,domain,'[]')
|
||||
|
||||
def getNodeSync():
|
||||
response = hsd.getInfo()
|
||||
@@ -560,12 +571,73 @@ def getBids(account, domain="NONE"):
|
||||
for bid in response:
|
||||
if 'value' not in bid:
|
||||
bid['value'] = -1000000
|
||||
|
||||
# Backup for older HSD versions
|
||||
if 'height' not in bid:
|
||||
bid['height'] = 0
|
||||
bids.append(bid)
|
||||
return bids
|
||||
|
||||
def getReveals(account,domain):
|
||||
return hsw.getWalletRevealsByName(domain,account)
|
||||
|
||||
def getPendingReveals(account):
|
||||
bids = getBids(account)
|
||||
domains = getDomains(account,False)
|
||||
pending = []
|
||||
for domain in domains:
|
||||
if domain['state'] == "REVEAL":
|
||||
reveals = getReveals(account,domain['name'])
|
||||
for bid in bids:
|
||||
if bid['name'] == domain['name']:
|
||||
state_found = False
|
||||
for reveal in reveals:
|
||||
if reveal['own'] == True:
|
||||
if bid['value'] == reveal['value']:
|
||||
state_found = True
|
||||
|
||||
if not state_found:
|
||||
pending.append(bid)
|
||||
return pending
|
||||
|
||||
|
||||
def getPendingRedeems(account,password):
|
||||
hsw.rpc_selectWallet(account)
|
||||
hsw.rpc_walletPassphrase(password,10)
|
||||
tx = hsw.rpc_createREDEEM('','default')
|
||||
if tx['error']:
|
||||
return []
|
||||
|
||||
pending = []
|
||||
try:
|
||||
for output in tx['result']['outputs']:
|
||||
if output['covenant']['type'] != 5:
|
||||
continue
|
||||
if output['covenant']['action'] != "REDEEM":
|
||||
continue
|
||||
nameHash = output['covenant']['items'][0]
|
||||
# Try to get the name from hash
|
||||
name = hsd.rpc_getNameByHash(nameHash)
|
||||
if name['error']:
|
||||
pending.append(nameHash)
|
||||
else:
|
||||
pending.append(name['result'])
|
||||
except:
|
||||
print("Failed to parse redeems")
|
||||
|
||||
return pending
|
||||
|
||||
def getPendingRegisters(account):
|
||||
bids = getBids(account)
|
||||
domains = getDomains(account,False)
|
||||
pending = []
|
||||
for domain in domains:
|
||||
if domain['state'] == "CLOSED" and domain['registered'] == False:
|
||||
for bid in bids:
|
||||
if bid['name'] == domain['name']:
|
||||
if bid['value'] == domain['highest']:
|
||||
pending.append(bid)
|
||||
return pending
|
||||
|
||||
def getRevealTX(reveal):
|
||||
prevout = reveal['prevout']
|
||||
@@ -573,7 +645,11 @@ def getRevealTX(reveal):
|
||||
index = prevout['index']
|
||||
tx = hsd.getTxByHash(hash)
|
||||
if 'inputs' not in tx:
|
||||
# Check if registered
|
||||
print(f'Something is up with this tx: {hash}')
|
||||
print(tx)
|
||||
print('---')
|
||||
# No idea what happened here
|
||||
# Check if registered?
|
||||
return None
|
||||
return tx['inputs'][index]['prevout']['hash']
|
||||
|
||||
@@ -616,7 +692,6 @@ def revealAll(account):
|
||||
response = hsw.rpc_walletPassphrase(password,10)
|
||||
if response['error'] is not None:
|
||||
return
|
||||
# Try to send the batch of all renew, reveal and redeem actions
|
||||
|
||||
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}",json={"method": "sendbatch","params": [[["REVEAL"]]]}).json()
|
||||
except Exception as e:
|
||||
@@ -626,6 +701,58 @@ def revealAll(account):
|
||||
}
|
||||
}
|
||||
|
||||
def redeemAll(account):
|
||||
account_name = check_account(account)
|
||||
password = ":".join(account.split(":")[1:])
|
||||
|
||||
if account_name == False:
|
||||
return {
|
||||
"error": {
|
||||
"message": "Invalid account"
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
# Try to select and login to the wallet
|
||||
response = hsw.rpc_selectWallet(account_name)
|
||||
if response['error'] is not None:
|
||||
return
|
||||
response = hsw.rpc_walletPassphrase(password,10)
|
||||
if response['error'] is not None:
|
||||
return
|
||||
|
||||
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}",json={"method": "sendbatch","params": [[["REDEEM"]]]}).json()
|
||||
except Exception as e:
|
||||
return {
|
||||
"error": {
|
||||
"message": str(e)
|
||||
}
|
||||
}
|
||||
|
||||
def registerAll(account):
|
||||
account_name = check_account(account)
|
||||
password = ":".join(account.split(":")[1:])
|
||||
|
||||
if account_name == False:
|
||||
return {
|
||||
"error": {
|
||||
"message": "Invalid account"
|
||||
}
|
||||
}
|
||||
|
||||
# try:
|
||||
domains = getPendingRegisters(account_name)
|
||||
if len(domains) == 0:
|
||||
return {
|
||||
"error": {
|
||||
"message": "Nothing to do."
|
||||
}
|
||||
}
|
||||
batch = []
|
||||
for domain in domains:
|
||||
batch.append(["UPDATE",domain['name'],{"records":[]}])
|
||||
return sendBatch(account,batch)
|
||||
|
||||
def rescan_auction(account,domain):
|
||||
# Get height of the start of the auction
|
||||
response = hsw.rpc_selectWallet(account)
|
||||
|
||||
@@ -9,6 +9,9 @@ import dns.asyncresolver
|
||||
import httpx
|
||||
from requests_doh import DNSOverHTTPSSession, add_dns_provider
|
||||
import requests
|
||||
import urllib3
|
||||
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Disable insecure request warnings (since we are manually verifying the certificate)
|
||||
|
||||
def hip2(domain: str):
|
||||
domain_check = False
|
||||
@@ -75,9 +78,9 @@ def hip2(domain: str):
|
||||
break
|
||||
|
||||
|
||||
expiry_date = cert_obj.not_valid_after
|
||||
expiry_date = cert_obj.not_valid_after_utc
|
||||
# Check if expiry date is past
|
||||
if expiry_date < datetime.datetime.now():
|
||||
if expiry_date < datetime.datetime.now(datetime.timezone.utc):
|
||||
return "Hip2: Certificate is expired"
|
||||
|
||||
|
||||
@@ -114,6 +117,7 @@ def hip2(domain: str):
|
||||
|
||||
# Catch all exceptions
|
||||
except Exception as e:
|
||||
print(f"Hip2: Lookup failed with error: {e}",flush=True)
|
||||
return "Hip2: Lookup failed."
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
hsd_api=123480615465636893475aCwyaae6s45
|
||||
hsd_ip=localhost
|
||||
theme=black
|
||||
show_expired=false
|
||||
HSD_API=123480615465636893475aCwyaae6s45
|
||||
HSD_IP=localhost
|
||||
THEME=black
|
||||
SHOW_EXPIRED=false
|
||||
EXPLORER_TX=https://niami.io/tx/
|
||||
195
main.py
195
main.py
@@ -26,7 +26,7 @@ fees = 0.02
|
||||
revokeCheck = random.randint(100000,999999)
|
||||
|
||||
|
||||
theme = os.getenv("theme")
|
||||
THEME = os.getenv("THEME")
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
@@ -38,48 +38,6 @@ def index():
|
||||
if not account:
|
||||
return redirect("/logout")
|
||||
|
||||
domains = account_module.getDomains(account)
|
||||
|
||||
# Sort
|
||||
sort = request.args.get("sort")
|
||||
if sort == None:
|
||||
sort = "domain"
|
||||
sort = sort.lower()
|
||||
sort_price = ""
|
||||
sort_price_next = "⬇"
|
||||
sort_expiry = ""
|
||||
sort_expiry_next = "⬇"
|
||||
sort_domain = ""
|
||||
sort_domain_next = "⬇"
|
||||
reverse = False
|
||||
|
||||
direction = request.args.get("direction")
|
||||
if direction == None:
|
||||
direction = "⬇"
|
||||
|
||||
if direction == "⬆":
|
||||
reverse = True
|
||||
|
||||
if sort == "expiry":
|
||||
# Sort by next expiry
|
||||
domains = sorted(domains, key=lambda k: k['renewal'],reverse=reverse)
|
||||
sort_expiry = direction
|
||||
sort_expiry_next = reverseDirection(direction)
|
||||
|
||||
|
||||
elif sort == "price":
|
||||
# Sort by price
|
||||
domains = sorted(domains, key=lambda k: k['value'],reverse=reverse)
|
||||
sort_price = direction
|
||||
sort_price_next = reverseDirection(direction)
|
||||
else:
|
||||
# Sort by domain
|
||||
domains = sorted(domains, key=lambda k: k['name'],reverse=reverse)
|
||||
sort_domain = direction
|
||||
sort_domain_next = reverseDirection(direction)
|
||||
|
||||
domainsMobile = render.domains(domains,True)
|
||||
domains = render.domains(domains)
|
||||
|
||||
plugins = ""
|
||||
dashFunctions = plugins_module.getDashboardFunctions()
|
||||
@@ -87,11 +45,7 @@ def index():
|
||||
functionOutput = plugins_module.runPluginFunction(function["plugin"],function["function"],{},request.cookies.get("account"))
|
||||
plugins += render.plugin_output_dash(functionOutput,plugins_module.getPluginFunctionReturns(function["plugin"],function["function"]))
|
||||
|
||||
return render_template("index.html", account=account,domains=domains,
|
||||
domainsMobile=domainsMobile, plugins=plugins,
|
||||
sort_price=sort_price,sort_expiry=sort_expiry,
|
||||
sort_domain=sort_domain,sort_price_next=sort_price_next,
|
||||
sort_expiry_next=sort_expiry_next,sort_domain_next=sort_domain_next)
|
||||
return render_template("index.html", account=account, plugins=plugins)
|
||||
|
||||
def reverseDirection(direction: str):
|
||||
if direction == "⬆":
|
||||
@@ -170,7 +124,7 @@ def send():
|
||||
if address is None or amount is None:
|
||||
return redirect("/send?message=Invalid address or amount&address=" + address + "&amount=" + amount)
|
||||
|
||||
address_check = account_module.check_address(address,True,True)
|
||||
address_check = account_module.check_address(address.strip(),True,True)
|
||||
if not address_check:
|
||||
return redirect("/send?message=Invalid address&address=" + address + "&amount=" + amount)
|
||||
|
||||
@@ -254,7 +208,7 @@ def check_address():
|
||||
if address is None:
|
||||
return jsonify({"result": "Invalid address"})
|
||||
|
||||
return jsonify({"result": account_module.check_address(address)})
|
||||
return jsonify({"result": account_module.check_address(address.strip())})
|
||||
#endregion
|
||||
|
||||
#region Domains
|
||||
@@ -297,6 +251,8 @@ def auctions():
|
||||
if direction == "⬆":
|
||||
reverse = True
|
||||
|
||||
sortbyDomain = False
|
||||
|
||||
if sort == "price":
|
||||
# Sort by price
|
||||
bids = sorted(bids, key=lambda k: k['value'],reverse=reverse)
|
||||
@@ -306,38 +262,25 @@ def auctions():
|
||||
sort_state = direction
|
||||
sort_state_next = reverseDirection(direction)
|
||||
domains = sorted(domains, key=lambda k: k['state'],reverse=reverse)
|
||||
sortbyDomain = True
|
||||
elif sort == "time":
|
||||
sort_time = direction
|
||||
sort_time_next = reverseDirection(direction)
|
||||
bids = sorted(bids, key=lambda k: k['height'],reverse=reverse)
|
||||
|
||||
# If older HSD version sort by domain height
|
||||
if bids[0]['height'] == 0:
|
||||
domains = sorted(domains, key=lambda k: k['height'],reverse=reverse)
|
||||
sortbyDomain = True
|
||||
else:
|
||||
bids = sorted(bids, key=lambda k: k['height'],reverse=reverse)
|
||||
else:
|
||||
# Sort by domain
|
||||
bids = sorted(bids, key=lambda k: k['name'],reverse=reverse)
|
||||
sort_domain = direction
|
||||
sort_domain_next = reverseDirection(direction)
|
||||
|
||||
if sort == "state":
|
||||
bidsHtml = render.bidDomains(bids,domains,True)
|
||||
else:
|
||||
bidsHtml = render.bidDomains(bids,domains)
|
||||
|
||||
|
||||
pending_reveals = 0
|
||||
for domain in domains:
|
||||
if domain['state'] == "REVEAL":
|
||||
for bid in bids:
|
||||
if bid['name'] == domain['name']:
|
||||
bid_found = False
|
||||
reveals = account_module.getReveals(account,domain['name'])
|
||||
for reveal in reveals:
|
||||
if reveal['own'] == True:
|
||||
if bid['value'] == reveal['value']:
|
||||
bid_found = True
|
||||
if not bid_found:
|
||||
pending_reveals += 1
|
||||
|
||||
bidsHtml = render.bidDomains(bids,domains,sortbyDomain)
|
||||
plugins = ""
|
||||
|
||||
message = ''
|
||||
if 'message' in request.args:
|
||||
message = request.args.get("message")
|
||||
@@ -347,10 +290,11 @@ def auctions():
|
||||
sort_state=sort_state,sort_domain=sort_domain,
|
||||
sort_price_next=sort_price_next,
|
||||
sort_state_next=sort_state_next,sort_domain_next=sort_domain_next,
|
||||
bids=len(bids),reveal=pending_reveals,message=message,
|
||||
bids=len(bids),message=message,
|
||||
sort_time=sort_time,sort_time_next=sort_time_next)
|
||||
|
||||
@app.route('/reveal')
|
||||
@app.route('/all/reveal')
|
||||
def revealAllBids():
|
||||
# Check if the user is logged in
|
||||
if request.cookies.get("account") is None:
|
||||
@@ -371,6 +315,46 @@ def revealAllBids():
|
||||
return redirect("/success?tx=" + response['result']['hash'])
|
||||
|
||||
|
||||
@app.route('/all/redeem')
|
||||
def redeemAllBids():
|
||||
# Check if the user is logged in
|
||||
if request.cookies.get("account") is None:
|
||||
return redirect("/login")
|
||||
|
||||
account = account_module.check_account(request.cookies.get("account"))
|
||||
if not account:
|
||||
return redirect("/logout")
|
||||
|
||||
response = account_module.redeemAll(request.cookies.get("account"))
|
||||
if 'error' in response:
|
||||
print(response)
|
||||
if response['error'] != None:
|
||||
if response['error']['message'] == "Nothing to do.":
|
||||
return redirect("/auctions?message=No redeems pending")
|
||||
return redirect("/auctions?message=" + response['error']['message'])
|
||||
|
||||
return redirect("/success?tx=" + response['result']['hash'])
|
||||
|
||||
@app.route('/all/register')
|
||||
def registerAllDomains():
|
||||
# Check if the user is logged in
|
||||
if request.cookies.get("account") is None:
|
||||
return redirect("/login")
|
||||
|
||||
account = account_module.check_account(request.cookies.get("account"))
|
||||
if not account:
|
||||
return redirect("/logout")
|
||||
|
||||
response = account_module.registerAll(request.cookies.get("account"))
|
||||
if 'error' in response:
|
||||
print(response)
|
||||
if response['error'] != None:
|
||||
if response['error']['message'] == "Nothing to do.":
|
||||
return redirect("/auctions?message=No domains to register")
|
||||
return redirect("/auctions?message=" + response['error']['message'])
|
||||
|
||||
return redirect("/success?tx=" + response['hash'])
|
||||
|
||||
@app.route('/search')
|
||||
def search():
|
||||
# Check if the user is logged in
|
||||
@@ -736,7 +720,7 @@ def transfer(domain):
|
||||
|
||||
address_check = account_module.check_address(address,True,True)
|
||||
if not address_check:
|
||||
return redirect("/send?message=Invalid address&address=" + address)
|
||||
return redirect("/manage/" + domain + "?error=Invalid address")
|
||||
|
||||
address = address_check
|
||||
|
||||
@@ -845,7 +829,11 @@ def auction(domain):
|
||||
error=error)
|
||||
|
||||
if domainInfo['info'] is None:
|
||||
next_action = f'<a href="/auction/{domain}/open">Open Auction</a>'
|
||||
if 'registered' in domainInfo and domainInfo['registered'] == False and 'expired' in domainInfo and domainInfo['expired'] == False:
|
||||
# Needs to be registered
|
||||
next_action = f'ERROR GETTING NEXT STATE'
|
||||
else:
|
||||
next_action = f'<a href="/auction/{domain}/open">Open Auction</a>'
|
||||
return render_template("auction.html", account=account,
|
||||
|
||||
search_term=search_term,domain=search_term,next_action=next_action,
|
||||
@@ -871,9 +859,17 @@ def auction(domain):
|
||||
|
||||
if state == 'CLOSED':
|
||||
if not domainInfo['info']['registered']:
|
||||
state = 'AVAILABLE'
|
||||
next = "Available Now"
|
||||
next_action = f'<a href="/auction/{domain}/open">Open Auction</a>'
|
||||
if account_module.isOwnDomain(account,domain):
|
||||
print("Waiting to be registered")
|
||||
state = 'PENDING REGISTER'
|
||||
next = "Pending Register"
|
||||
next_action = f'<a href="/auction/{domain}/register">Register Domain</a>'
|
||||
|
||||
else:
|
||||
print("Not registered")
|
||||
state = 'AVAILABLE'
|
||||
next = "Available Now"
|
||||
next_action = f'<a href="/auction/{domain}/open">Open Auction</a>'
|
||||
else:
|
||||
state = 'REGISTERED'
|
||||
expires = domainInfo['info']['stats']['daysUntilExpire']
|
||||
@@ -1030,7 +1026,22 @@ def reveal_auction(domain):
|
||||
return redirect("/logout")
|
||||
|
||||
domain = domain.lower()
|
||||
response = account_module.revealAuction(request.cookies.get("account"),domain)
|
||||
response = account_module(request.cookies.get("account"),domain)
|
||||
if 'error' in response:
|
||||
return redirect("/auction/" + domain + "?message=" + response['error']['message'])
|
||||
return redirect("/success?tx=" + response['hash'])
|
||||
|
||||
@app.route('/auction/<domain>/register')
|
||||
def registerdomain(domain):
|
||||
# Check if the user is logged in
|
||||
if request.cookies.get("account") is None:
|
||||
return redirect("/login")
|
||||
|
||||
if not account_module.check_account(request.cookies.get("account")):
|
||||
return redirect("/logout")
|
||||
|
||||
domain = domain.lower()
|
||||
response = account_module.register(request.cookies.get("account"),domain)
|
||||
if 'error' in response:
|
||||
return redirect("/auction/" + domain + "?message=" + response['error']['message'])
|
||||
return redirect("/success?tx=" + response['hash'])
|
||||
@@ -1432,6 +1443,7 @@ def api_wallet(function):
|
||||
return jsonify({"error": "Not logged in"})
|
||||
|
||||
account = account_module.check_account(request.cookies.get("account"))
|
||||
password = request.cookies.get("account").split(":")[1]
|
||||
if not account:
|
||||
return jsonify({"error": "Invalid account"})
|
||||
|
||||
@@ -1449,6 +1461,27 @@ def api_wallet(function):
|
||||
|
||||
if function == "domainCount":
|
||||
return jsonify({"result": len(account_module.getDomains(account))})
|
||||
|
||||
if function == "bidCount":
|
||||
return jsonify({"result": len(account_module.getBids(account))})
|
||||
|
||||
if function == "pendingReveal":
|
||||
return jsonify({"result": len(account_module.getPendingReveals(account))})
|
||||
if function == "pendingRegister":
|
||||
return jsonify({"result": len(account_module.getPendingRegisters(account))})
|
||||
if function == "pendingRedeem":
|
||||
return jsonify({"result": len(account_module.getPendingRedeems(account,password))})
|
||||
|
||||
|
||||
if function == "domains":
|
||||
domains = account_module.getDomains(account)
|
||||
if 'error' in domains:
|
||||
return jsonify({"result": [], "error": domains['error']})
|
||||
|
||||
|
||||
|
||||
return jsonify({"result": domains})
|
||||
|
||||
|
||||
|
||||
return jsonify({"error": "Invalid function", "result": "Invalid function"}), 400
|
||||
@@ -1466,9 +1499,9 @@ def qr(data):
|
||||
# Theme
|
||||
@app.route('/assets/css/styles.min.css')
|
||||
def send_css():
|
||||
if theme == "live":
|
||||
if THEME == "live":
|
||||
return send_from_directory('templates/assets/css', 'styles.min.css')
|
||||
return send_from_directory('themes', f'{theme}.css')
|
||||
return send_from_directory('themes', f'{THEME}.css')
|
||||
|
||||
@app.route('/assets/<path:path>')
|
||||
def send_assets(path):
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
import json
|
||||
import account
|
||||
import requests
|
||||
|
||||
|
||||
# Plugin Data
|
||||
info = {
|
||||
"name": "Example Plugin",
|
||||
"description": "This is a plugin to be used as an example",
|
||||
"version": "1.0",
|
||||
"author": "Nathan.Woodburn/"
|
||||
}
|
||||
|
||||
|
||||
# Functions
|
||||
functions = {
|
||||
"search":{
|
||||
"name": "Search Owned",
|
||||
"type": "default",
|
||||
"description": "Search for owned domains containing a string",
|
||||
"params": {
|
||||
"search": {
|
||||
"name":"Search string",
|
||||
"type":"text"
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"domains":
|
||||
{
|
||||
"name": "List of owned domains",
|
||||
"type": "list"
|
||||
}
|
||||
}
|
||||
},
|
||||
"transfer":{
|
||||
"name": "Bulk Transfer Domains",
|
||||
"type": "default",
|
||||
"description": "Transfer domains to another wallet",
|
||||
"params": {
|
||||
"address": {
|
||||
"name":"Address to transfer to",
|
||||
"type":"address"
|
||||
},
|
||||
"domains": {
|
||||
"name":"List of domains to transfer",
|
||||
"type":"longText"
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"hash": {
|
||||
"name": "Hash of the transaction",
|
||||
"type": "tx"
|
||||
},
|
||||
"address":{
|
||||
"name": "Address of the new owner",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dns":{
|
||||
"name": "Set DNS for Domains",
|
||||
"type": "default",
|
||||
"description": "Set DNS for domains",
|
||||
"params": {
|
||||
"domains": {
|
||||
"name":"List of domains to set DNS for",
|
||||
"type":"longText"
|
||||
},
|
||||
"dns": {
|
||||
"name":"DNS",
|
||||
"type":"dns"
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"hash": {
|
||||
"name": "Hash of the transaction",
|
||||
"type": "tx"
|
||||
},
|
||||
"dns":{
|
||||
"name": "DNS",
|
||||
"type": "dns"
|
||||
}
|
||||
}
|
||||
},
|
||||
"niami": {
|
||||
"name": "Niami info",
|
||||
"type": "domain",
|
||||
"description": "Check the domains niami rating",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"rating":
|
||||
{
|
||||
"name": "Niami Rating",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"niamiSearch": {
|
||||
"name": "Niami info",
|
||||
"type": "search",
|
||||
"description": "Check the domains niami rating",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"rating":
|
||||
{
|
||||
"name": "Niami Rating",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"connections":{
|
||||
"name": "HSD Connections",
|
||||
"type": "dashboard",
|
||||
"description": "Show the number of connections the HSD node is connected to",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"connections":
|
||||
{
|
||||
"name": "HSD Connections",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def check(params, authentication):
|
||||
domains = params["domains"]
|
||||
domains = domains.splitlines()
|
||||
|
||||
wallet = authentication.split(":")[0]
|
||||
owned = account.getDomains(wallet)
|
||||
# Only keep owned domains ["name"]
|
||||
ownedNames = [domain["name"] for domain in owned]
|
||||
|
||||
domains = [domain for domain in domains if domain in ownedNames]
|
||||
|
||||
|
||||
return {"domains": domains}
|
||||
|
||||
def search(params, authentication):
|
||||
search = params["search"].lower()
|
||||
wallet = authentication.split(":")[0]
|
||||
owned = account.getDomains(wallet)
|
||||
# Only keep owned domains ["name"]
|
||||
ownedNames = [domain["name"] for domain in owned]
|
||||
|
||||
domains = [domain for domain in ownedNames if search in domain]
|
||||
|
||||
return {"domains": domains}
|
||||
|
||||
|
||||
def transfer(params, authentication):
|
||||
address = params["address"]
|
||||
return {"hash":"f921ffe1bb01884bf515a8079073ee9381cb93a56b486694eda2cce0719f27c0","address":address}
|
||||
|
||||
def dns(params,authentication):
|
||||
dns = params["dns"]
|
||||
return {"hash":"f921ffe1bb01884bf515a8079073ee9381cb93a56b486694eda2cce0719f27c0","dns":dns}
|
||||
|
||||
def niami(params, authentication):
|
||||
domain = params["domain"]
|
||||
response = requests.get(f"https://api.handshake.niami.io/domain/{domain}")
|
||||
data = response.json()["data"]
|
||||
if 'rating' not in data:
|
||||
return {"rating":"No rating found."}
|
||||
rating = str(data["rating"]["score"]) + " (" + data["rating"]["rarity"] + ")"
|
||||
return {"rating":rating}
|
||||
|
||||
def niamiSearch(params, authentication):
|
||||
return niami(params, authentication)
|
||||
|
||||
|
||||
def connections(params,authentication):
|
||||
outbound = account.hsd.getInfo()['pool']['outbound']
|
||||
return {"connections": outbound}
|
||||
@@ -1,32 +0,0 @@
|
||||
import json
|
||||
import account
|
||||
import requests
|
||||
|
||||
# Plugin Data
|
||||
info = {
|
||||
"name": "Plugin Template",
|
||||
"description": "Plugin Description",
|
||||
"version": "1.0",
|
||||
"author": "Nathan.Woodburn/"
|
||||
}
|
||||
|
||||
# Functions
|
||||
functions = {
|
||||
"main":{
|
||||
"name": "Function name",
|
||||
"type": "dashboard",
|
||||
"description": "Description",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"status":
|
||||
{
|
||||
"name": "Status of the function",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def main(params, authentication):
|
||||
return {"status": "Success"}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import json
|
||||
import account
|
||||
import requests
|
||||
|
||||
# Plugin Data
|
||||
info = {
|
||||
"name": "TX Count",
|
||||
"description": "Plugin for checking how many txs are in a wallet",
|
||||
"version": "1.0",
|
||||
"author": "Nathan.Woodburn/"
|
||||
}
|
||||
|
||||
# Functions
|
||||
functions = {
|
||||
"main":{
|
||||
"name": "List TXs",
|
||||
"type": "default",
|
||||
"description": "Get TXs",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"txs":
|
||||
{
|
||||
"name": "Transactions",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def main(params, authentication):
|
||||
wallet = authentication.split(":")[0]
|
||||
txCount = 0
|
||||
page = 1
|
||||
while True:
|
||||
txs = account.getTransactions(wallet,page)
|
||||
if len(txs) == 0:
|
||||
break
|
||||
txCount += len(txs)
|
||||
page += 1
|
||||
|
||||
return {"txs": f'Total TXs: {txCount}'}
|
||||
|
||||
72
render.py
72
render.py
@@ -3,6 +3,14 @@ import json
|
||||
import urllib.parse
|
||||
from flask import render_template
|
||||
from domainLookup import punycode_to_emoji
|
||||
import os
|
||||
|
||||
# Get Explorer URL
|
||||
TX_EXPLORER_URL = os.getenv("EXPLORER_TX")
|
||||
if TX_EXPLORER_URL is None:
|
||||
TX_EXPLORER_URL = "https://niami.io/tx/"
|
||||
|
||||
|
||||
|
||||
def domains(domains, mobile=False):
|
||||
html = ''
|
||||
@@ -21,10 +29,17 @@ def domains(domains, mobile=False):
|
||||
if emoji != name:
|
||||
name = f'{emoji} ({name})'
|
||||
|
||||
|
||||
link = f'/manage/{domain["name"]}'
|
||||
link_action = "Manage"
|
||||
if domain['registered'] == False:
|
||||
link_action = "Register"
|
||||
link = f'/auction/{domain["name"]}/register'
|
||||
|
||||
if not mobile:
|
||||
html += f'<tr><td>{name}</td><td>{expires} days</td><td>{paid} HNS</td><td><a href="/manage/{domain["name"]}">Manage</a></td></tr>'
|
||||
html += f'<tr><td>{name}</td><td>{expires} days</td><td>{paid:,.2f} HNS</td><td><a href="{link}">{link_action}</a></td></tr>'
|
||||
else:
|
||||
html += f'<tr><td><a href="/manage/{domain["name"]}">{name}</a></td><td>{expires} days</td></tr>'
|
||||
html += f'<tr><td><a href="{link}">{name}</a></td><td>{expires} days</td></tr>'
|
||||
|
||||
return html
|
||||
|
||||
@@ -58,17 +73,15 @@ def transactions(txs):
|
||||
amount += output["value"]
|
||||
|
||||
amount = amount / 1000000
|
||||
amount = round(amount, 2)
|
||||
amount = "{:,}".format(amount)
|
||||
|
||||
hash = "<a target='_blank' href='https://niami.io/tx/" + hash + "'>" + hash[:8] + "...</a>"
|
||||
hash = f"<a target='_blank' href='{TX_EXPLORER_URL}{hash}'>{hash[:8]}...</a>"
|
||||
if confirmations < 5:
|
||||
confirmations = "<td style='background-color: red;'>" + str(confirmations) + "</td>"
|
||||
confirmations = f"<td style='background-color: red;'>{confirmations}</td>"
|
||||
else:
|
||||
confirmations = "<td>" + str(confirmations) + "</td>"
|
||||
confirmations = f"<td>{confirmations:,}</td>"
|
||||
|
||||
|
||||
html += f'<tr><td>{action}</td><td>{address}</td><td>{hash}</td>{confirmations}<td>{amount} HNS</td></tr>'
|
||||
html += f'<tr><td>{action}</td><td>{address}</td><td>{hash}</td>{confirmations}<td>{amount:,.2f} HNS</td></tr>'
|
||||
return html
|
||||
|
||||
|
||||
@@ -92,14 +105,14 @@ def dns(data, edit=False):
|
||||
|
||||
|
||||
elif entry['type'] == 'DS':
|
||||
ds = str(entry['keyTag']) + " " + str(entry['algorithm']) + " " + str(entry['digestType']) + " " + entry['digest']
|
||||
ds = f"{entry['keyTag']} {entry['algorithm']} {entry['digestType']} {entry['digest']}"
|
||||
html_output += f"<td>{ds}</td>\n"
|
||||
|
||||
else:
|
||||
value = ""
|
||||
for key, val in entry.items():
|
||||
if key != 'type':
|
||||
value += str(val) + " "
|
||||
value += f'{val} '
|
||||
html_output += f"<td>{value}</td>\n"
|
||||
|
||||
if edit:
|
||||
@@ -119,18 +132,16 @@ def txs(data):
|
||||
|
||||
for entry in data:
|
||||
html_output += f"<tr><td>{entry['action']}</td>\n"
|
||||
html_output += f"<td><a target='_blank' href='https://niami.io/tx/{entry['txid']}'>{entry['txid'][:8]}...</a></td>\n"
|
||||
html_output += f"<td><a target='_blank' href='{TX_EXPLORER_URL}{entry['txid']}'>{entry['txid'][:8]}...</a></td>\n"
|
||||
amount = entry['amount']
|
||||
amount = amount / 1000000
|
||||
amount = round(amount, 2)
|
||||
|
||||
if entry['blind'] == None:
|
||||
html_output += f"<td>{amount} HNS</td>\n"
|
||||
html_output += f"<td>{amount:,.2f} HNS</td>\n"
|
||||
else:
|
||||
blind = entry['blind']
|
||||
blind = blind / 1000000
|
||||
blind = round(blind, 2)
|
||||
html_output += f"<td>{amount} + {blind} HNS</td>\n"
|
||||
html_output += f"<td>{amount:,.2f} + {blind:,.2f} HNS</td>\n"
|
||||
|
||||
html_output += f"<td>{timestamp_to_readable_time(entry['time'])}</td>\n"
|
||||
html_output += f"</tr>\n"
|
||||
@@ -149,20 +160,17 @@ def bids(bids,reveals):
|
||||
for bid in bids:
|
||||
lockup = bid['lockup']
|
||||
lockup = lockup / 1000000
|
||||
lockup = round(lockup, 2)
|
||||
html += "<tr>"
|
||||
html += f"<td>{lockup} HNS</td>"
|
||||
html += f"<td>{lockup:,.2f} HNS</td>"
|
||||
revealed = False
|
||||
for reveal in reveals:
|
||||
if reveal['bid'] == bid['prevout']['hash']:
|
||||
revealed = True
|
||||
value = reveal['value']
|
||||
value = value / 1000000
|
||||
value = round(value, 2)
|
||||
html += f"<td>{value} HNS</td>"
|
||||
html += f"<td>{value:,.2f} HNS</td>"
|
||||
bidValue = lockup - value
|
||||
bidValue = round(bidValue, 2)
|
||||
html += f"<td>{bidValue} HNS</td>"
|
||||
html += f"<td>{bidValue:,.2f} HNS</td>"
|
||||
break
|
||||
if not revealed:
|
||||
html += f"<td>Hidden until reveal</td>"
|
||||
@@ -175,30 +183,26 @@ def bids(bids,reveals):
|
||||
return html
|
||||
|
||||
|
||||
def bidDomains(bids,domains, sortState=False):
|
||||
def bidDomains(bids,domains, sortbyDomains=False):
|
||||
html = ''
|
||||
if not sortState:
|
||||
|
||||
if not sortbyDomains:
|
||||
for bid in bids:
|
||||
for domain in domains:
|
||||
if bid['name'] == domain['name']:
|
||||
lockup = bid['lockup']
|
||||
lockup = lockup / 1000000
|
||||
lockup = round(lockup, 2)
|
||||
bidValue = bid['value'] / 1000000
|
||||
bidValue = round(bidValue, 2)
|
||||
blind = lockup - bidValue
|
||||
bidValue = "{:,}".format(bidValue)
|
||||
blind = round(blind, 2)
|
||||
blind = "{:,}".format(blind)
|
||||
|
||||
bidDisplay = f'<b>{bidValue} HNS</b> + {blind} HNS blind'
|
||||
bidDisplay = f'<b>{bidValue:,.2f} HNS</b> + {blind:,.2f} HNS blind'
|
||||
|
||||
|
||||
html += "<tr>"
|
||||
html += f"<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' href='/auction/{domain['name']}'>{domain['name']}</a></td>"
|
||||
html += f"<td>{domain['state']}</td>"
|
||||
html += f"<td>{bidDisplay}</td>"
|
||||
html += f"<td>{bid['height']}</td>"
|
||||
html += f"<td>{domain['height']:,}</td>"
|
||||
html += "</tr>"
|
||||
else:
|
||||
for domain in domains:
|
||||
@@ -206,19 +210,15 @@ def bidDomains(bids,domains, sortState=False):
|
||||
if bid['name'] == domain['name']:
|
||||
lockup = bid['lockup']
|
||||
lockup = lockup / 1000000
|
||||
lockup = round(lockup, 2)
|
||||
bidValue = bid['value'] / 1000000
|
||||
bidValue = round(bidValue, 2)
|
||||
blind = lockup - bidValue
|
||||
bidValue = "{:,}".format(bidValue)
|
||||
blind = "{:,}".format(blind)
|
||||
|
||||
bidDisplay = f'<b>{bidValue} HNS</b> + {blind} HNS blind'
|
||||
bidDisplay = f'<b>{bidValue:,.2f} HNS</b> + {blind:,.2f} HNS blind'
|
||||
html += "<tr>"
|
||||
html += f"<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' href='/auction/{domain['name']}'>{domain['name']}</a></td>"
|
||||
html += f"<td>{domain['state']}</td>"
|
||||
html += f"<td>{bidDisplay}</td>"
|
||||
html += f"<td>{domain['height']}</td>"
|
||||
html += f"<td>{domain['height']:,}</td>"
|
||||
html += "</tr>"
|
||||
return html
|
||||
|
||||
|
||||
2
templates/assets/js/script.min.js
vendored
2
templates/assets/js/script.min.js
vendored
@@ -1 +1 @@
|
||||
async function request(e){try{const t=await fetch(`/api/v1/${e}`);if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);const o=await t.json();return void 0!==o.error?`Error: ${o.error}`:o.result}catch(e){return console.error("Request failed:",e),"Error"}}window.addEventListener("load",(async()=>{const e=["hsd-sync","hsd-version","hsd-height","wallet-sync","wallet-available","wallet-total","wallet-locked","wallet-pending","wallet-domainCount"],t=["wallet-available","wallet-total","wallet-locked","wallet-pending"];for(const o of e){const e=document.getElementById(o);if(e){const l=o.replace(/-/g,"/");let n=await request(l);t.includes(o)&&(n=Number(n).toFixed(2),n=n.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")),e.innerHTML=n}}})),function(){"use strict";var e=document.querySelector(".sidebar"),t=document.querySelectorAll("#sidebarToggle, #sidebarToggleTop");if(e){e.querySelector(".collapse");var o=[].slice.call(document.querySelectorAll(".sidebar .collapse")).map((function(e){return new bootstrap.Collapse(e,{toggle:!1})}));for(var l of t)l.addEventListener("click",(function(t){if(document.body.classList.toggle("sidebar-toggled"),e.classList.toggle("toggled"),e.classList.contains("toggled"))for(var l of o)l.hide()}));window.addEventListener("resize",(function(){if(Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)<768)for(var e of o)e.hide()}))}var n=document.querySelector("body.fixed-nav .sidebar");n&&n.on("mousewheel DOMMouseScroll wheel",(function(e){if(Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)>768){var t=e.originalEvent,o=t.wheelDelta||-t.detail;this.scrollTop+=30*(o<0?1:-1),e.preventDefault()}}));var r=document.querySelector(".scroll-to-top");r&&window.addEventListener("scroll",(function(){var e=window.pageYOffset;r.style.display=e>100?"block":"none"}))}();
|
||||
async function request(e){try{const t=await fetch(`/api/v1/${e}`);if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);const n=await t.json();return void 0!==n.error?`Error: ${n.error}`:n.result}catch(e){return console.error("Request failed:",e),"Error"}}function sortTable(e,t=!1){const n=document.getElementById("data-table"),a=n.querySelector("tbody"),o=Array.from(a.querySelectorAll("tr")),r=n.querySelectorAll("th");let l=n.getAttribute("data-sort-order")||"asc",c=n.getAttribute("data-sort-column")||"-1";l=t||c!=e?"asc":"asc"===l?"desc":"asc",n.setAttribute("data-sort-order",l),n.setAttribute("data-sort-column",e),o.sort(((t,n)=>{let a=t.cells[e].innerText.trim(),o=n.cells[e].innerText.trim(),r=parseFloat(a.replace(/[^0-9.,]/g,"").replace(/,/g,"")),c=parseFloat(o.replace(/[^0-9.,]/g,"").replace(/,/g,""));return isNaN(r)||isNaN(c)?"asc"===l?a.localeCompare(o):o.localeCompare(a):"asc"===l?r-c:c-r})),a.innerHTML="",o.forEach((e=>a.appendChild(e))),updateSortIndicators(r,e,l)}function updateSortIndicators(e,t,n){e.forEach(((e,a)=>{let o=e.querySelector(".sort-indicator");o.innerHTML=a===t?"asc"===n?" ▲":" ▼":""}))}window.addEventListener("load",(async()=>{const e=["hsd-sync","hsd-version","hsd-height","wallet-sync","wallet-available","wallet-total","wallet-locked","wallet-pending","wallet-domainCount","wallet-bidCount","wallet-pendingReveal","wallet-pendingRegister","wallet-pendingRedeem"],t=["wallet-available","wallet-total","wallet-locked"];for(const n of e){const e=document.getElementById(n);if(e){const a=n.replace(/-/g,"/");let o=await request(a);t.includes(n)&&(o=Number(o).toFixed(2)),o=o.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),e.innerHTML=o}}})),document.addEventListener("DOMContentLoaded",(function(){fetch("/api/v1/wallet/domains").then((e=>e.json())).then((e=>{const t=document.querySelector("#data-table tbody");t.innerHTML="",e.result.forEach((e=>{const n=document.createElement("tr"),a=document.createElement("td");a.textContent=e.name,n.appendChild(a);var o="Unknown";"stats"in e&&"daysUntilExpire"in e.stats&&(o=e.stats.daysUntilExpire);const r=document.createElement("td");r.textContent=`${o} days`,n.appendChild(r);const l=document.createElement("td");l.textContent=`${(e.value/1e6).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,",")} HNS`,n.appendChild(l);const c=document.createElement("td");c.innerHTML=e.registered?"<a href='/manage/"+e.name+"'>Manage</a>":"<a href='/auction/"+e.name+"/register'>Register</a>",n.appendChild(c),t.appendChild(n)})),sortTable(0,!0)})).catch((e=>console.error("Error fetching data:",e)))})),setInterval((async function(){const e=["hsd-sync","hsd-height","wallet-sync","wallet-pending","wallet-available","wallet-total"];for(const t of e){const e=document.getElementById(t);if(e){const n=t.replace(/-/g,"/");let a=await request(n);["wallet-available","wallet-total"].includes(t)&&(a=Number(a).toFixed(2)),a=a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),e.innerHTML=a}}}),2e4),function(){"use strict";var e=document.querySelector(".sidebar"),t=document.querySelectorAll("#sidebarToggle, #sidebarToggleTop");if(e){e.querySelector(".collapse");var n=[].slice.call(document.querySelectorAll(".sidebar .collapse")).map((function(e){return new bootstrap.Collapse(e,{toggle:!1})}));for(var a of t)a.addEventListener("click",(function(t){if(document.body.classList.toggle("sidebar-toggled"),e.classList.toggle("toggled"),e.classList.contains("toggled"))for(var a of n)a.hide()}));window.addEventListener("resize",(function(){if(Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)<768)for(var e of n)e.hide()}))}var o=document.querySelector("body.fixed-nav .sidebar");o&&o.on("mousewheel DOMMouseScroll wheel",(function(e){if(Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)>768){var t=e.originalEvent,n=t.wheelDelta||-t.detail;this.scrollTop+=30*(n<0?1:-1),e.preventDefault()}}));var r=document.querySelector(".scroll-to-top");r&&window.addEventListener("scroll",(function(){var e=window.pageYOffset;r.style.display=e>100?"block":"none"}))}();
|
||||
@@ -87,7 +87,7 @@
|
||||
<div class="row align-items-center no-gutters">
|
||||
<div class="col me-2">
|
||||
<div class="text-uppercase text-success fw-bold text-xs mb-1"><span>Total Bids</span></div>
|
||||
<div class="text-dark fw-bold h5 mb-0"><span>{{bids}}</span></div>
|
||||
<div class="text-dark fw-bold h5 mb-0"><span id="wallet-bidCount">0</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,9 +101,43 @@
|
||||
<div class="text-uppercase text-info fw-bold text-xs mb-1"><span>Pending Reveal</span></div>
|
||||
<div class="row g-0 align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="text-dark fw-bold h5 mb-0 me-3"><span>{{reveal}}</span></div>
|
||||
<div class="text-dark fw-bold h5 mb-0 me-3"><span id="wallet-pendingReveal">0</span></div>
|
||||
</div>
|
||||
<div class="col"><a class="btn btn-primary" role="button" href="/reveal">Reveal All</a></div>
|
||||
<div class="col"><a class="btn btn-primary" role="button" href="/all/reveal">Reveal All</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mb-4">
|
||||
<div class="card shadow border-start-info py-2">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center no-gutters">
|
||||
<div class="col me-2">
|
||||
<div class="text-uppercase text-info fw-bold text-xs mb-1"><span>Pending Redeem</span></div>
|
||||
<div class="row g-0 align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="text-dark fw-bold h5 mb-0 me-3"><span id="wallet-pendingRedeem">0</span></div>
|
||||
</div>
|
||||
<div class="col"><a class="btn btn-primary" role="button" href="/all/redeem">Redeem All</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-xl-3 mb-4">
|
||||
<div class="card shadow border-start-info py-2">
|
||||
<div class="card-body">
|
||||
<div class="row align-items-center no-gutters">
|
||||
<div class="col me-2">
|
||||
<div class="text-uppercase text-info fw-bold text-xs mb-1"><span>Pending Register</span></div>
|
||||
<div class="row g-0 align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="text-dark fw-bold h5 mb-0 me-3"><span id="wallet-pendingRegister">0</span></div>
|
||||
</div>
|
||||
<div class="col"><a class="btn btn-primary" role="button" href="/all/register">Register All</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,7 +155,7 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a href="/auctions?direction={{sort_domain_next}}">Domain{{sort_domain}}</a></th>
|
||||
<th><a href="/auctions?sort=domain&direction={{sort_domain_next}}">Domain{{sort_domain}}</a></th>
|
||||
<th><a href="/auctions?sort=state&direction={{sort_state_next}}">State{{sort_state}}</a></th>
|
||||
<th><a href="/auctions?sort=price&direction={{sort_price_next}}">Bid{{sort_price}}</a></th>
|
||||
<th><a href="/auctions?sort=time&direction={{sort_time_next}}">Block{{sort_time}}</a></th>
|
||||
|
||||
@@ -130,13 +130,30 @@
|
||||
</div>
|
||||
</div>{{plugins|safe}}
|
||||
</div>
|
||||
<div class="row d-none d-sm-none d-md-block">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h6 class="text-primary fw-bold m-0">Domains</h6>
|
||||
</div>
|
||||
<div class="card-body"><div class="table-responsive">
|
||||
<table class="table" id="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th onclick="sortTable(0)">Domain <span class="sort-indicator"></span></th>
|
||||
<th onclick="sortTable(1)">Expires <span class="sort-indicator"></span></th>
|
||||
<th onclick="sortTable(2)">Price Paid <span class="sort-indicator"></span></th>
|
||||
<th><span class="sort-indicator"></span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- {{domains | safe}} -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- <div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -150,29 +167,7 @@
|
||||
{{domains | safe}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row d-block d-sm-block d-md-none">
|
||||
<div class="col">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h6 class="text-primary fw-bold m-0">Domains</h6>
|
||||
</div>
|
||||
<div class="card-body"><div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a href="/?direction={{sort_domain_next}}">Domain{{sort_domain}}</a></th>
|
||||
<th><a href="/?sort=expiry&direction={{sort_expiry_next}}">Expires{{sort_expiry}}</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{domainsMobile | safe}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div></div>
|
||||
</div> --></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</div>
|
||||
<div class="card" style="max-width: 500px;margin: auto;margin-top: 50px;">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Your transaction has been sent and will be mined soon.</h4><span style="display: block;font-size: 12px;">TX: {{tx}}</span><span style="display: block;">Check your transaction on a block explorer</span><a class="card-link" href="https://niami.io/tx/{{tx}}" target="_blank">Niami</a><a class="card-link" href="https://3xpl.com/handshake/transaction/{{tx}}" target="_blank">3xpl</a>
|
||||
<h4 class="card-title">Your transaction has been sent and will be mined soon.</h4><span style="display: block;font-size: 12px;">TX: {{tx}}</span><span style="display: block;">Check your transaction on a block explorer</span><a class="card-link" href="https://niami.io/tx/{{tx}}" target="_blank">Niami</a><a class="card-link" href="https://3xpl.com/handshake/transaction/{{tx}}" target="_blank">3xpl</a><a class="card-link" href="https://hns.cymon.de/tx/{{tx}}" target="_blank">HNS.Cymon.de</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user