2019-09-18 18:45:21 +00:00
|
|
|
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 {
|
2019-09-20 13:30:20 +00:00
|
|
|
cliCtx sdkcontext.CLIContext
|
|
|
|
nonceLock *AddrLocker
|
2019-09-18 18:45:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewPersonalEthAPI creates an instance of the public ETH Web3 API.
|
2019-09-20 13:30:20 +00:00
|
|
|
func NewPersonalEthAPI(cliCtx sdkcontext.CLIContext, nonceLock *AddrLocker) *PersonalEthAPI {
|
2019-09-18 18:45:21 +00:00
|
|
|
return &PersonalEthAPI{
|
2019-09-20 13:30:20 +00:00
|
|
|
cliCtx: cliCtx,
|
|
|
|
nonceLock: nonceLock,
|
2019-09-18 18:45:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|