MoneroWalletRPCClient: simplify instantiation

This commit is contained in:
The MMGen Project 2021-10-10 20:18:15 +00:00
commit 641c6bdf97
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 17 additions and 24 deletions

View file

@ -706,6 +706,19 @@ class MoneroRPCClientRaw(MoneroRPCClient):
class MoneroWalletRPCClient(MoneroRPCClient):
auth_type = 'digest'
def __init__(self,daemon,test_connection=True):
RPCClient.__init__(
self,
daemon.host,
daemon.rpc_port,
test_connection = test_connection )
self.daemon = daemon
self.auth = auth_data(daemon.user,daemon.passwd)
self.set_backend('requests')
rpcmethods = (
'get_version',
'get_height', # sync height of the open wallet

View file

@ -341,12 +341,7 @@ class MoneroWalletOps:
if not uopt.no_start_wallet_daemon:
self.wd.restart()
self.c = MoneroWalletRPCClient(
host = self.wd.host,
port = self.wd.rpc_port,
user = self.wd.user,
passwd = self.wd.passwd
)
self.c = MoneroWalletRPCClient(daemon=self.wd)
def create_addr_data(self):
if uarg.wallets:
@ -742,12 +737,7 @@ class MoneroWalletOps:
self.wd2.start()
self.c = MoneroWalletRPCClient(
host = self.wd2.host,
port = self.wd2.rpc_port,
user = self.wd2.user,
passwd = self.wd2.passwd
)
self.c = MoneroWalletRPCClient(daemon=self.wd2)
async def main(self):
gmsg(f'\n{self.desc}ing account #{self.account} of wallet {self.source.idx}' + (

View file

@ -236,13 +236,7 @@ class TestSuiteXMRWallet(TestSuiteBase):
datadir = os.path.join('test','daemons'),
daemon_addr = f'127.0.0.1:{md.rpc_port}',
)
wd_rpc = MoneroWalletRPCClient(
host = wd.host,
port = wd.rpc_port,
user = wd.user,
passwd = wd.passwd,
test_connection = False,
)
wd_rpc = MoneroWalletRPCClient( daemon=wd, test_connection=False )
self.users[user] = ud(
sid = sid,
mmwords = f'test/ref/{sid}.mmwords',

View file

@ -124,11 +124,7 @@ class unit_tests:
if not opt.no_daemon_autostart:
md.start()
wd.start()
c = MoneroWalletRPCClient(
host = wd.host,
port = wd.rpc_port,
user = wd.user,
passwd = wd.passwd )
c = MoneroWalletRPCClient(daemon=wd)
await c.call('get_version')
for md,wd in daemons: