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

Commit 2d61ca3

Browse files
committed
Fix refund broadcast
1 parent aff1a65 commit 2d61ca3

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

market/contracts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def add_order_confirmation(self,
486486
vendor_priv = derive_childkey(masterkey_v, chaincode, bitcointools.MAINNET_PRIVATE)
487487
tx.sign(vendor_priv)
488488
tx.broadcast(self.blockchain)
489-
self.log.info("Broadcasting payout tx %s to network" % tx.get_hash())
489+
self.log.info("broadcasting payout tx %s to network" % tx.get_hash())
490490
self.db.sales.update_payment_tx(order_id, tx.get_hash())
491491

492492
confirmation = json.dumps(conf_json["vendor_order_confirmation"]["invoice"], indent=4)
@@ -634,7 +634,7 @@ def add_receipt(self,
634634
receipt_json["buyer_receipt"]["receipt"]["payout"] = {}
635635
if tx.multisign(signatures, redeem_script):
636636
tx.broadcast(self.blockchain)
637-
self.log.info("Broadcasting payout tx %s to network" % tx.get_hash())
637+
self.log.info("broadcasting payout tx %s to network" % tx.get_hash())
638638
receipt_json["buyer_receipt"]["receipt"]["payout"]["txid"] = tx.get_hash()
639639

640640
receipt_json["buyer_receipt"]["receipt"]["payout"]["signature(s)"] = buyer_signatures
@@ -724,7 +724,7 @@ def accept_receipt(self, notification_listener, blockchain, receipt_json=None):
724724

725725
tx.multisign(signatures, redeem_script)
726726
tx.broadcast(self.blockchain)
727-
self.log.info("Broadcasting payout tx %s to network" % tx.get_hash())
727+
self.log.info("broadcasting payout tx %s to network" % tx.get_hash())
728728

729729
self.db.sales.update_payment_tx(order_id, tx.get_hash())
730730

market/network.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ def release_funds(self, order_id):
953953

954954
tx.multisign(signatures, redeem_script)
955955
tx.broadcast(self.protocol.multiplexer.blockchain)
956-
self.log.info("Broadcasting payout tx %s to network" % tx.get_hash())
956+
self.log.info("broadcasting payout tx %s to network" % tx.get_hash())
957957

958958
if self.db.purchases.get_purchase(order_id) is not None:
959959
self.db.purchases.update_status(order_id, 6)
@@ -1017,7 +1017,6 @@ def refund(self, order_id):
10171017
contract["buyer_order"]["order"]["id"]["pubkeys"]["guid"],
10181018
encoder=nacl.encoding.HexEncoder).to_curve25519_public_key()
10191019
refund_address = contract["buyer_order"]["order"]["refund_address"]
1020-
redeem_script = contract["buyer_order"]["order"]["payment"]["redeem_script"]
10211020
tx = BitcoinTransaction.make_unsigned(outpoints, refund_address,
10221021
testnet=self.protocol.multiplexer.testnet)
10231022
chaincode = contract["buyer_order"]["order"]["payment"]["chaincode"]
@@ -1027,14 +1026,25 @@ def refund(self, order_id):
10271026
refund_json = {"refund": {}}
10281027
refund_json["refund"]["order_id"] = order_id
10291028
if "moderator" in contract["buyer_order"]["order"]:
1029+
redeem_script = contract["buyer_order"]["order"]["payment"]["redeem_script"]
10301030
sigs = tx.create_signature(vendor_priv, redeem_script)
10311031
refund_json["refund"]["value"] = round(tx.get_out_value() / float(100000000), 8)
10321032
refund_json["refund"]["signature(s)"] = sigs
10331033
else:
10341034
tx.sign(vendor_priv)
10351035
tx.broadcast(self.protocol.multiplexer.blockchain)
1036+
self.log.info("broadcasting refund tx %s to network" % tx.get_hash())
10361037
refund_json["refund"]["txid"] = tx.get_hash()
10371038

1039+
contract["refund"] = refund_json["refund"]
1040+
self.db.sales.update_status(order_id, 7)
1041+
file_path = DATA_FOLDER + "store/contracts/trade receipts/" + order_id + ".json"
1042+
with open(file_path, 'w') as outfile:
1043+
outfile.write(json.dumps(contract, indent=4))
1044+
file_path = DATA_FOLDER + "store/contracts/in progress/" + order_id + ".json"
1045+
if os.path.exists(file_path):
1046+
os.remove(file_path)
1047+
10381048
def get_node(node_to_ask):
10391049
def parse_response(response):
10401050
if not response[0]:

market/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def rpc_refund(self, sender, pubkey, encrypted):
392392

393393
tx.multisign(signatures, redeem_script)
394394
tx.broadcast(self.multiplexer.blockchain)
395-
self.log.info("Broadcasting refund tx %s to network" % tx.get_hash())
395+
self.log.info("broadcasting refund tx %s to network" % tx.get_hash())
396396

397397
self.db.sales.update_status(order_id, 7)
398398
file_path = DATA_FOLDER + "purchases/trade receipts/" + order_id + ".json"

market/transactions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def broadcast(self, libbitcoin_client):
135135
libbitcoin_server: an `obelisk.Libbitcoin_client` object.
136136
"""
137137
libbitcoin_client.broadcast(self.to_raw_tx())
138-
self.log.info("Broadcasting payout tx %s to network" % b2lx(self.tx.GetHash()))
139138

140139
def check_for_funding(self, address):
141140
"""

0 commit comments

Comments
 (0)