|
14 | 14 | import pickle |
15 | 15 | import time |
16 | 16 | from binascii import unhexlify |
| 17 | +from bitcoin.core import COutPoint, lx |
17 | 18 | from collections import OrderedDict |
18 | 19 | from config import DATA_FOLDER, TRANSACTION_FEE |
19 | 20 | from dht.node import Node |
@@ -953,6 +954,14 @@ def release_funds(self, order_id): |
953 | 954 | This function should be called to release funds from a disputed contract after |
954 | 955 | the moderator has resolved the dispute and provided his signature. |
955 | 956 | """ |
| 957 | + def sort_outpoints(): |
| 958 | + o = [] |
| 959 | + for s in contract["dispute_resolution"]["resolution"]["tx_signatures"]: |
| 960 | + for outpoint in outpoints: |
| 961 | + if COutPoint(lx(outpoint["txid"]), outpoint["vout"]).encode("hex") == s["outpoint"]: |
| 962 | + o.append(outpoint) |
| 963 | + outpoints = o |
| 964 | + |
956 | 965 | if os.path.exists(os.path.join(DATA_FOLDER, "purchases", "in progress", order_id + ".json")): |
957 | 966 | file_path = os.path.join(DATA_FOLDER, "purchases", "in progress", order_id + ".json") |
958 | 967 | outpoints = json.loads(self.db.purchases.get_outpoint(order_id)) |
@@ -983,6 +992,10 @@ def release_funds(self, order_id): |
983 | 992 | ["resolution"]["vendor_payout"]) * 100000000)), |
984 | 993 | 'address': vendor_address}) |
985 | 994 |
|
| 995 | + for s in contract["dispute_resolution"]["resolution"]["tx_signatures"]: |
| 996 | + if "outpoint" in s: |
| 997 | + sort_outpoints() |
| 998 | + break |
986 | 999 | tx = BitcoinTransaction.make_unsigned(outpoints, outputs, testnet=self.protocol.multiplexer.testnet) |
987 | 1000 | chaincode = contract["buyer_order"]["order"]["payment"]["chaincode"] |
988 | 1001 | redeem_script = str(contract["buyer_order"]["order"]["payment"]["redeem_script"]) |
|
0 commit comments