Browse Source

Merge #529: Check against dust threshold for single joins

f51990900f Check against dust threshold for single joins (Kristaps Kaupe)

Pull request description:

  Such joins will not work anyway.

  Related to discussion on IRC where somebody wanted to send 1 BTC but was actually sending 1 sat and it didn't work, of course.

Top commit has no ACKs.

Tree-SHA512: fc747a2ee2271c4554a45ccf872bbbaa1cea531b0ac7dc786137adfbee1d70db282fd65ed743dccb6018369885cd0e0804f431cffd7fc424ea3078ab277bbb6c
master
Kristaps Kaupe 6 years ago
parent
commit
0e08e7df99
No known key found for this signature in database
GPG Key ID: D47B1B4232B55437
  1. 26
      scripts/joinmarket-qt.py
  2. 7
      scripts/sendpayment.py

26
scripts/joinmarket-qt.py

@ -66,6 +66,7 @@ JM_CORE_VERSION = '0.6.1'
JM_GUI_VERSION = '11'
from jmbase import get_log
from jmbase.support import DUST_THRESHOLD
from jmclient import load_program_config, get_network, update_persist_config,\
open_test_wallet_maybe, get_wallet_path, get_p2sh_vbyte, get_p2pk_vbyte,\
jm_single, validate_address, weighted_order_choose, Taker,\
@ -109,6 +110,22 @@ def checkAddress(parent, addr):
mbtype='warn',
title="Error")
def checkAmount(parent, amount_str):
if not amount_str:
return False
amount_sat = btc.amount_to_sat(amount_str)
if amount_sat < DUST_THRESHOLD:
JMQtMessageBox(parent,
"Amount " + btc.amount_to_str(amount_sat) +
" is below dust threshold " +
btc.amount_to_str(DUST_THRESHOLD) + ".",
mbtype='warn',
title="Error")
return False
return True
def getSettingsWidgets():
results = []
sN = ['Recipient address', 'Number of counterparties', 'Mixdepth',
@ -609,11 +626,14 @@ class SpendTab(QWidget):
if not self.validateSettings():
return
destaddr = str(self.widgets[0][1].text())
#convert from bitcoins (enforced by QDoubleValidator) to satoshis
btc_amount_str = self.widgets[3][1].text()
amount = btc.amount_to_sat(btc_amount_str)
makercount = int(self.widgets[1][1].text())
mixdepth = int(self.widgets[2][1].text())
btc_amount_str = self.widgets[3][1].text()
# for coinjoin sends no point to send below dust threshold, likely
# there will be no makers for such amount.
if makercount != 0 and not checkAmount(self, btc_amount_str):
return
amount = btc.amount_to_sat(btc_amount_str)
if makercount == 0:
try:
txid = direct_send(mainWindow.wallet_service, amount, mixdepth,

7
scripts/sendpayment.py

@ -18,7 +18,7 @@ from jmclient import Taker, P2EPTaker, load_program_config, get_schedule,\
get_sendpayment_parser, get_max_cj_fee_values, check_regtest
from twisted.python.log import startLogging
from jmbase.support import get_log, set_logging_level, jmprint, \
EXIT_FAILURE, EXIT_ARGERROR
EXIT_FAILURE, EXIT_ARGERROR, DUST_THRESHOLD
import jmbitcoin as btc
@ -72,6 +72,11 @@ def main():
if not addr_valid:
jmprint('ERROR: Address invalid. ' + errormsg, "error")
sys.exit(EXIT_ARGERROR)
if amount < DUST_THRESHOLD:
jmprint('ERROR: Amount ' + btc.amount_to_str(amount) +
' is below dust threshold ' +
btc.amount_to_str(DUST_THRESHOLD) + '.', "error")
sys.exit(EXIT_ARGERROR)
schedule = [[options.mixdepth, amount, options.makercount,
destaddr, 0.0, NO_ROUNDING, 0]]
else:

Loading…
Cancel
Save