forked from PlatONnetwork/client-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersonal.py
80 lines (68 loc) · 2.28 KB
/
personal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from client_sdk_python.module import (
Module,
)
class Personal(Module):
"""
https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal
"""
def importRawKey(self, private_key, passphrase):
return self.web3.manager.request_blocking(
"personal_importRawKey",
[private_key, passphrase],
)
def newAccount(self, password):
return self.web3.manager.request_blocking(
"personal_newAccount", [password],
)
@property
def listAccounts(self):
return self.web3.manager.request_blocking(
"personal_listAccounts", [],
)
@property
def listWallets(self):
return self.web3.manager.request_blocking(
"personal_listWallets", [],
)
def sendTransaction(self, transaction, passphrase):
return self.web3.manager.request_blocking(
"personal_sendTransaction",
[transaction, passphrase],
)
def lockAccount(self, account):
return self.web3.manager.request_blocking(
"personal_lockAccount",
[account],
)
def unlockAccount(self, account, passphrase, duration=None):
try:
return self.web3.manager.request_blocking(
"personal_unlockAccount",
[account, passphrase, duration],
)
except ValueError as err:
if "could not decrypt" in str(err):
# Hack to handle go-ethereum error response.
return False
else:
raise
def sign(self, message, signer, passphrase):
return self.web3.manager.request_blocking(
'personal_sign',
[message, signer, passphrase],
)
def signTransaction(self, transaction_dict, passphrase):
return self.web3.manager.request_blocking(
'personal_signTransaction',
[transaction_dict, passphrase],
)
def ecRecover(self, message, signature):
return self.web3.manager.request_blocking(
'personal_ecRecover',
[message, signature],
)
def openWallet(self, url, passphrase):
return self.web3.manager.request_blocking(
'personal_openWallet',
[url, passphrase],
)