Spaces:
Sleeping
Sleeping
Update components/paymenthandling.py
Browse files
components/paymenthandling.py
CHANGED
|
@@ -1 +1,20 @@
|
|
|
|
|
|
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from solders.keypair import Keypair
|
| 2 |
+
from solana.rpc.async_api import AsyncClient
|
| 3 |
|
| 4 |
+
|
| 5 |
+
class PaymentHandler():
|
| 6 |
+
def __init__(self,agent):
|
| 7 |
+
self.agent=agent
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def create_keypair(self, agent_id=None):
|
| 11 |
+
"""Create a new keypair and return it as MongoDB-friendly format"""
|
| 12 |
+
keypair = Keypair()
|
| 13 |
+
keypair_data = {
|
| 14 |
+
"agent_id": agent_id,
|
| 15 |
+
"public_key": str(keypair.pubkey())
|
| 16 |
+
"secret_key": bytes(keypair).hex()
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|