Skip to content

wallet: if only have one output type, don't perform "mixed" coin selection - #26668

Merged
achow101 merged 1 commit into
bitcoin:masterfrom
furszy:2022_wallet_double_coin_selection
Dec 14, 2022
Merged

achow101 merged 1 commit into
bitcoin:masterfrom
furszy:2022_wallet_double_coin_selection

Conversation

@furszy

@furszy furszy commented Dec 8, 2022

Copy link
Copy Markdown
Member

For wallets that only have one output type, we are currently performing the same
selection process over the same coins twice.

The "mixed coin selection" doesn't add any value to the result
(there is nothing to mix if the available coins struct has only one type).

@DrahtBot

DrahtBot commented Dec 8, 2022 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK john-moffett, achow101, kristapsk

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26661 (wallet: Coin Selection, return accurate error messages by furszy)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@john-moffett john-moffett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK 89c1491

It's not important to this code, but this comment:

// If TypesCount() <= 1, there is nothing to mix.

got me wondering whether you could get to here with TypesCount() == 0, and I don't think you can, due to

// Return early if we cannot cover the target with the wallet's UTXO.
// We use the total effective value if we are not subtracting fee from outputs and 'available_coins' contains the data.
CAmount available_coins_total_amount = coin_selection_params.m_subtract_fee_outputs ? available_coins.GetTotalAmount() :
(available_coins.GetEffectiveTotalAmount().has_value() ? *available_coins.GetEffectiveTotalAmount() : 0);
if (selection_target > available_coins_total_amount) {
return std::nullopt; // Insufficient funds
}

@furszy

furszy commented Dec 12, 2022

Copy link
Copy Markdown
Member Author

Yes @john-moffett, if TypesCount() == 0 then we have no coins, so we never perform coin selection.

@achow101

Copy link
Copy Markdown
Member

ACK 89c1491

@kristapsk kristapsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cr utACK 89c1491

@achow101
achow101 merged commit ba47a4b into bitcoin:master Dec 14, 2022
@furszy
furszy deleted the 2022_wallet_double_coin_selection branch May 27, 2023 01:46
@bitcoin bitcoin locked and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants