Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented May 29, 2022

This PR makes check for DuplicateAddress error easier and earlier.

@hebasto hebasto added the Wallet label May 29, 2022
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.

Could move it even earlier in the flow and remove the code from the model (which requires the wallet to be locked):

Inside SendCoinsDialog ::PrepareSendText, before calling WalletModel::prepareTransaction, we are looping over all the entries to load up the recipients list --> Line 257 of SendCoinsDialog.

@hebasto
Copy link
Member Author

hebasto commented May 30, 2022

which requires the wallet to be locked

Do you mean "unlocking" using WalletModel::UnlockContext?

Inside SendCoinsDialog ::PrepareSendText, before calling WalletModel::prepareTransaction, we are looping over all the entries to load up the recipients list --> Line 257 of SendCoinsDialog.

Would it make logic a bit messier?

@furszy
Copy link
Member

furszy commented May 30, 2022

Do you mean "unlocking" using WalletModel::UnlockContext?

Yeah. I skipped the first two letters.

Would it make logic a bit messier?

I think that the current logic is messy actually. We are already validating all the recipients' data there. Check this out: furszy/bitcoin@6115d09 . I made the code flow cleaner there.

Before creating the recipient and adding it to the temporal recipients vector, we call to SendCoinsEntry::validate, which validates the address and the amount (failing if the address is invalid, or the amount is 0 or dust). So, when we are inside WalletModel:: prepareTransaction, we already know whether the address and/or the amount are valid or not. Those checks are duplicated.

I reworked the area a bit here (stopped after few commits to not enter in a long rabbit hole):
https://github.com/furszy/bitcoin/commits/220529-dupaddr

Feel free to cherry-pick any of those commits if you like them, all yours :). Maybe we could team up to get deeper over this rabbit hole in follow-up PRs.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 12, 2022

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

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member Author

hebasto commented Oct 24, 2022

Going to leave this PR up for grabs.

cc @furszy

@hebasto hebasto closed this Oct 24, 2022
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Oct 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants