diff --git a/cli.py b/cli.py index 7abcc76..e385f77 100644 --- a/cli.py +++ b/cli.py @@ -81,4 +81,5 @@ if __name__ == '__main__': erase_trade() role = 'seller' htlcTrade = Trade() - print("Creating new XCAT transaction...") + print("Creating new XCAT trade...") + seller_initiate(htlcTrade) diff --git a/database.py b/database.py index a452fa6..b923ac4 100644 --- a/database.py +++ b/database.py @@ -7,7 +7,8 @@ db = plyvel.DB('/tmp/testdb', create_if_missing=True) trade = get_trade() ## txid we retrieve by -txid = trade['sell']['fund_tx'] +if trade and 'sell' in trade: + txid = trade['sell']['fund_tx'] def create(hexstr): trade = hex2dict(hexstr) diff --git a/userInput.py b/userInput.py index 193ab14..be97d2f 100644 --- a/userInput.py +++ b/userInput.py @@ -1,7 +1,6 @@ from utils import * def get_trade_amounts(): - print("in user input") amounts = {} sell_currency = input("Which currency would you like to trade out of (bitcoin or zcash)? ") if sell_currency == '': diff --git a/utils.py b/utils.py index 59bf8da..a5d780a 100644 --- a/utils.py +++ b/utils.py @@ -66,8 +66,12 @@ def get_secret(): return line.strip('\n') def save_secret(secret): - with open('secret.json', 'w') as outfile: - outfile.write(secret) + try: + with open('secret.json', 'w') as outfile: + outfile.write(secret) + except IOError: + with open('secret.json', 'w+') as outfile: + outfile.write(secret) def save(trade): print("Saving trade")