Skip to content

Commit

Permalink
rebase master. fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
codemaestro64 committed May 24, 2020
1 parent 22f6d6f commit 9a30eda
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions multiwallet.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dcrlibwallet

import (
"bytes"
"context"
"encoding/json"
"os"
Expand Down Expand Up @@ -282,6 +283,7 @@ func (mw *MultiWallet) CreateNewWallet(walletName, privatePassphrase string, pri
if err != nil {
return nil, err
}

wallet := &Wallet{
Name: walletName,
CreatedAt: time.Now(),
Expand Down Expand Up @@ -405,12 +407,10 @@ func (mw *MultiWallet) saveNewWallet(wallet *Wallet, setupWallet func() error) (
return nil, errors.New(ErrExist)
}

// Check if any of the other wallets has the same seed with this wallet
// If so, return an error
for _, wal := range mw.wallets {
if wal.Seed == wallet.Seed {
return nil, errors.New(ErrSeedExists)
}
// check if wallet with same seed already exists
err = mw.checkForSeedClash(wallet.EncryptedSeed)
if err != nil {
return nil, err
}

if mw.IsConnectedToDecredNetwork() {
Expand Down Expand Up @@ -661,3 +661,14 @@ func (mw *MultiWallet) ChangePrivatePassphraseForWallet(walletID int, oldPrivate

return nil
}

// checkForSeedClash checks to see if any wallet in the multi wallet has the same seed as the passed seed
// returns an error if there is any
func (mw *MultiWallet) checkForSeedClash(encryptedSeed []byte) error {
for _, wal := range mw.wallets {
if bytes.Equal(wal.EncryptedSeed, encryptedSeed) {
return errors.New(ErrSeedExists)
}
}
return nil
}

0 comments on commit 9a30eda

Please sign in to comment.