aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-08-14 23:52:40 +0800
committerGitHub <noreply@github.com>2017-08-14 23:52:40 +0800
commitef0edc6e32d98d2fca54076f38cb317f43704900 (patch)
tree3c110e3aa936721d90537074ea187cbfb5f5991c /internal
parent6ca59d98f88d4b4cc8bdeb2f023ff8c1fa228c6f (diff)
parent02656f9f614374b3f30b0cc57562e31c570cdf3d (diff)
downloadgo-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar.gz
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar.bz2
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar.lz
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar.xz
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.tar.zst
go-tangerine-ef0edc6e32d98d2fca54076f38cb317f43704900.zip
Merge pull request #14885 from karalabe/trezor-boom
accounts, console, internal: support trezor hardware wallet
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go31
-rw-r--r--internal/web3ext/web3ext.go5
2 files changed, 32 insertions, 4 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 7874b7101..c3924b93a 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -230,22 +230,45 @@ func (s *PrivateAccountAPI) ListAccounts() []common.Address {
type rawWallet struct {
URL string `json:"url"`
Status string `json:"status"`
- Accounts []accounts.Account `json:"accounts"`
+ Failure string `json:"failure,omitempty"`
+ Accounts []accounts.Account `json:"accounts,omitempty"`
}
// ListWallets will return a list of wallets this node manages.
func (s *PrivateAccountAPI) ListWallets() []rawWallet {
wallets := make([]rawWallet, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() {
- wallets = append(wallets, rawWallet{
+ status, failure := wallet.Status()
+
+ raw := rawWallet{
URL: wallet.URL().String(),
- Status: wallet.Status(),
+ Status: status,
Accounts: wallet.Accounts(),
- })
+ }
+ if failure != nil {
+ raw.Failure = failure.Error()
+ }
+ wallets = append(wallets, raw)
}
return wallets
}
+// OpenWallet initiates a hardware wallet opening procedure, establishing a USB
+// connection and attempting to authenticate via the provided passphrase. Note,
+// the method may return an extra challenge requiring a second open (e.g. the
+// Trezor PIN matrix challenge).
+func (s *PrivateAccountAPI) OpenWallet(url string, passphrase *string) error {
+ wallet, err := s.am.Wallet(url)
+ if err != nil {
+ return err
+ }
+ pass := ""
+ if passphrase != nil {
+ pass = *passphrase
+ }
+ return wallet.Open(pass)
+}
+
// DeriveAccount requests a HD wallet to derive a new account, optionally pinning
// it for later reuse.
func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) {
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index 44fabd6ab..bf1db8819 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -493,6 +493,11 @@ web3._extend({
params: 2
}),
new web3._extend.Method({
+ name: 'openWallet',
+ call: 'personal_openWallet',
+ params: 2
+ }),
+ new web3._extend.Method({
name: 'deriveAccount',
call: 'personal_deriveAccount',
params: 3