laconicd-deprecated/rpc/personal_api.go
Austin Abell 6c72a79035
RPC unlock Ethermint key and eth_sign (#99)
* Set up personal account api for personal sign

* Added unlocking key functionality and attach to eth rpc

* Implemented eth_sign

* Transform V in sig based on yp and fix bug

* Fix lint issue

* Remove escape character from comment

* Switch error handling to panic on invalid unlocked key
2019-09-18 14:45:21 -04:00

35 lines
1.1 KiB
Go

package rpc
import (
"context"
sdkcontext "github.com/cosmos/cosmos-sdk/client/context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
// PersonalEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.
type PersonalEthAPI struct {
cliCtx sdkcontext.CLIContext
}
// NewPersonalEthAPI creates an instance of the public ETH Web3 API.
func NewPersonalEthAPI(cliCtx sdkcontext.CLIContext) *PersonalEthAPI {
return &PersonalEthAPI{
cliCtx: cliCtx,
}
}
// Sign calculates an Ethereum ECDSA signature for:
// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))
//
// Note, the produced signature conforms to the secp256k1 curve R, S and V values,
// where the V value will be 27 or 28 for legacy reasons.
//
// The key used to calculate the signature is decrypted with the given password.
//
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
func (e *PersonalEthAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error) {
return nil, nil
}