-
-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enforce order of payments #2313
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2313 +/- ##
==========================================
- Coverage 58.54% 57.86% -0.68%
==========================================
Files 61 61
Lines 9185 9184 -1
==========================================
- Hits 5377 5314 -63
- Misses 3808 3870 +62 ☔ View full report in Codecov by Sentry. |
@@ -602,6 +602,7 @@ async def get_standalone_payment( | |||
SELECT * | |||
FROM apipayments | |||
WHERE {clause} | |||
ORDER BY amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the logic why sorting by amount is desired and not by some other field (e.g. time comes to my mind).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its for internal payments, the one sending is negative the one receiving positive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original issue was that the extra
field was sometimes not correctly fetched for get payment (/api/v1/payments/${paymenHash}
). The extra
field contains (among others the webhook status).
The extra
field is updated like so on core
and withdraw
extension:
await update_payment_extra(
payment_hash=payment_hash,
extra={
"wh_success": r.is_success,
"wh_message": r.reason_phrase,
"wh_response": r.text,
},
outgoing=True,
)
Having outgoing=True
makes the update on the outgoing (negative) payment.
However, now I have just noticed that the call from lnurlp extension does not specify outgoing=True
.
This is indeed inconsistent (and fragile).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, now I have just noticed that the call from lnurlp extension does not specify outgoing=True.
This is indeed inconsistent (and fragile).
- nvm,
lnurlp
is not an outgoing payment. Its fine as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
The comment (now removed) explains the problem:
The problem is that by specifying the
wallet id
the order is not enforced if the same wallet is the sender and the receiver.An explicit
ORDER BY
has been added to the SQL statement.