aboutsummaryrefslogtreecommitdiffstats
path: root/signer
diff options
context:
space:
mode:
Diffstat (limited to 'signer')
-rw-r--r--signer/core/api.go19
-rw-r--r--signer/core/api_test.go3
-rw-r--r--signer/core/auditlog.go15
3 files changed, 24 insertions, 13 deletions
diff --git a/signer/core/api.go b/signer/core/api.go
index e9a335785..e112df9c7 100644
--- a/signer/core/api.go
+++ b/signer/core/api.go
@@ -36,8 +36,14 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
-// numberOfAccountsToDerive For hardware wallets, the number of accounts to derive
-const numberOfAccountsToDerive = 10
+const (
+ // numberOfAccountsToDerive For hardware wallets, the number of accounts to derive
+ numberOfAccountsToDerive = 10
+ // ExternalAPIVersion -- see extapi_changelog.md
+ ExternalAPIVersion = "4.0.0"
+ // InternalAPIVersion -- see intapi_changelog.md
+ InternalAPIVersion = "3.0.0"
+)
// ExternalAPI defines the external API through which signing requests are made.
type ExternalAPI interface {
@@ -55,6 +61,7 @@ type ExternalAPI interface {
// Should be moved to Internal API, in next phase when we have
// bi-directional communication
//Import(ctx context.Context, keyJSON json.RawMessage) (Account, error)
+ Version(ctx context.Context) (string, error)
}
// SignerUI specifies what method a UI needs to implement to be able to be used as a UI for the signer
@@ -539,7 +546,7 @@ func (api *SignerAPI) Sign(ctx context.Context, addr common.MixedcaseAddress, da
return nil, err
}
// Assemble sign the data with the wallet
- signature, err := wallet.SignHashWithPassphrase(account, res.Password, sighash)
+ signature, err := wallet.SignTextWithPassphrase(account, res.Password, data)
if err != nil {
api.UI.ShowError(err.Error())
return nil, err
@@ -610,3 +617,9 @@ func (api *SignerAPI) Import(ctx context.Context, keyJSON json.RawMessage) (Acco
}
return Account{Typ: "Account", URL: acc.URL, Address: acc.Address}, nil
}
+
+// Returns the external api version. This method does not require user acceptance. Available methods are
+// available via enumeration anyway, and this info does not contain user-specific data
+func (api *SignerAPI) Version(ctx context.Context) (string, error) {
+ return ExternalAPIVersion, nil
+}
diff --git a/signer/core/api_test.go b/signer/core/api_test.go
index a8aa23896..114470cf9 100644
--- a/signer/core/api_test.go
+++ b/signer/core/api_test.go
@@ -29,7 +29,6 @@ import (
"time"
"github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
@@ -135,7 +134,7 @@ func setup(t *testing.T) (*SignerAPI, chan string) {
db, err := NewAbiDBFromFile("../../cmd/clef/4byte.json")
if err != nil {
- utils.Fatalf(err.Error())
+ t.Fatal(err.Error())
}
var (
ui = &HeadlessUI{controller}
diff --git a/signer/core/auditlog.go b/signer/core/auditlog.go
index 1f9c90918..0cb6c9c47 100644
--- a/signer/core/auditlog.go
+++ b/signer/core/auditlog.go
@@ -80,14 +80,13 @@ func (l *AuditLogger) Export(ctx context.Context, addr common.Address) (json.Raw
return j, e
}
-//func (l *AuditLogger) Import(ctx context.Context, keyJSON json.RawMessage) (Account, error) {
-// // Don't actually log the json contents
-// l.log.Info("Import", "type", "request", "metadata", MetadataFromContext(ctx).String(),
-// "keyJSON size", len(keyJSON))
-// a, e := l.api.Import(ctx, keyJSON)
-// l.log.Info("Import", "type", "response", "addr", a.String(), "error", e)
-// return a, e
-//}
+func (l *AuditLogger) Version(ctx context.Context) (string, error) {
+ l.log.Info("Version", "type", "request", "metadata", MetadataFromContext(ctx).String())
+ data, err := l.api.Version(ctx)
+ l.log.Info("Version", "type", "response", "data", data, "error", err)
+ return data, err
+
+}
func NewAuditLogger(path string, api ExternalAPI) (*AuditLogger, error) {
l := log.New("api", "signer")