fix: Use variables for data file locations
All checks were successful
Build Docker / BuildImage (push) Successful in 29s
All checks were successful
Build Docker / BuildImage (push) Successful in 29s
This commit is contained in:
parent
4eea90c32d
commit
5354abca42
26
hsd.py
26
hsd.py
@ -33,12 +33,12 @@ if not os.path.exists('.local'):
|
||||
wallet_file = '/data/wallets.json'
|
||||
|
||||
# Create any missing files
|
||||
if not os.path.exists('accounts.json'):
|
||||
with open('accounts.json', 'w') as f:
|
||||
if not os.path.exists(account_file):
|
||||
with open(account_file, 'w') as f:
|
||||
json.dump({}, f, indent=4)
|
||||
|
||||
if not os.path.exists('wallets.json'):
|
||||
with open('wallets.json', 'w') as f:
|
||||
if not os.path.exists(wallet_file):
|
||||
with open(wallet_file, 'w') as f:
|
||||
json.dump([], f, indent=4)
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ def create_account() -> dict:
|
||||
# Generate a UUID
|
||||
userID = str(uuid.uuid4())
|
||||
|
||||
with open('accounts.json', 'r') as f:
|
||||
with open(account_file, 'r') as f:
|
||||
accounts = json.load(f)
|
||||
|
||||
# Check if the user already exists
|
||||
@ -78,7 +78,7 @@ def create_account() -> dict:
|
||||
'wallets': []
|
||||
}
|
||||
|
||||
with open('accounts.json', 'w') as f:
|
||||
with open(account_file, 'w') as f:
|
||||
json.dump(accounts, f, indent=4)
|
||||
|
||||
return {
|
||||
@ -96,7 +96,7 @@ def get_account(userID:str) -> dict:
|
||||
|
||||
def get_accounts() -> dict:
|
||||
# Read from accounts
|
||||
with open('accounts.json', 'r') as f:
|
||||
with open(account_file, 'r') as f:
|
||||
accounts = json.load(f)
|
||||
return accounts
|
||||
|
||||
@ -118,7 +118,7 @@ def import_wallet(name:str,userID:str,xpub:str) -> dict:
|
||||
|
||||
# Create the wallet using a UUID
|
||||
walletID = str(uuid.uuid4())
|
||||
with open('wallets.json', 'r') as f:
|
||||
with open(wallet_file, 'r') as f:
|
||||
wallets = json.load(f)
|
||||
|
||||
if walletID in wallets:
|
||||
@ -144,11 +144,11 @@ def import_wallet(name:str,userID:str,xpub:str) -> dict:
|
||||
}
|
||||
|
||||
accounts[userID]['wallets'].append(wallet)
|
||||
with open('accounts.json', 'w') as f:
|
||||
with open(account_file, 'w') as f:
|
||||
json.dump(accounts, f, indent=4)
|
||||
|
||||
wallets.append(walletID)
|
||||
with open('wallets.json', 'w') as f:
|
||||
with open(wallet_file, 'w') as f:
|
||||
json.dump(wallets, f, indent=4)
|
||||
|
||||
# Rescan the wallet to get the balance
|
||||
@ -241,7 +241,7 @@ def get_domains(userID:str, name:str) -> dict:
|
||||
})
|
||||
|
||||
# Save name value to accounts
|
||||
with open('accounts.json', 'r') as f:
|
||||
with open(account_file, 'r') as f:
|
||||
accounts = json.load(f)
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ def get_domains(userID:str, name:str) -> dict:
|
||||
wallet['names_value'] = names_value
|
||||
break
|
||||
|
||||
with open('accounts.json', 'w') as f:
|
||||
with open(account_file, 'w') as f:
|
||||
json.dump(accounts, f, indent=4)
|
||||
|
||||
return names
|
||||
@ -266,7 +266,7 @@ def get_domains_value(userID:str, name:str) -> int:
|
||||
'error': 'Wallet not found'
|
||||
}
|
||||
|
||||
with open('accounts.json', 'r') as f:
|
||||
with open(account_file, 'r') as f:
|
||||
accounts = json.load(f)
|
||||
|
||||
for account in accounts:
|
||||
|
6
main.py
6
main.py
@ -1,4 +1,4 @@
|
||||
from flask import Flask, request, jsonify
|
||||
from flask import Flask, redirect, request, jsonify
|
||||
import requests
|
||||
import json
|
||||
import hsd
|
||||
@ -95,7 +95,9 @@ def get_auctions():
|
||||
return jsonify(auction_json)
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return redirect("https://firewallet.au")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=8080, debug=True)
|
||||
|
Loading…
Reference in New Issue
Block a user