feat: Add support for test networks
All checks were successful
Build Docker / Build Image (push) Successful in 52s
All checks were successful
Build Docker / Build Image (push) Successful in 52s
This commit is contained in:
@@ -5,10 +5,10 @@ import threading
|
||||
import os
|
||||
import time
|
||||
|
||||
APIKEY = os.environ.get("hsd_api")
|
||||
ip = os.getenv("hsd_ip")
|
||||
if ip is None:
|
||||
ip = "localhost"
|
||||
KEY = account.HSD_API
|
||||
IP = account.HSD_IP
|
||||
PORT = account.HSD_WALLET_PORT
|
||||
|
||||
|
||||
if not os.path.exists("user_data"):
|
||||
os.mkdir("user_data")
|
||||
@@ -148,9 +148,9 @@ def automations_background(authentication):
|
||||
if response['error'] is not None:
|
||||
return
|
||||
# Try to send the batch of all renew, reveal and redeem actions
|
||||
requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["RENEW"]]]})
|
||||
requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REVEAL"]]]})
|
||||
requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REDEEM"]]]})
|
||||
requests.post(f"http://x:{KEY}@{IP}:{PORT}",json={"method": "sendbatch","params": [[["RENEW"]]]})
|
||||
requests.post(f"http://x:{KEY}@{IP}:{PORT}",json={"method": "sendbatch","params": [[["REVEAL"]]]})
|
||||
requests.post(f"http://x:{KEY}@{IP}:{PORT}",json={"method": "sendbatch","params": [[["REDEEM"]]]})
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
@@ -500,16 +500,15 @@ def advancedChangeLookahead(params, authentication):
|
||||
lookahead = int(lookahead)
|
||||
wallet = authentication.split(":")[0]
|
||||
password = ":".join(authentication.split(":")[1:])
|
||||
APIKEY = os.getenv("hsd_api")
|
||||
ip = os.getenv("hsd_ip")
|
||||
if ip is None:
|
||||
ip = "localhost"
|
||||
KEY = account.HSD_API
|
||||
IP = account.HSD_IP
|
||||
PORT = account.HSD_WALLET_PORT
|
||||
|
||||
# Unlock wallet
|
||||
response = requests.post(f"http://x:{APIKEY}@{ip}:12039/wallet/{wallet}/unlock",
|
||||
response = requests.post(f"http://x:{KEY}@{IP}:{PORT}/wallet/{wallet}/unlock",
|
||||
json={"passphrase": password, "timeout": 10})
|
||||
|
||||
response = requests.patch(f"http://x:{APIKEY}@{ip}:12039/wallet/{wallet}/account/default",
|
||||
response = requests.patch(f"http://x:{KEY}@{IP}:{PORT}/wallet/{wallet}/account/default",
|
||||
json={"lookahead": lookahead})
|
||||
|
||||
|
||||
|
||||
@@ -50,12 +50,11 @@ def main(params, authentication):
|
||||
batches.append(names[i:i+100])
|
||||
|
||||
# Unlock wallet
|
||||
api_key = os.getenv("hsd_api")
|
||||
ip = os.getenv("hsd_ip")
|
||||
if api_key is None:
|
||||
print("API key not set")
|
||||
return {"status": "API key not set", "transaction": "None"}
|
||||
response = requests.post(f'http://x:{api_key}@{ip}:12039/wallet/{wallet}/unlock',
|
||||
KEY = account.HSD_API
|
||||
IP = account.HSD_IP
|
||||
PORT = account.HSD_WALLET_PORT
|
||||
|
||||
response = requests.post(f'http://x:{KEY}@{IP}:{PORT}/wallet/{wallet}/unlock',
|
||||
json={'passphrase': password, 'timeout': 600})
|
||||
if response.status_code != 200:
|
||||
print("Failed to unlock wallet")
|
||||
@@ -74,7 +73,7 @@ def main(params, authentication):
|
||||
|
||||
batchTX = "[" + ", ".join(batch) + "]"
|
||||
responseContent = f'{{"method": "sendbatch","params":[ {batchTX} ]}}'
|
||||
response = requests.post(f'http://x:{api_key}@{ip}:12039', data=responseContent)
|
||||
response = requests.post(f'http://x:{KEY}@{IP}:{PORT}', data=responseContent)
|
||||
if response.status_code != 200:
|
||||
print("Failed to create batch",flush=True)
|
||||
print(f'Status code: {response.status_code}',flush=True)
|
||||
|
||||
53
plugins/testing.py
Normal file
53
plugins/testing.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import json
|
||||
import account
|
||||
import requests
|
||||
|
||||
# Plugin Data
|
||||
info = {
|
||||
"name": "Testing tools",
|
||||
"description": "Testing tools",
|
||||
"version": "1.0",
|
||||
"author": "Nathan.Woodburn/"
|
||||
}
|
||||
|
||||
# Functions
|
||||
functions = {
|
||||
"generate":{
|
||||
"name": "Generate blocks",
|
||||
"type": "default",
|
||||
"description": "Generate blocks to your wallet",
|
||||
"params": {
|
||||
"numblocks": {
|
||||
"name":"Number of blocks to generate",
|
||||
"type":"number"
|
||||
},
|
||||
"address": {
|
||||
"name":"Address to generate to",
|
||||
"type":"text"
|
||||
}
|
||||
},
|
||||
"returns": {
|
||||
"status":
|
||||
{
|
||||
"name": "Status of the function",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def generate(params, authentication):
|
||||
# hsd-cli rpc generatetoaddress $numblocks $address
|
||||
number = params["numblocks"]
|
||||
address = params["address"]
|
||||
if number == "" or int(number) < 1:
|
||||
number = 1
|
||||
|
||||
if address == "":
|
||||
wallet = authentication.split(":")[0]
|
||||
address = account.getAddress(wallet)
|
||||
|
||||
print(f"Generating {number} blocks to {address}")
|
||||
blocks = account.hsd.rpc_generateToAddress(address,number)
|
||||
return {"status": f"Successfully generated {number} blocks to {address}"}
|
||||
|
||||
Reference in New Issue
Block a user