Skip to content

Conversation

aureleoules
Copy link
Contributor

  • Moves CoinControl function definitions from coincontrol.h to coincontrol.cpp
  • Adds more documentation
  • Renames class member for an improved comprehension
  • Use std::optional for GetExternalOutput

@yancyribbens
Copy link
Contributor

These changes improve the code quality and implement the recommended practices described in the developer notes - source code organization.

Concept ACK

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK ae67293

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 12, 2022

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 Xekyo, achow101
Concept ACK yancyribbens
Stale ACK w0xlt, satsie, furszy, theStack

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:

  • #26567 (Wallet: estimate the size of signed inputs using descriptors by darosior)
  • #25273 (wallet: Pass through transaction locktime and preset input sequences and scripts to CreateTransaction by achow101)

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.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

In dba7f9b:
Why only change IsSelected and HasSelected and not the setters? Should be consistent.

Saying that, even if we are consistent on the renaming, I'm not so sure about it. Do you think that PreSelect(outpoint)/IsPreSelected(outpoint) is more understandable than Select(outpoint)/IsSelected(output)?

At least in my view, it doesn't look more readable than before.
Would instead aim for a good docstring and done.

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from ae67293 to 69b67d5 Compare September 13, 2022 17:04
@aureleoules
Copy link
Contributor Author

@furszy I've slightly improved the docstring of Select and SelectExternal and rolled back to IsSelected and HasSelected.
I kept the old setSelected as m_preset_inputs though.

Is it better?

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Yeah @aureleoules better 👍🏼 .

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from 69b67d5 to 4d77ada Compare September 15, 2022 22:20
@aureleoules
Copy link
Contributor Author

All cleaned-up @furszy!

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch 2 times, most recently from d0156a0 to 9d4cfd6 Compare September 15, 2022 22:27
Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

ACK 9d4cfd6

Comment on lines 83 to 84
* Pre-selects the given output.
* The output will be included in the transaction even if it's not the most optimal choice.
Copy link
Member

Choose a reason for hiding this comment

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

nit: would remove the "pre-selects" term and go directly with something like "store the given outpoint."

I don't think that the "pre" term here provides information to readers. (the second paragraph is great to express what the process will do with the selected outpoint)

(same for the others methods as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this?

Suggested change
* Pre-selects the given output.
* The output will be included in the transaction even if it's not the most optimal choice.
* Lock-in the selected output for spending.
* The output will be included in the transaction even if it's not the most optimal choice.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, sounds good 👌🏼 .


private:
std::set<COutPoint> setSelected;
std::set<COutPoint> m_preset_inputs;
std::map<COutPoint, CTxOut> m_external_txouts;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you've done such a fabulous job documenting the header methods (no good deed goes unpunished!) that I think I understand an external input is one that does not belong to the wallet.

If you find yourself in the code again, is there any chance to get a comment on this data structure describing what it is? Something like //! Map of inputs that do not belong to the wallet (if that is indeed the correct definition). Actually... just for my own learning, is that the correct definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!
And yes you are correct :) The wallet would not know how to sign these inputs but they are in the utxo set.

@satsie
Copy link
Contributor

satsie commented Sep 16, 2022

ACK 9d4cfd6, reviewed diff and ran unit + functional tests

I'm very new to the project but this was a great PR to review, especially after the changes that came in from earlier code review. Thanks for the comments you added on all the function definitions. Can confirm that they are helpful to new eyes and as far as I can tell, the changes are a nice cleanup that make things easier to read, understand, and follow the recommended practices (as mentioned in an earlier comment).

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from 9d4cfd6 to 287719a Compare September 16, 2022 17:05
@aureleoules
Copy link
Contributor Author

Thanks for the reviews, I addressed your comments @satsie @furszy.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

ACK 287719a

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from 287719a to 8031f47 Compare September 16, 2022 17:11
@aureleoules
Copy link
Contributor Author

sorry I failed my rebase @furszy

@furszy
Copy link
Member

