@@ -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 ]:
0 commit comments