From 9b04af4a65304e4286bec972dd7be3e8152c853c Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Fri, 25 Nov 2016 16:45:14 +0200 Subject: [PATCH] choose address based on INTERNAL flag in schedule --- jmclient/schedule.py | 7 ++++--- jmclient/taker.py | 7 +++++++ scripts/sample-schedule-for-testnet | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/jmclient/schedule.py b/jmclient/schedule.py index 00bef87..efd6d04 100644 --- a/jmclient/schedule.py +++ b/jmclient/schedule.py @@ -25,8 +25,9 @@ def get_schedule(filename): destaddr = destaddr.strip() except ValueError as e: return (False, "Failed to parse schedule line: " + sl) - success, errmsg = validate_address(destaddr) - if not success: - return (False, "Invalid address: " + destaddr + "," + errmsg) + if destaddr != "INTERNAL": + success, errmsg = validate_address(destaddr) + if not success: + return (False, "Invalid address: " + destaddr + "," + errmsg) schedule.append((mixdepth, amount, makercount, destaddr)) return (True, schedule) diff --git a/jmclient/taker.py b/jmclient/taker.py index 7979e10..1c81544 100644 --- a/jmclient/taker.py +++ b/jmclient/taker.py @@ -109,6 +109,13 @@ class Taker(object): self.cjamount = si[1] self.n_counterparties = si[2] self.my_cj_addr = si[3] + #if destination is flagged "INTERNAL", choose a destination + #from the next mixdepth modulo the maxmixdepth + if self.my_cj_addr == "INTERNAL": + next_mixdepth = (self.mixdepth + 1) % self.wallet.max_mix_depth + jlog.info("Choosing a destination from mixdepth: " + str(next_mixdepth)) + self.my_cj_addr = self.wallet.get_internal_addr(next_mixdepth) + jlog.info("Chose destination address: " + self.my_cj_addr) self.outputs = [] self.cjfee_total = 0 self.maker_txfee_contributions = 0 diff --git a/scripts/sample-schedule-for-testnet b/scripts/sample-schedule-for-testnet index 9959617..31762c9 100644 --- a/scripts/sample-schedule-for-testnet +++ b/scripts/sample-schedule-for-testnet @@ -1,3 +1,3 @@ #sample for testing -1, 50000000, 3, n18jvNgdCWkb5YWEMVARjBfcizg4kHcYRZ -0, 80000000, 2, n18jvNgdCWkb5YWEMVARjBfcizg4kHcYRZ \ No newline at end of file +1, 110000000, 3, INTERNAL +0, 20000000, 2, mnsquzxrHXpFsZeL42qwbKdCP2y1esN3qw \ No newline at end of file