diff --git a/README.md b/README.md index 5f100fd..160f7e9 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,11 @@ git clone https://github.com/Nathanwoodburn/firewalletbrowser.git cd firewalletbrowser python3 -m pip install -r requirements.txt cp example.env .env -# Edit .env to include your HSD API key ``` +Edit .env to have your HSD api key. +If you have HSD runnning on a separate computer also add the IP here + ## Usage Make sure HSD is running then run the following commands: @@ -29,5 +31,11 @@ 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_KEY=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 ``` \ No newline at end of file diff --git a/account.py b/account.py index 1670648..e5445f8 100644 --- a/account.py +++ b/account.py @@ -11,8 +11,13 @@ import json dotenv.load_dotenv() APIKEY = os.getenv("hsd_api") -hsd = api.hsd(APIKEY,'localhost') -hsw = api.hsw(APIKEY,'localhost') +ip = os.getenv("hsd_ip") +if ip is None: + ip = "localhost" + + +hsd = api.hsd(APIKEY,ip) +hsw = api.hsw(APIKEY,ip) # Verify the connection @@ -52,7 +57,7 @@ def check_password(cookie: str, password: str): def createWallet(account: str, password: str): # Create the account # Python wrapper doesn't support this yet - response = requests.put(f"http://x:{APIKEY}@localhost:12039/wallet/{account}") + response = requests.put(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}") print(response) print(response.json()) @@ -69,7 +74,7 @@ def createWallet(account: str, password: str): # Encrypt the wallet (python wrapper doesn't support this yet) - response = requests.post(f"http://x:{APIKEY}@localhost:12039/wallet/{account}/passphrase", + response = requests.post(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}/passphrase", json={"passphrase": password}) print(response) @@ -136,7 +141,7 @@ def getDomains(account): # return [] # use requests to get the domains - response = requests.get(f"http://x:{APIKEY}@localhost:12039/wallet/{account}/name?own=true") + response = requests.get(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}/name?own=true") info = response.json() return info @@ -159,7 +164,7 @@ def check_address(address: str, allow_name: bool = True, return_address: bool = return check_hip2(address[1:]) # Check if the address is a valid HNS address - response = requests.post(f"http://x:{APIKEY}@localhost:12037",json={ + response = requests.post(f"http://x:{APIKEY}@{ip}:12037",json={ "method": "validateaddress", "params": [address] }).json() @@ -212,7 +217,7 @@ def send(account,address,amount): response = hsw.rpc_walletPassphrase(password,10) # Unlock the account - # response = requests.post(f"http://x:{APIKEY}@localhost:12039/wallet/{account_name}/unlock", + # response = requests.post(f"http://x:{APIKEY}@{ip}:12039/wallet/{account_name}/unlock", # json={"passphrase": password,"timeout": 10}) if response['error'] is not None: return { @@ -568,7 +573,7 @@ def zapTXs(account): } try: - response = requests.post(f"http://x:{APIKEY}@localhost:12039/wallet/{account_name}/zap", + response = requests.post(f"http://x:{APIKEY}@{ip}:12039/wallet/{account_name}/zap", json={"age": age, "account": "default" }) diff --git a/example.env b/example.env index bdaabb4..1021333 100644 --- a/example.env +++ b/example.env @@ -1 +1,2 @@ -hsd_api=123480615465636893475aCwyaae6s45 \ No newline at end of file +hsd_api=123480615465636893475aCwyaae6s45 +hsd_ip=localhost \ No newline at end of file