Junaidb commited on
Commit
6ed97bd
·
verified ·
1 Parent(s): f1d82e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -1
app.py CHANGED
@@ -1,11 +1,42 @@
1
  from fastapi import FastAPI,Request,HTTPException,Response
2
  from pydantic import BaseModel
3
  from fastapi.responses import JSONResponse
 
4
 
5
  app=FastAPI()
 
 
 
6
 
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  @app.get("/")
10
  def Auth401(request:Request):
11
- return {"token":""}
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI,Request,HTTPException,Response
2
  from pydantic import BaseModel
3
  from fastapi.responses import JSONResponse
4
+ from .components.mongodbconnection import provideClient
5
 
6
  app=FastAPI()
7
+ client=provideClient()
8
+ db=client["agentpaymentdb"]
9
+ coll=db["agentpaymentcol"]
10
 
11
 
12
 
13
+
14
+ def load_keypair(agent):
15
+
16
+ documents=coll.find_one({"owner":"system"})
17
+ keypair=None
18
+
19
+ for doc in documents:
20
+ if doc["agent_id"]==agent:
21
+ keypair=doc["secret_key"]
22
+
23
+ secret_key_bytes =bytes.fromhex(keypair)
24
+ keypair = Keypair.from_bytes(secret_key)
25
+
26
+ print(f"✅ Keypair loaded from {path}")
27
+ print(f"📍 Public Key: {keypair.pubkey()}")
28
+
29
+ return keypair.pubkey()
30
+
31
+
32
  @app.get("/")
33
  def Auth401(request:Request):
34
+ return {"token":""}
35
+
36
+
37
+ @app.get("/agent/{id}")
38
+ def getAgentKey(id):
39
+ pkey=load_keypair(id)
40
+ return {"wallet":pkey}
41
+
42
+