Skip to content
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

Persist failed payment amount #589

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

dangeross
Copy link
Collaborator

@dangeross dangeross commented Nov 6, 2023

Persists the last failed payment amount to the payment_external_info table.

Fixes #551

@dangeross dangeross requested review from roeierez and ok300 November 6, 2023 22:38
@dangeross
Copy link
Collaborator Author

Think I need to consider how this will be remotely synced also

@roeierez
Copy link
Member

roeierez commented Nov 7, 2023

Think I need to consider how this will be remotely synced also

If the amount is needed to be synced then it should be written to the sync db such as when we write to payments_external_info table

@dangeross dangeross marked this pull request as draft November 7, 2023 11:49
@dangeross dangeross marked this pull request as ready for review November 7, 2023 14:51
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just need to clarify the migration.

let mut payment = Payment {
id: row.get(0)?,
payment_type: PaymentType::from_str(payment_type_str.as_str()).unwrap(),
payment_time: row.get(2)?,
amount_msat,
amount_msat: match status {
PaymentStatus::Failed => failed_amount_msat.unwrap_or_default(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a migration issue for existing failed payments (even with non zero invoices) that currently will get zero value here?

Copy link
Collaborator Author

@dangeross dangeross Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it would be 0 for previously failed payments. To my knowledge its not possible to retreive failed payment amounts from GL. The alternative is to add failed_amount_msat: Option<u64> to Payment directly. But it will still not have a value for a failed payment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not concerned about existing failed payments of zero invoices. We can't control these but I am worried about existing failed payments of invoices with amount. Shouldn't we fall back to the existing invoice amount to solve this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a good idea. But it is possible as a migration step? I'll look into it

@dangeross dangeross requested a review from roeierez November 9, 2023 10:04
Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@ok300 ok300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor suggestion, otherwise looks good.

amount_msat: match status {
PaymentStatus::Failed => failed_amount_msat.unwrap_or(amount_msat),
_ => amount_msat,
},
fee_msat: row.get(4)?,
status: row.get(5)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
status: row.get(5)?,
status,

@dangeross dangeross force-pushed the savage-persist-failed-payment-amount branch from 47db0e7 to d1289b4 Compare November 9, 2023 12:54
@dangeross dangeross merged commit acf081e into main Nov 9, 2023
7 checks passed
@dangeross dangeross deleted the savage-persist-failed-payment-amount branch November 9, 2023 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A failed Payment for a zero-amount invoice should include amount that was attempted to be sent
3 participants