Update shakeshift explorer and fix unencrypted wallets
This commit is contained in:
Binary file not shown.
@@ -122,7 +122,7 @@ HSD_IP: HSD IP address
|
|||||||
THEME: Theme to use (dark-purple, black)
|
THEME: Theme to use (dark-purple, black)
|
||||||
SHOW_EXPIRED: Show expired domains (true/false)
|
SHOW_EXPIRED: Show expired domains (true/false)
|
||||||
EXCLUDE: Comma separated list of wallets to exclude from the wallet list (default primary)
|
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/)
|
EXPLORER_TX: URL for exploring transactions (default https://shakeshift.com/transaction/)
|
||||||
HSD_NETWORK: Network to connect to (main, regtest, simnet)
|
HSD_NETWORK: Network to connect to (main, regtest, simnet)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
91
account.py
91
account.py
@@ -51,11 +51,13 @@ EXCLUDE = ["primary"]
|
|||||||
if os.getenv("EXCLUDE") is not None:
|
if os.getenv("EXCLUDE") is not None:
|
||||||
EXCLUDE = os.getenv("EXCLUDE").split(",")
|
EXCLUDE = os.getenv("EXCLUDE").split(",")
|
||||||
|
|
||||||
|
|
||||||
def hsdConnected():
|
def hsdConnected():
|
||||||
if hsdVersion() == -1:
|
if hsdVersion() == -1:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def hsdVersion(format=True):
|
def hsdVersion(format=True):
|
||||||
info = hsd.getInfo()
|
info = hsd.getInfo()
|
||||||
if 'error' in info:
|
if 'error' in info:
|
||||||
@@ -65,6 +67,7 @@ def hsdVersion(format=True):
|
|||||||
else:
|
else:
|
||||||
return info['version']
|
return info['version']
|
||||||
|
|
||||||
|
|
||||||
def check_account(cookie: str):
|
def check_account(cookie: str):
|
||||||
if cookie is None:
|
if cookie is None:
|
||||||
return False
|
return False
|
||||||
@@ -80,6 +83,7 @@ def check_account(cookie: str):
|
|||||||
return False
|
return False
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
||||||
def check_password(cookie: str, password: str):
|
def check_password(cookie: str, password: str):
|
||||||
account = check_account(cookie)
|
account = check_account(cookie)
|
||||||
if account == False:
|
if account == False:
|
||||||
@@ -95,6 +99,7 @@ def check_password(cookie: str, password: str):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def createWallet(account: str, password: str):
|
def createWallet(account: str, password: str):
|
||||||
if not hsdConnected():
|
if not hsdConnected():
|
||||||
return {
|
return {
|
||||||
@@ -104,7 +109,8 @@ def createWallet(account: str, password: str):
|
|||||||
}
|
}
|
||||||
# Create the account
|
# Create the account
|
||||||
# Python wrapper doesn't support this yet
|
# Python wrapper doesn't support this yet
|
||||||
response = requests.put(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}")
|
response = requests.put(
|
||||||
|
f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}")
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
@@ -116,7 +122,6 @@ def createWallet(account: str, password: str):
|
|||||||
seed = hsw.getMasterHDKey(account)
|
seed = hsw.getMasterHDKey(account)
|
||||||
seed = seed['mnemonic']['phrase']
|
seed = seed['mnemonic']['phrase']
|
||||||
|
|
||||||
|
|
||||||
# Encrypt the wallet (python wrapper doesn't support this yet)
|
# Encrypt the wallet (python wrapper doesn't support this yet)
|
||||||
response = requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/passphrase",
|
response = requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/passphrase",
|
||||||
json={"passphrase": password})
|
json={"passphrase": password})
|
||||||
@@ -127,6 +132,7 @@ def createWallet(account: str, password: str):
|
|||||||
"password": password
|
"password": password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def importWallet(account: str, password: str, seed: str):
|
def importWallet(account: str, password: str, seed: str):
|
||||||
if not hsdConnected():
|
if not hsdConnected():
|
||||||
return {
|
return {
|
||||||
@@ -141,7 +147,8 @@ def importWallet(account: str, password: str,seed: str):
|
|||||||
"mnemonic": seed,
|
"mnemonic": seed,
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.put(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}",json=data)
|
response = requests.put(
|
||||||
|
f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}", json=data)
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
@@ -168,6 +175,7 @@ def listWallets():
|
|||||||
return response
|
return response
|
||||||
return ['Wallet not connected']
|
return ['Wallet not connected']
|
||||||
|
|
||||||
|
|
||||||
def selectWallet(account: str):
|
def selectWallet(account: str):
|
||||||
# Select wallet
|
# Select wallet
|
||||||
response = hsw.rpc_selectWallet(account)
|
response = hsw.rpc_selectWallet(account)
|
||||||
@@ -178,6 +186,7 @@ def selectWallet(account: str):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def getBalance(account: str):
|
def getBalance(account: str):
|
||||||
# Get the total balance
|
# Get the total balance
|
||||||
info = hsw.getBalance('default', account)
|
info = hsw.getBalance('default', account)
|
||||||
@@ -200,13 +209,13 @@ def getBalance(account: str):
|
|||||||
total = total - (domainValue/1000000)
|
total = total - (domainValue/1000000)
|
||||||
locked = locked - (domainValue/1000000)
|
locked = locked - (domainValue/1000000)
|
||||||
|
|
||||||
|
|
||||||
# Only keep 2 decimal places
|
# Only keep 2 decimal places
|
||||||
total = round(total, 2)
|
total = round(total, 2)
|
||||||
available = round(available, 2)
|
available = round(available, 2)
|
||||||
|
|
||||||
return {'available': available, 'total': total, 'locked': locked}
|
return {'available': available, 'total': total, 'locked': locked}
|
||||||
|
|
||||||
|
|
||||||
def getBlockHeight():
|
def getBlockHeight():
|
||||||
# Get the block height
|
# Get the block height
|
||||||
info = hsd.getInfo()
|
info = hsd.getInfo()
|
||||||
@@ -214,6 +223,7 @@ def getBlockHeight():
|
|||||||
return 0
|
return 0
|
||||||
return info['chain']['height']
|
return info['chain']['height']
|
||||||
|
|
||||||
|
|
||||||
def getAddress(account: str):
|
def getAddress(account: str):
|
||||||
# Get the address
|
# Get the address
|
||||||
info = hsw.getAccountInfo(account, 'default')
|
info = hsw.getAccountInfo(account, 'default')
|
||||||
@@ -221,6 +231,7 @@ def getAddress(account: str):
|
|||||||
return ''
|
return ''
|
||||||
return info['receiveAddress']
|
return info['receiveAddress']
|
||||||
|
|
||||||
|
|
||||||
def getPendingTX(account: str):
|
def getPendingTX(account: str):
|
||||||
pending = 0
|
pending = 0
|
||||||
page = 1
|
page = 1
|
||||||
@@ -237,11 +248,14 @@ def getPendingTX(account: str):
|
|||||||
break
|
break
|
||||||
return pending
|
return pending
|
||||||
|
|
||||||
|
|
||||||
def getDomains(account, own=True):
|
def getDomains(account, own=True):
|
||||||
if own:
|
if own:
|
||||||
response = requests.get(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/name?own=true")
|
response = requests.get(
|
||||||
|
f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/name?own=true")
|
||||||
else:
|
else:
|
||||||
response = requests.get(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/name")
|
response = requests.get(
|
||||||
|
f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/name")
|
||||||
info = response.json()
|
info = response.json()
|
||||||
|
|
||||||
if SHOW_EXPIRED:
|
if SHOW_EXPIRED:
|
||||||
@@ -256,9 +270,9 @@ def getDomains(account,own=True):
|
|||||||
continue
|
continue
|
||||||
domains.append(domain)
|
domains.append(domain)
|
||||||
|
|
||||||
|
|
||||||
return domains
|
return domains
|
||||||
|
|
||||||
|
|
||||||
def getPageTXCache(account, page, size=100):
|
def getPageTXCache(account, page, size=100):
|
||||||
page = f"{page}-{size}"
|
page = f"{page}-{size}"
|
||||||
if not os.path.exists(f'cache'):
|
if not os.path.exists(f'cache'):
|
||||||
@@ -274,6 +288,7 @@ def getPageTXCache(account,page,size=100):
|
|||||||
return pageCache[page]['txid']
|
return pageCache[page]['txid']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def pushPageTXCache(account, page, txid, size=100):
|
def pushPageTXCache(account, page, txid, size=100):
|
||||||
page = f"{page}-{size}"
|
page = f"{page}-{size}"
|
||||||
if not os.path.exists(f'cache/{account}_page.json'):
|
if not os.path.exists(f'cache/{account}_page.json'):
|
||||||
@@ -291,6 +306,7 @@ def pushPageTXCache(account,page,txid,size=100):
|
|||||||
|
|
||||||
return pageCache[page]['txid']
|
return pageCache[page]['txid']
|
||||||
|
|
||||||
|
|
||||||
def getTXFromPage(account, page, size=100):
|
def getTXFromPage(account, page, size=100):
|
||||||
if page == 1:
|
if page == 1:
|
||||||
return getTransactions(account, 1, size)[-1]['hash']
|
return getTransactions(account, 1, size)[-1]['hash']
|
||||||
@@ -306,7 +322,6 @@ def getTXFromPage(account,page,size=100):
|
|||||||
return hash
|
return hash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getTransactions(account, page=1, limit=100):
|
def getTransactions(account, page=1, limit=100):
|
||||||
# Get the transactions
|
# Get the transactions
|
||||||
if hsdVersion() < 7:
|
if hsdVersion() < 7:
|
||||||
@@ -324,9 +339,11 @@ def getTransactions(account,page=1,limit=100):
|
|||||||
lastTX = getTXFromPage(account, page-1, limit)
|
lastTX = getTXFromPage(account, page-1, limit)
|
||||||
|
|
||||||
if lastTX:
|
if lastTX:
|
||||||
response = requests.get(f'http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/tx/history?reverse=true&limit={limit}&after={lastTX}')
|
response = requests.get(
|
||||||
|
f'http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/tx/history?reverse=true&limit={limit}&after={lastTX}')
|
||||||
elif page == 1:
|
elif page == 1:
|
||||||
response = requests.get(f'http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/tx/history?reverse=true&limit={limit}')
|
response = requests.get(
|
||||||
|
f'http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}/wallet/{account}/tx/history?reverse=true&limit={limit}')
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@@ -342,6 +359,7 @@ def getTransactions(account,page=1,limit=100):
|
|||||||
pushPageTXCache(account, page, data[-1]['hash'], limit)
|
pushPageTXCache(account, page, data[-1]['hash'], limit)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def getAllTransactions(account):
|
def getAllTransactions(account):
|
||||||
# Get the transactions
|
# Get the transactions
|
||||||
page = 0
|
page = 0
|
||||||
@@ -353,6 +371,7 @@ def getAllTransactions(account):
|
|||||||
page += 1
|
page += 1
|
||||||
return txs
|
return txs
|
||||||
|
|
||||||
|
|
||||||
def check_address(address: str, allow_name: bool = True, return_address: bool = False):
|
def check_address(address: str, allow_name: bool = True, return_address: bool = False):
|
||||||
# Check if the address is valid
|
# Check if the address is valid
|
||||||
if address.startswith('@'):
|
if address.startswith('@'):
|
||||||
@@ -399,7 +418,6 @@ def check_hip2(domain: str):
|
|||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def send(account, address, amount):
|
def send(account, address, amount):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -416,6 +434,7 @@ def send(account,address,amount):
|
|||||||
# response = requests.post(f"http://x:{APIKEY}@{ip}:{HSD_WALLET_PORT}/wallet/{account_name}/unlock",
|
# response = requests.post(f"http://x:{APIKEY}@{ip}:{HSD_WALLET_PORT}/wallet/{account_name}/unlock",
|
||||||
# json={"passphrase": password,"timeout": 10})
|
# json={"passphrase": password,"timeout": 10})
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -433,6 +452,7 @@ def send(account,address,amount):
|
|||||||
"tx": response['result']
|
"tx": response['result']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def isOwnDomain(account, name: str):
|
def isOwnDomain(account, name: str):
|
||||||
domains = getDomains(account)
|
domains = getDomains(account)
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
@@ -452,6 +472,7 @@ def getDomain(domain: str):
|
|||||||
}
|
}
|
||||||
return response['result']
|
return response['result']
|
||||||
|
|
||||||
|
|
||||||
def renewDomain(account, domain):
|
def renewDomain(account, domain):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -466,6 +487,7 @@ def renewDomain(account,domain):
|
|||||||
response = hsw.sendRENEW(account_name, password, domain)
|
response = hsw.sendRENEW(account_name, password, domain)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def getDNS(domain: str):
|
def getDNS(domain: str):
|
||||||
# Get the DNS
|
# Get the DNS
|
||||||
response = hsd.rpc_getNameResource(domain)
|
response = hsd.rpc_getNameResource(domain)
|
||||||
@@ -484,6 +506,7 @@ def getDNS(domain: str):
|
|||||||
return []
|
return []
|
||||||
return response['result']['records']
|
return response['result']['records']
|
||||||
|
|
||||||
|
|
||||||
def setDNS(account, domain, records):
|
def setDNS(account, domain, records):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -528,10 +551,12 @@ def setDNS(account,domain,records):
|
|||||||
response = hsw.sendUPDATE(account_name, password, domain, data)
|
response = hsw.sendUPDATE(account_name, password, domain, data)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def register(account, domain):
|
def register(account, domain):
|
||||||
# Maybe add default dns records?
|
# Maybe add default dns records?
|
||||||
return setDNS(account, domain, '[]')
|
return setDNS(account, domain, '[]')
|
||||||
|
|
||||||
|
|
||||||
def getNodeSync():
|
def getNodeSync():
|
||||||
response = hsd.getInfo()
|
response = hsd.getInfo()
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
@@ -541,6 +566,7 @@ def getNodeSync():
|
|||||||
sync = round(sync, 2)
|
sync = round(sync, 2)
|
||||||
return sync
|
return sync
|
||||||
|
|
||||||
|
|
||||||
def getWalletStatus():
|
def getWalletStatus():
|
||||||
response = hsw.rpc_getWalletInfo()
|
response = hsw.rpc_getWalletInfo()
|
||||||
if 'error' in response and response['error'] != None:
|
if 'error' in response and response['error'] != None:
|
||||||
@@ -559,7 +585,6 @@ def getWalletStatus():
|
|||||||
return "Error wallet ahead of node"
|
return "Error wallet ahead of node"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getBids(account, domain="NONE"):
|
def getBids(account, domain="NONE"):
|
||||||
if domain == "NONE":
|
if domain == "NONE":
|
||||||
response = hsw.getWalletBids(account)
|
response = hsw.getWalletBids(account)
|
||||||
@@ -577,9 +602,11 @@ def getBids(account, domain="NONE"):
|
|||||||
bids.append(bid)
|
bids.append(bid)
|
||||||
return bids
|
return bids
|
||||||
|
|
||||||
|
|
||||||
def getReveals(account, domain):
|
def getReveals(account, domain):
|
||||||
return hsw.getWalletRevealsByName(domain, account)
|
return hsw.getWalletRevealsByName(domain, account)
|
||||||
|
|
||||||
|
|
||||||
def getPendingReveals(account):
|
def getPendingReveals(account):
|
||||||
bids = getBids(account)
|
bids = getBids(account)
|
||||||
domains = getDomains(account, False)
|
domains = getDomains(account, False)
|
||||||
@@ -626,6 +653,7 @@ def getPendingRedeems(account,password):
|
|||||||
|
|
||||||
return pending
|
return pending
|
||||||
|
|
||||||
|
|
||||||
def getPendingRegisters(account):
|
def getPendingRegisters(account):
|
||||||
bids = getBids(account)
|
bids = getBids(account)
|
||||||
domains = getDomains(account, False)
|
domains = getDomains(account, False)
|
||||||
@@ -638,6 +666,7 @@ def getPendingRegisters(account):
|
|||||||
pending.append(bid)
|
pending.append(bid)
|
||||||
return pending
|
return pending
|
||||||
|
|
||||||
|
|
||||||
def getPendingFinalizes(account, password):
|
def getPendingFinalizes(account, password):
|
||||||
tx = createBatch(f'{account}:{password}', [["FINALIZE"]])
|
tx = createBatch(f'{account}:{password}', [["FINALIZE"]])
|
||||||
if 'error' in tx:
|
if 'error' in tx:
|
||||||
@@ -696,6 +725,7 @@ def revealAuction(account,domain):
|
|||||||
"error": str(e)
|
"error": str(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def revealAll(account):
|
def revealAll(account):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -714,7 +744,12 @@ def revealAll(account):
|
|||||||
return
|
return
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
return
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
|
return {
|
||||||
|
"error": {
|
||||||
|
"message": response['error']['message']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}", json={"method": "sendbatch", "params": [[["REVEAL"]]]}).json()
|
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}", json={"method": "sendbatch", "params": [[["REVEAL"]]]}).json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -724,6 +759,7 @@ def revealAll(account):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def redeemAll(account):
|
def redeemAll(account):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -742,7 +778,12 @@ def redeemAll(account):
|
|||||||
return
|
return
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
return
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
|
return {
|
||||||
|
"error": {
|
||||||
|
"message": response['error']['message']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}", json={"method": "sendbatch", "params": [[["REDEEM"]]]}).json()
|
return requests.post(f"http://x:{HSD_API}@{HSD_IP}:{HSD_WALLET_PORT}", json={"method": "sendbatch", "params": [[["REDEEM"]]]}).json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -752,6 +793,7 @@ def redeemAll(account):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def registerAll(account):
|
def registerAll(account):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -776,6 +818,7 @@ def registerAll(account):
|
|||||||
batch.append(["UPDATE", domain['name'], {"records": []}])
|
batch.append(["UPDATE", domain['name'], {"records": []}])
|
||||||
return sendBatch(account, batch)
|
return sendBatch(account, batch)
|
||||||
|
|
||||||
|
|
||||||
def finalizeAll(account):
|
def finalizeAll(account):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -789,6 +832,7 @@ def finalizeAll(account):
|
|||||||
|
|
||||||
return sendBatch(account, [["FINALIZE"]])
|
return sendBatch(account, [["FINALIZE"]])
|
||||||
|
|
||||||
|
|
||||||
def rescan_auction(account, domain):
|
def rescan_auction(account, domain):
|
||||||
# Get height of the start of the auction
|
# Get height of the start of the auction
|
||||||
response = hsw.rpc_selectWallet(account)
|
response = hsw.rpc_selectWallet(account)
|
||||||
@@ -853,7 +897,6 @@ def openAuction(account,domain):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def transfer(account, domain, address):
|
def transfer(account, domain, address):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -875,6 +918,7 @@ def transfer(account,domain,address):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def finalize(account, domain):
|
def finalize(account, domain):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -896,6 +940,7 @@ def finalize(account,domain):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -910,6 +955,7 @@ def finalize(account,domain):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def cancelTransfer(account, domain):
|
def cancelTransfer(account, domain):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -931,6 +977,7 @@ def cancelTransfer(account,domain):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -945,6 +992,7 @@ def cancelTransfer(account,domain):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def revoke(account, domain):
|
def revoke(account, domain):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -966,6 +1014,7 @@ def revoke(account,domain):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -980,6 +1029,7 @@ def revoke(account,domain):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def sendBatch(account, batch):
|
def sendBatch(account, batch):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -1001,6 +1051,7 @@ def sendBatch(account, batch):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -1027,6 +1078,7 @@ def sendBatch(account, batch):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def createBatch(account, batch):
|
def createBatch(account, batch):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
@@ -1048,6 +1100,7 @@ def createBatch(account, batch):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -1087,6 +1140,7 @@ def rescan():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def resendTXs():
|
def resendTXs():
|
||||||
try:
|
try:
|
||||||
response = hsw.walletResend()
|
response = hsw.walletResend()
|
||||||
@@ -1099,7 +1153,6 @@ def resendTXs():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def zapTXs(account):
|
def zapTXs(account):
|
||||||
age = 60 * 20 # 20 minutes
|
age = 60 * 20 # 20 minutes
|
||||||
|
|
||||||
@@ -1136,7 +1189,6 @@ def getxPub(account):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = hsw.getAccountInfo(account_name, "default")
|
response = hsw.getAccountInfo(account_name, "default")
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
@@ -1167,7 +1219,6 @@ def signMessage(account,domain,message):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = hsw.rpc_selectWallet(account_name)
|
response = hsw.rpc_selectWallet(account_name)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
@@ -1178,6 +1229,7 @@ def signMessage(account,domain,message):
|
|||||||
}
|
}
|
||||||
response = hsw.rpc_walletPassphrase(password, 10)
|
response = hsw.rpc_walletPassphrase(password, 10)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
|
if response['error']['message'] != "Wallet is not encrypted.":
|
||||||
return {
|
return {
|
||||||
"error": {
|
"error": {
|
||||||
"message": response['error']['message']
|
"message": response['error']['message']
|
||||||
@@ -1192,6 +1244,7 @@ def signMessage(account,domain,message):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def verifyMessageWithName(domain, signature, message):
|
def verifyMessageWithName(domain, signature, message):
|
||||||
try:
|
try:
|
||||||
response = hsd.rpc_verifyMessageWithName(domain, signature, message)
|
response = hsd.rpc_verifyMessageWithName(domain, signature, message)
|
||||||
@@ -1213,6 +1266,7 @@ def verifyMessage(address,signature,message):
|
|||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
def generateReport(account, format="{name},{expiry},{value},{maxBid}"):
|
def generateReport(account, format="{name},{expiry},{value},{maxBid}"):
|
||||||
domains = getDomains(account)
|
domains = getDomains(account)
|
||||||
|
|
||||||
@@ -1238,5 +1292,6 @@ def generateReport(account,format="{name},{expiry},{value},{maxBid}"):
|
|||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
||||||
def convertHNS(value: int):
|
def convertHNS(value: int):
|
||||||
return value/1000000
|
return value/1000000
|
||||||
@@ -2,4 +2,4 @@ HSD_API=123480615465636893475aCwyaae6s45
|
|||||||
HSD_IP=localhost
|
HSD_IP=localhost
|
||||||
THEME=black
|
THEME=black
|
||||||
SHOW_EXPIRED=false
|
SHOW_EXPIRED=false
|
||||||
EXPLORER_TX=https://niami.io/tx/
|
EXPLORER_TX=https://shakeshift.com/transaction/
|
||||||
10
main.py
10
main.py
@@ -178,7 +178,15 @@ def sendConfirmed():
|
|||||||
address = request.args.get("address")
|
address = request.args.get("address")
|
||||||
amount = float(request.args.get("amount"))
|
amount = float(request.args.get("amount"))
|
||||||
response = account_module.send(request.cookies.get("account"),address,amount)
|
response = account_module.send(request.cookies.get("account"),address,amount)
|
||||||
if 'error' in response:
|
if 'error' in response and response['error'] != None:
|
||||||
|
# If error is a dict get the message
|
||||||
|
if isinstance(response['error'], dict):
|
||||||
|
if 'message' in response['error']:
|
||||||
|
return redirect("/send?message=" + response['error']['message'] + "&address=" + address + "&amount=" + str(amount))
|
||||||
|
else:
|
||||||
|
return redirect("/send?message=" + str(response['error']) + "&address=" + address + "&amount=" + str(amount))
|
||||||
|
|
||||||
|
# If error is a string
|
||||||
return redirect("/send?message=" + response['error'] + "&address=" + address + "&amount=" + str(amount))
|
return redirect("/send?message=" + response['error'] + "&address=" + address + "&amount=" + str(amount))
|
||||||
|
|
||||||
return redirect("/success?tx=" + response['tx'])
|
return redirect("/success?tx=" + response['tx'])
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import os
|
|||||||
info = {
|
info = {
|
||||||
"name": "Batching Functions",
|
"name": "Batching Functions",
|
||||||
"description": "This is a plugin that provides multiple functions to batch transactions",
|
"description": "This is a plugin that provides multiple functions to batch transactions",
|
||||||
"version": "1.0",
|
"version": "1.1",
|
||||||
"author": "Nathan.Woodburn/"
|
"author": "Nathan.Woodburn/"
|
||||||
}
|
}
|
||||||
# https://hsd-dev.org/api-docs/?shell--cli#sendbatch
|
# https://hsd-dev.org/api-docs/?shell--cli#sendbatch
|
||||||
@@ -394,7 +394,6 @@ def bid(params, authentication):
|
|||||||
for domain in domains:
|
for domain in domains:
|
||||||
batch.append(['BID', domain, bid, blind])
|
batch.append(['BID', domain, bid, blind])
|
||||||
|
|
||||||
print(batch)
|
|
||||||
response = sendBatch(batch, authentication)
|
response = sendBatch(batch, authentication)
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import os
|
|||||||
# Get Explorer URL
|
# Get Explorer URL
|
||||||
TX_EXPLORER_URL = os.getenv("EXPLORER_TX")
|
TX_EXPLORER_URL = os.getenv("EXPLORER_TX")
|
||||||
if TX_EXPLORER_URL is None:
|
if TX_EXPLORER_URL is None:
|
||||||
TX_EXPLORER_URL = "https://niami.io/tx/"
|
TX_EXPLORER_URL = "https://shakeshift.com/transaction/"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
<span style="display: block;">Check your transaction on a block explorer</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://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://3xpl.com/handshake/transaction/{{tx}}" target="_blank">3xpl</a>
|
||||||
<a class="card-link" href="https://hns.cymon.de/tx/{{tx}}" target="_blank">Cymon.de</a>
|
<a class="card-link" href="https://shakeshift.com/transaction/{{tx}}" target="_blank">ShakeShift</a>
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card" style="max-width: 500px;margin: auto;margin-top: 50px;">
|
<div class="card" style="max-width: 500px;margin: auto;margin-top: 50px;">
|
||||||
<div class="card-body">
|
<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><a class="card-link" href="https://hns.cymon.de/tx/{{tx}}" target="_blank">HNS.Cymon.de</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://shakeshift.com/transaction/{{tx}}" target="_blank">ShakeShift</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user