fix for new api
This commit is contained in:
parent
eaf723919c
commit
49d8f75e06
2 changed files with 11 additions and 8 deletions
1
nwcp.py
1
nwcp.py
|
|
@ -323,7 +323,6 @@ class NWCServiceProvider:
|
||||||
# Reference user
|
# Reference user
|
||||||
res["tags"].append(["p", nwc_pubkey])
|
res["tags"].append(["p", nwc_pubkey])
|
||||||
# Finalize response event
|
# Finalize response event
|
||||||
print(res)
|
|
||||||
res["content"] = self._encrypt_content(res["content"], nwc_pubkey)
|
res["content"] = self._encrypt_content(res["content"], nwc_pubkey)
|
||||||
self._sign_event(res)
|
self._sign_event(res)
|
||||||
|
|
||||||
|
|
|
||||||
18
tasks.py
18
tasks.py
|
|
@ -55,13 +55,14 @@ async def _process_invoice(
|
||||||
amount_msats: int,
|
amount_msats: int,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
):
|
):
|
||||||
async def execute_payment():
|
async def execute_payment() -> str :
|
||||||
return await pay_invoice(
|
payment = await pay_invoice(
|
||||||
wallet_id=wallet_id,
|
wallet_id=wallet_id,
|
||||||
payment_request=invoice,
|
payment_request=invoice,
|
||||||
max_sat=int(ceil(amount_msats / 1000)),
|
max_sat=int(ceil(amount_msats / 1000)),
|
||||||
description=description or "",
|
description=description or "",
|
||||||
)
|
)
|
||||||
|
return payment.payment_hash
|
||||||
|
|
||||||
payment_hash = None
|
payment_hash = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -274,19 +275,21 @@ async def _on_lookup_invoice(
|
||||||
raise Exception("Payment not found")
|
raise Exception("Payment not found")
|
||||||
invoice_data = bolt11_decode(payment.bolt11)
|
invoice_data = bolt11_decode(payment.bolt11)
|
||||||
is_settled = not payment.pending
|
is_settled = not payment.pending
|
||||||
timestamp = payment.time or invoice_data.date
|
timestamp = int(payment.time.timestamp()) or int(invoice_data.date)
|
||||||
|
expiry = int(payment.expiry.timestamp()) or timestamp + 3600
|
||||||
|
preimage = payment.preimage or "0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
res: Dict = {
|
res: Dict = {
|
||||||
"type": "outgoing" if payment.is_out else "incoming",
|
"type": "outgoing" if payment.is_out else "incoming",
|
||||||
"invoice": payment.bolt11,
|
"invoice": payment.bolt11,
|
||||||
"description": (
|
"description": (
|
||||||
invoice_data.description if invoice_data.description else payment.memo
|
invoice_data.description if invoice_data.description else payment.memo
|
||||||
),
|
),
|
||||||
"preimage": payment.preimage if is_settled or payment.is_in else None,
|
"preimage": preimage if is_settled or payment.is_in else None,
|
||||||
"payment_hash": payment.payment_hash,
|
"payment_hash": payment.payment_hash,
|
||||||
"amount": abs(payment.msat),
|
"amount": abs(payment.msat),
|
||||||
"fees_paid": abs(payment.fee),
|
"fees_paid": abs(payment.fee),
|
||||||
"created_at": timestamp,
|
"created_at": timestamp,
|
||||||
"expires_at": payment.expiry if payment.expiry else timestamp + 3600,
|
"expires_at": expiry,
|
||||||
"settled_at": timestamp if is_settled else None,
|
"settled_at": timestamp if is_settled else None,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
}
|
}
|
||||||
|
|
@ -335,6 +338,7 @@ async def _on_list_transactions(
|
||||||
for p in history:
|
for p in history:
|
||||||
invoice_data = bolt11_decode(p.bolt11)
|
invoice_data = bolt11_decode(p.bolt11)
|
||||||
is_settled = not p.pending
|
is_settled = not p.pending
|
||||||
|
timestamp = int(p.time.timestamp()) or invoice_data.date
|
||||||
transactions.append(
|
transactions.append(
|
||||||
{
|
{
|
||||||
"type": "outgoing" if p.is_out else "incoming",
|
"type": "outgoing" if p.is_out else "incoming",
|
||||||
|
|
@ -345,8 +349,8 @@ async def _on_list_transactions(
|
||||||
"payment_hash": p.payment_hash,
|
"payment_hash": p.payment_hash,
|
||||||
"amount": abs(p.msat),
|
"amount": abs(p.msat),
|
||||||
"fees_paid": p.fee,
|
"fees_paid": p.fee,
|
||||||
"created_at": p.time,
|
"created_at": timestamp,
|
||||||
"settled_at": p.time if is_settled else None,
|
"settled_at": timestamp if is_settled else None,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue