-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet: allow manually setting the wallet birthday #885
wallet: allow manually setting the wallet birthday #885
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some thoughts, nothing blocking IMO.
rpc/rpcserver/server.go
Outdated
@@ -693,8 +693,14 @@ func (s *loaderServer) CreateWallet(ctx context.Context, req *pb.CreateWalletReq | |||
pubPassphrase = []byte(wallet.InsecurePubPassphrase) | |||
} | |||
|
|||
// Use the current time for the birthday when the request's is empty. | |||
bday := req.Birthday |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
bday := time.Now()
if req.Birthday != 0 {
bday := time.Unix(req.Birthday, 0)
}
That then shortens the call below.
@@ -43,6 +43,7 @@ var ( | |||
defaultRPCKeyFile = filepath.Join(defaultAppDataDir, "rpc.key") | |||
defaultRPCCertFile = filepath.Join(defaultAppDataDir, "rpc.cert") | |||
defaultLogDir = filepath.Join(defaultAppDataDir, defaultLogDirname) | |||
defaultBirthday = time.Now().Unix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the default be a very early timestamp instead? Otherwise a user might fear their coins are gone if they don't know to set this parameter and are trying to restore from an old seed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the current time as the default because that was what was previously used whenever a new wallet was created:
fmt.Println("Creating the wallet...")
w, err := loader.CreateNewWallet(pubPass, privPass, seed, time.Now())
if err != nil {
return err
}
--->
fmt.Println("Creating the wallet...")
w, err := loader.CreateNewWallet(pubPass, privPass, seed, time.Unix(cfg.Birthday, 0))
if err != nil {
return err
}
; the earliest time the wallet could have participated in any transactions. | ||
; This timestamp will be used to estimate a block height that is an appropriate | ||
; starting place to scan for transactions related to this wallet. | ||
; birthday=1231006505 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should mention the default value/default behavior here.
@@ -188,7 +188,7 @@ func createWallet(cfg *config) error { | |||
} | |||
|
|||
fmt.Println("Creating the wallet...") | |||
w, err := loader.CreateNewWallet(pubPass, privPass, seed, time.Now()) | |||
w, err := loader.CreateNewWallet(pubPass, privPass, seed, time.Unix(cfg.Birthday, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I'm not familiar with btcwallet
as a standalone wallet. When is this code run vs. the CreateWallet
RPC call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When being used as a standalone tool, you can create a wallet from the command line with btcwallet --create
, which will run that code in that snippet
Adds a flag that allows for the wallet's birthday to be specified when being created. This gives the user control over where rescans begin for a BTC wallet that is recovered with a seed. This is meant to resolve #883.