2525from market .moderation import process_dispute
2626from market .profile import Profile
2727from market .protocol import MarketProtocol
28+ from market .transactions import BitcoinTransaction
2829from nacl .public import PrivateKey , PublicKey , Box
2930from protos import objects
3031from seed import peers
@@ -783,7 +784,10 @@ def close_dispute(self, order_id, resolution, buyer_percentage,
783784 raise Exception ("Libbitcoin server not online" )
784785 with open (DATA_FOLDER + "cases/" + order_id + ".json" , "r" ) as filename :
785786 contract = json .load (filename , object_pairs_hook = OrderedDict )
786- vendor_address = contract ["vendor_order_confirmation" ]["invoice" ]["payout" ]["address" ]
787+
788+ if "vendor_order_confirmation" in contract and float (vendor_percentage ) > 0 :
789+ vendor_address = contract ["vendor_order_confirmation" ]["invoice" ]["payout" ]["address" ]
790+
787791 buyer_address = contract ["buyer_order" ]["order" ]["refund_address" ]
788792
789793 buyer_guid = contract ["buyer_order" ]["order" ]["id" ]["guid" ]
@@ -808,9 +812,14 @@ def history_fetched(ec, history):
808812 for tx_type , txid , i , height , value in history : # pylint: disable=W0612
809813 if tx_type == obelisk .PointIdent .Output :
810814 satoshis += value
811- outpoint = txid .encode ("hex" ) + ":" + str (i )
812- if outpoint not in outpoints :
813- outpoints .append (outpoint )
815+ o = {
816+ "txid" : txid .encode ("hex" ),
817+ "vout" : i ,
818+ "value" : value ,
819+ "scriptPubKey" : "00"
820+ }
821+ if o not in outpoints :
822+ outpoints .append (o )
814823
815824 satoshis -= TRANSACTION_FEE
816825 moderator_fee = round (float (moderator_percentage * satoshis ))
@@ -830,7 +839,8 @@ def history_fetched(ec, history):
830839 dispute_json ["dispute_resolution" ]["resolution" ]["vendor_payout" ] = amt
831840 outputs .append ({'value' : amt ,
832841 'address' : vendor_address })
833- tx = bitcointools .mktx (outpoints , outputs )
842+ # FIXME: transactions need to take in multipe outputs now
843+ tx = BitcoinTransaction .make_unsigned (outpoints , payment_address )
834844 chaincode = contract ["buyer_order" ]["order" ]["payment" ]["chaincode" ]
835845 redeem_script = str (contract ["buyer_order" ]["order" ]["payment" ]["redeem_script" ])
836846 masterkey_m = bitcointools .bip32_extract_key (KeyChain (self .db ).bitcoin_master_privkey )
@@ -872,6 +882,7 @@ def parse_response(response):
872882 self .kserver .resolve (unhexlify (buyer_guid )).addCallback (get_node , buyer_guid , buyer_enc_key )
873883 self .db .Cases ().update_status (order_id , 1 )
874884
885+ # TODO: add a timeout on this call
875886 self .protocol .multiplexer .blockchain .fetch_history2 (payment_address , history_fetched )
876887 except Exception :
877888 pass
0 commit comments