From fd5e6d8d8ba36b8d5c07577082f91445087f205e Mon Sep 17 00:00:00 2001 From: AdamISZ Date: Mon, 21 Jan 2019 16:17:21 +0100 Subject: [PATCH] Fixes #305 Previous to this commit, a user could create a direct payment or Joinmarket coinjoin inadvertently by not using the correct arguments to sendpayment.py (missing -T or setting -N0). After this commit, the correct number of arguments (3) are insisted on, and -T takes precedence over -N 0. --- scripts/sendpayment.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/sendpayment.py b/scripts/sendpayment.py index 533c577..2173b88 100644 --- a/scripts/sendpayment.py +++ b/scripts/sendpayment.py @@ -51,8 +51,13 @@ def main(): parser = get_sendpayment_parser() (options, args) = parser.parse_args() load_program_config() - if options.schedule == '' and len(args) < 3: - parser.error('Needs a wallet, amount and destination address') + if options.p2ep and len(args) != 3: + parser.error("PayJoin requires exactly three arguments: " + "wallet, amount and destination address.") + sys.exit(0) + elif options.schedule == '' and len(args) != 3: + parser.error("Joinmarket sendpayment (coinjoin) needs arguments:" + " wallet, amount and destination address") sys.exit(0) #without schedule file option, use the arguments to create a schedule @@ -73,6 +78,9 @@ def main(): schedule = [[options.mixdepth, amount, options.makercount, destaddr, 0.0, 0]] else: + if options.p2ep: + parser.error("Schedule files are not compatible with PayJoin") + sys.exit(0) result, schedule = get_schedule(options.schedule) if not result: log.error("Failed to load schedule file, quitting. Check the syntax.") @@ -126,7 +134,7 @@ def main(): #wallet sync will now only occur on reactor start if we're joining. while not jm_single().bc_interface.wallet_synced: sync_wallet(wallet, fast=options.fastsync) - if options.makercount == 0: + if options.makercount == 0 and not options.p2ep: direct_send(wallet, amount, mixdepth, destaddr, options.answeryes) return