aboutsummaryrefslogtreecommitdiffstats
path: root/signer/core/api.go
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-02-05 18:23:57 +0800
committerGitHub <noreply@github.com>2019-02-05 18:23:57 +0800
commit43e8efe8955b8bb1fab7bfced33a6302fb69e48e (patch)
tree3db96494c913b31be950f5580bf49a82141b9255 /signer/core/api.go
parent520024dfd689d264807b7fe1fc28deba51d6ab20 (diff)
downloadgo-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.gz
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.bz2
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.lz
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.xz
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.tar.zst
go-tangerine-43e8efe8955b8bb1fab7bfced33a6302fb69e48e.zip
accounts, eth, clique, signer: support for external signer API (#18079)
* accounts, eth, clique: implement external backend + move sighash calc to backend * signer: implement account_Version on external API * accounts/external: enable ipc, add copyright * accounts, internal, signer: formatting * node: go fmt * flags: disallow --dev in combo with --externalsigner * accounts: remove clique-specific signing method, replace with more generic * accounts, consensus: formatting + fix error in tests * signer/core: remove (test-) import cycle * clique: remove unused import * accounts: remove CliqueHash and avoid dependency on package crypto * consensus/clique: unduplicate header encoding
Diffstat (limited to 'signer/core/api.go')
-rw-r--r--signer/core/api.go19
1 files changed, 16 insertions, 3 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
+}