Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
skip empty change addresses for makers
Browse files Browse the repository at this point in the history
works towards #418 but does not enable this behavior maker-side
  • Loading branch information
adlai committed Jul 16, 2016
1 parent f3afd81 commit 226bcf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion joinmarket/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def verify_unsigned_tx(self, txd):
if outs['value'] != expected_change_value:
return False, 'wrong change, i expect ' + str(
expected_change_value)
if times_seen_cj_addr != 1 or times_seen_change_addr != 1:
if (times_seen_cj_addr != 1 or # allow "sweeping" empty change
(expected_change_value != 0 and times_seen_change_addr != 1)):
fmt = ('cj or change addr not in tx '
'outputs once, #cjaddr={}, #chaddr={}').format
return False, (fmt(times_seen_cj_addr, times_seen_change_addr))
Expand Down
11 changes: 5 additions & 6 deletions joinmarket/taker.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,16 @@ def recv_txio(self, nick, utxo_list, cj_pub, change_addr):
change_amount = (total_input - self.cj_amount -
self.active_orders[nick]['txfee'] + real_cjfee)

# certain malicious and/or incompetent liquidity providers send
# inputs totalling less than the coinjoin amount! this leads to
# a change output of zero satoshis, so the invalid transaction
# fails harmlessly; let's fail earlier, with a clear message.
if change_amount < jm_single().DUST_THRESHOLD:
# change must either be above the DUST_THRESHOLD, or exactly zero
if change_amount != 0 and change_amount < jm_single().DUST_THRESHOLD:
fmt = ('ERROR counterparty requires sub-dust change. nick={}'
'totalin={:d} cjamount={:d} change={:d}').format
log.debug(fmt(nick, total_input, self.cj_amount, change_amount))
return # timeout marks this maker as nonresponsive

self.outputs.append({'address': change_addr, 'value': change_amount})
if change_amount != 0: # FIXME add support for this from maker-side
self.outputs.append({'address': change_addr, 'value': change_amount})

fmt = ('fee breakdown for {} totalin={:d} '
'cjamount={:d} txfee={:d} realcjfee={:d}').format
log.debug(fmt(nick, total_input, self.cj_amount,
Expand Down

0 comments on commit 226bcf8

Please sign in to comment.