diff --git a/contract.json b/contract.json index 5c40c4b..3a67382 100644 --- a/contract.json +++ b/contract.json @@ -1 +1 @@ -{"t2QrLFUqmp1v1xQSE3hmgwcYuinRb3BRWMm": {"funder": "tmTjZSg4pX2Us6V5HttiwFZwj464fD2ZgpY", "redeemer": "tmFRXyju7ANM7A9mg75ZjyhFW1UJEhUPwfQ", "redeemblocknum": 182, "zec_redeemScript": "63a820343e398e4e99a68e7de6ec57f00b6a14a8e6d0a7dd714efbab4dcbd385f4f3038876a9143ea29256c9d2888ca23de42a8b8e69ca2ec235b16702b600b17576a914c5acca6ef39c843c7a9c3ad01b2da95fe2edf5ba6888ac", "p2sh": "t2QrLFUqmp1v1xQSE3hmgwcYuinRb3BRWMm"}, "2MuWU5BpLpqJvvzkCPq8gFHA4VFFGyvjaJf": {"funder": "myfFr5twPYNwgeXyjCmGcrzXtCmfmWXKYp", "redeemer": "mrQzUGU1dwsWRx5gsKKSDPNtrsP65vCA3Z", "redeemblocknum": 146, "zec_redeemScript": "63a820343e398e4e99a68e7de6ec57f00b6a14a8e6d0a7dd714efbab4dcbd385f4f3038876a9147788b4511a25fba1092e67b307a6dcdb6da125d967029200b17576a914c7043e62a7391596116f54f6a64c8548e97d3fd96888ac", "p2sh": "2MuWU5BpLpqJvvzkCPq8gFHA4VFFGyvjaJf"}} \ No newline at end of file +{"t2N7TKhb8wwn5d3dyXGj7jfaLLgqJnj44A4": {"redeemer": "tmFRXyju7ANM7A9mg75ZjyhFW1UJEhUPwfQ", "funder": "tmTjZSg4pX2Us6V5HttiwFZwj464fD2ZgpY", "zec_redeemScript": "63a820e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8558876a9143ea29256c9d2888ca23de42a8b8e69ca2ec235b16702b600b17576a914c5acca6ef39c843c7a9c3ad01b2da95fe2edf5ba6888ac", "redeemblocknum": 182, "p2sh": "t2N7TKhb8wwn5d3dyXGj7jfaLLgqJnj44A4"}, "2N6MPUmxjqeKtG99zMPekT9jr8U64TPZVrA": {"redeemer": "mrQzUGU1dwsWRx5gsKKSDPNtrsP65vCA3Z", "funder": "myfFr5twPYNwgeXyjCmGcrzXtCmfmWXKYp", "zec_redeemScript": "63a820e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b8558876a9147788b4511a25fba1092e67b307a6dcdb6da125d967029200b17576a914c7043e62a7391596116f54f6a64c8548e97d3fd96888ac", "redeemblocknum": 146, "p2sh": "2N6MPUmxjqeKtG99zMPekT9jr8U64TPZVrA"}} \ No newline at end of file diff --git a/xcat.json b/xcat.json index da70bd3..e1f96f9 100644 --- a/xcat.json +++ b/xcat.json @@ -1 +1 @@ -{"id": 1, "buy": {"initiator": "tmFRXyju7ANM7A9mg75ZjyhFW1UJEhUPwfQ", "fund_tx": "9df973f468ce0b4398a9db2e8710b0ec268a3b3118f996f67f808af97e53a161", "fulfiller": "tmTjZSg4pX2Us6V5HttiwFZwj464fD2ZgpY", "p2sh": "t2QrLFUqmp1v1xQSE3hmgwcYuinRb3BRWMm", "amount": 1.2, "currency": "zcash"}, "sell": {"status": "funded", "fund_tx": "d1f679a3ee51fd563224e8114bed1d79fa6dc54d48163ec12ba17ba1d9e76baa", "p2sh": "2MuWU5BpLpqJvvzkCPq8gFHA4VFFGyvjaJf", "fulfiller": "mrQzUGU1dwsWRx5gsKKSDPNtrsP65vCA3Z", "initiator": "myfFr5twPYNwgeXyjCmGcrzXtCmfmWXKYp", "amount": 3.5, "currency": "bitcoin", "secret": "rabbits"}} \ No newline at end of file +{"sell": {"fulfiller": "mrQzUGU1dwsWRx5gsKKSDPNtrsP65vCA3Z", "currency": "bitcoin", "amount": 3.5, "initiator": "myfFr5twPYNwgeXyjCmGcrzXtCmfmWXKYp", "fund_tx": "6421178f62cdb3e1a8b7809d7c428254e26739e50fa8cdeceb20703497ba5b12", "status": "funded", "secret": "", "p2sh": "2N6MPUmxjqeKtG99zMPekT9jr8U64TPZVrA"}, "id": 1, "buy": {"fulfiller": "tmTjZSg4pX2Us6V5HttiwFZwj464fD2ZgpY", "amount": 1.2, "currency": "zcash", "initiator": "tmFRXyju7ANM7A9mg75ZjyhFW1UJEhUPwfQ", "p2sh": "t2N7TKhb8wwn5d3dyXGj7jfaLLgqJnj44A4"}} \ No newline at end of file diff --git a/xcat.py b/xcat.py index c73984b..6d50bd7 100644 --- a/xcat.py +++ b/xcat.py @@ -18,13 +18,15 @@ def check_p2sh(currency, address): def set_price(): trade = {} #TODO: make currencies interchangeable. Save to a tuple? - sell = input("Which currency would you like to trade out of? (bitcoin)") - sell = 'bitcoin' - buy = 'zcash' - sell_amt = input("How much {0} do you want to sell?".format(sell)) + sell = input("Which currency would you like to trade out of (bitcoin or zcash)? ") + if sell == 'bitcoin': + buy = 'zcash' + else: + buy = 'bitcoin' + sell_amt = input("How much {0} do you want to sell? ".format(sell)) sell_amt = 3.5 print(sell_amt) - buy_amt = input("How much {0} do you want to receive in exchange?".format(buy)) + buy_amt = input("How much {0} do you want to receive in exchange? ".format(buy)) buy_amt = 1.2 print(buy_amt) sell = {'currency': sell, 'amount': sell_amt} @@ -197,7 +199,7 @@ def buyer_redeem(): save_trade(trade) def print_trade(role): - print("Trade status:") + print("\nTrade status:") trade = get_trade() if role == 'seller': pprint(trade) @@ -207,6 +209,7 @@ def print_trade(role): if __name__ == '__main__': print("ZEC <-> BTC XCAT (Cross-Chain Atomic Transactions)") + print("=" * 50) # TODO: Get trade indicated by id number # TODO: pass trade into functions? # TODO: workflow framed as currency you're trading out of being sell. appropriate? @@ -218,6 +221,7 @@ if __name__ == '__main__': erase_trade() role = 'seller' trade = get_trade() + print("Creating new XCAT transaction...") else: role = sys.argv[1] print("Your role in demo:", role) @@ -248,7 +252,7 @@ if __name__ == '__main__': elif 'status' in trade['sell']: if 'fund_tx' in trade['buy']: # Means buyer has already funded the currency the transaction initiator wants to exchange into - print("Buyer funded the contract where you offered to buy {0}, redeeming funds from {1}...".format(trade['buy']['currency'], trade['buy']['p2sh'])) + input("Buyer funded the contract where you offered to buy {0}, type 'enter' to redeem {1} {0} from {2}.".format(trade['buy']['currency'], trade['buy']['amount'], trade['buy']['p2sh'])) seller_redeem() print("You have redeemed {0} {1}!".format(trade['buy']['amount'], trade['buy']['currency'])) print_trade('seller') @@ -268,7 +272,7 @@ if __name__ == '__main__': print_trade('buyer') elif trade['buy']['status'] == 'redeemed': # Seller has redeemed buyer's tx, buyer can now redeem. - print("The seller has redeemed the contract where you paid them in {0}, now redeeming your funds from {1}".format(trade['buy']['currency'], trade['sell']['p2sh'])) + input("Buyer funded the contract where you paid them in {0} to buy {1}, type 'enter' to redeem {2} {1} from {3}.".format(trade['buy']['currency'], trade['sell']['currency'], trade['buy']['amount'], trade['buy']['p2sh'])) buyer_redeem() print("XCAT trade complete!") print_trade('buyer')