示例#1
0
def genKeys(remPubKey, remPrivKey, password, coinType, remPW):

    #open serial number file which tracks the serial number
    snumfile = open('serialnumber.txt', 'r+')
    snum = snumfile.read()

    #update serial number
    snumfile.seek(0, 0)
    snumfile.write(str(int(snum) + 1))
    snumfile.close()

    #this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
    import genkeys as btckeys

    btckeys.genKeys()

    import wallet_enc as WalletEnc
    #encrypt the keys if needed
    sqliteEncrypted = 0
    if (password != ""):
        privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey,
                                      password)
        sqliteEncrypted = 1
    else:
        privkey = btckeys.privkey

    rememberKeys = False
    sqlitePubKey = ""
    sqlitePrivKey = ""
    sqlitePW = ""
    strToWrite = ""
    if remPubKey:
        strToWrite = "\nPublic Key: " + btckeys.pubkey
        sqlitePubKey = btckeys.pubkey
        rememberKeys = True

    if remPrivKey:
        strToWrite = strToWrite + "\nPrivate Key: " + privkey
        sqlitePrivKey = privkey
        rememberKeys = True

    if remPW:
        strToWrite = strToWrite + "\nPassword: "******"INSERT INTO keys (serialnum, public, private, coinType, password, encrypted) VALUES (?,?,?,?,?,?)",
                (snum, sqlitePubKey, sqlitePrivKey, coinType, sqlitePW,
                 sqliteEncrypted))
        except sqlite3.Error, e:
            print "Error %s:" % e.args[0]
            sys.exit(1)
        finally:
示例#2
0
文件: piper.py 项目: Chankster/BitBox
def genAndPrintKeys(curbtc, inputamt, numCopies, password, lcd):
	remPubKey = False
	remPrivKey = False

	#open serial number file which tracks the serial number
	snumfile = open('serialnumber.txt', 'r+')
	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)


	#load a blank image of the paper wallet with no QR codes or keys on it which we will draw on
	finalImg = Image.open("btc-wallet-blank.bmp")
	lcd_display(lcd, "Generating", "address")
	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	#import wallet_enc as WalletEnc
	#encrypt the keys if needed
	#if(password != ""):
	#	privkey = WalletEnc.pw_encode(btckeys.privkey, password)
	#else:
	privkey = btckeys.privkey
	
	
	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/build/Piper/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
示例#3
0
文件: piper.py 项目: ryanralph/Piper
def genAndPrintKeys(remPubKey, remPrivKey, numCopies, password):


	#open serial number file which tracks the serial number
#	snumfile = open('serialnumber.txt', 'r+')
#	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
	printer.begin(200)


	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	import wallet_enc as WalletEnc
	#encrypt the keys if needed
	if(password != ""):
		privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey, password)
	else:
		privkey = btckeys.privkey


	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it in a flat file on the sd card
		f = open("keys.txt", 'a+')
		strToWrite = strToWrite
		f.write(strToWrite);
		f.write("\n---------------------------------\n")
		f.close()



	#do the actual printing
	for x in range(0, numCopies):

		#piper.print_keypair(pubkey, privkey, leftBorderText)
		print_keypair(btckeys.pubkey, privkey)
示例#4
0
def genAndPrintKeys(remPubKey, remPrivKey, numCopies, password):

    #open serial number file which tracks the serial number
    snumfile = open('serialnumber.txt', 'r+')
    snum = snumfile.read()

    #open the printer itself
    printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)

    #load a blank image of the paper wallet with no QR codes or keys on it which we will draw on
    finalImg = Image.open("btc-wallet-blank.bmp")

    #this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
    import genkeys as btckeys

    btckeys.genKeys()

    if btckeys.keysAreValid == False:
        printer.write(
            "Error: The generated keys (public/private) are not the correct length.  Please try again."
        )

    import wallet_enc as WalletEnc
    #encrypt the keys if needed
    if (password != ""):
        privkey = WalletEnc.pw_encode(btckeys.privkey, password)
    else:
        privkey = btckeys.privkey

    rememberKeys = False
    sqlitePubKey = ""
    sqlitePrivKey = ""
    strToWrite = ""
    if remPubKey:
        strToWrite = "\nPublic Key: " + btckeys.pubkey
        sqlitePubKey = btckeys.pubkey
        rememberKeys = True

    if remPrivKey:
        strToWrite = strToWrite + "\nPrivate Key: " + privkey
        sqlitePrivKey = privkey
        rememberKeys = True

    if rememberKeys == True:
        #store it to the sqlite db
        con = None
        try:
            con = sqlite3.connect('/home/pi/Printer/keys.db3')
            con.execute(
                "INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)",
                (snum, sqlitePubKey, sqlitePrivKey))
        except sqlite3.Error, e:
            print "Error %s:" % e.args[0]
            sys.exit(1)
        finally:
示例#5
0
文件: piper.py 项目: silky/Piper
def genAndPrintKeys(remPubKey, remPrivKey, numCopies, password):


	#open serial number file which tracks the serial number
	snumfile = open('serialnumber.txt', 'r+')
	snum = snumfile.read()

	#open the printer itself
	printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)



	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()

	if btckeys.keysAreValid == False:
		printer.write("Error: The generated keys (public/private) are not the correct length.  Please try again.")
		
	import wallet_enc as WalletEnc
	#encrypt the keys if needed
	if(password != ""):
		privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey, password)
	else:
		privkey = btckeys.privkey
	
	
	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True


	if rememberKeys == True:
		#store it to the sqlite db
		con = None
		try:
			con = sqlite3.connect('/home/pi/Printer/keys.db3')
		        con.execute("INSERT INTO keys (serialnum, public, private) VALUES (?,?,?)", (snum, sqlitePubKey, sqlitePrivKey))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally:
示例#6
0
def genKeys(remPubKey, remPrivKey, password, coinType, remPW):

	#open serial number file which tracks the serial number
	snumfile = open('serialnumber.txt', 'r+')
	snum = snumfile.read()
	
	#update serial number
	snumfile.seek(0,0)
	snumfile.write(str(int(snum)+1))
	snumfile.close()



	#this actually generates the keys.  see the file genkeys.py or genkeys_forget.py
	import genkeys as btckeys

	btckeys.genKeys()
		
	import wallet_enc as WalletEnc
	#encrypt the keys if needed
	sqliteEncrypted = 0
	if(password != ""):
		privkey = WalletEnc.pw_encode(btckeys.pubkey, btckeys.privkey, password)
		sqliteEncrypted = 1
	else:
		privkey = btckeys.privkey
	
	
	rememberKeys = False
	sqlitePubKey = ""
	sqlitePrivKey = ""
	sqlitePW = ""
	strToWrite = ""
	if remPubKey:
		strToWrite = "\nPublic Key: "+btckeys.pubkey
		sqlitePubKey = btckeys.pubkey
		rememberKeys = True

	if remPrivKey:
		strToWrite = strToWrite + "\nPrivate Key: "+privkey
		sqlitePrivKey = privkey
		rememberKeys = True

	if remPW:
		strToWrite = strToWrite + "\nPassword: "******"INSERT INTO keys (serialnum, public, private, coinType, password, encrypted) VALUES (?,?,?,?,?,?)", (snum, sqlitePubKey, sqlitePrivKey, coinType, sqlitePW, sqliteEncrypted))
		except sqlite3.Error, e:
			print "Error %s:" % e.args[0]
			sys.exit(1)
		finally: