fix broken refactoring
This commit is contained in:
parent
0f42344c6b
commit
eaf723919c
2 changed files with 12 additions and 17 deletions
11
crud.py
11
crud.py
|
|
@ -79,14 +79,7 @@ async def get_nwc(data: GetNWC) -> Optional[NWCKey]:
|
||||||
},
|
},
|
||||||
NWCKey,
|
NWCKey,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
row = await db.fetchone(
|
|
||||||
"""
|
|
||||||
SELECT * FROM nwcprovider.keys
|
|
||||||
WHERE pubkey = ? AND (expires_at = 0 OR expires_at > ?)
|
|
||||||
""",
|
|
||||||
(data.pubkey, int(time.time()) if not data.include_expired else -1),
|
|
||||||
)
|
|
||||||
row = await db.fetchone(
|
row = await db.fetchone(
|
||||||
"""
|
"""
|
||||||
SELECT * FROM nwcprovider.keys
|
SELECT * FROM nwcprovider.keys
|
||||||
|
|
@ -108,7 +101,7 @@ async def get_nwc(data: GetNWC) -> Optional[NWCKey]:
|
||||||
""",
|
""",
|
||||||
{"last_used": int(time.time()), "pubkey": data.pubkey},
|
{"last_used": int(time.time()), "pubkey": data.pubkey},
|
||||||
)
|
)
|
||||||
return NWCKey(**row)
|
return row
|
||||||
|
|
||||||
|
|
||||||
async def get_budgets_nwc(data: GetBudgetsNWC) -> Optional[NWCBudget]:
|
async def get_budgets_nwc(data: GetBudgetsNWC) -> Optional[NWCBudget]:
|
||||||
|
|
|
||||||
18
tasks.py
18
tasks.py
|
|
@ -117,7 +117,7 @@ async def _on_pay_invoice(
|
||||||
pubkey=pubkey,
|
pubkey=pubkey,
|
||||||
refresh_last_used=True
|
refresh_last_used=True
|
||||||
))
|
))
|
||||||
error = await _check(nwc, "pay_invoice", payload)
|
error = await _check(nwc, "pay_invoice")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -149,7 +149,7 @@ async def _on_multi_pay_invoice(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
||||||
error = await _check(nwc, "multi_pay_invoice", payload)
|
error = await _check(nwc, "multi_pay_invoice")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -197,7 +197,7 @@ async def _on_make_invoice(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
||||||
error = await _check(nwc, "make_invoice", payload)
|
error = await _check(nwc, "make_invoice")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -210,7 +210,7 @@ async def _on_make_invoice(
|
||||||
description = params.get("description", "")
|
description = params.get("description", "")
|
||||||
description_hash = params.get("description_hash", None)
|
description_hash = params.get("description_hash", None)
|
||||||
expiry = params.get("expiry", None)
|
expiry = params.get("expiry", None)
|
||||||
payment_hash, payment_request = await create_invoice(
|
payment = await create_invoice(
|
||||||
wallet_id=nwc.wallet,
|
wallet_id=nwc.wallet,
|
||||||
amount=int(amount_msats / 1000),
|
amount=int(amount_msats / 1000),
|
||||||
currency="sat",
|
currency="sat",
|
||||||
|
|
@ -219,6 +219,8 @@ async def _on_make_invoice(
|
||||||
unhashed_description=description.encode("utf-8"),
|
unhashed_description=description.encode("utf-8"),
|
||||||
expiry=expiry,
|
expiry=expiry,
|
||||||
)
|
)
|
||||||
|
payment_hash = payment.payment_hash
|
||||||
|
payment_request = payment.bolt11
|
||||||
payment_status = await check_transaction_status(
|
payment_status = await check_transaction_status(
|
||||||
wallet_id=nwc.wallet, payment_hash=payment_hash
|
wallet_id=nwc.wallet, payment_hash=payment_hash
|
||||||
)
|
)
|
||||||
|
|
@ -251,7 +253,7 @@ async def _on_lookup_invoice(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
||||||
error = await _check(nwc, "lookup_invoice", payload)
|
error = await _check(nwc, "lookup_invoice")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -300,7 +302,7 @@ async def _on_list_transactions(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
||||||
error = await _check(nwc, "list_transactions", payload)
|
error = await _check(nwc, "list_transactions")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -358,7 +360,7 @@ async def _on_get_balance(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used= True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used= True))
|
||||||
error = await _check(nwc, "get_balance", payload)
|
error = await _check(nwc, "get_balance")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
@ -378,7 +380,7 @@ async def _on_get_info(
|
||||||
payload: Dict
|
payload: Dict
|
||||||
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
) -> List[Tuple[Optional[Dict], Optional[Dict], List]]:
|
||||||
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
nwc = await get_nwc(GetNWC(pubkey=pubkey, refresh_last_used=True))
|
||||||
error = await _check(nwc, "get_info", payload)
|
error = await _check(nwc, "get_info")
|
||||||
if error:
|
if error:
|
||||||
return [(None, error, [])]
|
return [(None, error, [])]
|
||||||
if not nwc:
|
if not nwc:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue