diff --git a/lnbits/extensions/watchonly/crud.py b/lnbits/extensions/watchonly/crud.py index b531989f9..3499eabb9 100644 --- a/lnbits/extensions/watchonly/crud.py +++ b/lnbits/extensions/watchonly/crud.py @@ -92,16 +92,18 @@ async def get_fresh_address(wallet_id: str) -> Addresses: address = await get_derive_address(wallet_id, wallet[4] + 1) await update_watch_wallet(wallet_id = wallet_id, address_no = wallet[4] + 1) + masterpub_id = urlsafe_short_hash() await db.execute( """ INSERT INTO addresses ( + id, address, wallet, amount ) - VALUES (?, ?, ?) + VALUES (?, ?, ?, ?) """, - (address, wallet_id, 0), + (masterpub_id, address, wallet_id, 0), ) return await get_address(address) diff --git a/lnbits/extensions/watchonly/migrations.py b/lnbits/extensions/watchonly/migrations.py index 16859c6d8..72ff4e33f 100644 --- a/lnbits/extensions/watchonly/migrations.py +++ b/lnbits/extensions/watchonly/migrations.py @@ -18,7 +18,8 @@ async def m001_initial(db): await db.execute( """ CREATE TABLE IF NOT EXISTS addresses ( - address TEXT NOT NULL PRIMARY KEY, + id TEXT NOT NULL PRIMARY KEY, + address TEXT NOT NULL, wallet TEXT NOT NULL, amount INTEGER NOT NULL ); diff --git a/lnbits/extensions/watchonly/models.py b/lnbits/extensions/watchonly/models.py index 86e63a8c5..9f2649c0a 100644 --- a/lnbits/extensions/watchonly/models.py +++ b/lnbits/extensions/watchonly/models.py @@ -23,6 +23,7 @@ class Mempool(NamedTuple): return cls(**dict(row)) class Addresses(NamedTuple): + id: str address: str wallet: str amount: int diff --git a/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html b/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html index 87d048dce..5d8ca8b02 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html +++ b/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html @@ -1,9 +1,10 @@ -

The WatchOnly extension uses mempool.space for blockchain data.
+

Watch Only extension uses mempool.space
+ For use with "account Extended Public Key" https://iancoleman.io/bip39/ - Created by, Ben Arc +
Created by, Ben Arc (using, Embit)

@@ -15,31 +16,31 @@ label="API info" :content-inset-level="0.5" > - + - GET /pay/api/v1/links + GET /watchonly/api/v1/wallet
Headers
{"X-Api-Key": <invoice_key>}
Body (application/json)
Returns 200 OK (application/json)
- [<pay_link_object>, ...] + [<wallets_object>, ...]
Curl example
curl -X GET {{ request.url_root }}pay/api/v1/links -H "X-Api-Key: {{ + >curl -X GET {{ request.url_root }}api/v1/wallet -H "X-Api-Key: {{ g.user.wallets[0].inkey }}"
- + GET - /pay/api/v1/links/<pay_id>
Headers
{"X-Api-Key": <invoice_key>}
@@ -47,10 +48,10 @@
Returns 201 CREATED (application/json)
- {"lnurl": <string>} + [<wallet_object>, ...]
Curl example
curl -X GET {{ request.url_root }}pay/api/v1/links/<pay_id> -H + >curl -X GET {{ request.url_root }}api/v1/wallet/<wallet_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}"
@@ -60,24 +61,22 @@ group="api" dense expand-separator - label="Create a charge link" + label="Create wallet" > - POST /pay/api/v1/links + POST /watchonly/api/v1/wallet
Headers
{"X-Api-Key": <admin_key>}
Body (application/json)
- {"description": <string> "amount": <integer>}
Returns 201 CREATED (application/json) -
- {"lnurl": <string>} + [<wallet_object>, ...]
Curl example
curl -X POST {{ request.url_root }}pay/api/v1/links -d - '{"description": <string>, "amount": <integer>}' -H + >curl -X POST {{ request.url_root }}api/v1/wallet -d + '{"title": <string>, "masterpub": <string>}' -H "Content-type: application/json" -H "X-Api-Key: {{ g.user.wallets[0].adminkey }}" @@ -88,44 +87,14 @@ group="api" dense expand-separator - label="Update a pay link" - > - - - PUT - /pay/api/v1/links/<pay_id> -
Headers
- {"X-Api-Key": <admin_key>}
-
Body (application/json)
- {"description": <string>, "amount": <integer>} -
- Returns 200 OK (application/json) -
- {"lnurl": <string>} -
Curl example
- curl -X PUT {{ request.url_root }}pay/api/v1/links/<pay_id> -d - '{"description": <string>, "amount": <integer>}' -H - "Content-type: application/json" -H "X-Api-Key: {{ - g.user.wallets[0].adminkey }}" - -
-
-
- DELETE - /pay/api/v1/links/<pay_id>
Headers
{"X-Api-Key": <admin_key>}
@@ -133,10 +102,95 @@
Curl example
curl -X DELETE {{ request.url_root }}pay/api/v1/links/<pay_id> + >curl -X DELETE {{ request.url_root }}api/v1/wallet/<wallet_id> -H "X-Api-Key: {{ g.user.wallets[0].adminkey }}"
+ + + + + + GET /watchonly/api/v1/addresses/<wallet_id> +
Headers
+ {"X-Api-Key": <invoice_key>}
+
Body (application/json)
+
+ Returns 200 OK (application/json) +
+ [<address_object>, ...] +
Curl example
+ curl -X GET {{ request.url_root }}api/v1/addresses/<wallet_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" + +
+
+
+ + + + + GET /watchonly/api/v1/address/<wallet_id> +
Headers
+ {"X-Api-Key": <invoice_key>}
+
Body (application/json)
+
+ Returns 200 OK (application/json) +
+ [<address_object>, ...] +
Curl example
+ curl -X GET {{ request.url_root }}api/v1/address/<wallet_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" + +
+
+
+ + + + + + GET /watchonly/api/v1/mempool +
Headers
+ {"X-Api-Key": <admin_key>}
+
Body (application/json)
+
+ Returns 200 OK (application/json) +
+ [<mempool_object>, ...] +
Curl example
+ curl -X GET {{ request.url_root }}api/v1/mempool -H "X-Api-Key: {{ + g.user.wallets[0].adminkey }}" + +
+
+
+ + + + + POST /watchonly/api/v1/mempool +
Headers
+ {"X-Api-Key": <admin_key>}
+
Body (application/json)
+
+ Returns 201 CREATED (application/json) +
+ [<mempool_object>, ...] +
Curl example
+ curl -X PUT {{ request.url_root }}api/v1/mempool -d + '{"endpoint": <string>}' -H + "Content-type: application/json" -H "X-Api-Key: {{ + g.user.wallets[0].adminkey }}" + +
+
+
+
diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 8b241d5aa..c99ba1f94 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -66,14 +66,8 @@