mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
8b2b109939
* imported -> local * reverting to the state of the PR at eb1e3c3d1 * use changes from develop * del * rem patch * patch * rename to local * gazelle * add back build * imported rename * gaz * local * merge fix + remove proto changes * comment revert * build * gofmt and one new reference * gofmt pt2 * Update validator/accounts/wallet_edit.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Update validator/rpc/accounts.go * rename * gaz Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
57 lines
1.9 KiB
Go
57 lines
1.9 KiB
Go
package accounts
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/validator/accounts/userprompt"
|
|
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
|
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
|
"github.com/prysmaticlabs/prysm/validator/keymanager/remote"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// EditWalletConfigurationCli for a user's on-disk wallet, being able to change
|
|
// things such as remote gRPC credentials for remote signing, derivation paths
|
|
// for HD wallets, and more.
|
|
func EditWalletConfigurationCli(cliCtx *cli.Context) error {
|
|
w, err := wallet.OpenWalletOrElseCli(cliCtx, func(cliCtx *cli.Context) (*wallet.Wallet, error) {
|
|
return nil, wallet.ErrNoWalletFound
|
|
})
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not open wallet")
|
|
}
|
|
switch w.KeymanagerKind() {
|
|
case keymanager.Local:
|
|
return errors.New("not possible to edit local keymanager configuration")
|
|
case keymanager.Derived:
|
|
return errors.New("derived keymanager is not yet supported")
|
|
case keymanager.Remote:
|
|
enc, err := w.ReadKeymanagerConfigFromDisk(cliCtx.Context)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not read config")
|
|
}
|
|
opts, err := remote.UnmarshalOptionsFile(enc)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not unmarshal config")
|
|
}
|
|
log.Info("Current configuration")
|
|
// Prints the current configuration to stdout.
|
|
fmt.Println(opts)
|
|
newCfg, err := userprompt.InputRemoteKeymanagerConfig(cliCtx)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not get keymanager config")
|
|
}
|
|
encodedCfg, err := remote.MarshalOptionsFile(cliCtx.Context, newCfg)
|
|
if err != nil {
|
|
return errors.Wrap(err, "could not marshal config file")
|
|
}
|
|
if err := w.WriteKeymanagerConfigToDisk(cliCtx.Context, encodedCfg); err != nil {
|
|
return errors.Wrap(err, "could not write config to disk")
|
|
}
|
|
default:
|
|
return fmt.Errorf(errKeymanagerNotSupported, w.KeymanagerKind())
|
|
}
|
|
return nil
|
|
}
|