Exemple #1
0
  def sendCoins(self):
    sendAmt = self.amountBox.get()            #Amount to send
    recvKey = self.recieverKey.get("1.0",'end-1c')   #recievers public key

    if not sendAmt:
      messagebox.showwarning("Warning", "Please enter a BitCoin amount.")
    elif len(recvKey) <= 1:
      messagebox.showwarning("Warning", "Please enter the receivers key.")
    else:
      result = messagebox.askyesno("Send Confirmation", 'Sending {} BitCoins to reciever:\n {}'.format(sendAmt, recvKey))

      if result:
        print('Sending {} BitCoins to reciever:\n {}'.format(sendAmt, recvKey))
        t = Transaction(owner=KeyStore.getPrivateKey(), callback=self.update_balance)
        
        try:
          pubKey = self.client.keyTable[recvKey]
        except:
          messagebox.showwarning('Address not found.', 'Oops. That PyCoin address could not be found.')
          return
        try:
          t.add_output(Transaction.Output(int(sendAmt), RSA.importKey(pubKey)))
        except:
          messagebox.showwarning('Insufficient funds.', 'Oops. It looks like you ran out of money. :(')
          return
        t.finish_transaction()

      self.amountBox.delete(0,END)
Exemple #2
0
 def initApp(self):
   #Connect Here
   self.client = P2PClientManager.getClient(port=random.randint(40000, 60000))
   self.client.subscribe(Message.NEW_TRANSACTION, self.update_balance)
   self.client.subscribe_to_info(self.update_status)
   t = threading.Thread(target=self.start_miner)
   t.start()
   if not self.db.hasRanBefore():
     c = CoinBase(owner=KeyStore.getPrivateKey(), amt=100)
     c.finish_transaction()
     self.db.setRanBefore()
     #messagebox.showinfo('Welcome', 'This is your first time running the app. You get to start off with 100 PyCoins!')
   #Get balance, Save to variable below
   self.coin_balance.set(str(KeyStore.get_balance()))
   print('PyCoin Address: ', SHA.new(KeyStore.getPublicKey().exportKey()).hexdigest())
   log.debug("GUI created")