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

Commit

Permalink
Fix bug resending dispute close
Browse files Browse the repository at this point in the history
  • Loading branch information
cpacia committed Nov 9, 2016
1 parent afc9cd1 commit c26fb93
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions market/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,26 +803,28 @@ def close_dispute(self, order_id, resolution, buyer_percentage,
Called when a moderator closes a dispute. It will create a payout transactions refunding both
parties and send it to them in a dispute_close message.
"""
if float(vendor_percentage) < 0 or float(moderator_percentage) < 0 or float(buyer_percentage) < 0:
raise Exception("Payouts percentages must be positive")
if float(vendor_percentage) + float(buyer_percentage) > 1:
raise Exception("Payout exceeds 100% of value")
if not self.protocol.multiplexer.blockchain.connected:
raise Exception("Libbitcoin server not online")
if not self.protocol.multiplexer.testnet and \
not (moderator_address[:1] == "1" or moderator_address[:1] == "3"):
raise Exception("Bitcoin address is not a mainnet address")
elif self.protocol.multiplexer.testnet and not \
(moderator_address[:1] == "n" or moderator_address[:1] == "m" or moderator_address[:1] == "2"):
raise Exception("Bitcoin address is not a testnet address")
try:
bitcointools.b58check_to_hex(moderator_address)
except AssertionError:
raise Exception("Invalid Bitcoin address")

with open(os.path.join(DATA_FOLDER, "cases", order_id + ".json"), "r") as filename:
contract = json.load(filename, object_pairs_hook=OrderedDict)

if "dispute_resolution" not in contract:
if float(vendor_percentage) < 0 or float(moderator_percentage) < 0 or float(buyer_percentage) < 0:
raise Exception("Payouts percentages must be positive")
if float(vendor_percentage) + float(buyer_percentage) > 1:
raise Exception("Payout exceeds 100% of value")
if not self.protocol.multiplexer.blockchain.connected:
raise Exception("Libbitcoin server not online")
if not self.protocol.multiplexer.testnet and \
not (moderator_address[:1] == "1" or moderator_address[:1] == "3"):
raise Exception("Bitcoin address is not a mainnet address")
elif self.protocol.multiplexer.testnet and not \
(moderator_address[:1] == "n" or moderator_address[:1] == "m" or moderator_address[:1] == "2"):
raise Exception("Bitcoin address is not a testnet address")
try:
bitcointools.b58check_to_hex(moderator_address)
except AssertionError:
raise Exception("Invalid Bitcoin address")

buyer_address = contract["buyer_order"]["order"]["refund_address"]

buyer_guid = contract["buyer_order"]["order"]["id"]["guid"]
Expand Down

0 comments on commit c26fb93

Please sign in to comment.