Browse Source

Qt: fix run join before info mbox is closed

add_frost
zebra-lucky 2 weeks ago
parent
commit
dc6832e069
  1. 27
      scripts/joinmarket-qt.py
  2. 2
      scripts/sendpayment.py
  3. 2
      scripts/tumbler.py
  4. 8
      src/jmclient/cli_options.py
  5. 13
      src/jmclient/wallet_rpc.py

27
scripts/joinmarket-qt.py

@ -761,12 +761,13 @@ class SpendTab(QWidget):
def resizeScroll(self, mini, maxi):
self.textedit.verticalScrollBar().setValue(maxi)
def restartWaitWrap(self):
async def restartWaitWrap(self):
if restart_wait(self.waitingtxid):
self.restartTimer.stop()
self.waitingtxid = None
mainWindow.statusBar().showMessage("Transaction in a block, now continuing.")
self.startJoin()
mainWindow.statusBar().showMessage(
"Transaction in a block, now continuing.")
await self.startJoin()
async def startMultiple(self):
if jm_single().bc_interface is None:
@ -816,12 +817,13 @@ class SpendTab(QWidget):
#start another transactions while waiting. Also, use :0 because
#it always exists
self.waitingtxid=txid
self.restartTimer.timeout.connect(self.restartWaitWrap)
self.restartTimer.timeout.connect(
lambda: asyncio.ensure_future(self.restartWaitWrap()))
self.restartTimer.start(5000)
self.updateSchedView()
return
self.updateSchedView()
self.startJoin()
await self.startJoin()
async def checkDirectSend(self, dtx, destaddr, amount, fee, custom_change_addr):
"""Give user info to decide whether to accept a direct send;
@ -951,9 +953,9 @@ class SpendTab(QWidget):
destaddr, 0, NO_ROUNDING, 0]]
self.spendstate.updateType('single')
self.spendstate.updateRun('running')
self.startJoin()
await self.startJoin()
def getMaxCJFees(self, relfee, absfee):
async def getMaxCJFees(self, relfee, absfee):
""" Used as a callback to decide relative and absolute
maximum fees for coinjoins, in cases where the user has not
set these values in the config (which is the default)."""
@ -971,12 +973,11 @@ class SpendTab(QWidget):
"max_cj_fee_rel = your-value-as-decimal\n"
"in the [POLICY] section.\n"
"Note: If you don't do this, this dialog will interrupt the tumbler.")
asyncio.ensure_future(
JMQtMessageBox(
self, msg, mbtype="info", title="Setting fee limits."))
await JMQtMessageBox(self, msg, mbtype="info",
title="Setting fee limits.")
return relfee, absfee
def startJoin(self):
async def startJoin(self):
if not mainWindow.wallet_service:
asyncio.ensure_future(
JMQtMessageBox(self, "Cannot start without a loaded wallet.",
@ -995,8 +996,8 @@ class SpendTab(QWidget):
custom_change = None
if len(self.changeInput.text().strip()) > 0:
custom_change = str(self.changeInput.text().strip())
maxcjfee = get_max_cj_fee_values(jm_single().config, None,
user_callback=self.getMaxCJFees)
maxcjfee = await get_max_cj_fee_values(jm_single().config, None,
user_callback=self.getMaxCJFees)
log.info("Using maximum coinjoin fee limits per maker of {:.4%}, {} "
"".format(maxcjfee[0], btc.amount_to_str(maxcjfee[1])))
wallet = mainWindow.wallet_service.wallet

2
scripts/sendpayment.py

@ -186,7 +186,7 @@ async def main():
maxcjfee = (1, float('inf'))
if not options.pickorders and options.makercount != 0:
maxcjfee = get_max_cj_fee_values(jm_single().config, options)
maxcjfee = await get_max_cj_fee_values(jm_single().config, options)
log.info("Using maximum coinjoin fee limits per maker of {:.4%}, {} "
"".format(maxcjfee[0], btc.amount_to_str(maxcjfee[1])))

2
scripts/tumbler.py

@ -67,7 +67,7 @@ async def main():
# the sync call here will now be a no-op:
wallet_service.startService()
maxcjfee = get_max_cj_fee_values(jm_single().config, options_org)
maxcjfee = await get_max_cj_fee_values(jm_single().config, options_org)
log.info("Using maximum coinjoin fee limits per maker of {:.4%}, {} sat"
.format(*maxcjfee))

8
src/jmclient/cli_options.py

@ -1,4 +1,6 @@
#! /usr/bin/env python
import asyncio
import random
from optparse import OptionParser, OptionValueError
from configparser import NoOptionError
@ -210,8 +212,8 @@ max_cj_fee_rel = {rel_val}\n""".format(rel_val=rel_val, abs_val=abs_val))
return rel_val, abs_val
def get_max_cj_fee_values(config, parser_options,
user_callback=prompt_user_for_cj_fee):
async def get_max_cj_fee_values(config, parser_options,
user_callback=prompt_user_for_cj_fee):
""" Given a config object, retrieve the chosen maximum absolute
and relative coinjoin fees chosen by the user, or prompt
the user via the user_callback function, if not present in
@ -241,6 +243,8 @@ def get_max_cj_fee_values(config, parser_options,
if any(x is None for x in fee_values):
fee_values = user_callback(*fee_values)
if asyncio.iscoroutine(fee_values):
fee_values = await fee_values
return tuple(map(lambda j: fee_types[j](fee_values[j]),
range(len(fee_values))))

13
src/jmclient/wallet_rpc.py

@ -1315,7 +1315,7 @@ class JMWalletDaemon(Service):
#route to start a coinjoin transaction
@app.route('/wallet/<string:walletname>/taker/coinjoin', methods=['POST'])
def docoinjoin(self, request, walletname):
async def docoinjoin(self, request, walletname):
self.check_cookie(request)
if not self.services["wallet"]:
raise NoWalletFound()
@ -1352,8 +1352,8 @@ class JMWalletDaemon(Service):
# why no defaults).
def dummy_user_callback(rel, abs):
raise ConfigNotPresent()
max_cj_fee= get_max_cj_fee_values(jm_single().config,
None, user_callback=dummy_user_callback)
max_cj_fee= await get_max_cj_fee_values(
jm_single().config, None, user_callback=dummy_user_callback)
# Before actual start, update our coinjoin state:
if not self.activate_coinjoin_state(CJ_TAKER_RUNNING):
raise ServiceAlreadyStarted()
@ -1409,7 +1409,7 @@ class JMWalletDaemon(Service):
signature=result[0], message=result[1], address=result[2])
@app.route('/wallet/<string:walletname>/taker/schedule', methods=['POST'])
def start_tumbler(self, request, walletname):
async def start_tumbler(self, request, walletname):
self.check_cookie(request)
if self.coinjoin_state is not CJ_NOT_RUNNING or self.tumbler_options is not None:
@ -1451,9 +1451,8 @@ class JMWalletDaemon(Service):
def dummy_user_callback(rel, abs):
raise ConfigNotPresent()
max_cj_fee = get_max_cj_fee_values(jm_single().config,
None,
user_callback=dummy_user_callback)
max_cj_fee = await get_max_cj_fee_values(
jm_single().config, None, user_callback=dummy_user_callback)
jm_single().mincjamount = tumbler_options['mincjamount']

Loading…
Cancel
Save