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

Commit 4125c93

Browse files
committed
skip empty change addresses for makers
works towards #418 but does not enable this behavior maker-side
1 parent 816242d commit 4125c93

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

joinmarket/maker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ def verify_unsigned_tx(self, txd):
188188
if outs['value'] != expected_change_value:
189189
return False, 'wrong change, i expect ' + str(
190190
expected_change_value)
191-
if times_seen_cj_addr != 1 or times_seen_change_addr != 1:
191+
if (times_seen_cj_addr != 1 or # allow "sweeping" empty change
192+
(expected_change_value != 0 and times_seen_change_addr != 1)):
192193
fmt = ('cj or change addr not in tx '
193194
'outputs once, #cjaddr={}, #chaddr={}').format
194195
return False, (fmt(times_seen_cj_addr, times_seen_change_addr))

joinmarket/taker.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,16 @@ def recv_txio(self, nick, utxo_list, cj_pub, change_addr):
126126
change_amount = total_input - self.cj_amount - order[
127127
'txfee'] + real_cjfee
128128

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

139-
self.outputs.append({'address': change_addr, 'value': change_amount})
136+
if change_amount != 0: # FIXME add support for this from maker-side
137+
self.outputs.append({'address': change_addr, 'value': change_amount})
138+
140139
fmt = ('fee breakdown for {} totalin={:d} '
141140
'cjamount={:d} txfee={:d} realcjfee={:d}').format
142141
log.debug(fmt(nick, total_input, self.cj_amount,

0 commit comments

Comments
 (0)