mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2024-11-19 01:43:42 +01:00
fix lndrest
lnbits wallet use getter
This commit is contained in:
parent
26e4c2f238
commit
93a20dc0e6
@ -333,7 +333,7 @@ async def pay_invoice(
|
||||
# payment.ok can be True (paid) or None (pending)!
|
||||
logger.debug(f"updating payment {temp_id}")
|
||||
async with db.connect() as conn:
|
||||
fee = (payment.fee_msat or 0) + service_fee_msat
|
||||
fee = abs(payment.fee_msat or 0) + service_fee_msat
|
||||
await update_payment_details(
|
||||
checking_id=temp_id,
|
||||
status=(
|
||||
|
@ -132,7 +132,7 @@ class AlbyWallet(Wallet):
|
||||
return PaymentResponse(None, None, None, None, error_message)
|
||||
|
||||
checking_id = data["payment_hash"]
|
||||
fee_msat = data["fee"]
|
||||
fee_msat = abs(data["fee"])
|
||||
preimage = data["payment_preimage"]
|
||||
|
||||
return PaymentResponse(True, checking_id, fee_msat, preimage, None)
|
||||
@ -170,7 +170,7 @@ class AlbyWallet(Wallet):
|
||||
"CREATED": None,
|
||||
"SETTLED": True,
|
||||
}
|
||||
# todo: extract fee and preimage
|
||||
# TODO: extract fee and preimage
|
||||
# maybe use the more specific endpoints:
|
||||
# - https://api.getalby.com/invoices/incoming
|
||||
# - https://api.getalby.com/invoices/outgoing
|
||||
|
@ -104,7 +104,7 @@ class BlinkWallet(Wallet):
|
||||
memo: Optional[str] = None,
|
||||
description_hash: Optional[bytes] = None,
|
||||
unhashed_description: Optional[bytes] = None,
|
||||
**kwargs,
|
||||
**_,
|
||||
) -> InvoiceResponse:
|
||||
# https://dev.blink.sv/api/btc-ln-receive
|
||||
|
||||
@ -188,7 +188,7 @@ class BlinkWallet(Wallet):
|
||||
checking_id = bolt11_decode(bolt11).payment_hash
|
||||
|
||||
payment_status = await self.get_payment_status(checking_id)
|
||||
fee_msat = payment_status.fee_msat
|
||||
fee_msat = abs(payment_status.fee_msat or 0)
|
||||
preimage = payment_status.preimage
|
||||
return PaymentResponse(True, checking_id, fee_msat, preimage, None)
|
||||
except Exception as exc:
|
||||
|
@ -161,7 +161,7 @@ class ClicheWallet(Wallet):
|
||||
statuses = {"pending": None, "complete": True, "failed": False}
|
||||
return PaymentStatus(
|
||||
statuses[payment["status"]],
|
||||
abs(payment.get("fee_msatoshi")),
|
||||
abs(payment.get("fee_msatoshi", 0)),
|
||||
payment.get("preimage"),
|
||||
)
|
||||
|
||||
|
@ -127,7 +127,12 @@ class LNbitsWallet(Wallet):
|
||||
|
||||
success = True if payment.success else None
|
||||
fee_msat = abs(payment.fee_msat or 0)
|
||||
return PaymentResponse(success, checking_id, fee_msat, payment.preimage)
|
||||
return PaymentResponse(
|
||||
ok=success,
|
||||
checking_id=checking_id,
|
||||
fee_msat=fee_msat,
|
||||
preimage=payment.preimage,
|
||||
)
|
||||
|
||||
except httpx.HTTPStatusError as exc:
|
||||
try:
|
||||
@ -189,8 +194,10 @@ class LNbitsWallet(Wallet):
|
||||
return PaymentPendingStatus()
|
||||
|
||||
return PaymentSuccessStatus(
|
||||
fee_msat=abs(data["details"]["fee"]), preimage=data["preimage"]
|
||||
fee_msat=abs(data["details"].get("fee", 0)),
|
||||
preimage=data.get("preimage"),
|
||||
)
|
||||
|
||||
except Exception:
|
||||
return PaymentPendingStatus()
|
||||
|
||||
|
@ -260,7 +260,7 @@ class LndRestWallet(Wallet):
|
||||
if payment is not None and payment.get("status"):
|
||||
return PaymentStatus(
|
||||
paid=statuses[payment["status"]],
|
||||
fee_msat=abs(payment.get("fee_msat")),
|
||||
fee_msat=abs(payment.get("fee_msat", 0)),
|
||||
preimage=payment.get("payment_preimage"),
|
||||
)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user