Add key retrieval
This commit is contained in:
parent
4c651d7d35
commit
333caafa90
|
@ -30,6 +30,12 @@ class JSONRPCWallet(object):
|
|||
_log.debug("JSONRPC backend auth: '{user}'/'{stars}'".format(
|
||||
user=user, stars=('*' * len(password)) if password else ''))
|
||||
|
||||
def get_view_key(self):
|
||||
return self.raw_request('query_key', {'key_type': 'view_key'})['key']
|
||||
|
||||
def get_seed(self):
|
||||
return self.raw_request('query_key', {'key_type': 'mnemonic'})['key']
|
||||
|
||||
def get_accounts(self):
|
||||
accounts = []
|
||||
try:
|
||||
|
|
|
@ -21,6 +21,18 @@ class Wallet(object):
|
|||
self.accounts.append(_acc)
|
||||
idx += 1
|
||||
|
||||
def get_view_key(self):
|
||||
"""
|
||||
Returns private view key.
|
||||
"""
|
||||
return self._backend.get_view_key()
|
||||
|
||||
def get_seed(self):
|
||||
"""
|
||||
Returns word seed.
|
||||
"""
|
||||
return self._backend.get_seed()
|
||||
|
||||
def new_account(self, label=None):
|
||||
acc, addr = self._backend.new_account(label=label)
|
||||
assert acc.index == len(self.accounts)
|
||||
|
|
|
@ -49,12 +49,24 @@ def a2str(a):
|
|||
label=a.label or "")
|
||||
|
||||
w = get_wallet()
|
||||
masteraddr = w.get_address()
|
||||
print(
|
||||
"Master address: {addr}\n" \
|
||||
"Balance: {total:16.12f} ({unlocked:16.12f} unlocked)".format(
|
||||
addr=a2str(w.get_address()),
|
||||
addr=a2str(masteraddr),
|
||||
total=w.get_balance(),
|
||||
unlocked=w.get_balance(unlocked=True)))
|
||||
print(
|
||||
"Keys:\n" \
|
||||
" private view: {svk}\n" \
|
||||
" public spend: {psk}\n" \
|
||||
" public view: {pvk}\n\n" \
|
||||
"Seed:\n{seed}".format(
|
||||
svk=w.get_view_key(),
|
||||
psk=masteraddr.get_spend_key(),
|
||||
pvk=masteraddr.get_view_key(),
|
||||
seed=w.get_seed()
|
||||
))
|
||||
|
||||
if len(w.accounts) > 1:
|
||||
print("\nWallet has {num} account(s):".format(num=len(w.accounts)))
|
||||
|
|
Loading…
Reference in New Issue