Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ func createWallet(createWalletParams *asset.CreateWalletParams, skipConnect bool
return errors.New("no providers specified")
}
endpoints := strings.Split(providerDef, providerDelimiter)
n := len(endpoints)

// TODO: This procedure may actually work for walletTypeGeth too.
ks := keystore.NewKeyStore(filepath.Join(walletDir, "keystore"), keystore.LightScryptN, keystore.LightScryptP)
Expand All @@ -607,36 +606,9 @@ func createWallet(createWalletParams *asset.CreateWalletParams, skipConnect bool
}

if !skipConnect {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

var unknownEndpoints []string

for _, endpoint := range endpoints {
known, compliant := providerIsCompliant(endpoint)
if known && !compliant {
return fmt.Errorf("provider %q is known to have an insufficient API for DEX", endpoint)
} else if !known {
unknownEndpoints = append(unknownEndpoints, endpoint)
}
}

if len(unknownEndpoints) > 0 && createWalletParams.Net == dex.Mainnet {
providers, err := connectProviders(ctx, unknownEndpoints, createWalletParams.Logger, big.NewInt(chainIDs[createWalletParams.Net]), createWalletParams.Net)
if err != nil {
return err
}
defer func() {
for _, p := range providers {
p.ec.Close()
}
}()
if len(providers) != n {
return fmt.Errorf("Could not connect to all providers")
}
if err := checkProvidersCompliance(ctx, walletDir, providers, createWalletParams.Logger); err != nil {
return err
}
if err := createAndCheckProviders(context.Background(), walletDir, endpoints,
createWalletParams.Net, createWalletParams.Logger); err != nil {
return fmt.Errorf("create and check providers problem: %v", err)
}
}
return importKeyToKeyStore(ks, priv, createWalletParams.Pass)
Expand Down Expand Up @@ -893,7 +865,8 @@ func (w *ETHWallet) Reconfigure(ctx context.Context, cfg *asset.WalletConfig, cu
}

if rpc, is := w.node.(*multiRPCClient); is {
if err := rpc.reconfigure(ctx, cfg.Settings); err != nil {
walletDir := getWalletDir(w.dir, w.net)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The getWalletDir path seems unnecessary. It will end up being something like $HOME/.dexc/simnet/assetdb/eth/simnet and I don't think the last siment is necessary. The keystore folder already lives there though, is it worth changing now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've noticed that too. Not sure if we should change it though. However, nobody should be using this on mainnet, and we can move our testnet folders around if we do change it.
Maybe someone else has a more decisive opinion.

@buck54321 buck54321 Feb 8, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This has always bugged me too. On one hand, the asset package shouldn't make assumptions about what the caller is going to give. On the other hand, as you pointed out, it's stupid with the extra directory.

Anyway, won't this change bork existing wallets?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Anyway, won't this change bork existing wallets?

Yes. Existing testnet eth multiprc wallets.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Just leaving for now, can be addressed in another pr if necessary.

if err := rpc.reconfigure(ctx, cfg.Settings, walletDir); err != nil {
return false, err
}
}
Expand Down
Loading