mmgen-xmrwallet: support current param to --restore-height
This commit is contained in:
parent
b606b47fcc
commit
005e4df538
2 changed files with 30 additions and 13 deletions
|
|
@ -60,7 +60,9 @@ opts_data = {
|
|||
-k, --use-internal-keccak-module Force use of the internal keccak module
|
||||
-p, --hash-preset=P Use scrypt hash preset 'P' for password
|
||||
hashing (default: '{gc.dfl_hash_preset}')
|
||||
-r, --restore-height=H Scan from height 'H' when creating wallets
|
||||
-r, --restore-height=H Scan from height 'H' when creating wallets.
|
||||
Use special value ‘current’ to create empty
|
||||
wallet at current blockchain height.
|
||||
-R, --no-relay Save transaction to file instead of relaying
|
||||
-s, --no-start-wallet-daemon Don’t start the wallet daemon at startup
|
||||
-S, --no-stop-wallet-daemon Don’t stop the wallet daemon at exit
|
||||
|
|
|
|||
|
|
@ -468,6 +468,9 @@ class MoneroWalletOps:
|
|||
daemon_addr = self.cfg.daemon or None,
|
||||
)
|
||||
|
||||
if self.name == 'create' and self.cfg.restore_height is None:
|
||||
self.wd.usr_daemon_args = ['--offline']
|
||||
|
||||
self.c = MoneroWalletRPCClient(
|
||||
cfg = self.cfg,
|
||||
daemon = self.wd,
|
||||
|
|
@ -477,6 +480,20 @@ class MoneroWalletOps:
|
|||
if not self.cfg.no_start_wallet_daemon:
|
||||
async_run(self.c.restart_daemon())
|
||||
|
||||
def get_coin_daemon_rpc(self):
|
||||
|
||||
host,port = self.cfg.daemon.split(':') if self.cfg.daemon else ('localhost',self.wd.daemon_port)
|
||||
|
||||
from .daemon import CoinDaemon
|
||||
return MoneroRPCClient(
|
||||
cfg = self.cfg,
|
||||
proto = self.proto,
|
||||
daemon = CoinDaemon( self.cfg, 'xmr' ),
|
||||
host = host,
|
||||
port = int(port),
|
||||
user = None,
|
||||
passwd = None )
|
||||
|
||||
def create_addr_data(self):
|
||||
if uarg.wallets:
|
||||
idxs = AddrIdxList(uarg.wallets)
|
||||
|
|
@ -713,19 +730,25 @@ class MoneroWalletOps:
|
|||
opts = ('restore_height',)
|
||||
|
||||
def check_uopts(self):
|
||||
if int(self.cfg.restore_height or 0) < 0:
|
||||
die(1,f'{self.cfg.restore_height}: invalid value for --restore-height (less than zero)')
|
||||
if self.cfg.restore_height != 'current':
|
||||
if int(self.cfg.restore_height or 0) < 0:
|
||||
die(1,f'{self.cfg.restore_height}: invalid value for --restore-height (less than zero)')
|
||||
|
||||
async def process_wallet(self,d,fn,last):
|
||||
msg_r('') # for pexpect
|
||||
|
||||
if self.cfg.restore_height == 'current':
|
||||
restore_height = self.get_coin_daemon_rpc().call_raw('get_height')['height']
|
||||
else:
|
||||
restore_height = self.cfg.restore_height
|
||||
|
||||
from .xmrseed import xmrseed
|
||||
ret = self.c.call(
|
||||
'restore_deterministic_wallet',
|
||||
filename = os.path.basename(fn),
|
||||
password = d.wallet_passwd,
|
||||
seed = xmrseed().fromhex(d.sec.wif,tostr=True),
|
||||
restore_height = self.cfg.restore_height,
|
||||
restore_height = restore_height,
|
||||
language = 'English' )
|
||||
|
||||
pp_msg(ret) if self.cfg.debug else msg(' Address: {}'.format( ret['address'] ))
|
||||
|
|
@ -740,15 +763,7 @@ class MoneroWalletOps:
|
|||
|
||||
host,port = self.cfg.daemon.split(':') if self.cfg.daemon else ('localhost',self.wd.daemon_port)
|
||||
|
||||
from .daemon import CoinDaemon
|
||||
self.dc = MoneroRPCClient(
|
||||
cfg = self.cfg,
|
||||
proto = self.proto,
|
||||
daemon = CoinDaemon( self.cfg, 'xmr' ),
|
||||
host = host,
|
||||
port = int(port),
|
||||
user = None,
|
||||
passwd = None )
|
||||
self.dc = self.get_coin_daemon_rpc()
|
||||
|
||||
self.accts_data = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue