wallet: use last synced block as birthday in development environments
In this commit, we address an issue with chains that are not current, like in the often case of regtest and simnet chains. Syncing the wallet would fail due to the chain not being current and not finding a suitable birthday block. We fix this by just using the last synced block as the birthday block to ensure we can properly sync to the chain.
This commit is contained in:
parent
ea7c6c3ed9
commit
06bf42c746
1 changed files with 15 additions and 2 deletions
|
@ -612,13 +612,26 @@ func (w *Wallet) syncToBirthday() (*waddrmgr.BlockStamp, error) {
|
|||
}
|
||||
|
||||
// If a birthday stamp has yet to be found, we'll return an error
|
||||
// indicating so.
|
||||
if birthdayStamp == nil {
|
||||
// indicating so, but only if this is a live chain like it is the case
|
||||
// with testnet and mainnet.
|
||||
if birthdayStamp == nil && !w.isDevEnv() {
|
||||
tx.Rollback()
|
||||
return nil, fmt.Errorf("did not find a suitable birthday "+
|
||||
"block with a timestamp greater than %v", birthday)
|
||||
}
|
||||
|
||||
// Otherwise, if we're in a development environment and we've yet to
|
||||
// find a birthday block due to the chain not being current, we'll
|
||||
// use the last block we've synced to as our birthday to proceed.
|
||||
if birthdayStamp == nil {
|
||||
syncedTo := w.Manager.SyncedTo()
|
||||
err := w.Manager.SetBirthdayBlock(ns, syncedTo, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
birthdayStamp = &syncedTo
|
||||
}
|
||||
|
||||
if err := tx.Commit(); err != nil {
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue