firewallet-mobile-api/main.py
Nathan Woodburn f9af1b2606
All checks were successful
Build Docker / BuildImage (push) Successful in 45s
feat: Add initial watchonly server files
2024-06-03 12:22:28 +10:00

102 lines
2.5 KiB
Python

from flask import Flask, request, jsonify
import requests
import json
import hsd
import hns
app = Flask(__name__)
@app.route("/status", methods=["GET"])
def status():
status_json = {"status": "ok", "hsd": hsd.get_status()}
return jsonify(status_json)
@app.route("/rescan", methods=["POST"])
def rescan():
# Only allow rescan if app is in debug mode
if app.debug == False:
return jsonify({"error": "Cannot rescan manually in production mode"})
return jsonify(hsd.rescan())
@app.route("/account", methods=["POST"])
def account():
account_json = hsd.create_account()
return jsonify(account_json)
@app.route("/account", methods=["GET"])
def accounts():
userID = request.args.get("uuid")
account_json = hsd.get_account(userID)
return jsonify(account_json)
@app.route("/wallet", methods=["POST"])
def create_wallet():
userID = request.args.get("uuid")
name = request.args.get("name")
xpub = request.args.get("xpub")
wallet_json = hsd.import_wallet(name, userID, xpub)
return jsonify(wallet_json)
@app.route("/wallet", methods=["GET"])
def get_wallet():
userID = request.args.get("uuid")
name = request.args.get("name")
wallets_json = hsd.get_wallet(userID, name)
return jsonify(wallets_json)
@app.route("/wallet/address", methods=["GET"])
def get_address():
userID = request.args.get("uuid")
name = request.args.get("name")
address_json = hsd.get_address(userID, name)
return jsonify(address_json)
@app.route("/wallet/balance", methods=["GET"])
def get_balance():
userID = request.args.get("uuid")
name = request.args.get("name")
balance_json = hsd.get_balance(userID, name)
return jsonify(balance_json)
@app.route('/wallet/domains', methods=['GET'])
def get_domains():
userID = request.args.get('uuid')
name = request.args.get('name')
domain_json = hsd.get_domains(userID, name)
return jsonify(domain_json)
@app.route('/wallet/send', methods=['POST'])
def send():
userID = request.args.get('uuid')
name = request.args.get('name')
address = request.args.get('address')
amount = request.args.get('amount')
send_json = hsd.send_to_address(userID, name, address, amount)
return jsonify(send_json)
@app.route('/wallet/auctions', methods=['GET'])
def get_auctions():
userID = request.args.get('uuid')
name = request.args.get('name')
auction_json = hsd.get_auctions(userID, name)
return jsonify(auction_json)
if __name__ == "__main__":
app.run(host="127.0.0.1", port=8080, debug=True)