github.com/immesys/bw2bc@v1.1.0/xeth/frontend.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package xeth
    18  
    19  // Frontend should be implemented by users of XEth. Its methods are
    20  // called whenever XEth makes a decision that requires user input.
    21  type Frontend interface {
    22  	// UnlockAccount is called when a transaction needs to be signed
    23  	// but the key corresponding to the transaction's sender is
    24  	// locked.
    25  	//
    26  	// It should unlock the account with the given address and return
    27  	// true if unlocking succeeded.
    28  	UnlockAccount(address []byte) bool
    29  
    30  	// This is called for all transactions inititated through
    31  	// Transact. It should prompt the user to confirm the transaction
    32  	// and return true if the transaction was acknowledged.
    33  	//
    34  	// ConfirmTransaction is not used for Call transactions
    35  	// because they cannot change any state.
    36  	ConfirmTransaction(tx string) bool
    37  }
    38  
    39  // dummyFrontend is a non-interactive frontend that allows all
    40  // transactions but cannot not unlock any keys.
    41  type dummyFrontend struct{}
    42  
    43  func (dummyFrontend) UnlockAccount([]byte) bool      { return false }
    44  func (dummyFrontend) ConfirmTransaction(string) bool { return true }