|
|
@ -33,6 +33,7 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil" |
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil" |
|
|
|
"github.com/ethereum/go-ethereum/internal/ethapi" |
|
|
|
"github.com/ethereum/go-ethereum/internal/ethapi" |
|
|
|
"github.com/ethereum/go-ethereum/log" |
|
|
|
"github.com/ethereum/go-ethereum/log" |
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/signer/core/apitypes" |
|
|
|
"github.com/ethereum/go-ethereum/signer/storage" |
|
|
|
"github.com/ethereum/go-ethereum/signer/storage" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ type ExternalAPI interface { |
|
|
|
// New request to create a new account
|
|
|
|
// New request to create a new account
|
|
|
|
New(ctx context.Context) (common.Address, error) |
|
|
|
New(ctx context.Context) (common.Address, error) |
|
|
|
// SignTransaction request to sign the specified transaction
|
|
|
|
// SignTransaction request to sign the specified transaction
|
|
|
|
SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error) |
|
|
|
SignTransaction(ctx context.Context, args apitypes.SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error) |
|
|
|
// SignData - request to sign the given data (plus prefix)
|
|
|
|
// SignData - request to sign the given data (plus prefix)
|
|
|
|
SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data interface{}) (hexutil.Bytes, error) |
|
|
|
SignData(ctx context.Context, contentType string, addr common.MixedcaseAddress, data interface{}) (hexutil.Bytes, error) |
|
|
|
// SignTypedData - request to sign the given structured data (plus prefix)
|
|
|
|
// SignTypedData - request to sign the given structured data (plus prefix)
|
|
|
@ -104,7 +105,7 @@ type Validator interface { |
|
|
|
// ValidateTransaction does a number of checks on the supplied transaction, and
|
|
|
|
// ValidateTransaction does a number of checks on the supplied transaction, and
|
|
|
|
// returns either a list of warnings, or an error (indicating that the transaction
|
|
|
|
// returns either a list of warnings, or an error (indicating that the transaction
|
|
|
|
// should be immediately rejected).
|
|
|
|
// should be immediately rejected).
|
|
|
|
ValidateTransaction(selector *string, tx *SendTxArgs) (*ValidationMessages, error) |
|
|
|
ValidateTransaction(selector *string, tx *apitypes.SendTxArgs) (*apitypes.ValidationMessages, error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SignerAPI defines the actual implementation of ExternalAPI
|
|
|
|
// SignerAPI defines the actual implementation of ExternalAPI
|
|
|
@ -220,24 +221,24 @@ func (m Metadata) String() string { |
|
|
|
type ( |
|
|
|
type ( |
|
|
|
// SignTxRequest contains info about a Transaction to sign
|
|
|
|
// SignTxRequest contains info about a Transaction to sign
|
|
|
|
SignTxRequest struct { |
|
|
|
SignTxRequest struct { |
|
|
|
Transaction SendTxArgs `json:"transaction"` |
|
|
|
Transaction apitypes.SendTxArgs `json:"transaction"` |
|
|
|
Callinfo []ValidationInfo `json:"call_info"` |
|
|
|
Callinfo []apitypes.ValidationInfo `json:"call_info"` |
|
|
|
Meta Metadata `json:"meta"` |
|
|
|
Meta Metadata `json:"meta"` |
|
|
|
} |
|
|
|
} |
|
|
|
// SignTxResponse result from SignTxRequest
|
|
|
|
// SignTxResponse result from SignTxRequest
|
|
|
|
SignTxResponse struct { |
|
|
|
SignTxResponse struct { |
|
|
|
//The UI may make changes to the TX
|
|
|
|
//The UI may make changes to the TX
|
|
|
|
Transaction SendTxArgs `json:"transaction"` |
|
|
|
Transaction apitypes.SendTxArgs `json:"transaction"` |
|
|
|
Approved bool `json:"approved"` |
|
|
|
Approved bool `json:"approved"` |
|
|
|
} |
|
|
|
} |
|
|
|
SignDataRequest struct { |
|
|
|
SignDataRequest struct { |
|
|
|
ContentType string `json:"content_type"` |
|
|
|
ContentType string `json:"content_type"` |
|
|
|
Address common.MixedcaseAddress `json:"address"` |
|
|
|
Address common.MixedcaseAddress `json:"address"` |
|
|
|
Rawdata []byte `json:"raw_data"` |
|
|
|
Rawdata []byte `json:"raw_data"` |
|
|
|
Messages []*NameValueType `json:"messages"` |
|
|
|
Messages []*NameValueType `json:"messages"` |
|
|
|
Callinfo []ValidationInfo `json:"call_info"` |
|
|
|
Callinfo []apitypes.ValidationInfo `json:"call_info"` |
|
|
|
Hash hexutil.Bytes `json:"hash"` |
|
|
|
Hash hexutil.Bytes `json:"hash"` |
|
|
|
Meta Metadata `json:"meta"` |
|
|
|
Meta Metadata `json:"meta"` |
|
|
|
} |
|
|
|
} |
|
|
|
SignDataResponse struct { |
|
|
|
SignDataResponse struct { |
|
|
|
Approved bool `json:"approved"` |
|
|
|
Approved bool `json:"approved"` |
|
|
@ -537,7 +538,7 @@ func (api *SignerAPI) lookupOrQueryPassword(address common.Address, title, promp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// SignTransaction signs the given Transaction and returns it both as json and rlp-encoded form
|
|
|
|
// SignTransaction signs the given Transaction and returns it both as json and rlp-encoded form
|
|
|
|
func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error) { |
|
|
|
func (api *SignerAPI) SignTransaction(ctx context.Context, args apitypes.SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error) { |
|
|
|
var ( |
|
|
|
var ( |
|
|
|
err error |
|
|
|
err error |
|
|
|
result SignTxResponse |
|
|
|
result SignTxResponse |
|
|
@ -548,7 +549,7 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth |
|
|
|
} |
|
|
|
} |
|
|
|
// If we are in 'rejectMode', then reject rather than show the user warnings
|
|
|
|
// If we are in 'rejectMode', then reject rather than show the user warnings
|
|
|
|
if api.rejectMode { |
|
|
|
if api.rejectMode { |
|
|
|
if err := msgs.getWarnings(); err != nil { |
|
|
|
if err := msgs.GetWarnings(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -585,7 +586,7 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
// Convert fields into a real transaction
|
|
|
|
// Convert fields into a real transaction
|
|
|
|
var unsignedTx = result.Transaction.toTransaction() |
|
|
|
var unsignedTx = result.Transaction.ToTransaction() |
|
|
|
// Get the password for the transaction
|
|
|
|
// Get the password for the transaction
|
|
|
|
pw, err := api.lookupOrQueryPassword(acc.Address, "Account password", |
|
|
|
pw, err := api.lookupOrQueryPassword(acc.Address, "Account password", |
|
|
|
fmt.Sprintf("Please enter the password for account %s", acc.Address.String())) |
|
|
|
fmt.Sprintf("Please enter the password for account %s", acc.Address.String())) |
|
|
@ -621,7 +622,7 @@ func (api *SignerAPI) SignGnosisSafeTx(ctx context.Context, signerAddress common |
|
|
|
} |
|
|
|
} |
|
|
|
// If we are in 'rejectMode', then reject rather than show the user warnings
|
|
|
|
// If we are in 'rejectMode', then reject rather than show the user warnings
|
|
|
|
if api.rejectMode { |
|
|
|
if api.rejectMode { |
|
|
|
if err := msgs.getWarnings(); err != nil { |
|
|
|
if err := msgs.GetWarnings(); err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|