Beispiel #1
0
def main_loop(ui):
    transaction = {"penny": 0, "dime": 0, "quarter": 0, "nickel": 0, "total": 0}
    while True:
        logger.info("Updating exchange rate")
        update_exchange_rates(ui, totals["all"])
        transaction = waitForButton(ui, transaction)
        totals["all"] += transaction["total"]
        totals["penny"] += transaction["penny"]
        totals["nickel"] += transaction["nickel"]
        totals["dime"] += transaction["dime"]
        totals["quarter"] += transaction["quarter"]
        logger.info("Total amount inserted: {0}USD".format(locale.currency(transaction["total"])))

        with open("totals.json", "w") as total_file:
            total_file.write(json.dumps(totals))
            # get a keypair
        pubkey, privkey, snum = piper.genKeys()
        text = "Public Key: {0}\nPrivate Key: {1}\nSerial Number: {2}\n".format(pubkey, privkey, snum) + "-" * 20 + "\n"
        logger.info(text)
        with open("keys.txt", "a+") as key_file:
            key_file.write(text)
        leftMarkText = "Serial Number: {0}".format(snum)
        ui.display_message("Sending transaction!")
        if DEBUGGING:
            logger.debug("JK we're not actually sending it")
            transaction = {"penny": 0, "dime": 0, "quarter": 0, "nickel": 0, "total": 0}
            piper.print_keypair(pubkey, privkey, leftMarkText)
            continue
        response = send_coins(pubkey, transaction["total"], snum)
        if response == None:
            logger.info("Not enough money! Send refund of {0:}".format(locale.currency(transaction["total"])))
            minimum = btc_to_usd * (0.00005460 + COINBASE_MIN_TX_FEE)
            ui.display_message(
                "Not enough money!\nMinimum is {0}USD\nPlease try again!".format(locale.currency(minimum))
            )
            time.sleep(2)
            continue
        elif response["success"]:
            # do the actual printing
            coinbase_tx = response["transaction"]
            ui.display_message("Transaction successful!\nPrinting wallet\nPlease wait...")
            logger.info("Successful transaction: {0}".format(coinbase_tx["id"]))
            logger.info("Printing wallet, please wait")
            piper.print_keypair(pubkey, privkey, leftMarkText)
            logger.info("resetting values")
            transaction = {"penny": 0, "dime": 0, "quarter": 0, "nickel": 0, "total": 0}
        else:
            logger.error("Something is very wrong!")
            logger.info("You should probably refund", transaction["total"])
            ui.display_message("Transaction Failure. :-(")
            logger.info(response)
Beispiel #2
0
	def reprint(self, event):
		#print_keypair(pubkey, privkey, leftBorderText)
		Piper.print_keypair(event.widget.pubkey, event.widget.privkey, "Serial Number: "+str(event.widget.serialnum))
Beispiel #3
0
#check for proper number of arguments
if len(sys.argv) != 3:
	printUsageAndExit()

#check for remember or forget flag
if sys.argv[1] == "-r":
	rememberKeys = True
elif sys.argv[1] == "-f":
	rememberKeys = False
else:
	printUsageAndExit()


#try to parse the number of copies
try:
	numCopies = int(sys.argv[2])
except ValueError:
	printUsageAndExit()

#make sure the number of copies to print is valid
if numCopies <= 0:
	print "The number of copies must be >= 0"
	sys.exit(0);

# get a keypair
pubkey, privkey, snum = Piper.genKeys()
leftMarkText = "Serial Number: {0}".format(snum)
# do the actual printing
Piper.print_keypair(pubkey, privkey, leftMarkText)

Beispiel #4
0
	def reprint(self, event):
		#print_keypair(pubkey, privkey, leftBorderText)
		Piper.print_keypair(event.widget.pubkey, event.widget.privkey, "Serial Number: "+str(event.widget.serialnum), event.widget.coinType)