github.com/ConsenSys/Quorum@v20.10.0+incompatible/signer/core/plugin_api.go (about) 1 package core 2 3 import ( 4 "context" 5 "errors" 6 7 "github.com/ethereum/go-ethereum/accounts" 8 "github.com/ethereum/go-ethereum/plugin/account" 9 ) 10 11 // <Quorum> 12 13 type approvalCreatorService struct { 14 creator account.CreatorService 15 ui UIClientAPI 16 } 17 18 // NewApprovalCreatorService adds a wrapper to the provided creator service which requires UI approval before executing the service's methods 19 func NewApprovalCreatorService(creator account.CreatorService, ui UIClientAPI) account.CreatorService { 20 return &approvalCreatorService{ 21 creator: creator, 22 ui: ui, 23 } 24 } 25 26 func (s *approvalCreatorService) NewAccount(ctx context.Context, newAccountConfig interface{}) (accounts.Account, error) { 27 if resp, err := s.ui.ApproveNewAccount(&NewAccountRequest{MetadataFromContext(ctx)}); err != nil { 28 return accounts.Account{}, err 29 } else if !resp.Approved { 30 return accounts.Account{}, ErrRequestDenied 31 } 32 33 return s.creator.NewAccount(ctx, newAccountConfig) 34 } 35 36 // ImportRawKey is unsupported in the clef external API for parity with the available keystore account functionality 37 func (s *approvalCreatorService) ImportRawKey(_ context.Context, _ string, _ interface{}) (accounts.Account, error) { 38 return accounts.Account{}, errors.New("not supported") 39 }