aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go42
-rw-r--r--internal/web3ext/web3ext.go10
2 files changed, 52 insertions, 0 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index e5a8124b1..7938b264a 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -28,6 +28,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
+ "github.com/ethereum/go-ethereum/accounts/scwallet"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
@@ -44,6 +45,7 @@ import (
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/syndtr/goleveldb/leveldb"
+ "github.com/tyler-smith/go-bip39"
)
const (
@@ -471,6 +473,46 @@ func (s *PrivateAccountAPI) SignAndSendTransaction(ctx context.Context, args Sen
return s.SendTransaction(ctx, args, passwd)
}
+func (s *PrivateAccountAPI) InitializeWallet(ctx context.Context, url string) (string, error) {
+ wallet, err := s.am.Wallet(url)
+ if err != nil {
+ return "", err
+ }
+
+ entropy, err := bip39.NewEntropy(256)
+ if err != nil {
+ return "", err
+ }
+
+ mnemonic, err := bip39.NewMnemonic(entropy)
+ if err != nil {
+ return "", err
+ }
+
+ seed := bip39.NewSeed(mnemonic, "")
+
+ switch wallet := wallet.(type) {
+ case *scwallet.Wallet:
+ return mnemonic, wallet.Initialize(seed)
+ default:
+ return "", fmt.Errorf("Specified wallet does not support initialization")
+ }
+}
+
+func (s *PrivateAccountAPI) Unpair(ctx context.Context, url string, pin string) error {
+ wallet, err := s.am.Wallet(url)
+ if err != nil {
+ return err
+ }
+
+ switch wallet := wallet.(type) {
+ case *scwallet.Wallet:
+ return wallet.Unpair([]byte(pin))
+ default:
+ return fmt.Errorf("Specified wallet does not support pairing")
+ }
+}
+
// PublicBlockChainAPI provides an API to access the Ethereum blockchain.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicBlockChainAPI struct {
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go
index 36fde166b..31c0c57ec 100644
--- a/internal/web3ext/web3ext.go
+++ b/internal/web3ext/web3ext.go
@@ -613,6 +613,16 @@ web3._extend({
params: 2,
inputFormatter: [web3._extend.formatters.inputTransactionFormatter, null]
}),
+ new web3._extend.Method({
+ name: 'unpair',
+ call: 'personal_unpair',
+ params: 2
+ }),
+ new web3._extend.Method({
+ name: 'initializeWallet',
+ call: 'personal_initializeWallet',
+ params: 1
+ })
],
properties: [
new web3._extend.Property({