mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 18:44:20 +01:00
print timestamp
This commit is contained in:
@@ -10,6 +10,8 @@ class Proof(BaseModel):
|
||||
secret: str
|
||||
reserved: bool = False # whether this proof is reserved for sending
|
||||
send_id: str = "" # unique ID of send attempt
|
||||
time_created: str = ""
|
||||
time_reserved: str = ""
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row):
|
||||
@@ -19,6 +21,8 @@ class Proof(BaseModel):
|
||||
secret=row[2],
|
||||
reserved=row[3] or False,
|
||||
send_id=row[4] or "",
|
||||
time_created=row[5] or "",
|
||||
time_reserved=row[6] or "",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -29,6 +33,8 @@ class Proof(BaseModel):
|
||||
secret=d["secret"],
|
||||
reserved=d["reserved"] or False,
|
||||
send_id=d["send_id"] or "",
|
||||
time_created=d["time_created"] or "",
|
||||
time_reserved=d["time_reserved"] or "",
|
||||
)
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
||||
@@ -4,6 +4,8 @@ import asyncio
|
||||
import base64
|
||||
import json
|
||||
import math
|
||||
from datetime import datetime
|
||||
|
||||
from functools import wraps
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
@@ -151,17 +153,21 @@ async def burn(ctx, token: str, all: bool):
|
||||
async def pending(ctx):
|
||||
wallet: Wallet = ctx.obj["WALLET"]
|
||||
await init_wallet(wallet)
|
||||
wallet.status()
|
||||
reserved_proofs = await get_reserved_proofs(wallet.db)
|
||||
if len(reserved_proofs):
|
||||
sorted_proofs = sorted(reserved_proofs, key=itemgetter("send_id"))
|
||||
for key, value in groupby(sorted_proofs, key=itemgetter("send_id")):
|
||||
grouped_proofs = list(value)
|
||||
token = await wallet.serialize_proofs(grouped_proofs)
|
||||
reserved_date = datetime.utcfromtimestamp(
|
||||
int(grouped_proofs[0].time_reserved)
|
||||
).strftime("%Y-%m-%d %H:%M:%S")
|
||||
print(
|
||||
f"Amount: {sum([p['amount'] for p in grouped_proofs])} sat. ID: {key}"
|
||||
f"Amount: {sum([p['amount'] for p in grouped_proofs])} sat Sent: {reserved_date} ID: {key}\n"
|
||||
)
|
||||
print(token)
|
||||
print("")
|
||||
wallet.status()
|
||||
|
||||
|
||||
@cli.command("pay", help="Pay lightning invoice.")
|
||||
|
||||
@@ -70,7 +70,7 @@ async def m002_add_proofs_reserved(db):
|
||||
await db.execute("ALTER TABLE proofs ADD COLUMN reserved BOOL")
|
||||
|
||||
|
||||
async def m003_add_proofs_sendid(db):
|
||||
async def m003_add_proofs_sendid_and_timestamps(db):
|
||||
"""
|
||||
Column with unique ID for each initiated send attempt
|
||||
so proofs can be later grouped together for each send attempt.
|
||||
|
||||
Reference in New Issue
Block a user