furszy commented Sep 16, 2022

or well, not ACK :p.
You forgot to change the m_preset_inputs inside CCoinControl

@aureleoules
Copy link
Contributor Author

aureleoules commented Sep 16, 2022

Should be all good now, I've actually renamed setSelected to m_selected_inputs instead of m_preset_inputs.
Edit: also fixed typo Lock-in the selected coins for spending. to Lock-in the given output for spending.

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from 8031f47 to 5db911a Compare September 16, 2022 17:38
@satsie
Copy link
Contributor

satsie commented Sep 16, 2022

ACK 5db911a

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

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

ACK 5db911a

@aureleoules
Copy link
Contributor Author

I think this is ready for merging? @w0xlt if you could reACK that would be great 😄.

@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from 5db911a to 3f1a6d9 Compare October 28, 2022 12:36
@DrahtBot DrahtBot requested review from satsie and w0xlt and removed request for w0xlt April 25, 2023 16:18
@achow101 achow101 requested review from murchandamus and removed request for satsie and w0xlt April 25, 2023 16:19
-BEGIN VERIFY SCRIPT-
sed -i 's/setSelected/m_selected_inputs/g' src/wallet/coincontrol.h src/wallet/coincontrol.cpp
-END VERIFY SCRIPT-
Move definitions to coincontrol.cpp and add documentation.
@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from b76fbbe to c975c42 Compare April 26, 2023 08:37
@aureleoules aureleoules force-pushed the 2022-09-refactor-coincontrol branch from c975c42 to daba957 Compare April 26, 2023 08:41
@aureleoules
Copy link
Contributor Author

Rebased

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

ACK daba957

m_external_txouts.emplace(outpoint, txout);
}

void CCoinControl::UnSelect(const COutPoint& output)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: If it’s not too much of a bother, and if you have to touch the code again, I would consider it an improvement to change UnSelect to Unselect. The first time I scanned that passage, the capitalized “S” in the middle of the word made me think that it was actually just “Select”. Even more nitty, I’d use the adjective “unselected” to refer to things that were not picked in the first place, I would prefer “to deselect” to refer to removing things from a selection.

Suggested change
void CCoinControl::UnSelect(const COutPoint& output)
void CCoinControl::Deselect(const COutPoint& output)

m_selected_inputs.erase(output);
}

void CCoinControl::UnSelectAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit with the same reasoning as above:

Suggested change
void CCoinControl::UnSelectAll()
void CCoinControl::DeselectAll()

@DrahtBot DrahtBot requested review from satsie, theStack and w0xlt and removed request for satsie and w0xlt May 3, 2023 14:03
@achow101
Copy link
Member

achow101 commented May 3, 2023

ACK daba957

@DrahtBot DrahtBot requested review from satsie and w0xlt and removed request for satsie and w0xlt May 3, 2023 15:10
@achow101 achow101 merged commit 0e70a1b into bitcoin:master May 3, 2023
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 4, 2023
daba957 refactor: Make ListSelected return vector (Sebastian Falbesoner)
9477662 wallet: Move CoinCointrol definitions to .cpp (Aurèle Oulès)
1db23da wallet: Use std::optional for GetExternalOutput and fixups (Aurèle Oulès)
becc45b scripted-diff: Rename setSelected->m_selected_inputs (Aurèle Oulès)

Pull request description:

  - Moves CoinControl function definitions from `coincontrol.h` to `coincontrol.cpp`
  - Adds more documentation
  - Renames class member for an improved comprehension
  - Use `std::optional` for `GetExternalOutput`

ACKs for top commit:
  achow101:
    ACK daba957
  Xekyo:
    ACK daba957

Tree-SHA512: 3bf2dc834a3246c2f53f8c55154258e605fcb169431d3f7b156931f33c7e3b1ae28e03e16b37f9140a827890eb7798be485b2c36bfc23ff29bb01763f289a07c
@bitcoin bitcoin locked and limited conversation to collaborators May 2, 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.