mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
signer: remove staticcheck warnings
This commit is contained in:
parent
dbef66a6b8
commit
e9317828d2
8 changed files with 11 additions and 39 deletions
|
|
@ -269,7 +269,7 @@ type (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrRequestDenied = errors.New("Request denied")
|
var ErrRequestDenied = errors.New("request denied")
|
||||||
|
|
||||||
// NewSignerAPI creates a new API that can be used for Account management.
|
// NewSignerAPI creates a new API that can be used for Account management.
|
||||||
// ksLocation specifies the directory where to store the password protected private
|
// ksLocation specifies the directory where to store the password protected private
|
||||||
|
|
@ -552,6 +552,9 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth
|
||||||
}
|
}
|
||||||
|
|
||||||
rlpdata, err := rlp.EncodeToBytes(signedTx)
|
rlpdata, err := rlp.EncodeToBytes(signedTx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
response := ethapi.SignTransactionResult{Raw: rlpdata, Tx: signedTx}
|
response := ethapi.SignTransactionResult{Raw: rlpdata, Tx: signedTx}
|
||||||
|
|
||||||
// Finally, send the signed tx to the UI
|
// Finally, send the signed tx to the UI
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ func (ui *headlessUi) ApproveTx(request *core.SignTxRequest) (core.SignTxRespons
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *headlessUi) ApproveSignData(request *core.SignDataRequest) (core.SignDataResponse, error) {
|
func (ui *headlessUi) ApproveSignData(request *core.SignDataRequest) (core.SignDataResponse, error) {
|
||||||
approved := "Y" == <-ui.approveCh
|
approved := (<-ui.approveCh == "Y")
|
||||||
return core.SignDataResponse{approved}, nil
|
return core.SignDataResponse{approved}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ func (ui *headlessUi) ApproveListing(request *core.ListRequest) (core.ListRespon
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *headlessUi) ApproveNewAccount(request *core.NewAccountRequest) (core.NewAccountResponse, error) {
|
func (ui *headlessUi) ApproveNewAccount(request *core.NewAccountRequest) (core.NewAccountResponse, error) {
|
||||||
if "Y" == <-ui.approveCh {
|
if <-ui.approveCh == "Y" {
|
||||||
return core.NewAccountResponse{true}, nil
|
return core.NewAccountResponse{true}, nil
|
||||||
}
|
}
|
||||||
return core.NewAccountResponse{false}, nil
|
return core.NewAccountResponse{false}, nil
|
||||||
|
|
|
||||||
|
|
@ -58,34 +58,6 @@ func (ui *CommandlineUI) readString() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// readPassword reads a single line from stdin, trimming it from the trailing new
|
|
||||||
// line and returns it. The input will not be echoed.
|
|
||||||
func (ui *CommandlineUI) readPassword() string {
|
|
||||||
fmt.Printf("Enter password to approve:\n")
|
|
||||||
fmt.Printf("> ")
|
|
||||||
|
|
||||||
text, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
|
||||||
if err != nil {
|
|
||||||
log.Crit("Failed to read password", "err", err)
|
|
||||||
}
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Println("-----------------------")
|
|
||||||
return string(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
// readPassword reads a single line from stdin, trimming it from the trailing new
|
|
||||||
// line and returns it. The input will not be echoed.
|
|
||||||
func (ui *CommandlineUI) readPasswordText(inputstring string) string {
|
|
||||||
fmt.Printf("Enter %s:\n", inputstring)
|
|
||||||
fmt.Printf("> ")
|
|
||||||
text, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
|
||||||
if err != nil {
|
|
||||||
log.Crit("Failed to read password", "err", err)
|
|
||||||
}
|
|
||||||
fmt.Println("-----------------------")
|
|
||||||
return string(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ui *CommandlineUI) OnInputRequired(info UserInputRequest) (UserInputResponse, error) {
|
func (ui *CommandlineUI) OnInputRequired(info UserInputRequest) (UserInputResponse, error) {
|
||||||
|
|
||||||
fmt.Printf("## %s\n\n%s\n", info.Title, info.Prompt)
|
fmt.Printf("## %s\n\n%s\n", info.Title, info.Prompt)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
|
@ -27,7 +26,6 @@ import (
|
||||||
|
|
||||||
type StdIOUI struct {
|
type StdIOUI struct {
|
||||||
client rpc.Client
|
client rpc.Client
|
||||||
mu sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStdIOUI() *StdIOUI {
|
func NewStdIOUI() *StdIOUI {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ func (v *ValidationMessages) getWarnings() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(messages) > 0 {
|
if len(messages) > 0 {
|
||||||
return fmt.Errorf("Validation failed: %s", strings.Join(messages, ","))
|
return fmt.Errorf("validation failed: %s", strings.Join(messages, ","))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ func (s *UIServerAPI) Export(ctx context.Context, addr common.Address) (json.Raw
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if wallet.URL().Scheme != keystore.KeyStoreScheme {
|
if wallet.URL().Scheme != keystore.KeyStoreScheme {
|
||||||
return nil, fmt.Errorf("Account is not a keystore-account")
|
return nil, fmt.Errorf("account is not a keystore-account")
|
||||||
}
|
}
|
||||||
return ioutil.ReadFile(wallet.URL().Path)
|
return ioutil.ReadFile(wallet.URL().Path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ func (r *rulesetUI) checkApproval(jsfunc string, jsarg []byte, err error) (bool,
|
||||||
log.Info("Op rejected")
|
log.Info("Op rejected")
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, fmt.Errorf("Unknown response")
|
return false, fmt.Errorf("unknown response")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *rulesetUI) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {
|
func (r *rulesetUI) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ type Storage interface {
|
||||||
// EphemeralStorage is an in-memory storage that does
|
// EphemeralStorage is an in-memory storage that does
|
||||||
// not persist values to disk. Mainly used for testing
|
// not persist values to disk. Mainly used for testing
|
||||||
type EphemeralStorage struct {
|
type EphemeralStorage struct {
|
||||||
data map[string]string
|
data map[string]string
|
||||||
namespace string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put stores a value by key. 0-length keys results in noop.
|
// Put stores a value by key. 0-length keys results in noop.
|
||||||
|
|
@ -83,5 +82,5 @@ type NoStorage struct{}
|
||||||
func (s *NoStorage) Put(key, value string) {}
|
func (s *NoStorage) Put(key, value string) {}
|
||||||
func (s *NoStorage) Del(key string) {}
|
func (s *NoStorage) Del(key string) {}
|
||||||
func (s *NoStorage) Get(key string) (string, error) {
|
func (s *NoStorage) Get(key string) (string, error) {
|
||||||
return "", errors.New("I forgot")
|
return "", errors.New("missing key, I probably forgot")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue