def printWallet(self): print "printWallet!" global tab1 try: qty = int(tab1.walletQuantity.get()) if(tab1.verPass.get() != tab1.walletPass.get()): print "Error, passwords don't match!" qrPopup = QRPopup() qrPopup.showAlert("Error, passwords don't match!") return remFlag = "" rKey = tab1.remKey.get() if(rKey == 1): remFlag = True elif(rKey == 2): remFlag = False else: #invalid option, return return remPrivFlag = "" rKey = tab1.remPrivKey.get() if(rKey == 1): remPrivFlag = True elif(rKey == 2): remPrivFlag = False else: #invalid option, return return Piper.genAndPrintKeys(remFlag, remPrivFlag, qty, tab1.walletPass.get()) except ValueError: print "Please enter an int!" qrPopup = QRPopup() qrPopup.showAlert("Error, enter an integer for the copies of wallet field!")
print "\t[numCopies]\tThe number of copies of the paper wallet that you want to print. A value of 1 would print 1 paper wallet, A value of 4 would print 4 identical paper wallets, etc." sys.exit(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); Piper.genAndPrintKeys(rememberKeys, rememberKeys, numCopies, "")
print "Options explained: " print "\t[-r | -f]\tSelect -r or -f to remember or forget the generated keys, respectively." print "\t[numCopies]\tThe number of copies of the paper wallet that you want to print. A value of 1 would print 1 paper wallet, A value of 4 would print 4 identical paper wallets, etc." sys.exit(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) Piper.genAndPrintKeys(rememberKeys, rememberKeys, numCopies, "")
import piper as Piper REMEMBER = True while True: # Read in coin values button_pressed = False # Read in button press if button_pressed: # vend bitcoin Piper.genAndPrintKeys(REMEMBER, REMEMBER, 1, "") UI.reset()
def printWallet(self): print "printWallet!" global tab1 try: qty = int(tab1.walletQuantity.get()) if(tab1.verPass.get() != tab1.walletPass.get()): print "Error, passwords don't match!" qrPopup = QRPopup() qrPopup.showAlert("Error, passwords don't match!") return remFlag = "" rKey = tab1.remKey.get() if(rKey == 1): remFlag = True elif(rKey == 2): remFlag = False else: #invalid option, return return remPrivFlag = "" rKey = tab1.remPrivKey.get() if(rKey == 1): remPrivFlag = True elif(rKey == 2): remPrivFlag = False else: #invalid option, return return remPWKey = tab1.remPW.get() if(remPWKey == 1): remPW = True elif(remPWKey == 2): remPW = False else: #invalid option, return return #get cointype con = None try: con = sqlite3.connect('/home/pi/Printer/settings.db3') cur = con.cursor() cur.execute("SELECT value FROM Settings WHERE Settings.key='cointype';") row = cur.fetchone() coinType = row[0] cur.execute("SELECT value FROM Settings WHERE Settings.key='randomPasswordLength';") row = cur.fetchone() randPwLength = row[0] cur.execute("SELECT value FROM Settings WHERE Settings.key='keyGenType';") row = cur.fetchone() keyGenType = row[0] except sqlite3.Error, e: print("Error %s:" % e.args[0]) sys.exit(1) finally: if con: con.commit() con.close() encKey = tab1.encKey.get() if(encKey == 3): #generate random password now pw = Piper.getRandPass(int(randPwLength)) tab1.walletPass.set(pw) tab1.verPass.set(pw) printPW = tab1.printPW.get() if(printPW == 1): Piper.genAndPrintKeysAndPass(remFlag, remPrivFlag, qty, tab1.walletPass.get(), coinType, remPW) elif(printPW == 2): Piper.genAndPrintKeys(remFlag, remPrivFlag, qty, tab1.walletPass.get(), coinType, remPW, keyGenType) else: #invalid option, return return
#check on the setting to automatically encrypt the private key #load settings from DB con = None try: con = sqlite3.connect('/home/pi/Printer/settings.db3') cur = con.cursor() cur.execute("SELECT key, value FROM Settings;") # heatTime, coinType, addrPrefix, encType FROM piper_settings LIMIT 1;") rows = cur.fetchall() settings = {} for row in rows: settings[row[0]] = row[1] except sqlite3.Error, e: print("Error %s:" % e.args[0]) sys.exit(1) finally: if con: con.commit() con.close() coinType = settings["cointype"] pw = "" if settings["headlessEnc"] == "1" and settings["keyGenType"] != "bip0032": pw = Piper.getRandPass(int(settings['randomPasswordLength'])) Piper.genAndPrintKeysAndPass(rememberKeys, rememberKeys, numCopies, pw, coinType, rememberKeys) else: Piper.genAndPrintKeys(rememberKeys, rememberKeys, numCopies, pw, coinType, rememberKeys, settings["keyGenType"])
d.pause() input = float(input) / 100 btc, usd = get_cur_exchange_rate() if not btc: time.sleep(2) continue lcd_display(lcd, "$" + "{:.2f}".format(input) + " Inserted", "1USD=B" + "{:.7f}".format(usd)) if command == ">": d.pause() input = float(input) / 100 returnAmt = usd * input lcd_display(lcd, "$" + "{:.2f}".format(input) + " Inserted", "Return " "{:.5f}".format(returnAmt)) time.sleep(2) pubkey = Piper.genAndPrintKeys(btc, input, 1, "", lcd) lcd_display(lcd, "DOEN! ^_^", " ") print pubkey time.sleep(2) d.resume() print "Stopping" d.stop() d.join() lcd.clear() if not args.debug: GPIO.cleanup() arduino.close() sys.exit(0)