This commit is contained in:
dni ⚡ 2024-07-24 16:53:13 +02:00
parent 81edca6ac4
commit 95cb652809
2 changed files with 11 additions and 14 deletions

View File

@ -158,7 +158,6 @@ class CoreLightningWallet(Wallet):
}
r = await run_sync(lambda: self.ln.call(self.pay, payload))
fee_msat = r["amount_msat"] - r["amount_sent_msat"]
return PaymentResponse(
True, r["payment_hash"], fee_msat, r["payment_preimage"], None
@ -224,17 +223,14 @@ class CoreLightningWallet(Wallet):
# no payment with this payment_hash is found
return PaymentFailedStatus()
payment_resp = r["pays"][-1]
res = r["pays"][-1]
if payment_resp["payment_hash"] == checking_id:
status = payment_resp["status"]
if res["payment_hash"] == checking_id:
status = res["status"]
if status == "complete":
fee_msat = int(
payment_resp["amount_msat"] - payment_resp["amount_send_msat"]
)
fee_msat = res["amount_msat"] - res["amount_sent_msat"]
return PaymentSuccessStatus(
fee_msat=fee_msat, preimage=payment_resp["preimage"]
fee_msat=fee_msat, preimage=res["preimage"]
)
elif status == "failed":
return PaymentFailedStatus()

View File

@ -198,8 +198,8 @@ class CoreLightningRestWallet(Wallet):
)
checking_id = data["payment_hash"]
preimage = data["payment_preimage"]
fee_msat = data["msatoshi"] - data["msatoshi_sent"]
preimage = data["payment_pre:mage"]
fee_msat = data["msatoshi_sent"] - data["msatoshi"]
return PaymentResponse(status, checking_id, fee_msat, preimage, None)
except httpx.HTTPStatusError as exc:
@ -265,9 +265,10 @@ class CoreLightningRestWallet(Wallet):
fee_msat, preimage = None, None
if self.statuses[pay["status"]]:
# cut off "msat" and convert to int
fee_msat = int(pay["amount_msat"][:-4]) - int(
pay["amount_sent_msat"][:-4]
)
amount_msat = int(pay["amount_msat"][:-4])
# amount_sent_msat is a negative value
amount_sent_msat = abs(int(pay["amount_sent_msat"][:-4]))
fee_msat = amount_sent_msat - amount_msat
preimage = pay["preimage"]
return PaymentStatus(self.statuses.get(pay["status"]), fee_msat, preimage)