mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 21:17:16 +00:00
ec3db0f56c
* signer: introduce external signer command * cmd/signer, rpc: Implement new signer. Add info about remote user to Context * signer: refactored request/response, made use of urfave.cli * cmd/signer: Use common flags * cmd/signer: methods to validate calldata against abi * cmd/signer: work on abi parser * signer: add mutex around UI * cmd/signer: add json 4byte directory, remove passwords from api * cmd/signer: minor changes * cmd/signer: Use ErrRequestDenied, enable lightkdf * cmd/signer: implement tests * cmd/signer: made possible for UI to modify tx parameters * cmd/signer: refactors, removed channels in ui comms, added UI-api via stdin/out * cmd/signer: Made lowercase json-definitions, added UI-signer test functionality * cmd/signer: update documentation * cmd/signer: fix bugs, improve abi detection, abi argument display * cmd/signer: minor change in json format * cmd/signer: rework json communication * cmd/signer: implement mixcase addresses in API, fix json id bug * cmd/signer: rename fromaccount, update pythonpoc with new json encoding format * cmd/signer: make use of new abi interface * signer: documentation * signer/main: remove redundant option * signer: implement audit logging * signer: create package 'signer', minor changes * common: add 0x-prefix to mixcaseaddress in json marshalling + validation * signer, rules, storage: implement rules + ephemeral storage for signer rules * signer: implement OnApprovedTx, change signing response (API BREAKAGE) * signer: refactoring + documentation * signer/rules: implement dispatching to next handler * signer: docs * signer/rules: hide json-conversion from users, ensure context is cleaned * signer: docs * signer: implement validation rules, change signature of call_info * signer: fix log flaw with string pointer * signer: implement custom 4byte databsae that saves submitted signatures * signer/storage: implement aes-gcm-backed credential storage * accounts: implement json unmarshalling of url * signer: fix listresponse, fix gas->uint64 * node: make http/ipc start methods public * signer: add ipc capability+review concerns * accounts: correct docstring * signer: address review concerns * rpc: go fmt -s * signer: review concerns+ baptize Clef * signer,node: move Start-functions to separate file * signer: formatting
114 lines
3.3 KiB
Go
114 lines
3.3 KiB
Go
// Copyright 2018 The go-ethereum Authors
|
|
// This file is part of go-ethereum.
|
|
//
|
|
// go-ethereum is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// go-ethereum is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
package core
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
|
"github.com/ethereum/go-ethereum/log"
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
)
|
|
|
|
type StdIOUI struct {
|
|
client rpc.Client
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func NewStdIOUI() *StdIOUI {
|
|
log.Info("NewStdIOUI")
|
|
client, err := rpc.DialContext(context.Background(), "stdio://")
|
|
if err != nil {
|
|
log.Crit("Could not create stdio client", "err", err)
|
|
}
|
|
return &StdIOUI{client: *client}
|
|
}
|
|
|
|
// dispatch sends a request over the stdio
|
|
func (ui *StdIOUI) dispatch(serviceMethod string, args interface{}, reply interface{}) error {
|
|
err := ui.client.Call(&reply, serviceMethod, args)
|
|
if err != nil {
|
|
log.Info("Error", "exc", err.Error())
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveTx(request *SignTxRequest) (SignTxResponse, error) {
|
|
var result SignTxResponse
|
|
err := ui.dispatch("ApproveTx", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveSignData(request *SignDataRequest) (SignDataResponse, error) {
|
|
var result SignDataResponse
|
|
err := ui.dispatch("ApproveSignData", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveExport(request *ExportRequest) (ExportResponse, error) {
|
|
var result ExportResponse
|
|
err := ui.dispatch("ApproveExport", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveImport(request *ImportRequest) (ImportResponse, error) {
|
|
var result ImportResponse
|
|
err := ui.dispatch("ApproveImport", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveListing(request *ListRequest) (ListResponse, error) {
|
|
var result ListResponse
|
|
err := ui.dispatch("ApproveListing", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ApproveNewAccount(request *NewAccountRequest) (NewAccountResponse, error) {
|
|
var result NewAccountResponse
|
|
err := ui.dispatch("ApproveNewAccount", request, &result)
|
|
return result, err
|
|
}
|
|
|
|
func (ui *StdIOUI) ShowError(message string) {
|
|
err := ui.dispatch("ShowError", &Message{message}, nil)
|
|
if err != nil {
|
|
log.Info("Error calling 'ShowError'", "exc", err.Error(), "msg", message)
|
|
}
|
|
}
|
|
|
|
func (ui *StdIOUI) ShowInfo(message string) {
|
|
err := ui.dispatch("ShowInfo", Message{message}, nil)
|
|
if err != nil {
|
|
log.Info("Error calling 'ShowInfo'", "exc", err.Error(), "msg", message)
|
|
}
|
|
}
|
|
func (ui *StdIOUI) OnApprovedTx(tx ethapi.SignTransactionResult) {
|
|
err := ui.dispatch("OnApprovedTx", tx, nil)
|
|
if err != nil {
|
|
log.Info("Error calling 'OnApprovedTx'", "exc", err.Error(), "tx", tx)
|
|
}
|
|
}
|
|
|
|
func (ui *StdIOUI) OnSignerStartup(info StartupInfo) {
|
|
err := ui.dispatch("OnSignerStartup", info, nil)
|
|
if err != nil {
|
|
log.Info("Error calling 'OnSignerStartup'", "exc", err.Error(), "info", info)
|
|
}
|
|
}
|