Example #1
0
 def clickedDoIt(self):
    isBackupCreated = False
    if self.passphrase:
       self.wlt.unlock(securePassphrase=SecureBinaryData(self.passphrase))
    if self.optPaperBackupOne.isChecked():
       isBackupCreated = OpenPaperBackupWindow('Single', self.parent(), self.main, self.wlt)
    elif self.optPaperBackupFrag.isChecked():
       isBackupCreated = OpenPaperBackupWindow('Frag', self.parent(), self.main, self.wlt)
    elif self.optDigitalBackupPlain.isChecked():
       if self.main.digitalBackupWarning():
          isBackupCreated = self.main.makeWalletCopy(self, self.wlt, 'Decrypt', 'decrypt')
    elif self.optDigitalBackupCrypt.isChecked():
       isBackupCreated = self.main.makeWalletCopy(self, self.wlt, 'Encrypt', 'encrypt')
    elif self.optIndivKeyListTop.isChecked():
       if self.wlt.useEncryption and self.wlt.isLocked:
          dlg = DlgUnlockWallet(self.wlt, self, self.main, 'Unlock Private Keys')
          if not dlg.exec_():
             if self.main.usermode == USERMODE.Expert:
                QMessageBox.warning(self, tr('Unlock Failed'), tr("""
                   Wallet was not be unlocked.  The public keys and addresses
                   will still be shown, but private keys will not be available
                   unless you reopen the dialog with the correct passphrase."""), \
                   QMessageBox.Ok)
             else:
                QMessageBox.warning(self, tr('Unlock Failed'), tr("""
                   'Wallet could not be unlocked to display individual keys."""), \
                   QMessageBox.Ok)
                if self.main.usermode == USERMODE.Standard:
                   return
       DlgShowKeyList(self.wlt, self.parent(), self.main).exec_()
       isBackupCreated = True
    if isBackupCreated:
       self.isBackupCreated = True
      def sendDust():
         try:
            utxiList = []
            for utxo in self.dustTableModel.dustTxOutlist:
               # The PyCreateAndSignTx method require PyTx and PyBtcAddress objects
               rawTx = TheBDM.getTxByHash(utxo.getTxHash()).serialize()
               a160 = CheckHash160(utxo.getRecipientScrAddr())
               for pyAddr in self.dustTableModel.wlt.addrMap.values():
                  if a160 == pyAddr.getAddr160():
                     pubKey = pyAddr.binPublicKey65.toBinStr()
                     txoIdx = utxo.getTxOutIndex()
                     utxiList.append(UnsignedTxInput(rawTx, txoIdx, None, pubKey))
                     break
            # Make copies, destroy them in the finally clause
            privKeyMap = {}
            for addrObj in self.dustTableModel.wlt.addrMap.values():
               scrAddr = SCRADDR_P2PKH_BYTE + addrObj.getAddr160()
               if self.dustTableModel.wlt.useEncryption and self.dustTableModel.wlt.isLocked:
                  # Target wallet is encrypted...
                  unlockdlg = DlgUnlockWallet(self.dustTableModel.wlt,
                        self.main, self.main, 'Unlock Wallet to Import')
                  if not unlockdlg.exec_():
                     QMessageBox.critical(self, 'Wallet is Locked', \
                        'Cannot send dust without unlocking the wallet!', \
                        QMessageBox.Ok)
                     return
               privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
            signedTx = PyCreateAndSignTx(utxiList,
                  [],
                  privKeyMap, SIGHASH_NONE|SIGHASH_ANYONECANPAY )
            
            print "-------------"
            print binary_to_hex(signedTx.serialize())
            
            # sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
            # sock.send(signedTx.serialize())
            # sock.send(b'\n')
            # sock.close()
                  

         except socket.error as err:
            QMessageBox.critical(self.main, tr('Negative Value'), tr("""
               Failed to connect to dust-b-gone server: %s""" % err.strerror), QMessageBox.Ok)            
         except NegativeValueError:
            QMessageBox.critical(self.main, tr('Negative Value'), tr("""
               You must enter a positive value of at least 0.0000 0001 
               and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
         except TooMuchPrecisionError:
            QMessageBox.critical(self.main.main, tr('Too much precision'), tr("""
               Bitcoins can only be specified down to 8 decimal places. 
               The smallest unit of a Groestlcoin is 0.0000 0001 GRS.
               Please enter a dust limit of at least 0.0000 0001 and less than %s.""" % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
         finally:
            for scraddr in privKeyMap:
               privKeyMap[scraddr].destroy()
Example #3
0
 def getPrivateKeyFromAddrInput(self):
    addr160 = addrStr_to_hash160(str(self.addressLineEdit.text()))
    walletId = self.main.getWalletForAddr160(addr160)
    wallet = self.main.walletMap[walletId]
    if wallet.useEncryption and wallet.isLocked:
       # Target wallet is encrypted...
       unlockdlg = DlgUnlockWallet(wallet, self, self.main, 'Unlock Wallet to Import')
       if not unlockdlg.exec_():
          QMessageBox.critical(self, 'Wallet is Locked', \
             'Cannot import private keys without unlocking wallet!', \
             QMessageBox.Ok)
          return
    return wallet.addrMap[addr160].binPrivKey32_Plain.toBinStr()
Example #4
0
 def getPrivateKeyFromAddrInput(self):
     addr160 = addrStr_to_hash160(str(self.addressLineEdit.text()))
     walletId = self.main.getWalletForAddr160(addr160)
     wallet = self.main.walletMap[walletId]
     if wallet.useEncryption and wallet.isLocked:
         # Target wallet is encrypted...
         unlockdlg = DlgUnlockWallet(wallet, self, self.main,
                                     'Unlock Wallet to Import')
         if not unlockdlg.exec_():
             QMessageBox.critical(self, 'Wallet is Locked', \
                'Cannot import private keys without unlocking wallet!', \
                QMessageBox.Ok)
             return
     return wallet.addrMap[addr160].binPrivKey32_Plain.toBinStr()
Example #5
0
   def getPrivateKeyFromAddrInput(self):
      atype, addr160 = addrStr_to_hash160(str(self.addressLineEdit.text()))
      if atype==P2SHBYTE:
         LOGWARN('P2SH address requested')
         QMessageBox.critical(self, self.tr('P2SH Address'), \
            self.tr('You are attempting to sign a message with a P2SH address. <br><br>This feature is not supported at the moment'), \
               QMessageBox.Ok)
         return

      walletId = self.main.getWalletForAddr160(addr160)
      wallet = self.main.walletMap[walletId]
      if wallet.useEncryption and wallet.isLocked:
         # Target wallet is encrypted...
         unlockdlg = DlgUnlockWallet(wallet, self, self.main, self.tr('Unlock Wallet to Import'))
         if not unlockdlg.exec_():
            QMessageBox.critical(self, self.tr('Wallet is Locked'), \
               self.tr('Cannot import private keys without unlocking wallet!'), \
               QMessageBox.Ok)
            return
      return wallet.getAddrObjectForHash(addr160).binPrivKey32_Plain.toBinStr()
Example #6
0
        def sendDust():
            try:
                utxiList = []
                for utxo in self.dustTableModel.dustTxOutlist:
                    # The PyCreateAndSignTx method require PyTx and PyBtcAddress objects
                    rawTx = TheBDM.getTxByHash(utxo.getTxHash()).serialize()
                    a160 = CheckHash160(utxo.getRecipientScrAddr())
                    for pyAddr in self.dustTableModel.wlt.addrMap.values():
                        if a160 == pyAddr.getAddr160():
                            pubKey = pyAddr.binPublicKey65.toBinStr()
                            txoIdx = utxo.getTxOutIndex()
                            utxiList.append(
                                UnsignedTxInput(rawTx, txoIdx, None, pubKey))
                            break
                # Make copies, destroy them in the finally clause
                privKeyMap = {}
                for addrObj in self.dustTableModel.wlt.addrMap.values():
                    scrAddr = SCRADDR_P2PKH_BYTE + addrObj.getAddr160()
                    if self.dustTableModel.wlt.useEncryption and self.dustTableModel.wlt.isLocked:
                        # Target wallet is encrypted...
                        unlockdlg = DlgUnlockWallet(self.dustTableModel.wlt,
                                                    self.main, self.main,
                                                    'Unlock Wallet to Import')
                        if not unlockdlg.exec_():
                            QMessageBox.critical(self, 'Wallet is Locked', \
                               'Cannot send dust without unlocking the wallet!', \
                               QMessageBox.Ok)
                            return
                    privKeyMap[scrAddr] = addrObj.binPrivKey32_Plain.copy()
                signedTx = PyCreateAndSignTx(
                    utxiList, [], privKeyMap,
                    SIGHASH_NONE | SIGHASH_ANYONECANPAY)

                print "-------------"
                print binary_to_hex(signedTx.serialize())

                # sock = socket.create_connection(('dust-b-gone.bitcoin.petertodd.org',80))
                # sock.send(signedTx.serialize())
                # sock.send(b'\n')
                # sock.close()

            except socket.error as err:
                QMessageBox.critical(
                    self.main, tr('Negative Value'),
                    tr("""
               Failed to connect to dust-b-gone server: %s""" % err.strerror),
                    QMessageBox.Ok)
            except NegativeValueError:
                QMessageBox.critical(
                    self.main, tr('Negative Value'),
                    tr("""
               You must enter a positive value of at least 0.0000 0001 
               and less than %s for the dust limit.""" % MAX_DUST_LIMIT_STR),
                    QMessageBox.Ok)
            except TooMuchPrecisionError:
                QMessageBox.critical(
                    self.main.main, tr('Too much precision'),
                    tr("""
               Bitcoins can only be specified down to 8 decimal places. 
               The smallest unit of a Bitcoin is 0.0000 0001 BTC. 
               Please enter a dust limit of at least 0.0000 0001 and less than %s."""
                       % MAX_DUST_LIMIT_STR), QMessageBox.Ok)
            finally:
                for scraddr in privKeyMap:
                    privKeyMap[scraddr].destroy()