feat: Update path and xpub from authentication

This commit is contained in:
Nathan Woodburn 2025-01-29 12:32:45 +11:00
parent 8205ccedd5
commit 4caf148095
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 8 additions and 7 deletions

View File

@ -6,5 +6,5 @@ These plugins aren't included by default as there are already a lot of plugins i
Go to Plugins > Custom Plugin Manager
Import this URL:
```
https://git.woodburn.au/nathanwoodburn/FireWalletPlugins.git
https://git.woodburn.au/nathanwoodburn/hns-address-plugin.git
```

View File

@ -1,5 +1,5 @@
import json
# import account
import account
import requests
import os
import subprocess
@ -48,7 +48,7 @@ functions = {
def initialize():
# Check if hns-address is installed
if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "hns-address")):
if not os.path.exists("hns-address"):
# Try to install hns-address
try:
print("Cloning hns-address...")
@ -59,10 +59,11 @@ def initialize():
return -1
# Check if npm install was successful
if not os.path.exists(os.path.join(os.path.dirname(os.path.realpath(__file__)), "hns-address", "node_modules")):
if not os.path.exists("hns-address/node_modules"):
path = os.path.realpath("hns-address")
try:
print("Installing hns-address dependencies...")
result = subprocess.run(["npm", "install"], cwd=os.path.join(os.path.dirname(os.path.realpath(__file__)), "hns-address"), capture_output=True, text=True)
result = subprocess.run(["npm", "install"], cwd=path, capture_output=True, text=True)
if result.returncode != 0:
return -1
except:
@ -86,9 +87,9 @@ def generate(params, authentication):
startIndex = 0
if (xpub == None):
xpub = "xpub6BvF6DnLZRV6my62FuQ8nw5TRebL8qr9Wa7u2tE1aEedHWBt4XAfSaNTmP1SM2nXErGWSzxRAHVwqstPzRrsXtA2vn1a4KzLwAVEgLNmfca"
xpub = account.getxPub(authentication)
result = subprocess.run(["node", "generate-address.js", "--xpub", xpub, "--number", str(count), "--startIndex", str(startIndex)], capture_output=True, text=True, cwd=os.path.join(os.path.dirname(os.path.realpath(__file__)), "hns-address"))
result = subprocess.run(["node", "generate-address.js", "--xpub", xpub, "--number", str(count), "--startIndex", str(startIndex)], capture_output=True, text=True, cwd=os.path.realpath("hns-address"))
with open(f"{xpub}-addresses.txt", "w") as f:
f.write(result.stdout)