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

Filter duplicate coins before coin selection #1279

Merged
merged 2 commits into from Jan 31, 2024

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Jan 16, 2024

Fixes #1240

Description

We now filter out duplicate coins before calling CoinSelectionAlgorithm::coin_select. If a UTXO exists in both required_utxos and optional_utxos, only the copy in required_utxos will be kept.

Test helper methods are also updated to not create duplicate UTXOs.

Changelog notice

Fixed

  • Filter out duplicate UTXOs before calling CoinSelectionAlgorithm::coin_select. If a UTXO exists in both required_utxos and optional_utxos, only the copy in required_utxos will be kept.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

* [ ] This pull request breaks the existing API

  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@evanlinjin evanlinjin self-assigned this Jan 16, 2024
@evanlinjin evanlinjin added the bug Something isn't working label Jan 16, 2024
@LLFourn
Copy link
Contributor

LLFourn commented Jan 19, 2024

Can't we just fix this before passing it in rather than change every coin selection algorithm?

@evanlinjin
Copy link
Member Author

Can't we just fix this before passing it in rather than change every coin selection algorithm?

That's a good point. I assumed that people will use the trait directly. If we assume that people will always go through the TxBuilder what you suggested is better.

@LLFourn
Copy link
Contributor

LLFourn commented Jan 22, 2024

I don't think anyone is using these directly so I'd go for the more succinct fix.

@evanlinjin evanlinjin changed the title CoinSelectionAlgorithm implementations should filter duplicates Filter duplicate coins before coin selection Jan 29, 2024
Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

utACK 5299db3

@evanlinjin evanlinjin merged commit 070fffb into bitcoindevkit:master Jan 31, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Duplicate inputs coin selection
3 participants