gui icon indicating copy to clipboard operation
gui copied to clipboard

refactor: interfaces, make 'createTransaction' less error-prone

Open furszy opened this issue 1 year ago • 11 comments
trafficstars

Bundle all function's outputs inside the util::Result returned object.

Removals:

  • The input-output 'change_pos' ref arg from createTransaction, which has been a source of bugs in the past.
  • The 'fee' ref arg from createTransaction, which is currently only set when the transaction creation process succeeds.
  • The currently unreachable AmountWithFeeExceedsBalance error (more info about its re-introduction at https://github.com/bitcoin/bitcoin/pull/25269).

Additionally, this PR moves the CreatedTransactionResult struct into its own file. This change is made to avoid further expanding the GUI dependencies on wallet.h. Structurally, the GUI should only access the model/interfaces and never the wallet directly.

furszy avatar Mar 22 '24 12:03 furszy

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 ryanofsky
Concept ACK hebasto, vasild
Stale ACK pablomartin4btc

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:

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.

DrahtBot avatar Mar 22 '24 12:03 DrahtBot

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin-core/gui/runs/22979285609

DrahtBot avatar Mar 22 '24 13:03 DrahtBot

While introducing a new wallet/util_spend.h header, it seems reasonable to address all related IWYU warnings, no?

hebasto avatar May 12 '24 13:05 hebasto

cc @achow101 @ryanofsky

hebasto avatar May 12 '24 13:05 hebasto

🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

Leave a comment here, if you need help tracking down a confusing failure.

Debug: https://github.com/bitcoin-core/gui/runs/25073685372

DrahtBot avatar May 16 '24 21:05 DrahtBot

nit: on 2nd. commit (https://github.com/bitcoin-core/gui/commit/95aaaa4f023c6a6b629c36cfb9d8abd4bab1cb66), you forgot to remove the change from the makefile as it's not longer needed.

Removed. Thanks.

furszy avatar May 17 '24 01:05 furszy

CI failure is unrelated.

furszy avatar May 17 '24 14:05 furszy

I just noticed https://github.com/bitcoin/bitcoin/pull/25269, which I hadn't seen when I posted my comment above. It looks like that PR was closed for inactivity but it does look like a good approach that solves the issue I didn't like in my comment. (Though maybe that PR is still a slight regression because it doesn't include the amount of the fee in the error message.) I wonder if you'd consider reopening that PR and maybe including the changes in this PR there, or basing this PR on that one?

Or if you no longer think that PR is worth pursuing, I think you could separate the cleanups here from the issue that PR was trying to address by leaving the CAmount& fee output parameter and GUI code intact here, but still doing the other cleanups.

ryanofsky avatar May 17 '24 18:05 ryanofsky

Concept ACK.

Additionally, this PR moves the CreatedTransactionResult struct into its own file.

This part of the PR description seems no longer relevant.

Thanks for the review ryanofsky!

I just noticed bitcoin/bitcoin#25269, which I hadn't seen when I posted my comment above. It looks like that PR was closed for inactivity but it does look like a good approach that solves the issue I didn't like in my comment. (Though maybe that PR is still a slight regression because it doesn't include the amount of the fee in the error message.) I wonder if you'd consider reopening that PR and maybe including the changes in this PR there, or basing this PR on that one?

Yeah sure, I closed it for lack of movement after 6 months. I just reopen it, reworking part of it, and rebased this one on top. I think it make sense to re-introduce the functionality there and cleanup the GUI code here.

I agree on focusing this PR on the code cleanup only.

hebasto avatar Jul 15 '24 15:07 hebasto

Drafted until https://github.com/bitcoin/bitcoin/pull/25269 gets merged. This is a continuation of that work.

furszy avatar Jul 15 '24 19:07 furszy

Concept ACK

vasild avatar Jul 22 '24 12:07 vasild

🐙 This pull request conflicts with the target branch and needs rebase.

DrahtBot avatar May 20 '25 09:05 DrahtBot

Are you still working on this?

achow101 avatar Oct 22 '25 14:10 achow101