feat: Add configurable hsd ip
All checks were successful
Build Docker / Build Image (push) Successful in 31s

This commit is contained in:
Nathan Woodburn 2024-01-29 15:48:36 +11:00
parent 2076cb6d0c
commit f54e1367f9
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 25 additions and 11 deletions

View File

@ -8,9 +8,11 @@ git clone https://github.com/Nathanwoodburn/firewalletbrowser.git
cd firewalletbrowser cd firewalletbrowser
python3 -m pip install -r requirements.txt python3 -m pip install -r requirements.txt
cp example.env .env 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 ## Usage
Make sure HSD is running then run the following commands: 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: To run using a HSD running directly on the host:
```bash ```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
``` ```

View File

@ -11,8 +11,13 @@ import json
dotenv.load_dotenv() dotenv.load_dotenv()
APIKEY = os.getenv("hsd_api") APIKEY = os.getenv("hsd_api")
hsd = api.hsd(APIKEY,'localhost') ip = os.getenv("hsd_ip")
hsw = api.hsw(APIKEY,'localhost') if ip is None:
ip = "localhost"
hsd = api.hsd(APIKEY,ip)
hsw = api.hsw(APIKEY,ip)
# Verify the connection # Verify the connection
@ -52,7 +57,7 @@ def check_password(cookie: str, password: str):
def createWallet(account: str, password: str): 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:{APIKEY}@localhost:12039/wallet/{account}") response = requests.put(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}")
print(response) print(response)
print(response.json()) print(response.json())
@ -69,7 +74,7 @@ def createWallet(account: str, password: str):
# 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:{APIKEY}@localhost:12039/wallet/{account}/passphrase", response = requests.post(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}/passphrase",
json={"passphrase": password}) json={"passphrase": password})
print(response) print(response)
@ -136,7 +141,7 @@ def getDomains(account):
# return [] # return []
# use requests to get the domains # 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() info = response.json()
return info return info
@ -159,7 +164,7 @@ def check_address(address: str, allow_name: bool = True, return_address: bool =
return check_hip2(address[1:]) return check_hip2(address[1:])
# Check if the address is a valid HNS address # 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", "method": "validateaddress",
"params": [address] "params": [address]
}).json() }).json()
@ -212,7 +217,7 @@ def send(account,address,amount):
response = hsw.rpc_walletPassphrase(password,10) response = hsw.rpc_walletPassphrase(password,10)
# Unlock the account # 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}) # json={"passphrase": password,"timeout": 10})
if response['error'] is not None: if response['error'] is not None:
return { return {
@ -568,7 +573,7 @@ def zapTXs(account):
} }
try: 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, json={"age": age,
"account": "default" "account": "default"
}) })

View File

@ -1 +1,2 @@
hsd_api=123480615465636893475aCwyaae6s45 hsd_api=123480615465636893475aCwyaae6s45
hsd_ip=localhost