frontend.go 1.0 KB

12345678910111213141516171819202122232425262728
  1. package xeth
  2. // Frontend should be implemented by users of XEth. Its methods are
  3. // called whenever XEth makes a decision that requires user input.
  4. type Frontend interface {
  5. // UnlockAccount is called when a transaction needs to be signed
  6. // but the key corresponding to the transaction's sender is
  7. // locked.
  8. //
  9. // It should unlock the account with the given address and return
  10. // true if unlocking succeeded.
  11. UnlockAccount(address []byte) bool
  12. // This is called for all transactions inititated through
  13. // Transact. It should prompt the user to confirm the transaction
  14. // and return true if the transaction was acknowledged.
  15. //
  16. // ConfirmTransaction is not used for Call transactions
  17. // because they cannot change any state.
  18. ConfirmTransaction(tx string) bool
  19. }
  20. // dummyFrontend is a non-interactive frontend that allows all
  21. // transactions but cannot not unlock any keys.
  22. type dummyFrontend struct{}
  23. func (dummyFrontend) UnlockAccount([]byte) bool { return false }
  24. func (dummyFrontend) ConfirmTransaction(string) bool { return true }