Skip to content

Commit

Permalink
client/asset: removed Seeded field from WalletInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Oct 22, 2021
1 parent d202f6d commit 10f299c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
3 changes: 0 additions & 3 deletions client/asset/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ type WalletInfo struct {
// UnitInfo is the information about unit names and conversion factors for
// the asset.
UnitInfo dex.UnitInfo `json:"unitinfo"`
// Seeded represents a built-in wallet. If Seeded is true, the wallet must be
// created with a deterministic seed using (Driver).Create before it can be opened.
Seeded bool
}

// ConfigOption is a wallet configuration option.
Expand Down
26 changes: 10 additions & 16 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -2033,8 +2033,13 @@ func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) er
return newError(missingWalletErr, "%d -> %s wallet not found",
assetID, unbip(assetID))
}
seeded := oldWallet.Info().Seeded
if seeded && newWalletPW != nil {

oldDef, err := walletDefinition(assetID, oldWallet.walletType)
if err != nil {
return fmt.Errorf("failed to locate old wallet definition: %v", err)
}

if walletDef.Seeded && newWalletPW != nil {
return newError(passwordErr, "cannot set a password on a built-in wallet")
}
oldDepositAddr := oldWallet.currentDepositAddress()
Expand All @@ -2057,11 +2062,6 @@ func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) er
}
}()

oldDef, err := walletDefinition(assetID, oldWallet.walletType)
if err != nil {
return fmt.Errorf("failed to locate old wallet definition: %v", err)
}

if walletDef.Seeded {
if newWalletPW != nil {
return newError(passwordErr, "cannot set a password on a seeded wallet")
Expand All @@ -2084,15 +2084,9 @@ func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) er
}
}

if oldWallet.connected() {
oldDef, err := walletDefinition(assetID, oldWallet.walletType)
// Error can be normal if the wallet was created before wallet types
// were a thing. Just assume this is an old wallet and therefore not
// seeded.
if err == nil && oldDef.Seeded {
oldWallet.Disconnect()
restartOnFail = true
}
if oldWallet.connected() && oldDef.Seeded {
oldWallet.Disconnect()
restartOnFail = true
}
} else if newWalletPW == nil && oldDef.Seeded {
// If we're switching from a seeded wallet and no password was provided,
Expand Down

0 comments on commit 10f299c

Please sign in to comment.