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

Commit aff1a65

Browse files
committed
Fix bug releasing funds after dispute
1 parent afc72f5 commit aff1a65

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

api/restapi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from twisted.protocols.basic import FileSender
1919

2020
from config import DATA_FOLDER, RESOLVER, LIBBITCOIN_SERVER_TESTNET, LIBBITCOIN_SERVER, \
21-
set_value, get_value, str_to_bool
21+
set_value, get_value, str_to_bool, TRANSACTION_FEE
2222
from protos.countries import CountryCode
2323
from protos import objects
2424
from keys import blockchainid
@@ -858,7 +858,8 @@ def get_settings(self, request):
858858
"terms_conditions": "" if settings[9] is None else settings[9],
859859
"refund_policy": "" if settings[10] is None else settings[10],
860860
"resolver": get_value("CONSTANTS", "RESOLVER"),
861-
"network_connection": nat_type
861+
"network_connection": nat_type,
862+
"transaction_fee": TRANSACTION_FEE
862863
}
863864
mods = []
864865
try:

market/network.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import nacl.utils
1212
import obelisk
1313
import os.path
14-
import pickle
1514
import time
1615
from binascii import unhexlify
1716
from collections import OrderedDict
@@ -906,35 +905,34 @@ def release_funds(self, order_id):
906905
the moderator has resolved the dispute and provided his signature.
907906
"""
908907
if os.path.exists(DATA_FOLDER + "purchases/in progress/" + order_id + ".json"):
909-
file_path = DATA_FOLDER + "purchases/trade receipts/" + order_id + ".json"
910-
outpoints = pickle.loads(self.db.purchases.get_outpoint(order_id))
908+
file_path = DATA_FOLDER + "purchases/in progress/" + order_id + ".json"
909+
outpoints = json.loads(self.db.purchases.get_outpoint(order_id))
911910
elif os.path.exists(DATA_FOLDER + "store/contracts/in progress/" + order_id + ".json"):
912911
file_path = DATA_FOLDER + "store/contracts/in progress/" + order_id + ".json"
913-
outpoints = pickle.loads(self.db.sales.get_outpoint(order_id))
912+
outpoints = json.loads(self.db.sales.get_outpoint(order_id))
914913

915914
with open(file_path, 'r') as filename:
916915
contract = json.load(filename, object_pairs_hook=OrderedDict)
917916

918-
vendor_address = contract["vendor_order_confirmation"]["invoice"]["payout"]["address"]
919-
buyer_address = contract["buyer_order"]["order"]["refund_address"]
920-
921917
outputs = []
922918

923919
outputs.append({'value': int(float(contract["dispute_resolution"]
924920
["resolution"]["moderator_fee"]) * 100000000),
925921
'address': contract["dispute_resolution"]["resolution"]["moderator_address"]})
926922

927923
if "buyer_payout" in contract["dispute_resolution"]["resolution"]:
924+
buyer_address = contract["buyer_order"]["order"]["refund_address"]
928925
outputs.append({'value': int(float(contract["dispute_resolution"]
929926
["resolution"]["buyer_payout"]) * 100000000),
930927
'address': buyer_address})
931928

932929
if "vendor_payout" in contract["dispute_resolution"]["resolution"]:
930+
vendor_address = contract["vendor_order_confirmation"]["invoice"]["payout"]["address"]
933931
outputs.append({'value': int(float(contract["dispute_resolution"]
934932
["resolution"]["vendor_payout"]) * 100000000),
935933
'address': vendor_address})
936934

937-
tx = BitcoinTransaction.make_unsigned(outpoints, outputs)
935+
tx = BitcoinTransaction.make_unsigned(outpoints, outputs, testnet=self.protocol.multiplexer.testnet)
938936
chaincode = contract["buyer_order"]["order"]["payment"]["chaincode"]
939937
redeem_script = str(contract["buyer_order"]["order"]["payment"]["redeem_script"])
940938
masterkey = bitcointools.bip32_extract_key(KeyChain(self.db).bitcoin_master_privkey)
@@ -993,8 +991,6 @@ def get_result(result):
993991
pass
994992
return ret
995993
except Exception:
996-
import traceback
997-
traceback.print_exc()
998994
return None
999995

1000996
if node_to_ask.ip is None:
@@ -1011,7 +1007,7 @@ def refund(self, order_id):
10111007
to the buyer with contain the signature.
10121008
"""
10131009
file_path = DATA_FOLDER + "store/contracts/in progress/" + order_id + ".json"
1014-
outpoints = pickle.loads(self.db.sales.get_outpoint(order_id))
1010+
outpoints = json.loads(self.db.sales.get_outpoint(order_id))
10151011

10161012
with open(file_path, 'r') as filename:
10171013
contract = json.load(filename, object_pairs_hook=OrderedDict)

openbazaard.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,7 @@ def start(self):
228228
parser.add_argument('--pidfile', help="name of the pid file", default="openbazaard.pid")
229229
args = parser.parse_args(sys.argv[2:])
230230

231-
OKBLUE = '\033[94m'
232-
ENDC = '\033[0m'
233-
print "________ " + OKBLUE + " __________" + ENDC
234-
print "\_____ \ ______ ____ ____" + OKBLUE + \
235-
"\______ \_____ _____________ _____ _______" + ENDC
236-
print " / | \\\____ \_/ __ \ / \\" + OKBLUE +\
237-
"| | _/\__ \ \___ /\__ \ \__ \\\_ __ \ " + ENDC
238-
print "/ | \ |_> > ___/| | \ " + OKBLUE \
239-
+ "| \ / __ \_/ / / __ \_/ __ \| | \/" + ENDC
240-
print "\_______ / __/ \___ >___| /" + OKBLUE + "______ /(____ /_____ \(____ (____ /__|" + ENDC
241-
print " \/|__| \/ \/ " + OKBLUE + " \/ \/ \/ \/ \/" + ENDC
242-
print
243-
print "OpenBazaar Server v0.1 starting..."
231+
self.print_splash_screen()
244232

245233
unix = ("linux", "linux2", "darwin")
246234

@@ -284,4 +272,20 @@ def restart(self):
284272
print "Restarting OpenBazaar server..."
285273
self.daemon.restart()
286274

275+
@staticmethod
276+
def print_splash_screen():
277+
OKBLUE = '\033[94m'
278+
ENDC = '\033[0m'
279+
print "________ " + OKBLUE + " __________" + ENDC
280+
print "\_____ \ ______ ____ ____" + OKBLUE + \
281+
"\______ \_____ _____________ _____ _______" + ENDC
282+
print " / | \\\____ \_/ __ \ / \\" + OKBLUE +\
283+
"| | _/\__ \ \___ /\__ \ \__ \\\_ __ \ " + ENDC
284+
print "/ | \ |_> > ___/| | \ " + OKBLUE \
285+
+ "| \ / __ \_/ / / __ \_/ __ \| | \/" + ENDC
286+
print "\_______ / __/ \___ >___| /" + OKBLUE + "______ /(____ /_____ \(____ (____ /__|" + ENDC
287+
print " \/|__| \/ \/ " + OKBLUE + " \/ \/ \/ \/ \/" + ENDC
288+
print
289+
print "OpenBazaar Server v0.1 starting..."
290+
287291
Parser(OpenBazaard('/tmp/openbazaard.pid'))

0 commit comments

Comments
 (0)