github.com/MetalBlockchain/subnet-evm@v0.4.9/accounts/errors.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc.
     2  //
     3  // This file is a derived work, based on the go-ethereum library whose original
     4  // notices appear below.
     5  //
     6  // It is distributed under a license compatible with the licensing terms of the
     7  // original code from which it is derived.
     8  //
     9  // Much love to the original authors for their work.
    10  // **********
    11  // Copyright 2017 The go-ethereum Authors
    12  // This file is part of the go-ethereum library.
    13  //
    14  // The go-ethereum library is free software: you can redistribute it and/or modify
    15  // it under the terms of the GNU Lesser General Public License as published by
    16  // the Free Software Foundation, either version 3 of the License, or
    17  // (at your option) any later version.
    18  //
    19  // The go-ethereum library is distributed in the hope that it will be useful,
    20  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    21  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    22  // GNU Lesser General Public License for more details.
    23  //
    24  // You should have received a copy of the GNU Lesser General Public License
    25  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    26  
    27  package accounts
    28  
    29  import (
    30  	"errors"
    31  	"fmt"
    32  )
    33  
    34  // ErrUnknownAccount is returned for any requested operation for which no backend
    35  // provides the specified account.
    36  var ErrUnknownAccount = errors.New("unknown account")
    37  
    38  // ErrUnknownWallet is returned for any requested operation for which no backend
    39  // provides the specified wallet.
    40  var ErrUnknownWallet = errors.New("unknown wallet")
    41  
    42  // ErrNotSupported is returned when an operation is requested from an account
    43  // backend that it does not support.
    44  var ErrNotSupported = errors.New("not supported")
    45  
    46  // ErrInvalidPassphrase is returned when a decryption operation receives a bad
    47  // passphrase.
    48  var ErrInvalidPassphrase = errors.New("invalid password")
    49  
    50  // ErrWalletAlreadyOpen is returned if a wallet is attempted to be opened the
    51  // second time.
    52  var ErrWalletAlreadyOpen = errors.New("wallet already open")
    53  
    54  // ErrWalletClosed is returned if a wallet is offline.
    55  var ErrWalletClosed = errors.New("wallet closed")
    56  
    57  // AuthNeededError is returned by backends for signing requests where the user
    58  // is required to provide further authentication before signing can succeed.
    59  //
    60  // This usually means either that a password needs to be supplied, or perhaps a
    61  // one time PIN code displayed by some hardware device.
    62  type AuthNeededError struct {
    63  	Needed string // Extra authentication the user needs to provide
    64  }
    65  
    66  // NewAuthNeededError creates a new authentication error with the extra details
    67  // about the needed fields set.
    68  func NewAuthNeededError(needed string) error {
    69  	return &AuthNeededError{
    70  		Needed: needed,
    71  	}
    72  }
    73  
    74  // Error implements the standard error interface.
    75  func (err *AuthNeededError) Error() string {
    76  	return fmt.Sprintf("authentication needed: %s", err.Needed)
    77  }