Skip to content

Conversation

martonp
Copy link
Collaborator

@martonp martonp commented Jan 22, 2022

The wallet birthday for the bitcoin SPV wallet was previously
always set to a hardcoded value. This diff stores the time when
the app seed was generated in the db to give an earliest possible
time so scan from, and also adds options on the UI to specify the
desired wallet birthday. Also, the wallet birthday can now be updated
when reconfiguring the wallet

Closes #1270.

@martonp
Copy link
Collaborator Author

martonp commented Jan 22, 2022

Screen Shot 2022-01-22 at 12 50 27 PM

If fresh wallet is selected, the current time will be used for the birthday. If earliest possible is selected, if the seed generation time is stored, that time will be used, otherwise the hardcoded date will be used. If the custom date is selected, that date will be used unless either the seed generation time is or the hardcoded date is later.

@buck54321
Copy link
Member

This seems like exactly what WalletDefinition.ConfigOpts are for.

@martonp
Copy link
Collaborator Author

martonp commented Jan 25, 2022

I was thinking the ConfigOpts were things that could change after the wallet has already been created, while this is something that is just needed for wallet creation. I guess it does make sense though to be able to update the wallet birthday and then do a rescan though.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

Working well.

@martonp martonp changed the title client/ui/btc: More accurate wallet bday client/ui/btc: Configure wallet bday Jan 28, 2022
@martonp
Copy link
Collaborator Author

martonp commented Jan 28, 2022

It's now using WalletDefinition.ConfigOpts . On the create wallet screen it looks the same as in the picture above, but when reconfiguring the wallet, there is just a regular date input. If the wallet is reconfigured with a new birthday, rescan will update the walletdb and use the new birthday.

@chappjc

This comment was marked as resolved.

@chappjc
Copy link
Member

chappjc commented Feb 8, 2022

In testing, I hit an existing data race in ReconfigureWallet that I believe can be resolved as follows:

I'm gonna put this in a tiny PR so we can have it in 0.4.1

@chappjc
Copy link
Member

chappjc commented Feb 22, 2022

Conflicts with QR code merged. Will review latest commit asap though.

@martonp martonp force-pushed the walletBday branch 2 times, most recently from 4720cc9 to a468245 Compare February 22, 2022 15:35
@chappjc chappjc self-requested a review February 24, 2022 17:04
Copy link
Member

@buck54321 buck54321 left a comment

Choose a reason for hiding this comment

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

Just a couple of comments.

@@ -1896,6 +1909,17 @@ func (c *Core) WalletState(assetID uint32) *WalletState {
return wallet.state()
}

// AssetHasActiveOrders checks whether there are any active orders or
// negotiating matches for the specified asset.
func (c *Core) AssetHasActiveOrders(assetID uint32) bool {
Copy link
Member

Choose a reason for hiding this comment

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

OK, but the front-end has everything it needs for this already in the User object.

Copy link
Member

@chappjc chappjc Feb 28, 2022

Choose a reason for hiding this comment

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

That reminds me, I had something similar in frontend for the rescan PR but we ended up moving into Core for the check. 3ab44ef Can use that JS or something like it if you want to move the logic to frontend.

This is a different use case of course, but here's the previous discussion: #1374 (comment)
I ended up agreeing that it made sense to check in Core, but I also appreciate that frontend can know too, even if its check might turn out to be stale, with Core ultimately blocking it.

Copy link
Member

Choose a reason for hiding this comment

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

Ohhhh, this method is double-purposed in apiWalletSettings as well as loadWallet. Yah, it could be omitted from the wallet setting response.

@chappjc
Copy link
Member

chappjc commented Feb 28, 2022

Silly conflict with btc.go.

Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

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

All working well. Just a few formatting and grammatical issues with the birthday config opt description.

IsBoolean bool `json:"isboolean"`
IsDate bool `json:"isdate"`
DisableWhenActive bool `json:"disablewhenactive"`
IsBirthdayConfig bool `json:"isBirthdayConfig"`
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a separate field, how about just handle a special DefaultValue "now" or "birthday" like you did with the min and max values.

if (opt.isdate && opt.default === 'now')

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The behavior I wanted on the UI was to have the default value be "now" if the current installation created the seed, but otherwise be the default value passed in the config.

@martonp martonp force-pushed the walletBday branch 3 times, most recently from 9498976 to 97e966a Compare March 3, 2022 22:03
@chappjc
Copy link
Member

chappjc commented Mar 4, 2022

can merge, but I made conflicts

martonp added 6 commits March 4, 2022 14:19
The wallet birthday for the bitcoin SPV wallet was previously
always set to a hardcoded value. This diff stores the time when
the app seed was generated in the db to give an earliest possible
time so scan from, and also adds options on the UI to specify the
desired wallet birthday. Also, the wallet birthday can now be updated
when reconfiguring the wallet.
@chappjc chappjc merged commit 32721d8 into decred:master Mar 4, 2022
@chappjc chappjc added this to the 0.5 milestone Apr 21, 2022
@martonp martonp deleted the walletBday branch December 20, 2022 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

btc spv: don't use hard-coded wallet birthday unless restoring
4 participants