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

feat(backend): Check pending transaction before selecting utxos #2627

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

lmuntaner
Copy link
Contributor

@lmuntaner lmuntaner commented Oct 3, 2024

Motivation

Avoid users double spending their utxos.

In this PR, before we select the utxos for a transaction, we check whether the user has any pending utxos. If that is the case, then the endpoint fails.

Ideally, we would ignore the pending utxos and use other utxos. But this is an improvement we can do later.

Changes

  • Add one entry to enum SelectedUtxosFeeError: PendingTransactions.
  • Prune pending utxos and check whether there are any within btc_select_user_utxos_fee.

Tests

  • I added a test to check the return value of the new error. For this, I checked that if we don't prune, the error is returned.

@lmuntaner lmuntaner marked this pull request as ready for review October 3, 2024 06:31
@lmuntaner lmuntaner requested a review from a team as a code owner October 3, 2024 06:31
@lmuntaner
Copy link
Contributor Author

@bitdivine please review

@lmuntaner lmuntaner force-pushed the lm-check-pending-tx-selecting-utxos branch from bc276cb to 05ea107 Compare October 3, 2024 07:35
Copy link
Member

@bitdivine bitdivine left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lmuntaner lmuntaner force-pushed the lm-check-pending-tx-selecting-utxos branch from 05ea107 to c6a7afe Compare October 3, 2024 07:56
@lmuntaner lmuntaner merged commit f52aebb into main Oct 3, 2024
16 checks passed
@lmuntaner lmuntaner deleted the lm-check-pending-tx-selecting-utxos branch October 3, 2024 08:42
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.

2 participants