From 3cbc27f53d69d8f1bf4d48e26c9cb22d0e115d07 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sun, 8 Nov 2020 19:44:30 +0000 Subject: [PATCH] Additional modular commands. --- cmd/account/create/input.go | 97 +++++ cmd/account/create/input_internal_test.go | 161 +++++++ cmd/account/create/output.go | 45 ++ cmd/account/create/output_internal_test.go | 113 +++++ cmd/account/create/process.go | 144 +++++++ cmd/account/create/process_internal_test.go | 315 ++++++++++++++ cmd/account/create/run.go | 50 +++ cmd/account/import/input.go | 88 ++++ cmd/account/import/input_internal_test.go | 152 +++++++ cmd/account/import/output.go | 45 ++ cmd/account/import/output_internal_test.go | 113 +++++ cmd/account/import/process.go | 51 +++ cmd/account/import/process_internal_test.go | 95 +++++ cmd/account/import/run.go | 50 +++ cmd/account/key/input.go | 52 +++ cmd/account/key/input_internal_test.go | 129 ++++++ cmd/account/key/output.go | 36 ++ cmd/account/key/output_internal_test.go | 69 +++ cmd/account/key/process.go | 65 +++ cmd/account/key/process_internal_test.go | 87 ++++ cmd/account/key/run.go | 50 +++ cmd/accountcreate.go | 80 +--- cmd/accountimport.go | 63 +-- cmd/accountkey.go | 47 +-- cmd/depositverify.go | 2 +- cmd/exitverify.go | 2 +- cmd/networks.go | 3 +- cmd/passphrases.go | 18 - cmd/root.go | 45 +- cmd/signing.go | 15 +- cmd/wallet/create/input.go | 89 ++++ cmd/wallet/create/input_internal_test.go | 134 ++++++ cmd/wallet/create/output.go | 43 ++ cmd/wallet/create/output_internal_test.go | 62 +++ cmd/wallet/create/process.go | 134 ++++++ cmd/wallet/create/process_internal_test.go | 152 +++++++ cmd/wallet/create/run.go | 50 +++ cmd/wallet/delete/input.go | 59 +++ cmd/wallet/delete/input_internal_test.go | 103 +++++ cmd/wallet/delete/output.go | 29 ++ cmd/wallet/delete/output_internal_test.go | 50 +++ cmd/wallet/delete/process.go | 48 +++ cmd/wallet/delete/process_internal_test.go | 77 ++++ cmd/wallet/delete/run.go | 50 +++ cmd/wallet/export/input.go | 67 +++ cmd/wallet/export/input_internal_test.go | 112 +++++ cmd/wallet/export/output.go | 33 ++ cmd/wallet/export/output_internal_test.go | 50 +++ cmd/wallet/export/process.go | 50 +++ cmd/wallet/export/process_internal_test.go | 88 ++++ cmd/wallet/export/run.go | 50 +++ cmd/wallet/import/input.go | 82 ++++ cmd/wallet/import/input_internal_test.go | 134 ++++++ cmd/wallet/import/output.go | 60 +++ cmd/wallet/import/output_internal_test.go | 90 ++++ cmd/wallet/import/process.go | 51 +++ cmd/wallet/import/process_internal_test.go | 132 ++++++ cmd/wallet/import/run.go | 50 +++ cmd/walletcreate.go | 114 +---- cmd/walletdelete.go | 36 +- cmd/walletexport.go | 40 +- cmd/walletimport.go | 87 +--- core/account.go | 8 +- docs/usage.md | 6 +- go.mod | 32 +- go.sum | 440 ++++++++++++++++++++ signing/signroot.go | 4 +- testutil/bytes.go | 29 ++ util/bls_test.go | 55 +++ util/depositinfo.go | 7 + util/depositinfo_internal_test.go | 255 ++++++++++++ util/depositinfo_test.go | 76 ++++ util/logging_internal_test.go | 80 ++++ util/scratchaccount.go | 3 +- util/scratchaccount_test.go | 136 ++++++ 75 files changed, 5351 insertions(+), 468 deletions(-) create mode 100644 cmd/account/create/input.go create mode 100644 cmd/account/create/input_internal_test.go create mode 100644 cmd/account/create/output.go create mode 100644 cmd/account/create/output_internal_test.go create mode 100644 cmd/account/create/process.go create mode 100644 cmd/account/create/process_internal_test.go create mode 100644 cmd/account/create/run.go create mode 100644 cmd/account/import/input.go create mode 100644 cmd/account/import/input_internal_test.go create mode 100644 cmd/account/import/output.go create mode 100644 cmd/account/import/output_internal_test.go create mode 100644 cmd/account/import/process.go create mode 100644 cmd/account/import/process_internal_test.go create mode 100644 cmd/account/import/run.go create mode 100644 cmd/account/key/input.go create mode 100644 cmd/account/key/input_internal_test.go create mode 100644 cmd/account/key/output.go create mode 100644 cmd/account/key/output_internal_test.go create mode 100644 cmd/account/key/process.go create mode 100644 cmd/account/key/process_internal_test.go create mode 100644 cmd/account/key/run.go create mode 100644 cmd/wallet/create/input.go create mode 100644 cmd/wallet/create/input_internal_test.go create mode 100644 cmd/wallet/create/output.go create mode 100644 cmd/wallet/create/output_internal_test.go create mode 100644 cmd/wallet/create/process.go create mode 100644 cmd/wallet/create/process_internal_test.go create mode 100644 cmd/wallet/create/run.go create mode 100644 cmd/wallet/delete/input.go create mode 100644 cmd/wallet/delete/input_internal_test.go create mode 100644 cmd/wallet/delete/output.go create mode 100644 cmd/wallet/delete/output_internal_test.go create mode 100644 cmd/wallet/delete/process.go create mode 100644 cmd/wallet/delete/process_internal_test.go create mode 100644 cmd/wallet/delete/run.go create mode 100644 cmd/wallet/export/input.go create mode 100644 cmd/wallet/export/input_internal_test.go create mode 100644 cmd/wallet/export/output.go create mode 100644 cmd/wallet/export/output_internal_test.go create mode 100644 cmd/wallet/export/process.go create mode 100644 cmd/wallet/export/process_internal_test.go create mode 100644 cmd/wallet/export/run.go create mode 100644 cmd/wallet/import/input.go create mode 100644 cmd/wallet/import/input_internal_test.go create mode 100644 cmd/wallet/import/output.go create mode 100644 cmd/wallet/import/output_internal_test.go create mode 100644 cmd/wallet/import/process.go create mode 100644 cmd/wallet/import/process_internal_test.go create mode 100644 cmd/wallet/import/run.go create mode 100644 testutil/bytes.go create mode 100644 util/bls_test.go create mode 100644 util/depositinfo_internal_test.go create mode 100644 util/depositinfo_test.go create mode 100644 util/logging_internal_test.go create mode 100644 util/scratchaccount_test.go diff --git a/cmd/account/create/input.go b/cmd/account/create/input.go new file mode 100644 index 0000000..dbd2b2b --- /dev/null +++ b/cmd/account/create/input.go @@ -0,0 +1,97 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/core" + "github.com/wealdtech/ethdo/util" + e2wallet "github.com/wealdtech/go-eth2-wallet" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + timeout time.Duration + // For all accounts. + wallet e2wtypes.Wallet + accountName string + passphrase string + walletPassphrase string + // For distributed accounts. + participants uint32 + signingThreshold uint32 + // For pathed accounts. + path string +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + + // Account name. + if viper.GetString("account") == "" { + return nil, errors.New("account is required") + } + _, data.accountName, err = e2wallet.WalletAndAccountNames(viper.GetString("account")) + if err != nil { + return nil, errors.Wrap(err, "failed to obtain account name") + } + if data.accountName == "" { + return nil, errors.New("account name is required") + } + + // Wallet. + ctx, cancel := context.WithTimeout(ctx, data.timeout) + defer cancel() + data.wallet, err = core.WalletFromInput(ctx) + cancel() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain wallet") + } + + // Passphrase. + data.passphrase, err = util.GetOptionalPassphrase() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain passphrase") + } + + // Wallet passphrase. + data.walletPassphrase = util.GetWalletPassphrase() + + // Participants. + if viper.GetInt32("participants") == 0 { + return nil, errors.New("participants must be at least one") + } + data.participants = viper.GetUint32("participants") + + // Signing threshold. + if viper.GetInt32("signing-threshold") == 0 { + return nil, errors.New("signing threshold must be at least one") + } + data.signingThreshold = viper.GetUint32("signing-threshold") + + // Path. + data.path = viper.GetString("path") + + return data, nil +} diff --git a/cmd/account/create/input_internal_test.go b/cmd/account/create/input_internal_test.go new file mode 100644 index 0000000..98bd380 --- /dev/null +++ b/cmd/account/create/input_internal_test.go @@ -0,0 +1,161 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + testWallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "timeout is required", + }, + { + name: "WalletUnknown", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Unknown/Test account", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain wallet: wallet not found", + }, + { + name: "AccountMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "account is required", + }, + { + name: "AccountWalletOnly", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + "account": "Test wallet/", + }, + err: "account name is required", + }, + { + name: "AccountMalformed", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "//", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain account name: invalid account format", + }, + { + name: "MultiplePassphrases", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": []string{"ce%NohGhah4ye5ra", "other"}, + "participants": 3, + "signing-threshold": 2, + }, + err: "failed to obtain passphrase: multiple passphrases supplied", + }, + { + name: "ParticipantsZero", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + "participants": 0, + "signing-threshold": 2, + }, + err: "participants must be at least one", + }, + { + name: "SigningThresholdZero", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + "participants": 3, + "signing-threshold": 0, + }, + err: "signing threshold must be at least one", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + "participants": 3, + "signing-threshold": 2, + }, + res: &dataIn{ + timeout: 5 * time.Second, + accountName: "Test account", + passphrase: "ce%NohGhah4ye5ra", + participants: 3, + signingThreshold: 2, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + // Cannot compare accounts directly, so need to check each element individually. + require.Equal(t, test.res.timeout, res.timeout) + require.Equal(t, test.res.accountName, res.accountName) + require.Equal(t, test.res.passphrase, res.passphrase) + require.Equal(t, test.res.participants, res.participants) + require.Equal(t, test.res.signingThreshold, res.signingThreshold) + } + }) + } +} diff --git a/cmd/account/create/output.go b/cmd/account/create/output.go new file mode 100644 index 0000000..ff47530 --- /dev/null +++ b/cmd/account/create/output.go @@ -0,0 +1,45 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "fmt" + + "github.com/pkg/errors" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataOut struct { + account e2wtypes.Account +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + if data.account == nil { + return "", errors.New("no account") + } + + if pubKeyProvider, ok := data.account.(e2wtypes.AccountCompositePublicKeyProvider); ok { + return fmt.Sprintf("%#x", pubKeyProvider.CompositePublicKey().Marshal()), nil + } + + if pubKeyProvider, ok := data.account.(e2wtypes.AccountPublicKeyProvider); ok { + return fmt.Sprintf("%#x", pubKeyProvider.PublicKey().Marshal()), nil + } + + return "", errors.New("no public key available") +} diff --git a/cmd/account/create/output_internal_test.go b/cmd/account/create/output_internal_test.go new file mode 100644 index 0000000..10a2a2b --- /dev/null +++ b/cmd/account/create/output_internal_test.go @@ -0,0 +1,113 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "encoding/hex" + "strings" + "testing" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + distributed "github.com/wealdtech/go-eth2-wallet-distributed" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func hexToBytes(input string) []byte { + res, err := hex.DecodeString(strings.TrimPrefix(input, "0x")) + if err != nil { + panic(err) + } + return res +} + +func TestOutput(t *testing.T) { + testWallet, err := nd.CreateWallet(context.Background(), "Test", scratch.New(), keystorev4.New()) + require.NoError(t, err) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + viper.Set("passphrase", "pass") + interop0, err := testWallet.(e2wtypes.WalletAccountImporter).ImportAccount(context.Background(), + "Interop 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + []byte("pass"), + ) + require.NoError(t, err) + + distributedWallet, err := distributed.CreateWallet(context.Background(), "Test distributed", scratch.New(), keystorev4.New()) + require.NoError(t, err) + require.NoError(t, distributedWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + distributed0, err := distributedWallet.(e2wtypes.WalletDistributedAccountImporter).ImportDistributedAccount(context.Background(), + "Distributed 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + 2, + [][]byte{ + hexToBytes("0x876dd4705157eb66dc71bc2e07fb151ea53e1a62a0bb980a7ce72d15f58944a8a3752d754f52f4a60dbfc7b18169f268"), + hexToBytes("0xaec922bd7a9b7b1dc21993133b586b0c3041c1e2e04b513e862227b9d7aecaf9444222f7e78282a449622ffc6278915d"), + }, + map[uint64]string{ + 1: "localhost-1:12345", + 2: "localhost-2:12345", + 3: "localhost-3:12345", + }, + []byte("pass"), + ) + require.NoError(t, err) + + tests := []struct { + name string + dataOut *dataOut + res string + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "AccountNil", + dataOut: &dataOut{}, + err: "no account", + }, + { + name: "Account", + dataOut: &dataOut{ + account: interop0, + }, + res: "0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c", + }, + { + name: "DistributedAccount", + dataOut: &dataOut{ + account: distributed0, + }, + res: "0x876dd4705157eb66dc71bc2e07fb151ea53e1a62a0bb980a7ce72d15f58944a8a3752d754f52f4a60dbfc7b18169f268", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res, res) + } + }) + } +} diff --git a/cmd/account/create/process.go b/cmd/account/create/process.go new file mode 100644 index 0000000..49c746c --- /dev/null +++ b/cmd/account/create/process.go @@ -0,0 +1,144 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "regexp" + + "github.com/pkg/errors" + "github.com/wealdtech/ethdo/util" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.passphrase != "" && !util.AcceptablePassphrase(data.passphrase) { + return nil, errors.New("supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") + } + locker, isLocker := data.wallet.(e2wtypes.WalletLocker) + if isLocker { + if err := locker.Unlock(ctx, []byte(data.walletPassphrase)); err != nil { + return nil, errors.Wrap(err, "failed to unlock wallet") + } + defer locker.Lock(ctx) + } + if data.participants == 0 { + return nil, errors.New("participants is required") + } + + // Create style of account based on input. + switch { + case data.participants > 1: + return processDistributed(ctx, data) + case data.path != "": + return processPathed(ctx, data) + default: + return processStandard(ctx, data) + } +} + +func processStandard(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.passphrase == "" { + return nil, errors.New("passphrase is required") + } + + results := &dataOut{} + + creator, isCreator := data.wallet.(e2wtypes.WalletAccountCreator) + if !isCreator { + return nil, errors.New("wallet does not support account creation") + } + ctx, cancel := context.WithTimeout(ctx, data.timeout) + defer cancel() + account, err := creator.CreateAccount(ctx, data.accountName, []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to create account") + } + results.account = account + return results, nil +} + +func processPathed(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.passphrase == "" { + return nil, errors.New("passphrase is required") + } + match, err := regexp.Match("^m/[0-9]+/[0-9]+(/[0-9+])+", []byte(data.path)) + if err != nil { + return nil, errors.Wrap(err, "unable to match path to regular expression") + } + if !match { + // nolint + return nil, errors.New("path does not match expected format m/...") + } + + results := &dataOut{} + + creator, isCreator := data.wallet.(e2wtypes.WalletPathedAccountCreator) + if !isCreator { + return nil, errors.New("wallet does not support account creation with an explicit path") + } + + ctx, cancel := context.WithTimeout(ctx, data.timeout) + defer cancel() + account, err := creator.CreatePathedAccount(ctx, data.path, data.accountName, []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to create account") + } + results.account = account + return results, nil +} + +func processDistributed(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.signingThreshold == 0 { + return nil, errors.New("signing threshold required") + } + if data.signingThreshold <= data.participants/2 { + return nil, errors.New("signing threshold must be more than half the number of participants") + } + if data.signingThreshold > data.participants { + return nil, errors.New("signing threshold cannot be higher than the number of participants") + } + + results := &dataOut{} + + creator, isCreator := data.wallet.(e2wtypes.WalletDistributedAccountCreator) + if !isCreator { + return nil, errors.New("wallet does not support distributed account creation") + } + + ctx, cancel := context.WithTimeout(ctx, data.timeout) + defer cancel() + account, err := creator.CreateDistributedAccount(ctx, + data.accountName, + data.participants, + data.signingThreshold, + []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to create account") + } + results.account = account + return results, nil +} diff --git a/cmd/account/create/process_internal_test.go b/cmd/account/create/process_internal_test.go new file mode 100644 index 0000000..b139b3a --- /dev/null +++ b/cmd/account/create/process_internal_test.go @@ -0,0 +1,315 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + "crypto/tls" + "crypto/x509" + "fmt" + "math/rand" + "os" + "testing" + "time" + + "github.com/attestantio/dirk/testing/daemon" + "github.com/attestantio/dirk/testing/resources" + "github.com/pkg/errors" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + dirk "github.com/wealdtech/go-eth2-wallet-dirk" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + hd "github.com/wealdtech/go-eth2-wallet-hd/v2" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + "google.golang.org/grpc/credentials" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + testNDWallet, err := nd.CreateWallet(context.Background(), + "Test", + scratch.New(), + keystorev4.New(), + ) + require.NoError(t, err) + testHDWallet, err := hd.CreateWallet(context.Background(), + "Test", + []byte("pass"), + scratch.New(), + keystorev4.New(), + []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + ) + require.NoError(t, err) + + // #nosec G404 + port1 := uint32(12000 + rand.Intn(4000)) + // #nosec G404 + port2 := uint32(12000 + rand.Intn(4000)) + // #nosec G404 + port3 := uint32(12000 + rand.Intn(4000)) + peers := map[uint64]string{ + 1: fmt.Sprintf("signer-test01:%d", port1), + 2: fmt.Sprintf("signer-test02:%d", port2), + 3: fmt.Sprintf("signer-test03:%d", port3), + } + _, path, err := daemon.New(context.Background(), "", 1, port1, peers) + require.NoError(t, err) + defer os.RemoveAll(path) + _, path, err = daemon.New(context.Background(), "", 2, port2, peers) + require.NoError(t, err) + defer os.RemoveAll(path) + _, path, err = daemon.New(context.Background(), "", 3, port3, peers) + require.NoError(t, err) + defer os.RemoveAll(path) + endpoints := []*dirk.Endpoint{ + dirk.NewEndpoint("signer-test01", port1), + dirk.NewEndpoint("signer-test02", port2), + dirk.NewEndpoint("signer-test03", port3), + } + credentials, err := credentialsFromCerts(context.Background(), resources.ClientTest01Crt, resources.ClientTest01Key, resources.CACrt) + require.NoError(t, err) + testDistributedWallet, err := dirk.OpenWallet(context.Background(), "Wallet 3", credentials, endpoints) + require.NoError(t, err) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "WalletPassphraseIncorrect", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Good", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "bad", + participants: 1, + signingThreshold: 1, + }, + err: "failed to unlock wallet: incorrect passphrase", + }, + { + name: "PassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Good", + passphrase: "", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + }, + err: "passphrase is required", + }, + { + name: "PassphraseWeak", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Good", + passphrase: "poor", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + }, + err: "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Good", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + }, + }, + { + name: "PathMalformed", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Pathed", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + path: "n/12381/3600/1/2/3", + }, + err: "path does not match expected format m/...", + }, + { + name: "PathPassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Pathed", + passphrase: "", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + path: "m/12381/3600/1/2/3", + }, + err: "passphrase is required", + }, + { + name: "PathNotSupported", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testNDWallet, + accountName: "Pathed", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + path: "m/12381/3600/1/2/3", + }, + err: "wallet does not support account creation with an explicit path", + }, + { + name: "GoodWithPath", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testHDWallet, + accountName: "Pathed", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 1, + signingThreshold: 1, + path: "m/12381/3600/1/2/3", + }, + }, + { + name: "DistributedSigningThresholdZero", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testDistributedWallet, + accountName: "Remote", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 3, + signingThreshold: 0, + }, + err: "signing threshold required", + }, + { + name: "DistributedSigningThresholdNotHalf", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testDistributedWallet, + accountName: "Remote", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 3, + signingThreshold: 1, + }, + err: "signing threshold must be more than half the number of participants", + }, + { + name: "DistributedSigningThresholdTooHigh", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testDistributedWallet, + accountName: "Remote", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 3, + signingThreshold: 4, + }, + err: "signing threshold cannot be higher than the number of participants", + }, + { + name: "DistributedNotSupported", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testNDWallet, + accountName: "Remote", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 3, + signingThreshold: 2, + }, + err: "wallet does not support distributed account creation", + }, + { + name: "DistributedGood", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testDistributedWallet, + accountName: "Remote", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + participants: 3, + signingThreshold: 2, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.dataIn.accountName, res.account.Name()) + } + }) + } +} + +func TestNilData(t *testing.T) { + _, err := processStandard(context.Background(), nil) + require.EqualError(t, err, "no data") + _, err = processPathed(context.Background(), nil) + require.EqualError(t, err, "no data") + _, err = processDistributed(context.Background(), nil) + require.EqualError(t, err, "no data") +} + +func credentialsFromCerts(ctx context.Context, clientCert []byte, clientKey []byte, caCert []byte) (credentials.TransportCredentials, error) { + clientPair, err := tls.X509KeyPair(clientCert, clientKey) + if err != nil { + return nil, errors.Wrap(err, "failed to load client keypair") + } + + tlsCfg := &tls.Config{ + Certificates: []tls.Certificate{clientPair}, + MinVersion: tls.VersionTLS13, + } + + if caCert != nil { + cp := x509.NewCertPool() + if !cp.AppendCertsFromPEM(caCert) { + return nil, errors.New("failed to add CA certificate") + } + tlsCfg.RootCAs = cp + } + + return credentials.NewTLS(tlsCfg), nil +} diff --git a/cmd/account/create/run.go b/cmd/account/create/run.go new file mode 100644 index 0000000..dc4da9a --- /dev/null +++ b/cmd/account/create/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountcreate + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the account create data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/account/import/input.go b/cmd/account/import/input.go new file mode 100644 index 0000000..66cc710 --- /dev/null +++ b/cmd/account/import/input.go @@ -0,0 +1,88 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + "encoding/hex" + "strings" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/core" + "github.com/wealdtech/ethdo/util" + e2wallet "github.com/wealdtech/go-eth2-wallet" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + timeout time.Duration + wallet e2wtypes.Wallet + key []byte + accountName string + passphrase string + walletPassphrase string +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + + // Account name. + if viper.GetString("account") == "" { + return nil, errors.New("account is required") + } + _, data.accountName, err = e2wallet.WalletAndAccountNames(viper.GetString("account")) + if err != nil { + return nil, errors.Wrap(err, "failed to obtain account name") + } + if data.accountName == "" { + return nil, errors.New("account name is required") + } + + // Wallet. + ctx, cancel := context.WithTimeout(ctx, data.timeout) + defer cancel() + data.wallet, err = core.WalletFromInput(ctx) + cancel() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain wallet") + } + + // Passphrase. + data.passphrase, err = util.GetOptionalPassphrase() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain passphrase") + } + + // Wallet passphrase. + data.walletPassphrase = util.GetWalletPassphrase() + + // Key. + if viper.GetString("key") == "" { + return nil, errors.New("key is required") + } + data.key, err = hex.DecodeString(strings.TrimPrefix(viper.GetString("key"), "0x")) + if err != nil { + return nil, errors.Wrap(err, "key is malformed") + } + + return data, nil +} diff --git a/cmd/account/import/input_internal_test.go b/cmd/account/import/input_internal_test.go new file mode 100644 index 0000000..af40738 --- /dev/null +++ b/cmd/account/import/input_internal_test.go @@ -0,0 +1,152 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + testWallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "timeout is required", + }, + { + name: "WalletUnknown", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Unknown/Test account", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain wallet: wallet not found", + }, + { + name: "AccountMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "account is required", + }, + { + name: "AccountWalletOnly", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + "account": "Test wallet/", + }, + err: "account name is required", + }, + { + name: "AccountMalformed", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "//", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain account name: invalid account format", + }, + { + name: "MultiplePassphrases", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": []string{"ce%NohGhah4ye5ra", "other"}, + }, + err: "failed to obtain passphrase: multiple passphrases supplied", + }, + { + name: "KeyMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "key is required", + }, + { + name: "KeyMalformed", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + "key": "invalid", + }, + err: "key is malformed: encoding/hex: invalid byte: U+0069 'i'", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Test account", + "passphrase": "ce%NohGhah4ye5ra", + "key": "0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866", + }, + res: &dataIn{ + timeout: 5 * time.Second, + accountName: "Test account", + passphrase: "ce%NohGhah4ye5ra", + key: hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + // Cannot compare accounts directly, so need to check each element individually. + require.Equal(t, test.res.timeout, res.timeout) + require.Equal(t, test.res.accountName, res.accountName) + require.Equal(t, test.res.passphrase, res.passphrase) + } + }) + } +} diff --git a/cmd/account/import/output.go b/cmd/account/import/output.go new file mode 100644 index 0000000..ad6997b --- /dev/null +++ b/cmd/account/import/output.go @@ -0,0 +1,45 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + "fmt" + + "github.com/pkg/errors" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataOut struct { + account e2wtypes.Account +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + if data.account == nil { + return "", errors.New("no account") + } + + if pubKeyProvider, ok := data.account.(e2wtypes.AccountCompositePublicKeyProvider); ok { + return fmt.Sprintf("%#x", pubKeyProvider.CompositePublicKey().Marshal()), nil + } + + if pubKeyProvider, ok := data.account.(e2wtypes.AccountPublicKeyProvider); ok { + return fmt.Sprintf("%#x", pubKeyProvider.PublicKey().Marshal()), nil + } + + return "", errors.New("no public key available") +} diff --git a/cmd/account/import/output_internal_test.go b/cmd/account/import/output_internal_test.go new file mode 100644 index 0000000..bb45128 --- /dev/null +++ b/cmd/account/import/output_internal_test.go @@ -0,0 +1,113 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + "encoding/hex" + "strings" + "testing" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + distributed "github.com/wealdtech/go-eth2-wallet-distributed" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func hexToBytes(input string) []byte { + res, err := hex.DecodeString(strings.TrimPrefix(input, "0x")) + if err != nil { + panic(err) + } + return res +} + +func TestOutput(t *testing.T) { + testWallet, err := nd.CreateWallet(context.Background(), "Test", scratch.New(), keystorev4.New()) + require.NoError(t, err) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + viper.Set("passphrase", "pass") + interop0, err := testWallet.(e2wtypes.WalletAccountImporter).ImportAccount(context.Background(), + "Interop 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + []byte("pass"), + ) + require.NoError(t, err) + + distributedWallet, err := distributed.CreateWallet(context.Background(), "Test distributed", scratch.New(), keystorev4.New()) + require.NoError(t, err) + require.NoError(t, distributedWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + distributed0, err := distributedWallet.(e2wtypes.WalletDistributedAccountImporter).ImportDistributedAccount(context.Background(), + "Distributed 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + 2, + [][]byte{ + hexToBytes("0x876dd4705157eb66dc71bc2e07fb151ea53e1a62a0bb980a7ce72d15f58944a8a3752d754f52f4a60dbfc7b18169f268"), + hexToBytes("0xaec922bd7a9b7b1dc21993133b586b0c3041c1e2e04b513e862227b9d7aecaf9444222f7e78282a449622ffc6278915d"), + }, + map[uint64]string{ + 1: "localhost-1:12345", + 2: "localhost-2:12345", + 3: "localhost-3:12345", + }, + []byte("pass"), + ) + require.NoError(t, err) + + tests := []struct { + name string + dataOut *dataOut + res string + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "AccountNil", + dataOut: &dataOut{}, + err: "no account", + }, + { + name: "Account", + dataOut: &dataOut{ + account: interop0, + }, + res: "0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c", + }, + { + name: "DistributedAccount", + dataOut: &dataOut{ + account: distributed0, + }, + res: "0x876dd4705157eb66dc71bc2e07fb151ea53e1a62a0bb980a7ce72d15f58944a8a3752d754f52f4a60dbfc7b18169f268", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res, res) + } + }) + } +} diff --git a/cmd/account/import/process.go b/cmd/account/import/process.go new file mode 100644 index 0000000..b921097 --- /dev/null +++ b/cmd/account/import/process.go @@ -0,0 +1,51 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + + "github.com/pkg/errors" + "github.com/wealdtech/ethdo/util" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.passphrase == "" { + return nil, errors.New("passphrase is required") + } + if !util.AcceptablePassphrase(data.passphrase) { + return nil, errors.New("supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") + } + locker, isLocker := data.wallet.(e2wtypes.WalletLocker) + if isLocker { + if err := locker.Unlock(ctx, []byte(data.walletPassphrase)); err != nil { + return nil, errors.Wrap(err, "failed to unlock wallet") + } + defer locker.Lock(ctx) + } + + results := &dataOut{} + + account, err := data.wallet.(e2wtypes.WalletAccountImporter).ImportAccount(ctx, data.accountName, data.key, []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to import account") + } + results.account = account + + return results, nil +} diff --git a/cmd/account/import/process_internal_test.go b/cmd/account/import/process_internal_test.go new file mode 100644 index 0000000..7a1e91c --- /dev/null +++ b/cmd/account/import/process_internal_test.go @@ -0,0 +1,95 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + testNDWallet, err := nd.CreateWallet(context.Background(), + "Test", + scratch.New(), + keystorev4.New(), + ) + require.NoError(t, err) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "PassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testNDWallet, + accountName: "Good", + passphrase: "", + walletPassphrase: "pass", + key: hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + }, + err: "passphrase is required", + }, + { + name: "PassphraseWeak", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testNDWallet, + accountName: "Good", + passphrase: "poor", + walletPassphrase: "pass", + key: hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + }, + err: "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: testNDWallet, + accountName: "Good", + passphrase: "ce%NohGhah4ye5ra", + walletPassphrase: "pass", + key: hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.dataIn.accountName, res.account.Name()) + } + }) + } +} diff --git a/cmd/account/import/run.go b/cmd/account/import/run.go new file mode 100644 index 0000000..7e8721d --- /dev/null +++ b/cmd/account/import/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountimport + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the account import data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/account/key/input.go b/cmd/account/key/input.go new file mode 100644 index 0000000..8a89e62 --- /dev/null +++ b/cmd/account/key/input.go @@ -0,0 +1,52 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/core" + "github.com/wealdtech/ethdo/util" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + timeout time.Duration + account e2wtypes.Account + passphrases []string +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + + // Account. + _, data.account, err = core.WalletAndAccountFromInput(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to obtain acount") + } + + // Passphrases. + data.passphrases = util.GetPassphrases() + + return data, nil +} diff --git a/cmd/account/key/input_internal_test.go b/cmd/account/key/input_internal_test.go new file mode 100644 index 0000000..c86d66b --- /dev/null +++ b/cmd/account/key/input_internal_test.go @@ -0,0 +1,129 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + testWallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + require.NoError(t, testWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + viper.Set("passphrase", "pass") + _, err = testWallet.(e2wtypes.WalletAccountImporter).ImportAccount(context.Background(), + "Interop 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + []byte("pass"), + ) + require.NoError(t, err) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "account": "Test wallet/Interop 0", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "timeout is required", + }, + { + name: "WalletUnknown", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Unknown/Interop 0", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain acount: faild to open wallet for account: wallet not found", + }, + { + name: "AccountMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain acount: faild to open wallet for account: invalid account format", + }, + { + name: "AccountWalletOnly", + vars: map[string]interface{}{ + "timeout": "5s", + "passphrase": "ce%NohGhah4ye5ra", + "account": "Test wallet/", + }, + err: "failed to obtain acount: no account name", + }, + { + name: "AccountMalformed", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "//", + "passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain acount: faild to open wallet for account: invalid account format", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "account": "Test wallet/Interop 0", + "passphrase": []string{"ce%NohGhah4ye5ra", "pass"}, + "key": "0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866", + }, + res: &dataIn{ + timeout: 5 * time.Second, + passphrases: []string{"ce%NohGhah4ye5ra", "pass"}, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + // Cannot compare accounts directly, so need to check each element individually. + require.Equal(t, test.res.timeout, res.timeout) + require.Equal(t, test.res.passphrases, res.passphrases) + } + }) + } +} diff --git a/cmd/account/key/output.go b/cmd/account/key/output.go new file mode 100644 index 0000000..5377e83 --- /dev/null +++ b/cmd/account/key/output.go @@ -0,0 +1,36 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + "fmt" + + "github.com/pkg/errors" +) + +type dataOut struct { + key []byte +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + if len(data.key) == 0 { + return "", errors.New("no account") + } + + return fmt.Sprintf("%#x", data.key), nil +} diff --git a/cmd/account/key/output_internal_test.go b/cmd/account/key/output_internal_test.go new file mode 100644 index 0000000..f53c5a4 --- /dev/null +++ b/cmd/account/key/output_internal_test.go @@ -0,0 +1,69 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + "encoding/hex" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func hexToBytes(input string) []byte { + res, err := hex.DecodeString(strings.TrimPrefix(input, "0x")) + if err != nil { + panic(err) + } + return res +} + +func TestOutput(t *testing.T) { + tests := []struct { + name string + dataOut *dataOut + res string + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "AccountNil", + dataOut: &dataOut{}, + err: "no account", + }, + { + name: "Good", + dataOut: &dataOut{ + key: hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + }, + res: "0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res, res) + } + }) + } +} diff --git a/cmd/account/key/process.go b/cmd/account/key/process.go new file mode 100644 index 0000000..85a6658 --- /dev/null +++ b/cmd/account/key/process.go @@ -0,0 +1,65 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + + "github.com/pkg/errors" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if len(data.passphrases) == 0 { + return nil, errors.New("passphrase is required") + } + + results := &dataOut{} + + privateKeyProvider, isPrivateKeyProvider := data.account.(e2wtypes.AccountPrivateKeyProvider) + if !isPrivateKeyProvider { + return nil, errors.New("account does not provide its private key") + } + + if locker, isLocker := data.account.(e2wtypes.AccountLocker); isLocker { + unlocked, err := locker.IsUnlocked(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to find out if account is locked") + } + if !unlocked { + for _, passphrase := range data.passphrases { + err = locker.Unlock(ctx, []byte(passphrase)) + if err == nil { + unlocked = true + break + } + } + if !unlocked { + return nil, errors.New("failed to unlock account") + } + // Because we unlocked the accout we should re-lock it when we're done. + defer locker.Lock(ctx) + } + } + key, err := privateKeyProvider.PrivateKey(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to obtain private key") + } + results.key = key.Marshal() + + return results, nil +} diff --git a/cmd/account/key/process_internal_test.go b/cmd/account/key/process_internal_test.go new file mode 100644 index 0000000..bb87573 --- /dev/null +++ b/cmd/account/key/process_internal_test.go @@ -0,0 +1,87 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + testNDWallet, err := nd.CreateWallet(context.Background(), + "Test", + scratch.New(), + keystorev4.New(), + ) + require.NoError(t, err) + require.NoError(t, testNDWallet.(e2wtypes.WalletLocker).Unlock(context.Background(), nil)) + viper.Set("passphrase", "pass") + interop0, err := testNDWallet.(e2wtypes.WalletAccountImporter).ImportAccount(context.Background(), + "Interop 0", + hexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + []byte("pass"), + ) + require.NoError(t, err) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "PassphrasesMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + account: interop0, + }, + err: "passphrase is required", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + account: interop0, + passphrases: []string{"ce%NohGhah4ye5ra", "pass"}, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.NotNil(t, res) + require.NotNil(t, res.key) + } + }) + } +} diff --git a/cmd/account/key/run.go b/cmd/account/key/run.go new file mode 100644 index 0000000..3fa1ce3 --- /dev/null +++ b/cmd/account/key/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package accountkey + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the account import data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if viper.GetBool("quiet") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/accountcreate.go b/cmd/accountcreate.go index 2fe4b6e..a05900a 100644 --- a/cmd/accountcreate.go +++ b/cmd/accountcreate.go @@ -14,16 +14,11 @@ package cmd import ( - "context" "fmt" - "os" - "regexp" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/wealdtech/ethdo/util" - e2wallet "github.com/wealdtech/go-eth2-wallet" - e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" + accountcreate "github.com/wealdtech/ethdo/cmd/account/create" ) var accountCreateCmd = &cobra.Command{ @@ -34,77 +29,26 @@ var accountCreateCmd = &cobra.Command{ ethdo account create --account="primary/operations" --passphrase="my secret" In quiet mode this will return 0 if the account is created successfully, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - assert(viper.GetString("account") != "", "--account is required") - - wallet, err := walletFromInput(ctx) - errCheck(err, "Failed to access wallet") - outputIf(debug, fmt.Sprintf("Opened wallet %q of type %s", wallet.Name(), wallet.Type())) - if wallet.Type() == "hierarchical deterministic" { - assert(getWalletPassphrase() != "", "walletpassphrase is required to create new accounts with hierarchical deterministic wallets") + RunE: func(cmd *cobra.Command, args []string) error { + res, err := accountcreate.Run(cmd) + if err != nil { + return err } - locker, isLocker := wallet.(e2wtypes.WalletLocker) - if isLocker { - errCheck(locker.Unlock(ctx, []byte(getWalletPassphrase())), "Failed to unlock wallet") + if viper.GetBool("quiet") { + return nil } - - _, accountName, err := e2wallet.WalletAndAccountNames(viper.GetString("account")) - errCheck(err, "Failed to obtain account name") - - var account e2wtypes.Account - if viper.GetUint("participants") > 0 { - // Want a distributed account. - distributedCreator, isDistributedCreator := wallet.(e2wtypes.WalletDistributedAccountCreator) - assert(isDistributedCreator, "Wallet does not support distributed account creation") - outputIf(debug, fmt.Sprintf("Distributed account has %d/%d threshold", viper.GetUint32("signing-threshold"), viper.GetUint32("participants"))) - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - if getOptionalPassphrase() != "" { - assert(util.AcceptablePassphrase(getPassphrase()), "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") - } - account, err = distributedCreator.CreateDistributedAccount(ctx, accountName, viper.GetUint32("participants"), viper.GetUint32("signing-threshold"), []byte(getOptionalPassphrase())) - } else { - assert(util.AcceptablePassphrase(getPassphrase()), "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") - if viper.GetString("path") != "" { - // Want a pathed account - creator, isCreator := wallet.(e2wtypes.WalletPathedAccountCreator) - assert(isCreator, "Wallet does not support account creation with an explicit path") - var match bool - match, err = regexp.Match("^m/[0-9]+/[0-9]+(/[0-9+])+", []byte(viper.GetString("path"))) - errCheck(err, "Unable to match path to regular expression") - assert(match, "Path does not match expected format m/...") - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - account, err = creator.CreatePathedAccount(ctx, viper.GetString("path"), accountName, []byte(getPassphrase())) - } else { - // Want a standard account. - creator, isCreator := wallet.(e2wtypes.WalletAccountCreator) - assert(isCreator, "Wallet does not support account creation") - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - account, err = creator.CreateAccount(ctx, accountName, []byte(getPassphrase())) - } + if res != "" { + fmt.Println(res) } - errCheck(err, "Failed to create account") - - if pubKeyProvider, ok := account.(e2wtypes.AccountCompositePublicKeyProvider); ok { - outputIf(verbose, fmt.Sprintf("%#x", pubKeyProvider.CompositePublicKey().Marshal())) - } else if pubKeyProvider, ok := account.(e2wtypes.AccountPublicKeyProvider); ok { - outputIf(verbose, fmt.Sprintf("%#x", pubKeyProvider.PublicKey().Marshal())) - } - - os.Exit(_exitSuccess) + return nil }, } func init() { accountCmd.AddCommand(accountCreateCmd) accountFlags(accountCreateCmd) - accountCreateCmd.Flags().Uint32("participants", 0, "Number of participants (for distributed accounts)") - accountCreateCmd.Flags().Uint32("signing-threshold", 0, "Signing threshold (for distributed accounts)") + accountCreateCmd.Flags().Uint32("participants", 1, "Number of participants (1 for non-distributed accounts, >1 for distributed accounts)") + accountCreateCmd.Flags().Uint32("signing-threshold", 1, "Signing threshold (1 for non-distributed accounts)") accountCreateCmd.Flags().String("path", "", "path of account (for hierarchical deterministic accounts)") } diff --git a/cmd/accountimport.go b/cmd/accountimport.go index 0f193b4..457b6f6 100644 --- a/cmd/accountimport.go +++ b/cmd/accountimport.go @@ -14,20 +14,13 @@ package cmd import ( - "context" "fmt" - "os" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/wealdtech/ethdo/util" - "github.com/wealdtech/go-bytesutil" - e2wallet "github.com/wealdtech/go-eth2-wallet" - e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" + accountimport "github.com/wealdtech/ethdo/cmd/account/import" ) -var accountImportKey string - var accountImportCmd = &cobra.Command{ Use: "import", Short: "Import an account", @@ -36,49 +29,29 @@ var accountImportCmd = &cobra.Command{ ethdo account import --account="primary/testing" --key="0x..." --passphrase="my secret" In quiet mode this will return 0 if the account is imported successfully, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - assert(!remote, "account import not available with remote wallets") - assert(viper.GetString("account") != "", "--account is required") - assert(accountImportKey != "", "--key is required") - assert(util.AcceptablePassphrase(getPassphrase()), "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") - - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - key, err := bytesutil.FromHexString(accountImportKey) - errCheck(err, "Invalid key") - - w, err := walletFromPath(ctx, viper.GetString("account")) - errCheck(err, "Failed to access wallet") - - _, ok := w.(e2wtypes.WalletAccountImporter) - assert(ok, fmt.Sprintf("wallets of type %q do not allow importing accounts", w.Type())) - - _, _, err = walletAndAccountFromPath(ctx, viper.GetString("account")) - assert(err != nil, "Account already exists") - - locker, isLocker := w.(e2wtypes.WalletLocker) - if isLocker { - errCheck(locker.Unlock(ctx, []byte(getWalletPassphrase())), "Failed to unlock wallet") + RunE: func(cmd *cobra.Command, args []string) error { + res, err := accountimport.Run(cmd) + if err != nil { + return err } - - _, accountName, err := e2wallet.WalletAndAccountNames(viper.GetString("account")) - errCheck(err, "Failed to obtain account name") - - account, err := w.(e2wtypes.WalletAccountImporter).ImportAccount(ctx, accountName, key, []byte(getPassphrase())) - errCheck(err, "Failed to create account") - - pubKey, err := bestPublicKey(account) - if err == nil { - outputIf(verbose, fmt.Sprintf("%#x", pubKey.Marshal())) + if viper.GetBool("quiet") { + return nil } - - os.Exit(_exitSuccess) + if res != "" { + fmt.Println(res) + } + return nil }, } func init() { accountCmd.AddCommand(accountImportCmd) accountFlags(accountImportCmd) - accountImportCmd.Flags().StringVar(&accountImportKey, "key", "", "Private key of the account to import (0x...)") + accountImportCmd.Flags().String("key", "", "Private key of the account to import (0x...)") +} + +func accountImportBindings() { + if err := viper.BindPFlag("key", accountImportCmd.Flags().Lookup("key")); err != nil { + panic(err) + } } diff --git a/cmd/accountkey.go b/cmd/accountkey.go index f5095df..9d3b3c0 100644 --- a/cmd/accountkey.go +++ b/cmd/accountkey.go @@ -14,13 +14,11 @@ package cmd import ( - "context" "fmt" - "os" "github.com/spf13/cobra" "github.com/spf13/viper" - e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" + accountkey "github.com/wealdtech/ethdo/cmd/account/key" ) // accountKeyCmd represents the account key command @@ -32,39 +30,18 @@ var accountKeyCmd = &cobra.Command{ ethdo account key --account="Personal wallet/Operations" --passphrase="my account passphrase" In quiet mode this will return 0 if the key can be obtained, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - assert(!remote, "account keys not available with remote wallets") - assert(viper.GetString("account") != "", "--account is required") - - _, account, err := walletAndAccountFromInput(ctx) - errCheck(err, "Failed to obtain account") - - privateKeyProvider, isPrivateKeyProvider := account.(e2wtypes.AccountPrivateKeyProvider) - assert(isPrivateKeyProvider, fmt.Sprintf("account %q does not provide its private key", viper.GetString("account"))) - - if locker, isLocker := account.(e2wtypes.AccountLocker); isLocker { - unlocked, err := locker.IsUnlocked(ctx) - errCheck(err, "Failed to find out if account is locked") - if !unlocked { - for _, passphrase := range getPassphrases() { - err = locker.Unlock(ctx, []byte(passphrase)) - if err == nil { - unlocked = true - break - } - } - } - assert(unlocked, "Failed to unlock account to obtain private key") - defer relockAccount(locker) + RunE: func(cmd *cobra.Command, args []string) error { + res, err := accountkey.Run(cmd) + if err != nil { + return err } - privateKey, err := privateKeyProvider.PrivateKey(ctx) - errCheck(err, "Failed to obtain private key") - - outputIf(!quiet, fmt.Sprintf("%#x", privateKey.Marshal())) - os.Exit(_exitSuccess) + if viper.GetBool("quiet") { + return nil + } + if res != "" { + fmt.Println(res) + } + return nil }, } diff --git a/cmd/depositverify.go b/cmd/depositverify.go index 6b63ce8..2e1a491 100644 --- a/cmd/depositverify.go +++ b/cmd/depositverify.go @@ -146,7 +146,7 @@ func validatorPubKeysFromInput(input string) (map[[48]byte]bool, error) { if err != nil { return nil, errors.Wrap(err, "failed to find public key file") } - lines := bytes.Split(bytes.Replace(data, []byte("\r\n"), []byte("\n"), -1), []byte("\n")) + lines := bytes.Split(bytes.ReplaceAll(data, []byte("\r\n"), []byte("\n")), []byte("\n")) if len(lines) == 0 { return nil, errors.New("file has no public keys") } diff --git a/cmd/exitverify.go b/cmd/exitverify.go index d393417..a49c2db 100644 --- a/cmd/exitverify.go +++ b/cmd/exitverify.go @@ -94,7 +94,7 @@ func obtainExitData(input string) (*validatorExitData, error) { } } exitData := &validatorExitData{} - err = json.Unmarshal([]byte(data), exitData) + err = json.Unmarshal(data, exitData) if err != nil { return nil, errors.Wrap(err, "data is not valid JSON") } diff --git a/cmd/networks.go b/cmd/networks.go index b6dec47..9de34d3 100644 --- a/cmd/networks.go +++ b/cmd/networks.go @@ -41,7 +41,6 @@ func network() string { depositContract := fmt.Sprintf("%x", depositContractAddress) if network, exists := networks[depositContract]; exists { return network - } else { - return "Unknown" } + return "Unknown" } diff --git a/cmd/passphrases.go b/cmd/passphrases.go index 2c48af5..d5b087b 100644 --- a/cmd/passphrases.go +++ b/cmd/passphrases.go @@ -31,21 +31,3 @@ func getWalletPassphrase() string { func getPassphrases() []string { return viper.GetStringSlice("passphrase") } - -// getPassphrase fetches the passphrase supplied by the user. -func getPassphrase() string { - passphrases := getPassphrases() - assert(len(passphrases) != 0, "passphrase is required") - assert(len(passphrases) == 1, "multiple passphrases supplied; cannot continue") - return passphrases[0] -} - -// getOptionalPassphrase fetches the passphrase if supplied by the user. -func getOptionalPassphrase() string { - passphrases := getPassphrases() - if len(passphrases) == 0 { - return "" - } - assert(len(passphrases) == 1, "multiple passphrases supplied; cannot continue") - return passphrases[0] -} diff --git a/cmd/root.go b/cmd/root.go index 8e42eaf..bbb8da3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -17,8 +17,6 @@ import ( "context" "fmt" "os" - "regexp" - "sort" "strconv" "strings" "time" @@ -47,9 +45,6 @@ var rootStore string // Store for wallet actions. var store e2wtypes.Store -// Remote connection. -var remote bool - // Prysm connection. var eth2GRPCConn *grpc.ClientConn @@ -81,6 +76,8 @@ func persistentPreRun(cmd *cobra.Command, args []string) { switch fmt.Sprintf("%s/%s", cmd.Parent().Name(), cmd.Name()) { case "account/create": accountCreateBindings() + case "account/import": + accountImportBindings() case "attester/inclusion": attesterInclusionBindings() case "exit/verify": @@ -89,6 +86,8 @@ func persistentPreRun(cmd *cobra.Command, args []string) { validatorDepositdataBindings() case "wallet/create": walletCreateBindings() + case "wallet/import": + walletImportBindings() } if quiet && verbose { @@ -119,9 +118,8 @@ func persistentPreRun(cmd *cobra.Command, args []string) { die(fmt.Sprintf("Unsupported wallet store %s", rootStore)) } err := e2wallet.UseStore(store) + viper.Set("store", store) errCheck(err, "Failed to use defined wallet store") - } else { - remote = true } } @@ -333,39 +331,6 @@ func walletAndAccountFromPath(ctx context.Context, path string) (e2wtypes.Wallet return wallet, account, nil } -// walletAndAccountsFromPath obtains the wallet and matching accounts given a path specification. -func walletAndAccountsFromPath(ctx context.Context, path string) (e2wtypes.Wallet, []e2wtypes.Account, error) { - wallet, err := walletFromPath(ctx, path) - if err != nil { - return nil, nil, errors.Wrap(err, "faild to open wallet for account") - } - - _, accountSpec, err := e2wallet.WalletAndAccountNames(path) - if err != nil { - return nil, nil, errors.Wrap(err, "failed to obtain account specification") - } - if accountSpec == "" { - accountSpec = "^.*$" - } else { - accountSpec = fmt.Sprintf("^%s$", accountSpec) - } - re := regexp.MustCompile(accountSpec) - - accounts := make([]e2wtypes.Account, 0) - for account := range wallet.Accounts(ctx) { - if re.Match([]byte(account.Name())) { - accounts = append(accounts, account) - } - } - - // Tidy up accounts by name. - sort.Slice(accounts, func(i, j int) bool { - return accounts[i].Name() < accounts[j].Name() - }) - - return wallet, accounts, nil -} - // connect connects to an Ethereum 2 endpoint. func connect() error { if eth2GRPCConn != nil { diff --git a/cmd/signing.go b/cmd/signing.go index 2a94fd4..169d140 100644 --- a/cmd/signing.go +++ b/cmd/signing.go @@ -22,11 +22,10 @@ import ( "github.com/spf13/viper" e2types "github.com/wealdtech/go-eth2-types/v2" e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" - wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" ) // signStruct signs an arbitrary structure. -func signStruct(account wtypes.Account, data interface{}, domain []byte) (e2types.Signature, error) { +func signStruct(account e2wtypes.Account, data interface{}, domain []byte) (e2types.Signature, error) { objRoot, err := ssz.HashTreeRoot(data) outputIf(debug, fmt.Sprintf("Object root is %#x", objRoot)) if err != nil { @@ -37,7 +36,7 @@ func signStruct(account wtypes.Account, data interface{}, domain []byte) (e2type } // verifyStruct verifies the signature of an arbitrary structure. -func verifyStruct(account wtypes.Account, data interface{}, domain []byte, signature e2types.Signature) (bool, error) { +func verifyStruct(account e2wtypes.Account, data interface{}, domain []byte, signature e2types.Signature) (bool, error) { objRoot, err := ssz.HashTreeRoot(data) outputIf(debug, fmt.Sprintf("Object root is %#x", objRoot)) if err != nil { @@ -55,7 +54,7 @@ type signingContainer struct { } // signRoot signs a root. -func signRoot(account wtypes.Account, root [32]byte, domain []byte) (e2types.Signature, error) { +func signRoot(account e2wtypes.Account, root [32]byte, domain []byte) (e2types.Signature, error) { if _, isProtectingSigner := account.(e2wtypes.AccountProtectingSigner); isProtectingSigner { // Signer signs the data to sign itself. return signGeneric(account, root[:], domain) @@ -75,7 +74,7 @@ func signRoot(account wtypes.Account, root [32]byte, domain []byte) (e2types.Sig return sign(account, signingRoot[:]) } -func verifyRoot(account wtypes.Account, root [32]byte, domain []byte, signature e2types.Signature) (bool, error) { +func verifyRoot(account e2wtypes.Account, root [32]byte, domain []byte, signature e2types.Signature) (bool, error) { // Build the signing data manually. container := &signingContainer{ Root: root[:], @@ -90,7 +89,7 @@ func verifyRoot(account wtypes.Account, root [32]byte, domain []byte, signature return verify(account, signingRoot[:], signature) } -func signGeneric(account wtypes.Account, data []byte, domain []byte) (e2types.Signature, error) { +func signGeneric(account e2wtypes.Account, data []byte, domain []byte) (e2types.Signature, error) { alreadyUnlocked, err := unlock(account) if err != nil { return nil, err @@ -115,7 +114,7 @@ func signGeneric(account wtypes.Account, data []byte, domain []byte) (e2types.Si } // sign signs arbitrary data, handling unlocking and locking as required. -func sign(account wtypes.Account, data []byte) (e2types.Signature, error) { +func sign(account e2wtypes.Account, data []byte) (e2types.Signature, error) { alreadyUnlocked, err := unlock(account) if err != nil { return nil, err @@ -140,7 +139,7 @@ func sign(account wtypes.Account, data []byte) (e2types.Signature, error) { } // verify the signature of arbitrary data. -func verify(account wtypes.Account, data []byte, signature e2types.Signature) (bool, error) { +func verify(account e2wtypes.Account, data []byte, signature e2types.Signature) (bool, error) { pubKey, err := bestPublicKey(account) if err != nil { return false, errors.Wrap(err, "failed to obtain account public key") diff --git a/cmd/wallet/create/input.go b/cmd/wallet/create/input.go new file mode 100644 index 0000000..d6ab010 --- /dev/null +++ b/cmd/wallet/create/input.go @@ -0,0 +1,89 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "strings" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/util" + e2wallet "github.com/wealdtech/go-eth2-wallet" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + // System. + timeout time.Duration + quiet bool + verbose bool + debug bool + // For all wallets. + store e2wtypes.Store + walletType string + walletName string + // For HD wallets. + passphrase string + mnemonic string +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + data.quiet = viper.GetBool("quiet") + data.verbose = viper.GetBool("verbose") + data.debug = viper.GetBool("debug") + + store, isStore := viper.Get("store").(e2wtypes.Store) + if !isStore { + return nil, errors.New("store is required") + } + data.store = store + + // Wallet name. + if viper.GetString("wallet") == "" { + return nil, errors.New("wallet is required") + } + data.walletName, _, err = e2wallet.WalletAndAccountNames(viper.GetString("wallet")) + if err != nil { + return nil, errors.Wrap(err, "failed to obtain wallet name") + } + if data.walletName == "" { + return nil, errors.New("wallet name is required") + } + + // Type. + data.walletType = strings.ToLower(viper.GetString("type")) + if data.walletType == "" { + return nil, errors.New("wallet type is required") + } + + // Passphrase. + data.passphrase = util.GetWalletPassphrase() + if data.passphrase == "" { + return nil, errors.New("wallet passphrase is required") + } + + // Mnemonic. + data.mnemonic = viper.GetString("mnemonic") + + return data, nil +} diff --git a/cmd/wallet/create/input_internal_test.go b/cmd/wallet/create/input_internal_test.go new file mode 100644 index 0000000..5f8731c --- /dev/null +++ b/cmd/wallet/create/input_internal_test.go @@ -0,0 +1,134 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "account": "Test wallet", + "wallet-passphrase": "ce%NohGhah4ye5ra", + "type": "nd", + }, + err: "timeout is required", + }, + { + name: "StoreMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "Test wallet", + "type": "nd", + "wallet-passphrase": "ce%NohGhah4ye5ra", + }, + err: "store is required", + }, + { + name: "WalletMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "store": store, + "type": "nd", + "wallet-passphrase": "ce%NohGhah4ye5ra", + }, + err: "wallet is required", + }, + { + name: "WalletInvalid", + vars: map[string]interface{}{ + "timeout": "5s", + "store": store, + "wallet": "/", + "type": "nd", + "wallet-passphrase": "ce%NohGhah4ye5ra", + }, + err: "failed to obtain wallet name: invalid account format", + }, + { + name: "TypeMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "store": store, + "wallet": "Test wallet", + "wallet-passphrase": "ce%NohGhah4ye5ra", + }, + err: "wallet type is required", + }, + { + name: "WalletPassphraseMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "store": store, + "wallet": "Test wallet", + "type": "nd", + }, + err: "wallet passphrase is required", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "store": store, + "wallet": "Test wallet", + "type": "nd", + "wallet-passphrase": "ce%NohGhah4ye5ra", + }, + res: &dataIn{ + timeout: 5 * time.Second, + store: store, + walletName: "Test account", + walletType: "nd", + passphrase: "ce%NohGhah4ye5ra", + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res.timeout, res.timeout) + } + }) + } +} diff --git a/cmd/wallet/create/output.go b/cmd/wallet/create/output.go new file mode 100644 index 0000000..21306de --- /dev/null +++ b/cmd/wallet/create/output.go @@ -0,0 +1,43 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "fmt" + + "github.com/pkg/errors" +) + +type dataOut struct { + mnemonic string +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + if data.mnemonic != "" { + return fmt.Sprintf(`The following phrase is your mnemonic for this wallet: + +%s + +Anyone with access to this mnemonic can recreate the accounts in this wallet, so please store this mnemonic safely. More information about mnemonics can be found at https://support.mycrypto.com/general-knowledge/cryptography/how-do-mnemonic-phrases-work + +Please note this mnemonic is not stored within the wallet, so cannot be retrieved or displayed again. As such, this mnemonic should be stored securely, ideally offline, before proceeding. +`, data.mnemonic), nil + } + + return "", nil +} diff --git a/cmd/wallet/create/output_internal_test.go b/cmd/wallet/create/output_internal_test.go new file mode 100644 index 0000000..a44c144 --- /dev/null +++ b/cmd/wallet/create/output_internal_test.go @@ -0,0 +1,62 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestOutput(t *testing.T) { + tests := []struct { + name string + dataOut *dataOut + res bool + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "Good", + dataOut: &dataOut{}, + }, + { + name: "GoodMnemonic", + dataOut: &dataOut{ + mnemonic: "test mnemonic", + }, + res: true, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + if test.res { + require.NotEqual(t, "", res) + } else { + require.Equal(t, "", res) + } + } + }) + } +} diff --git a/cmd/wallet/create/process.go b/cmd/wallet/create/process.go new file mode 100644 index 0000000..ae99555 --- /dev/null +++ b/cmd/wallet/create/process.go @@ -0,0 +1,134 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "crypto/rand" + "strings" + + "github.com/pkg/errors" + bip39 "github.com/tyler-smith/go-bip39" + "github.com/wealdtech/ethdo/util" + distributed "github.com/wealdtech/go-eth2-wallet-distributed" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + hd "github.com/wealdtech/go-eth2-wallet-hd/v2" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + "golang.org/x/text/unicode/norm" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + + switch data.walletType { + case "nd", "non-deterministic": + return processND(ctx, data) + case "hd", "hierarchical deterministic": + return processHD(ctx, data) + case "distributed": + return processDistributed(ctx, data) + default: + return nil, errors.New("wallet type not supported") + } +} + +func processND(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + + results := &dataOut{} + + if _, err := nd.CreateWallet(ctx, data.walletName, data.store, keystorev4.New()); err != nil { + return nil, err + } + return results, nil +} + +func processHD(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.passphrase == "" { + return nil, errors.New("wallet passphrase is required for hierarchical deterministic wallets") + } + if !util.AcceptablePassphrase(data.passphrase) { + return nil, errors.New("supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") + } + if data.quiet { + return nil, errors.New("creation of hierarchical deterministic wallets prints its mnemonic, so cannot be run with the --quiet flag") + } + + results := &dataOut{} + + // Only show the mnemonic on output if we generate it. + printMnemonic := data.mnemonic == "" + mnemonicPassphrase := "" + + if data.mnemonic == "" { + // Create a new random mnemonic. + entropy := make([]byte, 32) + _, err := rand.Read(entropy) + if err != nil { + return nil, errors.Wrap(err, "failed to generate entropy for wallet mnemonic") + } + data.mnemonic, err = bip39.NewMnemonic(entropy) + if err != nil { + return nil, errors.Wrap(err, "failed to generate wallet mnemonic") + } + } else { + // We have an existing mnemonic. If there are more than 24 words we treat the additional characters as the passphrase. + mnemonicParts := strings.Split(data.mnemonic, " ") + if len(mnemonicParts) > 24 { + data.mnemonic = strings.Join(mnemonicParts[:24], " ") + mnemonicPassphrase = strings.Join(mnemonicParts[24:], " ") + } + } + // Normalise the input. + data.mnemonic = string(norm.NFKD.Bytes([]byte(data.mnemonic))) + mnemonicPassphrase = string(norm.NFKD.Bytes([]byte(mnemonicPassphrase))) + + // Ensure the mnemonic is valid + if !bip39.IsMnemonicValid(data.mnemonic) { + return nil, errors.New("mnemonic is not valid") + } + + // Create seed from mnemonic and passphrase. + seed := bip39.NewSeed(data.mnemonic, mnemonicPassphrase) + + if _, err := hd.CreateWallet(ctx, data.walletName, []byte(data.passphrase), data.store, keystorev4.New(), seed); err != nil { + return nil, err + } + if printMnemonic { + results.mnemonic = data.mnemonic + } + + return results, nil +} + +func processDistributed(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + + results := &dataOut{} + + if _, err := distributed.CreateWallet(ctx, data.walletName, data.store, keystorev4.New()); err != nil { + return nil, err + } + + return results, nil +} diff --git a/cmd/wallet/create/process_internal_test.go b/cmd/wallet/create/process_internal_test.go new file mode 100644 index 0000000..3db6eaf --- /dev/null +++ b/cmd/wallet/create/process_internal_test.go @@ -0,0 +1,152 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "TypeUnknown", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "unknown", + walletName: "Test wallet", + }, + err: "wallet type not supported", + }, + { + name: "NDGood", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "nd", + walletName: "Test wallet", + }, + }, + { + name: "HDPassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + }, + err: "wallet passphrase is required for hierarchical deterministic wallets", + }, + { + name: "HDPassphraseWeak", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + passphrase: "weak", + }, + err: "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag", + }, + { + name: "HDQuiet", + dataIn: &dataIn{ + timeout: 5 * time.Second, + quiet: true, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + passphrase: "ce%NohGhah4ye5ra", + }, + err: "creation of hierarchical deterministic wallets prints its mnemonic, so cannot be run with the --quiet flag", + }, + { + name: "HDMnemonic", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + passphrase: "ce%NohGhah4ye5ra", + mnemonic: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art", + }, + }, + { + name: "HDMnemonicExtra", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + passphrase: "ce%NohGhah4ye5ra", + mnemonic: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art extra", + }, + }, + { + name: "HDGood", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "hd", + walletName: "Test wallet", + passphrase: "ce%NohGhah4ye5ra", + }, + }, + { + name: "DistributedGood", + dataIn: &dataIn{ + timeout: 5 * time.Second, + store: scratch.New(), + walletType: "distributed", + walletName: "Test wallet", + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + _, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestNilData(t *testing.T) { + _, err := processND(context.Background(), nil) + require.EqualError(t, err, "no data") + _, err = processHD(context.Background(), nil) + require.EqualError(t, err, "no data") + _, err = processDistributed(context.Background(), nil) + require.EqualError(t, err, "no data") +} diff --git a/cmd/wallet/create/run.go b/cmd/wallet/create/run.go new file mode 100644 index 0000000..c99d4c9 --- /dev/null +++ b/cmd/wallet/create/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletcreate + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the wallet create data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/wallet/delete/input.go b/cmd/wallet/delete/input.go new file mode 100644 index 0000000..2cfeb17 --- /dev/null +++ b/cmd/wallet/delete/input.go @@ -0,0 +1,59 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/core" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + // System. + timeout time.Duration + quiet bool + verbose bool + debug bool + wallet e2wtypes.Wallet +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetString("remote") != "" { + return nil, errors.New("wallet delete not available for remote wallets") + } + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + data.quiet = viper.GetBool("quiet") + data.verbose = viper.GetBool("verbose") + data.debug = viper.GetBool("debug") + + // Wallet. + wallet, err := core.WalletFromInput(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to access wallet") + } + data.wallet = wallet + + return data, nil +} diff --git a/cmd/wallet/delete/input_internal_test.go b/cmd/wallet/delete/input_internal_test.go new file mode 100644 index 0000000..9316b96 --- /dev/null +++ b/cmd/wallet/delete/input_internal_test.go @@ -0,0 +1,103 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "wallet": "Test wallet", + }, + err: "timeout is required", + }, + { + name: "WalletMissing", + vars: map[string]interface{}{ + "timeout": "5s", + }, + err: "failed to access wallet: cannot determine wallet", + }, + { + name: "WalletUnknown", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "unknown", + }, + err: "failed to access wallet: wallet not found", + }, + { + name: "Remote", + vars: map[string]interface{}{ + "timeout": "5s", + "remote": "remoteaddress", + }, + err: "wallet delete not available for remote wallets", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "Test wallet", + }, + res: &dataIn{ + timeout: 5 * time.Second, + wallet: wallet, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res.timeout, res.timeout) + require.Equal(t, test.vars["wallet"], res.wallet.Name()) + } + }) + } +} diff --git a/cmd/wallet/delete/output.go b/cmd/wallet/delete/output.go new file mode 100644 index 0000000..ec93166 --- /dev/null +++ b/cmd/wallet/delete/output.go @@ -0,0 +1,29 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + + "github.com/pkg/errors" +) + +type dataOut struct{} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + return "", nil +} diff --git a/cmd/wallet/delete/output_internal_test.go b/cmd/wallet/delete/output_internal_test.go new file mode 100644 index 0000000..257160d --- /dev/null +++ b/cmd/wallet/delete/output_internal_test.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestOutput(t *testing.T) { + tests := []struct { + name string + dataOut *dataOut + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "Good", + dataOut: &dataOut{}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, "", res) + } + }) + } +} diff --git a/cmd/wallet/delete/process.go b/cmd/wallet/delete/process.go new file mode 100644 index 0000000..93d282e --- /dev/null +++ b/cmd/wallet/delete/process.go @@ -0,0 +1,48 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + "os" + "path/filepath" + + "github.com/pkg/errors" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.wallet == nil { + return nil, errors.New("wallet is required") + } + + storeProvider, isProvider := data.wallet.(e2wtypes.StoreProvider) + if !isProvider { + return nil, errors.New("cannot obtain store for the wallet") + } + store := storeProvider.Store() + storeLocationProvider, isProvider := store.(e2wtypes.StoreLocationProvider) + if !isProvider { + return nil, errors.New("cannot obtain store location for the wallet") + } + walletLocation := filepath.Join(storeLocationProvider.Location(), data.wallet.ID().String()) + if err := os.RemoveAll(walletLocation); err != nil { + return nil, errors.Wrap(err, "failed to delete wallet") + } + + return &dataOut{}, nil +} diff --git a/cmd/wallet/delete/process_internal_test.go b/cmd/wallet/delete/process_internal_test.go new file mode 100644 index 0000000..07dcc30 --- /dev/null +++ b/cmd/wallet/delete/process_internal_test.go @@ -0,0 +1,77 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + "io/ioutil" + "os" + "testing" + "time" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + filesystem "github.com/wealdtech/go-eth2-wallet-store-filesystem" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + base, err := ioutil.TempDir("", "") + require.NoError(t, err) + defer os.RemoveAll(base) + store := filesystem.New(filesystem.WithLocation(base)) + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "WalletMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + }, + err: "wallet is required", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: wallet, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + _, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/cmd/wallet/delete/run.go b/cmd/wallet/delete/run.go new file mode 100644 index 0000000..3a845b0 --- /dev/null +++ b/cmd/wallet/delete/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletdelete + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the wallet create data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/wallet/export/input.go b/cmd/wallet/export/input.go new file mode 100644 index 0000000..59890c6 --- /dev/null +++ b/cmd/wallet/export/input.go @@ -0,0 +1,67 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/core" + "github.com/wealdtech/ethdo/util" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +type dataIn struct { + // System. + timeout time.Duration + quiet bool + verbose bool + debug bool + wallet e2wtypes.Wallet + passphrase string +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetString("remote") != "" { + return nil, errors.New("wallet export not available for remote wallets") + } + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + data.quiet = viper.GetBool("quiet") + data.verbose = viper.GetBool("verbose") + data.debug = viper.GetBool("debug") + + // Wallet. + wallet, err := core.WalletFromInput(ctx) + if err != nil { + return nil, errors.Wrap(err, "failed to access wallet") + } + data.wallet = wallet + + // Passphrase. + data.passphrase, err = util.GetPassphrase() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain export passphrase") + } + + return data, nil +} diff --git a/cmd/wallet/export/input_internal_test.go b/cmd/wallet/export/input_internal_test.go new file mode 100644 index 0000000..bfd1da6 --- /dev/null +++ b/cmd/wallet/export/input_internal_test.go @@ -0,0 +1,112 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "wallet": "Test wallet", + }, + err: "timeout is required", + }, + { + name: "WalletMissing", + vars: map[string]interface{}{ + "timeout": "5s", + }, + err: "failed to access wallet: cannot determine wallet", + }, + { + name: "WalletUnknown", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "unknown", + }, + err: "failed to access wallet: wallet not found", + }, + { + name: "Remote", + vars: map[string]interface{}{ + "timeout": "5s", + "remote": "remoteaddress", + }, + err: "wallet export not available for remote wallets", + }, + { + name: "PassphraseMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "Test wallet", + }, + err: "failed to obtain export passphrase: passphrase is required", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "wallet": "Test wallet", + "passphrase": "export", + }, + res: &dataIn{ + timeout: 5 * time.Second, + wallet: wallet, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res.timeout, res.timeout) + require.Equal(t, test.vars["wallet"], res.wallet.Name()) + } + }) + } +} diff --git a/cmd/wallet/export/output.go b/cmd/wallet/export/output.go new file mode 100644 index 0000000..dfa640b --- /dev/null +++ b/cmd/wallet/export/output.go @@ -0,0 +1,33 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + "fmt" + + "github.com/pkg/errors" +) + +type dataOut struct { + export []byte +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + + return fmt.Sprintf("%#x", data.export), nil +} diff --git a/cmd/wallet/export/output_internal_test.go b/cmd/wallet/export/output_internal_test.go new file mode 100644 index 0000000..fb33a3e --- /dev/null +++ b/cmd/wallet/export/output_internal_test.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestOutput(t *testing.T) { + tests := []struct { + name string + dataOut *dataOut + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "Good", + dataOut: &dataOut{}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, "", res) + } + }) + } +} diff --git a/cmd/wallet/export/process.go b/cmd/wallet/export/process.go new file mode 100644 index 0000000..56e1de6 --- /dev/null +++ b/cmd/wallet/export/process.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + + "github.com/pkg/errors" + "github.com/wealdtech/ethdo/util" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.wallet == nil { + return nil, errors.New("wallet is required") + } + if !util.AcceptablePassphrase(data.passphrase) { + return nil, errors.New("supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") + } + + exporter, isExporter := data.wallet.(e2wtypes.WalletExporter) + if !isExporter { + return nil, errors.New("wallet does not provide export") + } + + export, err := exporter.Export(ctx, []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to export wallet") + } + + results := &dataOut{ + export: export, + } + + return results, nil +} diff --git a/cmd/wallet/export/process_internal_test.go b/cmd/wallet/export/process_internal_test.go new file mode 100644 index 0000000..a77449a --- /dev/null +++ b/cmd/wallet/export/process_internal_test.go @@ -0,0 +1,88 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + "io/ioutil" + "os" + "testing" + "time" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + filesystem "github.com/wealdtech/go-eth2-wallet-store-filesystem" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + base, err := ioutil.TempDir("", "") + require.NoError(t, err) + defer os.RemoveAll(base) + store := filesystem.New(filesystem.WithLocation(base)) + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "WalletMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + }, + err: "wallet is required", + }, + { + name: "PassphraseWeak", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: wallet, + passphrase: "weak", + }, + err: "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + wallet: wallet, + passphrase: "ce%NohGhah4ye5ra", + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.NotNil(t, res.export) + } + }) + } +} diff --git a/cmd/wallet/export/run.go b/cmd/wallet/export/run.go new file mode 100644 index 0000000..85947fc --- /dev/null +++ b/cmd/wallet/export/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletexport + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the wallet create data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/wallet/import/input.go b/cmd/wallet/import/input.go new file mode 100644 index 0000000..5fac14e --- /dev/null +++ b/cmd/wallet/import/input.go @@ -0,0 +1,82 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "encoding/hex" + "io/ioutil" + "strings" + "time" + + "github.com/pkg/errors" + "github.com/spf13/viper" + "github.com/wealdtech/ethdo/util" +) + +type dataIn struct { + // System. + timeout time.Duration + quiet bool + verbose bool + debug bool + data []byte + passphrase string + verify bool +} + +func input(ctx context.Context) (*dataIn, error) { + var err error + data := &dataIn{} + + if viper.GetString("remote") != "" { + return nil, errors.New("wallet import not available for remote wallets") + } + + if viper.GetDuration("timeout") == 0 { + return nil, errors.New("timeout is required") + } + data.timeout = viper.GetDuration("timeout") + data.quiet = viper.GetBool("quiet") + data.verbose = viper.GetBool("verbose") + data.debug = viper.GetBool("debug") + + // Data. + if viper.GetString("data") == "" { + return nil, errors.New("data is required") + } + if !strings.HasPrefix(viper.GetString("data"), "0x") { + // Assume this is a path; read the file and replace the path with its contents. + fileData, err := ioutil.ReadFile(viper.GetString("data")) + if err != nil { + return nil, errors.Wrap(err, "failed to read wallet import data") + } + viper.Set("data", strings.TrimSpace(string(fileData))) + } + data.data, err = hex.DecodeString(strings.TrimPrefix(viper.GetString("data"), "0x")) + if err != nil { + return nil, errors.Wrap(err, "data is invalid") + } + + // Passphrase. + data.passphrase, err = util.GetPassphrase() + if err != nil { + return nil, errors.Wrap(err, "failed to obtain import passphrase") + } + + // Verify. + data.verify = viper.GetBool("verify") + + return data, nil +} diff --git a/cmd/wallet/import/input_internal_test.go b/cmd/wallet/import/input_internal_test.go new file mode 100644 index 0000000..7dd90b7 --- /dev/null +++ b/cmd/wallet/import/input_internal_test.go @@ -0,0 +1,134 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/spf13/viper" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestInput(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + data, err := wallet.(e2wtypes.WalletExporter).Export(context.Background(), []byte("ce%NohGhah4ye5ra")) + require.NoError(t, err) + require.NoError(t, e2wallet.UseStore(scratch.New())) + + tests := []struct { + name string + vars map[string]interface{} + res *dataIn + err string + }{ + { + name: "TimeoutMissing", + vars: map[string]interface{}{ + "data": fmt.Sprintf("%#x", data), + }, + err: "timeout is required", + }, + { + name: "DataMissing", + vars: map[string]interface{}{ + "timeout": "5s", + }, + err: "data is required", + }, + { + name: "DataInvalid", + vars: map[string]interface{}{ + "timeout": "5s", + "data": "0xinvalid", + }, + err: "data is invalid: encoding/hex: invalid byte: U+0069 'i'", + }, + { + name: "DataFileMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "data": "missing", + }, + err: "failed to read wallet import data: open missing: no such file or directory", + }, + { + name: "Remote", + vars: map[string]interface{}{ + "timeout": "5s", + "remote": "remoteaddress", + "data": fmt.Sprintf("%#x", data), + "passphrase": "export", + }, + err: "wallet import not available for remote wallets", + }, + { + name: "PassphraseMissing", + vars: map[string]interface{}{ + "timeout": "5s", + "data": fmt.Sprintf("%#x", data), + }, + err: "failed to obtain import passphrase: passphrase is required", + }, + { + name: "Good", + vars: map[string]interface{}{ + "timeout": "5s", + "data": fmt.Sprintf("%#x", data), + "passphrase": "export", + }, + res: &dataIn{ + timeout: 5 * time.Second, + }, + }, + { + name: "Verify", + vars: map[string]interface{}{ + "timeout": "5s", + "data": fmt.Sprintf("%#x", data), + "passphrase": "export", + "verify": true, + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + viper.Reset() + for k, v := range test.vars { + viper.Set(k, v) + } + res, err := input(context.Background()) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.NotNil(t, res) + } + }) + } +} diff --git a/cmd/wallet/import/output.go b/cmd/wallet/import/output.go new file mode 100644 index 0000000..2dd465e --- /dev/null +++ b/cmd/wallet/import/output.go @@ -0,0 +1,60 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "fmt" + + "github.com/gofrs/uuid" + "github.com/pkg/errors" +) + +type dataOut struct { + verify bool + quiet bool + verbose bool + export *export +} + +type accountInfo struct { + Name string `json:"name"` +} +type walletInfo struct { + ID uuid.UUID `json:"uuid"` + Name string `json:"name"` + Type string `json:"type"` +} +type export struct { + Wallet *walletInfo `json:"wallet"` + Accounts []*accountInfo `json:"accounts"` +} + +func output(ctx context.Context, data *dataOut) (string, error) { + if data == nil { + return "", errors.New("no data") + } + + res := "" + if data.verify { + res = fmt.Sprintf("Wallet name: %s\nWallet type: %s\nWallet UUID: %s\nWallet accounts: %d", data.export.Wallet.Name, data.export.Wallet.Type, data.export.Wallet.ID, len(data.export.Accounts)) + if data.verbose && len(data.export.Accounts) > 0 { + for _, account := range data.export.Accounts { + res = fmt.Sprintf("%s\n %s", res, account.Name) + } + } + } + + return res, nil +} diff --git a/cmd/wallet/import/output_internal_test.go b/cmd/wallet/import/output_internal_test.go new file mode 100644 index 0000000..3783764 --- /dev/null +++ b/cmd/wallet/import/output_internal_test.go @@ -0,0 +1,90 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "testing" + + "github.com/gofrs/uuid" + "github.com/stretchr/testify/require" +) + +func TestOutput(t *testing.T) { + export := &export{ + Wallet: &walletInfo{ + ID: uuid.FromBytesOrNil([]byte{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + }), + Name: "Test wallet", + Type: "non-deterministic", + }, + Accounts: []*accountInfo{ + { + Name: "Account 1", + }, + { + Name: "Account 2", + }, + }, + } + + tests := []struct { + name string + dataOut *dataOut + res string + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "Good", + dataOut: &dataOut{ + export: export, + }, + res: "", + }, + { + name: "Verify", + dataOut: &dataOut{ + verify: true, + export: export, + }, + res: "Wallet name: Test wallet\nWallet type: non-deterministic\nWallet UUID: 00010203-0405-0607-0809-0a0b0c0d0e0f\nWallet accounts: 2", + }, + { + name: "VerifyVerbose", + dataOut: &dataOut{ + verify: true, + verbose: true, + export: export, + }, + res: "Wallet name: Test wallet\nWallet type: non-deterministic\nWallet UUID: 00010203-0405-0607-0809-0a0b0c0d0e0f\nWallet accounts: 2\n Account 1\n Account 2", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + res, err := output(context.Background(), test.dataOut) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + require.Equal(t, test.res, res) + } + }) + } +} diff --git a/cmd/wallet/import/process.go b/cmd/wallet/import/process.go new file mode 100644 index 0000000..810ad34 --- /dev/null +++ b/cmd/wallet/import/process.go @@ -0,0 +1,51 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "encoding/json" + + "github.com/pkg/errors" + "github.com/wealdtech/go-ecodec" + e2wallet "github.com/wealdtech/go-eth2-wallet" +) + +func process(ctx context.Context, data *dataIn) (*dataOut, error) { + if data == nil { + return nil, errors.New("no data") + } + if data.data == nil { + return nil, errors.New("import data is required") + } + + ext := &export{} + if data.verify { + data, err := ecodec.Decrypt(data.data, []byte(data.passphrase)) + if err != nil { + return nil, errors.Wrap(err, "failed to decrypt export") + } + if err := json.Unmarshal(data, ext); err != nil { + return nil, errors.Wrap(err, "failed to read export") + } + } else if _, err := e2wallet.ImportWallet(data.data, []byte(data.passphrase)); err != nil { + return nil, errors.Wrap(err, "failed to import wallet") + } + + results := &dataOut{ + export: ext, + } + + return results, nil +} diff --git a/cmd/wallet/import/process_internal_test.go b/cmd/wallet/import/process_internal_test.go new file mode 100644 index 0000000..f5ca3e3 --- /dev/null +++ b/cmd/wallet/import/process_internal_test.go @@ -0,0 +1,132 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" + e2wallet "github.com/wealdtech/go-eth2-wallet" + keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" + nd "github.com/wealdtech/go-eth2-wallet-nd/v2" + scratch "github.com/wealdtech/go-eth2-wallet-store-scratch" + e2wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" +) + +func TestProcess(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + store := scratch.New() + require.NoError(t, e2wallet.UseStore(store)) + wallet, err := nd.CreateWallet(context.Background(), "Test wallet", store, keystorev4.New()) + require.NoError(t, err) + data, err := wallet.(e2wtypes.WalletExporter).Export(context.Background(), []byte("ce%NohGhah4ye5ra")) + require.NoError(t, err) + require.NoError(t, e2wallet.UseStore(scratch.New())) + + tests := []struct { + name string + dataIn *dataIn + err string + }{ + { + name: "Nil", + err: "no data", + }, + { + name: "DataMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + passphrase: "ce%NohGhah4ye5ra", + }, + err: "import data is required", + }, + { + name: "DataBad", + dataIn: &dataIn{ + timeout: 5 * time.Second, + data: append([]byte{0x00}, data...), + passphrase: "ce%NohGhah4ye5ra", + }, + err: "failed to import wallet: unhandled version 0x00", + }, + { + name: "PassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + data: data, + }, + err: "failed to import wallet: invalid key", + }, + { + name: "PassphraseIncorrect", + dataIn: &dataIn{ + timeout: 5 * time.Second, + data: data, + passphrase: "weak", + }, + err: "failed to import wallet: invalid key", + }, + { + name: "Good", + dataIn: &dataIn{ + timeout: 5 * time.Second, + data: data, + passphrase: "ce%NohGhah4ye5ra", + }, + }, + { + name: "VerifyDataBad", + dataIn: &dataIn{ + timeout: 5 * time.Second, + verify: true, + data: append([]byte{0x00}, data...), + passphrase: "ce%NohGhah4ye5ra", + }, + err: "failed to decrypt export: unhandled version 0x00", + }, + { + name: "VerifyPassphraseMissing", + dataIn: &dataIn{ + timeout: 5 * time.Second, + verify: true, + data: data, + }, + err: "failed to decrypt export: invalid key", + }, + { + name: "Verify", + dataIn: &dataIn{ + timeout: 5 * time.Second, + verify: true, + data: data, + passphrase: "ce%NohGhah4ye5ra", + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + _, err := process(context.Background(), test.dataIn) + if test.err != "" { + require.EqualError(t, err, test.err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/cmd/wallet/import/run.go b/cmd/wallet/import/run.go new file mode 100644 index 0000000..7f0ad2d --- /dev/null +++ b/cmd/wallet/import/run.go @@ -0,0 +1,50 @@ +// Copyright © 2019, 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package walletimport + +import ( + "context" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Run runs the wallet create data command. +func Run(cmd *cobra.Command) (string, error) { + ctx := context.Background() + dataIn, err := input(ctx) + if err != nil { + return "", errors.Wrap(err, "failed to obtain input") + } + + // Further errors do not need a usage report. + cmd.SilenceUsage = true + + dataOut, err := process(ctx, dataIn) + if err != nil { + return "", errors.Wrap(err, "failed to process") + } + + if !viper.GetBool("verbose") { + return "", nil + } + + results, err := output(ctx, dataOut) + if err != nil { + return "", errors.Wrap(err, "failed to obtain output") + } + + return results, nil +} diff --git a/cmd/walletcreate.go b/cmd/walletcreate.go index a4e8d8c..cd1082e 100644 --- a/cmd/walletcreate.go +++ b/cmd/walletcreate.go @@ -14,22 +14,11 @@ package cmd import ( - "context" - "crypto/rand" "fmt" - "os" - "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" - bip39 "github.com/tyler-smith/go-bip39" - "github.com/wealdtech/ethdo/util" - distributed "github.com/wealdtech/go-eth2-wallet-distributed" - keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" - hd "github.com/wealdtech/go-eth2-wallet-hd/v2" - nd "github.com/wealdtech/go-eth2-wallet-nd/v2" - "golang.org/x/text/unicode/norm" + walletcreate "github.com/wealdtech/ethdo/cmd/wallet/create" ) var walletCreateCmd = &cobra.Command{ @@ -40,103 +29,18 @@ var walletCreateCmd = &cobra.Command{ ethdo wallet create --wallet="Primary wallet" --type=non-deterministic In quiet mode this will return 0 if the wallet is created successfully, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - assert(viper.GetString("remote") == "", "wallet create not available with remote wallets") - assert(viper.GetString("wallet") != "", "--wallet is required") - assert(viper.GetString("type") != "", "--type is required") - - var err error - switch strings.ToLower(viper.GetString("type")) { - case "non-deterministic", "nd": - assert(viper.GetString("mnemonic") == "", "--mnemonic is not allowed with non-deterministic wallets") - err = walletCreateND(ctx, viper.GetString("wallet")) - case "hierarchical deterministic", "hd": - if quiet { - fmt.Printf("Creation of hierarchical deterministic wallets prints its mnemonic, so cannot be run with the --quiet flag") - os.Exit(_exitFailure) - } - assert(getWalletPassphrase() != "", "--walletpassphrase is required for hierarchical deterministic wallets") - assert(util.AcceptablePassphrase(getWalletPassphrase()), "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") - err = walletCreateHD(ctx, viper.GetString("wallet"), getWalletPassphrase(), viper.GetString("mnemonic")) - case "distributed": - assert(viper.GetString("mnemonic") == "", "--mnemonic is not allowed with distributed wallets") - err = walletCreateDistributed(ctx, viper.GetString("wallet")) - default: - die("unknown wallet type") + RunE: func(cmd *cobra.Command, args []string) error { + res, err := walletcreate.Run(cmd) + if err != nil { + return err } - errCheck(err, "Failed to create wallet") + if res != "" { + fmt.Println(res) + } + return nil }, } -// walletCreateND creates a non-deterministic wallet. -func walletCreateND(ctx context.Context, name string) error { - _, err := nd.CreateWallet(ctx, name, store, keystorev4.New()) - return err -} - -// walletCreateDistributed creates a distributed wallet. -func walletCreateDistributed(ctx context.Context, name string) error { - _, err := distributed.CreateWallet(ctx, name, store, keystorev4.New()) - return err -} - -// walletCreateHD creates a hierarchical-deterministic wallet. -func walletCreateHD(ctx context.Context, name string, passphrase string, mnemonic string) error { - encryptor := keystorev4.New() - - printMnemonic := mnemonic == "" - mnemonicPassphrase := "" - - if mnemonic == "" { - // Create a new random mnemonic. - entropy := make([]byte, 32) - _, err := rand.Read(entropy) - if err != nil { - return errors.Wrap(err, "failed to generate entropy for wallet mnemonic") - } - mnemonic, err = bip39.NewMnemonic(entropy) - if err != nil { - return errors.Wrap(err, "failed to generate wallet mnemonic") - } - } else { - // We have an existing mnemonic. If there are more than 24 words we treat the additional characters as the passphrase. - mnemonicParts := strings.Split(mnemonic, " ") - if len(mnemonicParts) > 24 { - mnemonic = strings.Join(mnemonicParts[:24], " ") - mnemonicPassphrase = strings.Join(mnemonicParts[24:], " ") - } - } - // Normalise the input. - mnemonic = string(norm.NFKD.Bytes([]byte(mnemonic))) - mnemonicPassphrase = string(norm.NFKD.Bytes([]byte(mnemonicPassphrase))) - - // Ensure the mnemonic is valid - if !bip39.IsMnemonicValid(mnemonic) { - return errors.New("mnemonic is not valid") - } - - // Create seed from mnemonic and passphrase. - seed := bip39.NewSeed(mnemonic, mnemonicPassphrase) - - _, err := hd.CreateWallet(ctx, name, []byte(passphrase), store, encryptor, seed) - - if printMnemonic { - fmt.Printf(`The following phrase is your mnemonic for this wallet: - -%s - -Anyone with access to this mnemonic can recreate the accounts in this wallet, so please store this mnemonic safely. More information about mnemonics can be found at https://support.mycrypto.com/general-knowledge/cryptography/how-do-mnemonic-phrases-work - -Please note this mnemonic is not stored within the wallet, so cannot be retrieved or displayed again. As such, this mnemonic should be written down or otherwise protected before proceeding. -`, mnemonic) - } - - return err -} - func init() { walletCmd.AddCommand(walletCreateCmd) walletFlags(walletCreateCmd) diff --git a/cmd/walletdelete.go b/cmd/walletdelete.go index 4697eb8..3a5c2dd 100644 --- a/cmd/walletdelete.go +++ b/cmd/walletdelete.go @@ -14,13 +14,10 @@ package cmd import ( - "context" - "os" - "path/filepath" + "fmt" "github.com/spf13/cobra" - "github.com/spf13/viper" - wtypes "github.com/wealdtech/go-eth2-wallet-types/v2" + walletdelete "github.com/wealdtech/ethdo/cmd/wallet/delete" ) var walletDeleteCmd = &cobra.Command{ @@ -31,26 +28,15 @@ var walletDeleteCmd = &cobra.Command{ ethdo wallet delete --wallet=primary In quiet mode this will return 0 if the wallet has been deleted, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - assert(viper.GetString("remote") == "", "wallet delete not available with remote wallets") - assert(viper.GetString("wallet") != "", "--wallet is required") - - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - wallet, err := walletFromPath(ctx, viper.GetString("wallet")) - errCheck(err, "Failed to access wallet") - - storeProvider, ok := wallet.(wtypes.StoreProvider) - assert(ok, "Cannot obtain store for the wallet") - store := storeProvider.Store() - storeLocationProvider, ok := store.(wtypes.StoreLocationProvider) - assert(ok, "Cannot obtain store location for the wallet") - walletLocation := filepath.Join(storeLocationProvider.Location(), wallet.ID().String()) - err = os.RemoveAll(walletLocation) - errCheck(err, "Failed to delete wallet") - - os.Exit(_exitSuccess) + RunE: func(cmd *cobra.Command, args []string) error { + res, err := walletdelete.Run(cmd) + if err != nil { + return err + } + if res != "" { + fmt.Println(res) + } + return nil }, } diff --git a/cmd/walletexport.go b/cmd/walletexport.go index b69e466..206e8f8 100644 --- a/cmd/walletexport.go +++ b/cmd/walletexport.go @@ -14,51 +14,33 @@ package cmd import ( - "context" "fmt" - "os" "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/wealdtech/ethdo/util" - types "github.com/wealdtech/go-eth2-wallet-types/v2" + walletexport "github.com/wealdtech/ethdo/cmd/wallet/export" ) -var walletExportPassphrase string - var walletExportCmd = &cobra.Command{ Use: "export", Short: "Export a wallet", Long: `Export a wallet for backup of transfer. For example: - ethdo wallet export --wallet=primary --exportpassphrase="my export secret" + ethdo wallet export --wallet=primary --passphrase="my export secret" In quiet mode this will return 0 if the wallet is able to be exported, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), viper.GetDuration("timeout")) - defer cancel() - - assert(viper.GetString("remote") == "", "wallet export not available with remote wallets") - assert(viper.GetString("wallet") != "", "--wallet is required") - assert(walletExportPassphrase != "", "--exportpassphrase is required") - assert(util.AcceptablePassphrase(walletExportPassphrase), "supplied passphrase is weak; use a stronger one or run with the --allow-weak-passphrases flag") - - wallet, err := walletFromPath(ctx, viper.GetString("wallet")) - errCheck(err, "Failed to access wallet") - - _, ok := wallet.(types.WalletExporter) - assert(ok, fmt.Sprintf("wallets of type %q do not allow exporting accounts", wallet.Type())) - - exportData, err := wallet.(types.WalletExporter).Export(ctx, []byte(walletExportPassphrase)) - errCheck(err, "Failed to export wallet") - - outputIf(!quiet, fmt.Sprintf("0x%x", exportData)) - os.Exit(_exitSuccess) + RunE: func(cmd *cobra.Command, args []string) error { + res, err := walletexport.Run(cmd) + if err != nil { + return err + } + if res != "" { + fmt.Println(res) + } + return nil }, } func init() { walletCmd.AddCommand(walletExportCmd) walletFlags(walletExportCmd) - walletExportCmd.Flags().StringVar(&walletExportPassphrase, "exportpassphrase", "", "Passphrase to protect the export") } diff --git a/cmd/walletimport.go b/cmd/walletimport.go index 1ebc635..37d66d7 100644 --- a/cmd/walletimport.go +++ b/cmd/walletimport.go @@ -14,24 +14,13 @@ package cmd import ( - "encoding/json" "fmt" - "io/ioutil" - "os" - "strings" - "github.com/google/uuid" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/wealdtech/go-bytesutil" - "github.com/wealdtech/go-ecodec" - e2wallet "github.com/wealdtech/go-eth2-wallet" + walletimport "github.com/wealdtech/ethdo/cmd/wallet/import" ) -var walletImportData string -var walletImportPassphrase string -var walletImportVerify bool - var walletImportCmd = &cobra.Command{ Use: "import", Short: "Import a wallet", @@ -40,68 +29,30 @@ var walletImportCmd = &cobra.Command{ ethdo wallet import --importdata=primary --importpassphrase="my export secret" In quiet mode this will return 0 if the wallet is imported successfully, otherwise 1.`, - Run: func(cmd *cobra.Command, args []string) { - assert(viper.GetString("remote") == "", "wallet import not available with remote wallets") - assert(walletImportData != "", "--importdata is required") - assert(walletImportPassphrase != "", "--importpassphrase is required") - assert(viper.GetString("wallet") == "", "--wallet is not allowed (the wallet will retain its name)") - - if !strings.HasPrefix(walletImportData, "0x") { - outputIf(debug, fmt.Sprintf("Reading wallet import from file %s", walletImportData)) - // Assume this is a path - fileData, err := ioutil.ReadFile(walletImportData) - errCheck(err, "Failed to read wallet import data") - walletImportData = strings.TrimSpace(string(fileData)) + RunE: func(cmd *cobra.Command, args []string) error { + res, err := walletimport.Run(cmd) + if err != nil { + return err } - outputIf(debug, fmt.Sprintf("Wallet import data is of length %d", len(walletImportData))) - importData, err := bytesutil.FromHexString(walletImportData) - errCheck(err, "Failed to decode wallet data") - - if walletImportVerify { - type accountInfo struct { - Name string `json:"name"` - } - type walletInfo struct { - ID uuid.UUID `json:"uuid"` - Name string `json:"name"` - Type string `json:"type"` - } - type export struct { - Wallet *walletInfo `json:"wallet"` - Accounts []*accountInfo `json:"accounts"` - } - - data, err := ecodec.Decrypt(importData, []byte(walletImportPassphrase)) - errCheck(err, "Failed to decrypt wallet") - ext := &export{} - err = json.Unmarshal(data, ext) - errCheck(err, "Failed to read wallet") - - outputIf(!quiet, fmt.Sprintf("Wallet name: %s", ext.Wallet.Name)) - outputIf(!quiet, fmt.Sprintf("Wallet type: %s", ext.Wallet.Type)) - outputIf(verbose, fmt.Sprintf("Wallet UUID: %s", ext.Wallet.ID)) - if verbose { - fmt.Printf("Wallet accounts:\n") - for _, account := range ext.Accounts { - outputIf(verbose, fmt.Sprintf(" %s", account.Name)) - } - } else { - outputIf(!quiet, fmt.Sprintf("Wallet accounts: %d", len(ext.Accounts))) - } - - } else { - _, err = e2wallet.ImportWallet(importData, []byte(walletImportPassphrase)) - errCheck(err, "Failed to import wallet") + if res != "" { + fmt.Println(res) } - - os.Exit(_exitSuccess) + return nil }, } func init() { walletCmd.AddCommand(walletImportCmd) walletFlags(walletImportCmd) - walletImportCmd.Flags().StringVar(&walletImportData, "importdata", "", "The data to import, or the name of a file to read") - walletImportCmd.Flags().StringVar(&walletImportPassphrase, "importpassphrase", "", "Passphrase protecting the data to import") - walletImportCmd.Flags().BoolVar(&walletImportVerify, "verify", false, "Verify the wallet can be imported, but do not import it") + walletImportCmd.Flags().String("data", "", "The data to import, or the name of a data import file") + walletImportCmd.Flags().Bool("verify", false, "Verify the wallet can be imported, but do not import it") +} + +func walletImportBindings() { + if err := viper.BindPFlag("data", walletImportCmd.Flags().Lookup("data")); err != nil { + panic(err) + } + if err := viper.BindPFlag("verify", walletImportCmd.Flags().Lookup("verify")); err != nil { + panic(err) + } } diff --git a/core/account.go b/core/account.go index 5c1aaeb..e52baa4 100644 --- a/core/account.go +++ b/core/account.go @@ -71,10 +71,14 @@ func setup() error { // WalletFromInput obtains a wallet given the information in the viper variable // "account", or if not present the viper variable "wallet". func WalletFromInput(ctx context.Context) (e2wtypes.Wallet, error) { - if viper.GetString("account") != "" { + switch { + case viper.GetString("account") != "": return WalletFromPath(ctx, viper.GetString("account")) + case viper.GetString("wallet") != "": + return WalletFromPath(ctx, viper.GetString("wallet")) + default: + return nil, errors.New("cannot determine wallet") } - return WalletFromPath(ctx, viper.GetString("wallet")) } // WalletFromPath obtains a wallet given a path specification. diff --git a/docs/usage.md b/docs/usage.md index ffa1311..e29ddc2 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -51,7 +51,7 @@ $ ethdo wallet delete --wallet="Old wallet" `ethdo wallet export` exports the wallet and all of its accounts. Options for exporting a wallet include: - `wallet`: the name of the wallet to export (defaults to "primary") - - `exportpassphrase`: the passphrase with which to encrypt the wallet backup + - `passphrase`: the passphrase with which to encrypt the wallet backup ```sh $ ethdo wallet export --wallet="Personal wallet" --exportpassphrase="my export secret" @@ -67,8 +67,8 @@ $ ethdo wallet export --wallet="Personal wallet" --exportpassphrase="my export s #### `import` `ethdo wallet import` imports a wallet and all of its accounts exported by `ethdo wallet export`. Options for importing a wallet include: - - `importdata`: the data exported by `ethdo wallet export` - - `importpassphrase`: the passphrase that was provided to `ethdo wallet export` to encrypt the data + - `data`: the data exported by `ethdo wallet export` + - `passphrase`: the passphrase that was provided to `ethdo wallet export` to encrypt the data - `verify`: confirm information about the wallet import without importing it ```sh diff --git a/go.mod b/go.mod index b386763..9f6b312 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,15 @@ go 1.13 require ( github.com/OneOfOne/xxhash v1.2.5 // indirect + github.com/attestantio/dirk v0.9.1 github.com/attestantio/go-eth2-client v0.6.8 github.com/ferranbt/fastssz v0.0.0-20201030134205-9b9624098321 github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/gofrs/uuid v3.3.0+incompatible github.com/gogo/protobuf v1.3.1 github.com/google/uuid v1.1.2 github.com/grpc-ecosystem/grpc-gateway v1.15.2 // indirect - github.com/herumi/bls-eth-go-binary v0.0.0-20201008062400-71567a52ad65 + github.com/herumi/bls-eth-go-binary v0.0.0-20201019012252-4b463a10c225 github.com/magiconair/properties v1.8.4 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.3.3 // indirect @@ -32,23 +34,25 @@ require ( github.com/tyler-smith/go-bip39 v1.0.2 github.com/wealdtech/eth2-signer-api v1.6.0 github.com/wealdtech/go-bytesutil v1.1.1 - github.com/wealdtech/go-ecodec v1.1.0 - github.com/wealdtech/go-eth2-types/v2 v2.5.0 - github.com/wealdtech/go-eth2-util v1.6.0 - github.com/wealdtech/go-eth2-wallet v1.14.1 + github.com/wealdtech/go-ecodec v1.1.1 + github.com/wealdtech/go-eth2-types/v2 v2.5.1 + github.com/wealdtech/go-eth2-util v1.6.1 + github.com/wealdtech/go-eth2-wallet v1.14.2 github.com/wealdtech/go-eth2-wallet-dirk v1.0.4 - github.com/wealdtech/go-eth2-wallet-distributed v1.1.1 - github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.1 - github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.1 - github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.1 - github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.1 - github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.0 - github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.0 - github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.0 + github.com/wealdtech/go-eth2-wallet-distributed v1.1.2 + github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.2 + github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.2 + github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.2 + github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.13 + github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.1 + github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.1 + github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.1 github.com/wealdtech/go-string2eth v1.1.0 golang.org/x/text v0.3.3 - google.golang.org/grpc v1.33.0 + google.golang.org/grpc v1.33.1 gopkg.in/ini.v1 v1.62.0 // indirect ) replace github.com/attestantio/go-eth2-client => ../../attestantio/go-eth2-client + +replace github.com/attestantio/dirk => ../../attestantio/dirk diff --git a/go.sum b/go.sum index 817f02e..e05d823 100644 --- a/go.sum +++ b/go.sum @@ -5,67 +5,144 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.68.0/go.mod h1:91NO4SCDjUfe1zeC0f4/dpckkUNpuNEyqm4X2KLrzNQ= +cloud.google.com/go v0.70.0/go.mod h1:/UTKYRQTWjVnSe7nGvoSzxEFUELzSI/yAYd0JQT6cRo= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/HdrHistogram/hdrhistogram-go v0.9.0/go.mod h1:nxrse8/Tzg2tg3DZcZjm6qEclQKK70g0KxO61gFFZD4= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI= github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/attestantio/dirk v0.9.1 h1:oof1Xm0uI4a2T9vhQB+f3Wjlngd2rnfsKi8aj1wqNh0= +github.com/attestantio/dirk v0.9.1/go.mod h1:oWsyIb/OXdx9pvDQqS3hdFBB1eFaYnrNjuvLtVwo69w= +github.com/attestantio/go-eth2-client v0.6.8 h1:Lsjx5P0pB8ruZBfJUbqy5hpevD4Zt8Z0Lg4V5m2s53E= +github.com/attestantio/go-eth2-client v0.6.8/go.mod h1:lYEayGHzZma9HMUJgyxFIzDWRck8n2IedP7KTkIwe0g= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.32.6 h1:HoswAabUWgnrUF7X/9dr4WRgrr8DyscxXvTDm7Qw/5c= github.com/aws/aws-sdk-go v1.32.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.33.5 h1:p2fr1ryvNTU6avUWLI+/H7FGv0TBIjzVM5WDgXBBv4U= github.com/aws/aws-sdk-go v1.33.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.33.11 h1:A7b3mNKbh/0zrhnNN/KxWD0YZJw2RImnjFXWOquYKB4= github.com/aws/aws-sdk-go v1.33.11/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.33.17/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.34.5 h1:FwubVVX9u+kW9qDCjVzyWOdsL+W5wPq683wMk2R2GXk= github.com/aws/aws-sdk-go v1.34.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.34.9 h1:cUGBW9CVdi0mS7K1hDzxIqTpfeWhpoQiguq81M1tjK0= github.com/aws/aws-sdk-go v1.34.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.35.7 h1:FHMhVhyc/9jljgFAcGkQDYjpC9btM0B8VfkLBfctdNE= github.com/aws/aws-sdk-go v1.35.7/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= +github.com/aws/aws-sdk-go v1.35.14 h1:nucVVXXjAr9UkmYCBWxQWRuYa5KOlaXjuJGg2ulW0K0= +github.com/aws/aws-sdk-go v1.35.14/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= +github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/ristretto v0.0.1/go.mod h1:T40EBc7CJke8TkpiYfGGKAeFjSaxuFXhuXRyumBd6RE= github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -82,36 +159,59 @@ github.com/ferranbt/fastssz v0.0.0-20200818222714-826c7ef45b30 h1:Sbm5yhPObRc+RC github.com/ferranbt/fastssz v0.0.0-20200818222714-826c7ef45b30/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= github.com/ferranbt/fastssz v0.0.0-20200826142241-3a913c5a1313 h1:8DS7uDmUkGF6UKNU1HivEsjrTusxLPb05KUr/D8ONWQ= github.com/ferranbt/fastssz v0.0.0-20200826142241-3a913c5a1313/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= +github.com/ferranbt/fastssz v0.0.0-20201020132831-68dc48984fd3/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= github.com/ferranbt/fastssz v0.0.0-20201030134205-9b9624098321 h1:9Pkbf8HgETu3xKpz12Sj5clUrVFp2O+ymK7pBsTPYRM= github.com/ferranbt/fastssz v0.0.0-20201030134205-9b9624098321/go.mod h1:DyEu2iuLBnb/T51BlsiO3yLYdJC6UbGMrIkqK1KmQxM= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-yaml v1.8.3 h1:VGzw2KWSUyQX0yXai02S0nttBc+Oa4Kvh6RCFoxt8SE= github.com/goccy/go-yaml v1.8.3/go.mod h1:wS4gNoLalDSJxo/SpngzPQ2BN4uuZVLCmbM4S3vd4+Y= +github.com/gofrs/uuid v1.2.0 h1:coDhrjgyJaglxSjxuJdqQSSdUpG3w6p1OwN2od6frBU= +github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= +github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -120,6 +220,12 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= +github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -127,12 +233,25 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200905233945-acf8798be1f7/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201009210932-67992a1a5a35/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -141,11 +260,19 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMchFtkdrS4BIj5o= github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= @@ -154,7 +281,9 @@ github.com/grpc-ecosystem/grpc-gateway v1.14.7/go.mod h1:oYZKL012gGh6LMyg/xA7Q2y github.com/grpc-ecosystem/grpc-gateway v1.15.2 h1:HC+hWRWf+v5zTMPyoaYTKIJih+4sd4XRWmj0qlG87Co= github.com/grpc-ecosystem/grpc-gateway v1.15.2/go.mod h1:vO11I9oWA+KsxmfFQPhLnnIb1VDE24M+pdxZFiuZcA8= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -165,6 +294,7 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -190,27 +320,42 @@ github.com/herumi/bls-eth-go-binary v0.0.0-20200722032157-41fc56eba7b4 h1:TfBVK1 github.com/herumi/bls-eth-go-binary v0.0.0-20200722032157-41fc56eba7b4/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= github.com/herumi/bls-eth-go-binary v0.0.0-20201008062400-71567a52ad65 h1:KUHKqKMt9r78Ko07pTvlvEW6vPq24+efv1YXWk9Ba1U= github.com/herumi/bls-eth-go-binary v0.0.0-20201008062400-71567a52ad65/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/herumi/bls-eth-go-binary v0.0.0-20201019012252-4b463a10c225 h1:S7pKW74AvYc89WawL6IxGSnJRxF4TkE1GITYqKFyYy4= +github.com/herumi/bls-eth-go-binary v0.0.0-20201019012252-4b463a10c225/go.mod h1:luAnRm3OsMQeokhGzpYmc0ZKwawY7o87PUEP11Z7r7U= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jackc/puddle v1.1.1 h1:PJAw7H/9hoWC4Kf3J8iNmL1SwA6E8vfsLqBiL+F6CtI= github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.2 h1:mpQEXihFnWGDy6X98EOTh81JYuxn7txby8ilJ3iIPGM= github.com/jackc/puddle v1.1.2/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -220,6 +365,9 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -230,10 +378,12 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2BA= @@ -255,37 +405,88 @@ github.com/mitchellh/mapstructure v1.3.2 h1:mRS76wmkOn3KkKAyXDu42V+6ebnXWIztFSYG github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E= github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.0 h1:Keo9qb7iRJs2voHvunFtuuYFsbWeOBh8/P9v/kVMFtw= github.com/pelletier/go-toml v1.8.0/go.mod h1:D6yutnOGMveHEPV7VQOuvI/gXY61bv+9bAOTRnLElKs= github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/protolambda/zssz v0.1.3/go.mod h1:a4iwOX5FE7/JkKA+J/PH0Mjo9oXftN6P8NZyL28gpag= github.com/protolambda/zssz v0.1.5 h1:7fjJjissZIIaa2QcvmhS/pZISMX21zVITt49sW1ouek= @@ -306,6 +507,7 @@ github.com/prysmaticlabs/go-ssz v0.0.0-20200101200214-e24db4d9e963/go.mod h1:Vec github.com/prysmaticlabs/go-ssz v0.0.0-20200612203617-6d5c9aa213ae h1:7qd0Af1ozWKBU3c93YW2RH+/09hJns9+ftqWUZyts9c= github.com/prysmaticlabs/go-ssz v0.0.0-20200612203617-6d5c9aa213ae/go.mod h1:VecIJZrewdAuhVckySLFt2wAAHRME934bSDurP8ftkc= github.com/r3labs/sse/v2 v2.3.0/go.mod h1:hUrYMKfu9WquG9MyI0r6TKiNH+6Sw/QPKm2YbNbU5g8= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -313,8 +515,10 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/rs/zerolog v1.20.0 h1:38k9hgtUBdxFwE34yS8rTHmHBa4eN16E4DJlv177LNs= github.com/rs/zerolog v1.20.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -322,11 +526,15 @@ github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1 github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -342,19 +550,26 @@ github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -367,10 +582,16 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tyler-smith/go-bip39 v1.0.2 h1:+t3w+KwLXO6154GNJY+qUtIxLTmFjfUmpguQT1OlOT8= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= +github.com/uber/jaeger-client-go v2.25.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/wealdtech/eth2-signer-api v1.5.0 h1:XkaEk7Y0vFbqUstHcCjVGssoqJy4zYnBcF76em1oWX8= github.com/wealdtech/eth2-signer-api v1.5.0/go.mod h1:5wlLQ7NO7nbXo3znJOwIWHN8S4C3xHcZ0uOg9Ue4mvg= github.com/wealdtech/eth2-signer-api v1.5.1 h1:RQb1xyZEcHGpVFNpTEKzLbGH/H04Ajb6y99b2sd8gVs= @@ -384,12 +605,16 @@ github.com/wealdtech/go-bytesutil v1.1.1 h1:ocEg3Ke2GkZ4vQw5lp46rmO+pfqCCTgq35gq github.com/wealdtech/go-bytesutil v1.1.1/go.mod h1:jENeMqeTEU8FNZyDFRVc7KqBdRKSnJ9CCh26TcuNb9s= github.com/wealdtech/go-ecodec v1.1.0 h1:yggrTSckcPJRaxxOxQF7FPm21kgE8WA6+f5jdq5Kr8o= github.com/wealdtech/go-ecodec v1.1.0/go.mod h1:PSdBFEB6cltdT7V4E1jbboufMZTZXcQOKG/2PeEjKK4= +github.com/wealdtech/go-ecodec v1.1.1 h1:Lti3l4r/tHxviU4GzYMkkLWPuY/pJeG+QURE8KJObYk= +github.com/wealdtech/go-ecodec v1.1.1/go.mod h1:PSdBFEB6cltdT7V4E1jbboufMZTZXcQOKG/2PeEjKK4= github.com/wealdtech/go-eth2-types/v2 v2.4.2 h1:EkOvP8Ma0Ru7WIh0haoST97rc0PYm2AJpuWG1HzgfCI= github.com/wealdtech/go-eth2-types/v2 v2.4.2/go.mod h1:hhKa4ZFaNU2fwUjEh8GYr8wKg5D1W4QyxZ3xpsb/2hw= github.com/wealdtech/go-eth2-types/v2 v2.4.3 h1:VFYVYw9J2P/HFXi7T9HX7vzM+xx6BZ4od5PlVsUP5OE= github.com/wealdtech/go-eth2-types/v2 v2.4.3/go.mod h1:hhKa4ZFaNU2fwUjEh8GYr8wKg5D1W4QyxZ3xpsb/2hw= github.com/wealdtech/go-eth2-types/v2 v2.5.0 h1:L8sl3yoICAbn3134CBLNUt0o5h2voe0Es2KD5O9r8YQ= github.com/wealdtech/go-eth2-types/v2 v2.5.0/go.mod h1:321w9X26lAnNa/lQJi2A6Lap5IsNORoLwFPoJ1i8QvY= +github.com/wealdtech/go-eth2-types/v2 v2.5.1 h1:59VZuwgqRaTjBu3b3CCaxG05XTmANtuTKA8hy3C6IFQ= +github.com/wealdtech/go-eth2-types/v2 v2.5.1/go.mod h1:UUtEgRum8HkPvImpu5+hFYRanMUjP0k6KWqHlYkOGbk= github.com/wealdtech/go-eth2-util v1.2.2 h1:LALunpMSJFvu89RHS1zl6RjZ52805utRvd12RtquB54= github.com/wealdtech/go-eth2-util v1.2.2/go.mod h1:R3VlTd69B2Jf58s62ChcyXt11ZK1/36CTplTuyR/6dE= github.com/wealdtech/go-eth2-util v1.3.0 h1:aX1+PnxB904GIf5JE9GRKYPuGQJsCT+Q7PG9BMeFN40= @@ -398,6 +623,8 @@ github.com/wealdtech/go-eth2-util v1.5.0 h1:b3fgyvoq/WocW9LkWT7zcO5VCKzKLCc97rPr github.com/wealdtech/go-eth2-util v1.5.0/go.mod h1:0PGWeWWc6qjky/aNjdPdguJdZ2HSEHHCA+3cTjvT+Hk= github.com/wealdtech/go-eth2-util v1.6.0 h1:l2OR0SqfYdEnb1I1Ggnk0w+B9/LA5aHdQ2KK2FPnGkY= github.com/wealdtech/go-eth2-util v1.6.0/go.mod h1:0PGWeWWc6qjky/aNjdPdguJdZ2HSEHHCA+3cTjvT+Hk= +github.com/wealdtech/go-eth2-util v1.6.1 h1:gYW2s6iea/6NoSuSbisMqETpcnQYfqQnpmGLPYc0XHY= +github.com/wealdtech/go-eth2-util v1.6.1/go.mod h1:0hCjncDU0yi6dzGgrCgWAj6grdvJ6loEKCGpCMfxo9c= github.com/wealdtech/go-eth2-wallet v1.10.2 h1:oUgi6Ih5fA9thhIipzXMSaLkiwDQXwT8q3bCOLpCr7s= github.com/wealdtech/go-eth2-wallet v1.10.2/go.mod h1:8H9pgp5K7X1kU1cJMS/B3DrMZF74ZlwBThownrcRYgk= github.com/wealdtech/go-eth2-wallet v1.11.0 h1:2KfrWDqF4sWGgk4N5+DaYmh0hOnqiCl0P4vCz5mx17U= @@ -410,6 +637,8 @@ github.com/wealdtech/go-eth2-wallet v1.14.0 h1:eZjopWDMlCHCE9SLydAXBr0Cqtm2HWL3O github.com/wealdtech/go-eth2-wallet v1.14.0/go.mod h1:HrJ4hLcTPZPjhdkZKZd07OFxA+r7d3i+7XKjYJbxdxk= github.com/wealdtech/go-eth2-wallet v1.14.1 h1:0XQ6Bc2vZQCvDMg4qD6usObsXEVUPaNdv31qpwHpm0g= github.com/wealdtech/go-eth2-wallet v1.14.1/go.mod h1:MfQZSlMPfUlvh8EAnlHan/ZQSr+lSWA1zD4QTl4116w= +github.com/wealdtech/go-eth2-wallet v1.14.2 h1:pk6JGQdeEafVmZw5JYg2gk/8IeZjf0mY8gjufdTfYo8= +github.com/wealdtech/go-eth2-wallet v1.14.2/go.mod h1:irzlGFMyRCWlvGgdI7IjS+/Oyr3Y+Dkkh5kxo0VCRDg= github.com/wealdtech/go-eth2-wallet-dirk v1.0.0 h1:1QUcWILF3h4OLCgTPpWklvRSuPu0fqrt15jwSm7CSC4= github.com/wealdtech/go-eth2-wallet-dirk v1.0.0/go.mod h1:VTzjJ51dedvYPr4huI7g7KXZVTpGR6ZrCDQwBxJpLck= github.com/wealdtech/go-eth2-wallet-dirk v1.0.1 h1:YUE1QlJPun8b+xbz0JM71/3t1i9zp9KjcZdJvtJQL+E= @@ -426,12 +655,17 @@ github.com/wealdtech/go-eth2-wallet-distributed v1.1.0 h1:OZjjuxcIYo+EhAfph7lYP1 github.com/wealdtech/go-eth2-wallet-distributed v1.1.0/go.mod h1:8r06Vpg/315/7Hl9CXq0ShQP8/cgUrBGzKKo6ywA4yQ= github.com/wealdtech/go-eth2-wallet-distributed v1.1.1 h1:KSaNQbtj5XXjttTVHe1oy+LgvHmi4NHNfLl+jaTM8fU= github.com/wealdtech/go-eth2-wallet-distributed v1.1.1/go.mod h1:Ik8JPsQQiMengG+dVUaLbFmGug1z9UOWqBDHkF1tGro= +github.com/wealdtech/go-eth2-wallet-distributed v1.1.2 h1:ABE1tyxGfXAPPphQ32dval7+9aP61BsIdtvuOJr3azY= +github.com/wealdtech/go-eth2-wallet-distributed v1.1.2/go.mod h1:BRl33Vt9urhVuNHGiBfrf0gRs+U+gKSWCV2kmzD5xTw= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.0.0 h1:IcpS4VpXhYz+TVupB5n6C6IQzaKwG+Rc8nvgCa/da4c= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.0.0/go.mod h1:X8WRO5hEwbjx8ZOqoRmtS1ngyflKs25GkP7qGv7yOqE= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.0 h1:CWb82xeNaZQt1Z829RyDALUy7UZbc6VOfTS+82jRdEQ= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.0/go.mod h1:JelKMM10UzDJNXdIcojMj6SCIsHC8NYn4c1S2FFk7OQ= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.1 h1:PYwMOCt92iWEHXdnsBaAk1/xygPfuBMkrXEgO8WtFdw= github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.1/go.mod h1:JelKMM10UzDJNXdIcojMj6SCIsHC8NYn4c1S2FFk7OQ= +github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.2 h1:JRZGHJWTX9iEYNg1jKSuO5WBrLVwMLExkJg04esRgss= +github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.2/go.mod h1:q+Ng4rNBsD7nMk6s07BpAa2V6Se1aH1dua2jk5orjc0= +github.com/wealdtech/go-eth2-wallet-encryptor-unencrypted v1.0.1/go.mod h1:49K88T/4LNQpB8ghVcjTKeRRi/bZHeYjN8Ef5S23yps= github.com/wealdtech/go-eth2-wallet-hd/v2 v2.1.3/go.mod h1:STigKib4ZSefVvJjx88V2QpUGaoyUE1TiupcpsHpvKE= github.com/wealdtech/go-eth2-wallet-hd/v2 v2.2.0 h1:L+yrAn8TC9DQUw+S7moOJxQTp2jrHCoAZLpI747Nx2g= github.com/wealdtech/go-eth2-wallet-hd/v2 v2.2.0/go.mod h1:lhSwtkIO/Pfg5kz8k50yrDgj7ZQaElCPsXnixlrQn/I= @@ -443,6 +677,8 @@ github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.0 h1:OhJm7hn6vlO+dazs5S1EBrZu/ZVQ github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.0/go.mod h1:LfgcOnQeBcqBEoHd4VNqwZhwqzz0Xh1DqnDmjHWONGs= github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.1 h1:QoIyyVQ/vaztkeG88L1vOZKkKMM43Wo8hutH+qn8jA4= github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.1/go.mod h1:smW8Ca0x7JO41urG0sgrlJALb1mGTSagnqaapMWiHfk= +github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.2 h1:3EYbuUrs4cCId+WxFAtx+H/uQXRRlBLzosMRSijpwps= +github.com/wealdtech/go-eth2-wallet-hd/v2 v2.5.2/go.mod h1:hmDme779S5sqxN+W+zmHpS0K8n13fGekHM3gUUB1Ip0= github.com/wealdtech/go-eth2-wallet-nd/v2 v2.1.2/go.mod h1:IssxoHII0ewO1VysMfCmdJP1D00tRhRhXIhhaEXIOVE= github.com/wealdtech/go-eth2-wallet-nd/v2 v2.2.0 h1:h4eePfG0ANOJYMonmIYOvxJ9uLmBEX4APb2O8Vhtv6k= github.com/wealdtech/go-eth2-wallet-nd/v2 v2.2.0/go.mod h1:Un2EtseZWSObmTBjgkt7Qz2am54S/0115jrF83lto1U= @@ -450,23 +686,31 @@ github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.0 h1:L1aPK9nc+8Ctcw+8I05vM6408weF github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.0/go.mod h1:e2q2uuEdq5+B3GE7jk+Mi9oz9V5nPPKXcXRg1XYavsU= github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.1 h1:inSu0xN3LQN9/nEXTri5IbGLfhsvHwyrXiCI3rAHTzc= github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.1/go.mod h1:72HjvN+bANNgv/YCZ4Rjwgn6wesg24aHSQlHzrbPFWo= +github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.2 h1:NwJV/Ll90WhqxhCcYCdHYWIURGXDt/GRPNFOvu4kzbg= +github.com/wealdtech/go-eth2-wallet-nd/v2 v2.3.2/go.mod h1:WyFAmQHBIUN4hd9hAZQ9Py+N7c+mmlpDSTgiNxvICCM= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.15.2 h1:Z4Pw7/Mlp6jJLoJnhgov8M1011HP/Pb3YYqcdYGCy6Q= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.15.2/go.mod h1:GSMbVCewjbxRrw32m6YCd9DOzCRjAXB3qUOQnr58JEs= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.0 h1:sWuSrAKdWSphiQCVcThozaFgTrwemXNXDI5CnFcP02s= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.0/go.mod h1:FvjUHDbBuZrytZGOfhLWgtBoxtrWhvkD47ABrUXvHs4= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.1 h1:l9YV6OBqcxp5fjscK63lzuCUIye8ANACjJdpm5ULGS8= github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.1/go.mod h1:Zxhj/4i8nRpk4LTTqFKbfI2KyvO3uqLMerNXqKZKDK0= +github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.13 h1:zVV0kL6TZ1fW/Od9BW9e7W5UJB78gNbcbRQK+HeJOL8= +github.com/wealdtech/go-eth2-wallet-store-filesystem v1.16.13/go.mod h1:x6sKafiDSvsUeiYZq7TE/ZWIWeAToXLIqgb7KCehgjU= github.com/wealdtech/go-eth2-wallet-store-s3 v1.7.2 h1:a7GWfFd139CODvvkuTbRIuRwAAjb55sFDGRh177KXGk= github.com/wealdtech/go-eth2-wallet-store-s3 v1.7.2/go.mod h1:VWvXScZKUWHbhQpadLX8Yj+mc8U/i4zGthQJee+o3xg= github.com/wealdtech/go-eth2-wallet-store-s3 v1.8.0 h1:+q7p58NvOEfEDw8NgEoNaSG/s1eFHpyg91NEobA6RF0= github.com/wealdtech/go-eth2-wallet-store-s3 v1.8.0/go.mod h1:OxYD+d79StAOHigNaI5bWuvjhanEyrD4MqTj8hIvt2Y= github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.0 h1:O5211UskLbK1WDecTXwugUlINDBQ26MqtiFn6u66fmA= github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.0/go.mod h1:dcQPLsRRYDiMV0DFYzTX6HRpP9WP+gWreAX5SLBOJ0I= +github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.1 h1:YGw5YanOepPGalSyvDKwCEdwvAmG9E3pwo7v6jR/7IM= +github.com/wealdtech/go-eth2-wallet-store-s3 v1.9.1/go.mod h1:FR+mhCaoZN4d+EEBSV2QT2cO4szdKvDLTHRygMrH6fk= github.com/wealdtech/go-eth2-wallet-store-scratch v1.4.2 h1:GvG3ZuzxbqFjGUaGoa8Tz7XbPlDA33G6nHQbSZInC3g= github.com/wealdtech/go-eth2-wallet-store-scratch v1.4.2/go.mod h1:+TbqLmJuT98PWi/xW1bp5nwZbKz+SIJYVh/+NUkmnb4= github.com/wealdtech/go-eth2-wallet-store-scratch v1.5.0/go.mod h1:RMIIV5/N8TgukTVzyumQd7AplpC440ZXDSk8VffeEwQ= github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.0 h1:41H6hnVsI/csBx20UHpI2pY922N7Vhcro35DFS+slj0= github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.0/go.mod h1:XtXHbl4OV/XenQsvGmXbh+bVXaGS788oa30DB7kDInA= +github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.1 h1:vv9lR8K76FUSNbzUU25MN4HNhZIBBI1kJBNfHq2WjRY= +github.com/wealdtech/go-eth2-wallet-store-scratch v1.6.1/go.mod h1:qnI6/VRpFyKGV+DhzdC1zmx2sA7mRRanCFlk4RYzoYs= github.com/wealdtech/go-eth2-wallet-types/v2 v2.2.0 h1:SfoBlW2LYjW05uHhnTZaezX37gbRsp+VYtxWT6SeAME= github.com/wealdtech/go-eth2-wallet-types/v2 v2.2.0/go.mod h1:XEvrlKFnHLbg1tj4Dep76XKASeS13TBpvdeXmvLiH+k= github.com/wealdtech/go-eth2-wallet-types/v2 v2.3.0-beta4 h1:VmpgUSr+aUexFmC2AYlQ7zpeAy0w0mcK58ihpDeMCL8= @@ -481,25 +725,49 @@ github.com/wealdtech/go-eth2-wallet-types/v2 v2.7.0 h1:pquFQdIWEiSYrpIpFuvsRuial github.com/wealdtech/go-eth2-wallet-types/v2 v2.7.0/go.mod h1:X9kYUH/E5YMqFMZ4xL6MJanABUkJGaH/yPZRT2o+yYA= github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.0 h1:30sYrHQBchcOv+N2yIB2APnqf1RjwAbgXK+IzmXS6cw= github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.0/go.mod h1:X9kYUH/E5YMqFMZ4xL6MJanABUkJGaH/yPZRT2o+yYA= +github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.1 h1:pcvljXdc/CqXl/JAXXtd6Ey5SqfOq9MvQutvM+5wvHQ= +github.com/wealdtech/go-eth2-wallet-types/v2 v2.8.1/go.mod h1:PWvCKqRknUmOdkXmMLpyW7wBVaAEP5BWSWRph4iWy98= github.com/wealdtech/go-indexer v1.0.0 h1:/S4rfWQbSOnnYmwnvuTVatDibZ8o1s9bmTCHO16XINg= github.com/wealdtech/go-indexer v1.0.0/go.mod h1:u1cjsbsOXsm5jzJDyLmZY7GsrdX8KYXKBXkZcAmk3Zg= +github.com/wealdtech/go-majordomo v1.0.1/go.mod h1:QoT4S1nUQwdQK19+CfepDwV+Yr7cc3dbF+6JFdQnIqY= github.com/wealdtech/go-string2eth v1.1.0 h1:USJQmysUrBYYmZs7d45pMb90hRSyEwizP7lZaOZLDAw= github.com/wealdtech/go-string2eth v1.1.0/go.mod h1:RUzsLjJtbZaJ/3UKn9kY19a/vCCUHtEWoUW3uiK6yGU= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191105034135-c7e5f84aec59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -513,11 +781,19 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rB golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -527,17 +803,26 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -545,75 +830,132 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200528225125-3c3fba18258b/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200927032502-5d4f70055728/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201024042810-be3efd7ff127 h1:pZPp9+iYUqwYKLjht0SDBbRCRK/9gAXDy7pz5fRDpjo= +golang.org/x/net v0.0.0-20201024042810-be3efd7ff127/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200620081246-981b61492c35 h1:wb/9mP8eUAmHfkM8RmpeLq6nUA7c2i5+bQOtcDftjaE= golang.org/x/sys v0.0.0-20200620081246-981b61492c35/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6 h1:X9xIZ1YU8bLZA3l6gqDUHSFiD0GFI9S548h6C8nDtOY= golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed h1:J22ig1FUekjjkmZUM7pTKixYm8DvrYsvrBZdunYeIuQ= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200821140526-fda516888d29 h1:mNuhGagCf3lDDm5C0376C/sxh6V7fy9WbdEu/YDNA04= golang.org/x/sys v0.0.0-20200821140526-fda516888d29/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb h1:HS9IzC4UFbpMBLQUDSQcU+ViVT1vdFCQVjdPVpTlZrs= golang.org/x/sys v0.0.0-20201013132646-2da7054afaeb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc h1:HVFDs9bKvTxP6bh1Rj9MCSo+UmafQtI8ZWDPVwVk9g4= +golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201024232916-9f70ab9862d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1 h1:a/mKvvZr9Jcc8oKfcmgzyp7OwF73JPWsQLvH1z2Kxck= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -632,36 +974,102 @@ golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201017001424-6003fad69a88/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.32.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.33.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200528191852-705c0b31589b/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200620020550-bd6e04640131 h1:IXNofpkLhv80L3TJQvj2YQLnMHZgAktycswvtXwQiRk= google.golang.org/genproto v0.0.0-20200620020550-bd6e04640131/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200710124503-20a17af7bd0e h1:k+p/u26/lVeNEpdxSeUrm7rTvoFckBKaf7gTzgmHyDA= @@ -672,30 +1080,48 @@ google.golang.org/genproto v0.0.0-20200715011427-11fb19a81f2c h1:6DWnZZ6EY/59QRR google.golang.org/genproto v0.0.0-20200715011427-11fb19a81f2c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200722002428-88e341933a54 h1:ASrBgpl9XvkNTP0m39/j18mid7aoF21npu2ioIBxYnY= google.golang.org/genproto v0.0.0-20200722002428-88e341933a54/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200731012542-8145dea6a485/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200814021100-8c09557e8a18 h1:hjnc4GP1IeBnHi+u3sp8be4ELyIHmFSO5p8DUdJUVt4= google.golang.org/genproto v0.0.0-20200814021100-8c09557e8a18/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200815001618-f69a88009b70 h1:wboULUXGF3c5qdUnKp+6gLAccE6PRpa/czkYvQ4UXv8= google.golang.org/genproto v0.0.0-20200815001618-f69a88009b70/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201002142447-3860012362da/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201013134114-7f9ee70cb474 h1:TbNifhX2UFPFG5PL1RUfAajMT29pJ1hq6FME8V8ZdgE= google.golang.org/genproto v0.0.0-20201013134114-7f9ee70cb474/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201022181438-0ff5f38871d5 h1:YejJbGvoWsTXHab4OKNrzk27Dr7s4lPLnewbHue1+gM= +google.golang.org/genproto v0.0.0-20201022181438-0ff5f38871d5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.0 h1:IBKSUNL2uBS2DkJBncPP+TwT0sp9tgA8A75NjHt6umg= google.golang.org/grpc v1.33.0/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.1 h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -714,7 +1140,10 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -726,12 +1155,16 @@ gopkg.in/ini.v1 v1.60.1 h1:P5y5shSkb0CFe44qEeMBgn8JLow09MP17jlJHanke5g= gopkg.in/ini.v1 v1.60.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -740,9 +1173,16 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/signing/signroot.go b/signing/signroot.go index 7c61120..4d830eb 100644 --- a/signing/signroot.go +++ b/signing/signroot.go @@ -44,9 +44,9 @@ func SignRoot(account e2wtypes.Account, root []byte, domain []byte) ([]byte, err // outputIf(debug, fmt.Sprintf("Signing %x (%d)", data, len(data))) if protectingSigner, isProtectingSigner := account.(e2wtypes.AccountProtectingSigner); isProtectingSigner { // Signer takes root and domain. - signature, err = signProtected(protectingSigner, root[:], domain) + signature, err = signProtected(protectingSigner, root, domain) } else if signer, isSigner := account.(e2wtypes.AccountSigner); isSigner { - signature, err = sign(signer, root[:], domain) + signature, err = sign(signer, root, domain) } else { return nil, errors.New("account does not provide signing facility") } diff --git a/testutil/bytes.go b/testutil/bytes.go new file mode 100644 index 0000000..6e81714 --- /dev/null +++ b/testutil/bytes.go @@ -0,0 +1,29 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package testutil + +import ( + "encoding/hex" + "strings" +) + +// HexToBytes converts a hex string to a byte array. +// This should only be used for pre-defined test strings; it will panic if the input is invalid. +func HexToBytes(input string) []byte { + res, err := hex.DecodeString(strings.TrimPrefix(input, "0x")) + if err != nil { + panic(err) + } + return res +} diff --git a/util/bls_test.go b/util/bls_test.go new file mode 100644 index 0000000..c94d513 --- /dev/null +++ b/util/bls_test.go @@ -0,0 +1,55 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/wealdtech/ethdo/util" + e2types "github.com/wealdtech/go-eth2-types/v2" +) + +func TestBLSID(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + in uint64 + strRes string + }{ + { + name: "Zero", + in: 0, + strRes: "0", + }, + { + name: "One", + in: 1, + strRes: "1", + }, + { + name: "High", + in: 0x7fffffff, + strRes: "2147483647", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + blsID := util.BLSID(test.in) + require.Equal(t, test.strRes, blsID.GetDecString()) + }) + } +} diff --git a/util/depositinfo.go b/util/depositinfo.go index 2e654bd..2cd71ee 100644 --- a/util/depositinfo.go +++ b/util/depositinfo.go @@ -75,9 +75,16 @@ type depositInfoCLI struct { } func DepositInfoFromJSON(input []byte) ([]*DepositInfo, error) { + if len(input) == 0 { + return nil, errors.New("no data supplied") + } // Work out the type of data that we're dealing with, and decode it appropriately. depositInfo, err := tryRawTxData(input) if err != nil { + // At this point, ensure we have brackets around the deposit info. + if input[0] != '[' { + input = []byte(fmt.Sprintf("[%s]", string(input))) + } depositInfo, err = tryV3DepositInfoFromJSON(input) if err != nil { depositInfo, err = tryV1DepositInfoFromJSON(input) diff --git a/util/depositinfo_internal_test.go b/util/depositinfo_internal_test.go new file mode 100644 index 0000000..d8f5364 --- /dev/null +++ b/util/depositinfo_internal_test.go @@ -0,0 +1,255 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util + +import ( + "testing" + + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" +) + +func TestRawDepositInfo(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input []byte + err string + }{ + { + name: "Nil", + err: "invalid transaction length", + }, + { + name: "Invalid", + input: []byte("invalid"), + err: "public key invalid", + }, + { + name: "IncorrectSignature", + input: []byte(`0x02895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001209e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a35540000000000000000000000000000000000000000000000000000000000000030a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b0000000000000000000000000000000000000000000000000000000000000060b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2`), + err: "invalid function signature", + }, + { + name: "IncorrectSize", + input: []byte(`0x22895118`), + err: "invalid transaction length", + }, + { + name: "Good", + input: []byte(`0x22895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001209e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a35540000000000000000000000000000000000000000000000000000000000000030a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b0000000000000000000000000000000000000000000000000000000000000060b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2`), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + depositInfo, err := tryRawTxData(test.input) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, depositInfo) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} + +func TestCLIDepositInfo(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input []byte + err string + }{ + { + name: "Nil", + err: "unexpected end of JSON input", + }, + { + name: "Invalid", + input: []byte("invalid"), + err: "invalid character 'i' looking for beginning of value", + }, + { + name: "PubKeyInvalid", + input: []byte(`[{"pubkey":"invalid","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + err: "public key invalid", + }, + { + name: "WithdrawalCredentialsInvalid", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"invalid","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + err: "withdrawal credentials invalid", + }, + { + name: "SignatureInvalid", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"invalid","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + err: "signature invalid", + }, + { + name: "DepositMessageRootInvalid", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"invalid","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + err: "deposit message root invalid", + }, + { + name: "DepositDataRootInvalid", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"invalid","fork_version":"01020304"}]`), + err: "deposit data root invalid", + }, + { + name: "ForkVersionInvalid", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"invalid"}]`), + err: "fork version invalid", + }, + { + name: "Good", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + depositInfo, err := tryCLIDepositInfoFromJSON(test.input) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, depositInfo) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} + +func TestV3DepositInfo(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input []byte + err string + }{ + { + name: "Nil", + err: "unexpected end of JSON input", + }, + { + name: "Invalid", + input: []byte("invalid"), + err: "invalid character 'i' looking for beginning of value", + }, + { + name: "PubKeyInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"invalid","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"0x01020304","version":3}]`), + err: "public key invalid", + }, + { + name: "WithdrawalCredentialsInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"invalid","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"0x01020304","version":3}]`), + err: "withdrawal credentials invalid", + }, + { + name: "SignatureInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"invalid","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"0x01020304","version":3}]`), + err: "signature invalid", + }, + { + name: "DepositMessageRootInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"invalid","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"0x01020304","version":3}]`), + err: "deposit message root invalid", + }, + { + name: "DepositDataRootInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"invalid","fork_version":"0x01020304","version":3}]`), + err: "deposit data root invalid", + }, + { + name: "ForkVersionInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"invalid","version":3}]`), + err: "fork version invalid", + }, + { + name: "Good", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","value":32000000000,"signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"0x139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"0x01020304","version":3}]`), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + depositInfo, err := tryV3DepositInfoFromJSON(test.input) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, depositInfo) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} + +func TestV1DepositInfo(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input []byte + err string + }{ + { + name: "Nil", + err: "unexpected end of JSON input", + }, + { + name: "Invalid", + input: []byte("invalid"), + err: "invalid character 'i' looking for beginning of value", + }, + { + name: "PubKeyInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"invalid","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","value":32000000000,"deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","version":2}]`), + err: "public key invalid", + }, + { + name: "WithdrawalCredentialsInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"invalid","signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","value":32000000000,"deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","version":2}]`), + err: "withdrawal credentials invalid", + }, + { + name: "SignatureInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","signature":"invalid","value":32000000000,"deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","version":2}]`), + err: "signature invalid", + }, + { + name: "DepositDataRootInvalid", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","value":32000000000,"deposit_data_root":"invalid","version":2}]`), + err: "deposit data root invalid", + }, + { + name: "Good", + input: []byte(`[{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","value":32000000000,"deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","version":2}]`), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + depositInfo, err := tryV1DepositInfoFromJSON(test.input) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, depositInfo) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} diff --git a/util/depositinfo_test.go b/util/depositinfo_test.go new file mode 100644 index 0000000..6b195f2 --- /dev/null +++ b/util/depositinfo_test.go @@ -0,0 +1,76 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/wealdtech/ethdo/util" + e2types "github.com/wealdtech/go-eth2-types/v2" +) + +func TestDepositInfo(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input []byte + err string + }{ + { + name: "Nil", + err: "no data supplied", + }, + { + name: "Invalid", + input: []byte("bad"), + err: "unknown deposit data format", + }, + { + name: "Incorrect", + input: []byte("{}"), + err: "no public key for deposit 0", + }, + { + name: "Empty", + input: []byte("[]"), + err: "no deposits supplied", + }, + { + name: "V2", + input: []byte(`{"name":"Deposit for interop/00000","account":"interop/00000","pubkey":"0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"0x00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","signature":"0xb7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","value":32000000000,"deposit_data_root":"0x9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","version":2}`), + }, + { + name: "Launchpad", + input: []byte(`[{"pubkey":"a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c","withdrawal_credentials":"00fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b","amount":32000000000,"signature":"b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2","deposit_message_root":"139b510ea7f2788ab82da1f427d6cbe1db147c15a053db738ad5500cd83754a6","deposit_data_root":"9e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a3554","fork_version":"01020304"}]`), + }, + { + name: "Raw", + input: []byte(`0x22895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001209e51b386f4271c18149dd0f73297a26a4a8c15c3622c44af79c92446f44a35540000000000000000000000000000000000000000000000000000000000000030a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000fad2a6bfb0e7f1f0f45460944fbd8dfa7f37da06a4d13b3983cc90bb46963b0000000000000000000000000000000000000000000000000000000000000060b7a757a4c506ac6ac5f2d23e065de7d00dc9f5a6a3f9610a8b60b65f166379139ae382c91ecbbf5c9fabc34b1cd2cf8f0211488d50d8754716d8e72e17c1a00b5d9b37cc73767946790ebe66cf9669abfc5c25c67e1e2d1c2e11429d149c25a2`), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + depositInfo, err := util.DepositInfoFromJSON(test.input) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, depositInfo) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} diff --git a/util/logging_internal_test.go b/util/logging_internal_test.go new file mode 100644 index 0000000..e51d422 --- /dev/null +++ b/util/logging_internal_test.go @@ -0,0 +1,80 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util + +import ( + "testing" + + "github.com/rs/zerolog" + "github.com/stretchr/testify/require" + e2types "github.com/wealdtech/go-eth2-types/v2" +) + +func TestLogLevel(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + input string + level zerolog.Level + }{ + { + name: "Unknown", + input: "unknown", + level: zerolog.DebugLevel, + }, + { + name: "Disabled", + input: "None", + level: zerolog.Disabled, + }, + { + name: "Trace", + input: "Trace", + level: zerolog.TraceLevel, + }, + { + name: "Debug", + input: "Debug", + level: zerolog.DebugLevel, + }, + { + name: "Info", + input: "Info", + level: zerolog.InfoLevel, + }, + { + name: "Warn", + input: "Warn", + level: zerolog.WarnLevel, + }, + { + name: "Error", + input: "Error", + level: zerolog.ErrorLevel, + }, + { + name: "Fatal", + input: "Fatal", + level: zerolog.FatalLevel, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + level := logLevel(test.input) + require.Equal(t, test.level, level) + }) + } +} diff --git a/util/scratchaccount.go b/util/scratchaccount.go index aa22521..dee78c8 100644 --- a/util/scratchaccount.go +++ b/util/scratchaccount.go @@ -32,9 +32,8 @@ type ScratchAccount struct { func NewScratchAccount(privKey []byte, pubKey []byte) (*ScratchAccount, error) { if len(privKey) > 0 { return newScratchAccountFromPrivKey(privKey) - } else { - return newScratchAccountFromPubKey(pubKey) } + return newScratchAccountFromPubKey(pubKey) } func newScratchAccountFromPrivKey(privKey []byte) (*ScratchAccount, error) { diff --git a/util/scratchaccount_test.go b/util/scratchaccount_test.go new file mode 100644 index 0000000..e6b1c96 --- /dev/null +++ b/util/scratchaccount_test.go @@ -0,0 +1,136 @@ +// Copyright © 2020 Weald Technology Trading +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "github.com/wealdtech/ethdo/testutil" + "github.com/wealdtech/ethdo/util" + e2types "github.com/wealdtech/go-eth2-types/v2" +) + +func TestScratchAccountFromPrivKey(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + key []byte + err string + sigErr string + signature []byte + }{ + { + name: "Nil", + err: "public key must be 48 bytes", + }, + { + name: "KeyShort", + key: testutil.HexToBytes("0x295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + err: "private key must be 32 bytes", + }, + { + name: "KeyLong", + key: testutil.HexToBytes("0x2525295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + err: "private key must be 32 bytes", + }, + { + name: "Good", + key: testutil.HexToBytes("0x25295f0d1d592a90b333e26e85149708208e9f8e8bc18f6c77bd62f8ad7a6866"), + signature: testutil.HexToBytes("0x9004c971416fc1e48c0443d5650c4e998ab33b456223a1c3cd24da90e06174c0d66b80f492bc7b24d656a3c2d3051238020a3a4c0fd1fe98d61b97e9e5aa680841c965e8578425df4ce0b0a21270e330437931eadae1a9109336d415aeb420bb"), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + account, err := util.NewScratchAccount(test.key, nil) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, account.ID()) + require.Equal(t, "scratch", account.Name()) + require.Equal(t, "", account.Path()) + require.NotNil(t, account.PublicKey()) + require.False(t, account.IsUnlocked()) + _, err := account.Sign(testutil.HexToBytes("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")) + require.EqualError(t, err, "locked") + require.NoError(t, account.Unlock(nil)) + require.True(t, account.IsUnlocked()) + signature, err := account.Sign(testutil.HexToBytes("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")) + if test.sigErr == "" { + require.NoError(t, err) + require.Equal(t, test.signature, signature.Marshal()) + } else { + require.EqualError(t, err, test.sigErr) + } + account.Lock() + require.False(t, account.IsUnlocked()) + } else { + require.EqualError(t, err, test.err) + } + }) + } +} + +func TestScratchAccountFromPublicKey(t *testing.T) { + require.NoError(t, e2types.InitBLS()) + + tests := []struct { + name string + pubKey []byte + err string + }{ + { + name: "Nil", + err: "public key must be 48 bytes", + }, + { + name: "KeyShort", + pubKey: testutil.HexToBytes("0x9a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"), + err: "public key must be 48 bytes", + }, + { + name: "KeyLong", + pubKey: testutil.HexToBytes("0xa9a99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"), + err: "public key must be 48 bytes", + }, + { + name: "Good", + pubKey: testutil.HexToBytes("0xa99a76ed7796f7be22d5b7e85deeb7c5677e88e511e0b337618f8c4eb61349b4bf2d153f649f7b53359fe8b94a38e44c"), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + account, err := util.NewScratchAccount(nil, test.pubKey) + if test.err == "" { + require.NoError(t, err) + require.NotNil(t, account.ID()) + require.Equal(t, "scratch", account.Name()) + require.Equal(t, "", account.Path()) + require.False(t, account.IsUnlocked()) + _, err := account.Sign(testutil.HexToBytes("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")) + require.EqualError(t, err, "locked") + require.NoError(t, account.Unlock(nil)) + require.True(t, account.IsUnlocked()) + _, err = account.Sign(testutil.HexToBytes("0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")) + require.EqualError(t, err, "no private key") + account.Lock() + require.False(t, account.IsUnlocked()) + } else { + require.EqualError(t, err, test.err) + } + }) + } +}