diff --git a/lnbits/extensions/satspay/crud.py b/lnbits/extensions/satspay/crud.py
index 56c22b31a..5779592a8 100644
--- a/lnbits/extensions/satspay/crud.py
+++ b/lnbits/extensions/satspay/crud.py
@@ -9,7 +9,9 @@ from lnbits.helpers import urlsafe_short_hash
from quart import jsonify
import httpx
from lnbits.core.services import create_invoice, check_invoice_status
-from ..watchonly.crud import get_watch_wallet, get_derive_address
+from ..watchonly.crud import get_watch_wallet, get_derive_address, get_mempool
+
+import time
###############CHARGES##########################
@@ -66,10 +68,7 @@ async def get_charge(charge_id: str) -> Charges:
async def get_charges(user: str) -> List[Charges]:
rows = await db.fetchall("SELECT * FROM charges WHERE user = ?", (user,))
- for row in rows:
- await check_address_balance(row.id)
- rows = await db.fetchall("SELECT * FROM charges WHERE user = ?", (user,))
- return [charges.from_row(row) for row in rows]
+ return [Charges.from_row(row) for row in rows]
async def delete_charge(charge_id: str) -> None:
diff --git a/lnbits/extensions/satspay/migrations.py b/lnbits/extensions/satspay/migrations.py
index fddcb5867..044eed13b 100644
--- a/lnbits/extensions/satspay/migrations.py
+++ b/lnbits/extensions/satspay/migrations.py
@@ -13,7 +13,6 @@ async def m001_initial(db):
onchainwallet TEXT,
onchainaddress TEXT,
lnbitswallet TEXT,
- lnbitskey TEXT,
payment_request TEXT,
payment_hash TEXT,
webhook TEXT,
diff --git a/lnbits/extensions/satspay/templates/satspay/index.html b/lnbits/extensions/satspay/templates/satspay/index.html
index 31879c55c..f002d0138 100644
--- a/lnbits/extensions/satspay/templates/satspay/index.html
+++ b/lnbits/extensions/satspay/templates/satspay/index.html
@@ -36,24 +36,24 @@
:filter="filter"
>
+
+
+
+
-
-
-
+
+
+
+ {{ col.label }}
+
+
+
+
+
-
-
-
-
-
- {{ col.label }}
-
-
-
-
-
+
-
-
-
-
0 ){
- this.watchonlyactive = true
- }
- }
+ var getBalance = this.getBalance
+ setTimeout(function(){
+ for (i = 0; i < self.ChargeLinks.length; i++) {
+ getBalance(self.ChargeLinks[i].id)
}
-
-
-
-
- }
-
+ }, 5000);
+ getCharges()
}
})
diff --git a/lnbits/extensions/satspay/views_api.py b/lnbits/extensions/satspay/views_api.py
index c12ec2e93..b99ab6322 100644
--- a/lnbits/extensions/satspay/views_api.py
+++ b/lnbits/extensions/satspay/views_api.py
@@ -13,75 +13,28 @@ from .crud import (
get_charge,
get_charges,
delete_charge,
+ check_address_balance,
)
-###################WALLETS#############################
-
-@satspay_ext.route("/api/v1/wallet", methods=["GET"])
-@api_check_wallet_key("invoice")
-async def api_wallets_retrieve():
-
- try:
- return (
- jsonify([wallet._asdict() for wallet in await get_watch_wallets(g.wallet.user)]), HTTPStatus.OK
- )
- except:
- return ""
-
-@satspay_ext.route("/api/v1/wallet/", methods=["GET"])
-@api_check_wallet_key("invoice")
-async def api_wallet_retrieve(wallet_id):
- wallet = await get_watch_wallet(wallet_id)
-
- if not wallet:
- return jsonify({"message": "wallet does not exist"}), HTTPStatus.NOT_FOUND
-
- return jsonify({wallet}), HTTPStatus.OK
-
-
-@satspay_ext.route("/api/v1/wallet", methods=["POST"])
-@satspay_ext.route("/api/v1/wallet/", methods=["PUT"])
-@api_check_wallet_key("invoice")
-@api_validate_post_request(
- schema={
- "masterpub": {"type": "string", "empty": False, "required": True},
- "title": {"type": "string", "empty": False, "required": True},
- }
-)
-async def api_wallet_create_or_update(wallet_id=None):
- print("g.data")
- if not wallet_id:
- wallet = await create_watch_wallet(user=g.wallet.user, masterpub=g.data["masterpub"], title=g.data["title"])
- mempool = await get_mempool(g.wallet.user)
- if not mempool:
- create_mempool(user=g.wallet.user)
- return jsonify(wallet._asdict()), HTTPStatus.CREATED
- else:
- wallet = await update_watch_wallet(wallet_id=wallet_id, **g.data)
- return jsonify(wallet._asdict()), HTTPStatus.OK
-
-
-@satspay_ext.route("/api/v1/wallet/", methods=["DELETE"])
-@api_check_wallet_key("invoice")
-async def api_wallet_delete(wallet_id):
- wallet = await get_watch_wallet(wallet_id)
-
- if not wallet:
- return jsonify({"message": "Wallet link does not exist."}), HTTPStatus.NOT_FOUND
-
- await delete_watch_wallet(wallet_id)
-
- return jsonify({"deleted": "true"}), HTTPStatus.NO_CONTENT
-
-
#############################CHARGES##########################
+@satspay_ext.route("/api/v1/charges/balance/", methods=["GET"])
+@api_check_wallet_key("invoice")
+async def api_charges_balance(charge_id):
+
+ charge = await check_address_balance(charge_id)
+ if not charge:
+ return (
+ jsonify(""),
+ HTTPStatus.OK
+ )
+ else:
+ return jsonify(charge._asdict()), HTTPStatus.OK
@satspay_ext.route("/api/v1/charges", methods=["GET"])
@api_check_wallet_key("invoice")
async def api_charges_retrieve():
charges = await get_charges(g.wallet.user)
- print(charges)
if not charges:
return (
jsonify(""),
@@ -107,8 +60,8 @@ async def api_charge_retrieve(charge_id):
@api_check_wallet_key("invoice")
@api_validate_post_request(
schema={
- "onchainwallet": {"type": "string", "empty": False, "required": True},
- "lnbitswallet": {"type": "string", "empty": False, "required": True},
+ "onchainwallet": {"type": "string"},
+ "lnbitswallet": {"type": "string"},
"description": {"type": "string", "empty": False, "required": True},
"webhook": {"type": "string", "empty": False, "required": True},
"time": {"type": "integer", "min": 1, "required": True},