コード例 #1
0
    def buildCorruptWallet(self, walletPath):
        crpWlt = PyBtcWallet()
        crpWlt.createNewWallet(walletPath,
                               securePassphrase='testing',
                               doRegisterWithBDM=False)
        #not registering with the BDM, have to fill the wallet address pool manually
        crpWlt.fillAddressPool(100)

        #grab the last computed address
        lastaddr = crpWlt.addrMap[crpWlt.lastComputedChainAddr160]

        #corrupt the pubkey
        PubKey = hex_to_binary(
            '0478d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71a1518063243acd4dfe96b66e3f2ec8013c8e072cd09b3834a19f81f659cc3455'
        )
        lastaddr.binPublicKey65 = SecureBinaryData(PubKey)
        crpWlt.addrMap[crpWlt.lastComputedChainAddr160] = lastaddr

        crpWlt.fillAddressPool(200)

        #insert a gap and inconsistent encryption
        newAddr = PyBtcAddress()
        newAddr.chaincode = lastaddr.chaincode
        newAddr.chainIndex = 250
        PrivKey = hex_to_binary(
            'e3b0c44298fc1c149afbf4c8996fb92427ae41e5978fe51ca495991b7852b855')
        newAddr.binPrivKey32_Plain = SecureBinaryData(PrivKey)
        newAddr.binPublicKey65 = CryptoECDSA().ComputePublicKey( \
                                                  newAddr.binPrivKey32_Plain)
        newAddr.addrStr20 = newAddr.binPublicKey65.getHash160()
        newAddr.isInitialized = True

        crpWlt.addrMap[newAddr.addrStr20] = newAddr
        crpWlt.lastComputedChainAddr160 = newAddr.addrStr20
        crpWlt.fillAddressPool(250)

        lastAddr = crpWlt.addrMap[crpWlt.lastComputedChainAddr160]
        PrivKey = hex_to_binary(
            'e3b0c44298fc1c149afbf4c8996fb92427ae41e5978fe51ca495991b00000000')
        lastAddr.binPrivKey32_Plain = SecureBinaryData(PrivKey)
        lastAddr.binPublicKey65 = CryptoECDSA().ComputePublicKey( \
                                                  lastAddr.binPrivKey32_Plain)
        lastAddr.keyChanged = True
        crpWlt.kdfKey = crpWlt.kdf.DeriveKey(SecureBinaryData('testing'))
        lastAddr.lock(secureKdfOutput=crpWlt.kdfKey)
        lastAddr.useEncryption = True

        crpWlt.fillAddressPool(350)

        #TODO: corrupt a private key
        #break an address entry at binary level
        return crpWlt.uniqueIDB58
コード例 #2
0
   def buildCorruptWallet(self, walletPath):
      from armoryengine.PyBtcWallet import PyBtcWallet
      crpWlt = PyBtcWallet()
      crpWlt.createNewWallet(walletPath, securePassphrase='testing', doRegisterWithBDM=False)
      #not registering with the BDM, have to fill the wallet address pool manually 
      crpWlt.fillAddressPool(100)      

      #grab the last computed address
      lastaddr = crpWlt.addrMap[crpWlt.lastComputedChainAddr160]
      
      #corrupt the pubkey
      PubKey = hex_to_binary('0478d430274f8c5ec1321338151e9f27f4c676a008bdf8638d07c0b6be9ab35c71a1518063243acd4dfe96b66e3f2ec8013c8e072cd09b3834a19f81f659cc3455')
      lastaddr.binPublicKey65 = SecureBinaryData(PubKey)
      crpWlt.addrMap[crpWlt.lastComputedChainAddr160] = lastaddr
      
      crpWlt.fillAddressPool(200)
       
      #insert a gap and inconsistent encryption
      newAddr = PyBtcAddress()
      newAddr.chaincode = lastaddr.chaincode
      newAddr.chainIndex = 250
      PrivKey = hex_to_binary('e3b0c44298fc1c149afbf4c8996fb92427ae41e5978fe51ca495991b7852b855')
      newAddr.binPrivKey32_Plain = SecureBinaryData(PrivKey)
      newAddr.binPublicKey65 = CryptoECDSA().ComputePublicKey(newAddr.binPrivKey32_Plain)
      newAddr.addrStr20 = newAddr.binPublicKey65.getHash160()
      newAddr.isInitialized = True
      
      crpWlt.addrMap[newAddr.addrStr20] = newAddr
      crpWlt.lastComputedChainAddr160 = newAddr.addrStr20
      crpWlt.fillAddressPool(250)
      
      #TODO: corrupt a private key  
      #break an address entry at binary level    
      return crpWlt.uniqueIDB58
コード例 #3
0
class WalletWizard(ArmoryWizard):
    def __init__(self, parent, main):
        super(WalletWizard, self).__init__(parent, main)
        self.newWallet = None
        self.isBackupCreated = False
        self.setWindowTitle(tr("Wallet Creation Wizard"))
        self.setOption(QWizard.HaveFinishButtonOnEarlyPages, on=True)
        self.setOption(QWizard.IgnoreSubTitles, on=True)

        # Page 1: Create Wallet
        self.walletCreationPage = WalletCreationPage(self)
        self.addPage(self.walletCreationPage)

        # Page 2: Set Passphrase
        self.setPassphrasePage = SetPassphrasePage(self)
        self.addPage(self.setPassphrasePage)

        # Page 3: Verify Passphrase
        self.verifyPassphrasePage = VerifyPassphrasePage(self)
        self.addPage(self.verifyPassphrasePage)

        # Page 4: Create Paper Backup
        self.walletBackupPage = WalletBackupPage(self)
        self.addPage(self.walletBackupPage)

        # Page 5: Create Watching Only Wallet -- but only if expert, or offline
        self.hasCWOWPage = False
        if self.main.usermode == USERMODE.Expert or not self.main.internetAvail:
            self.hasCWOWPage = True
            self.createWOWPage = CreateWatchingOnlyWalletPage(self)
            self.addPage(self.createWOWPage)

        self.setButtonLayout([
            QWizard.BackButton, QWizard.Stretch, QWizard.NextButton,
            QWizard.FinishButton
        ])

    def initializePage(self, *args, **kwargs):

        if self.currentPage() == self.verifyPassphrasePage:
            self.verifyPassphrasePage.setPassphrase(
                self.setPassphrasePage.pageFrame.getPassphrase())
        elif self.hasCWOWPage and self.currentPage() == self.createWOWPage:
            self.createWOWPage.pageFrame.setWallet(self.newWallet)

        if self.currentPage() == self.walletBackupPage:
            self.createNewWalletFromWizard()
            self.walletBackupPage.pageFrame.setPassphrase(
                self.setPassphrasePage.pageFrame.getPassphrase())
            self.walletBackupPage.pageFrame.setWallet(self.newWallet)

            # Only hide the back button on wallet backup page
            self.setButtonLayout(
                [QWizard.Stretch, QWizard.NextButton, QWizard.FinishButton])
        else:
            self.setButtonLayout([
                QWizard.BackButton, QWizard.Stretch, QWizard.NextButton,
                QWizard.FinishButton
            ])

    def done(self, event):
        if self.newWallet and not self.walletBackupPage.pageFrame.isBackupCreated:
            reply = QMessageBox.question(self, tr('Wallet Backup Warning'), tr("""
               You have not made a backup for your new wallet.  You only have 
               to make a backup of your wallet <u>one time</u> to protect 
               all the funds held by this wallet <i>any time in the future</i>
               (it is a backup of the signing keys, not the coins themselves).
               <br><br>
               If you do not make a backup, you will <u>permanently</u> lose
               the money in this wallet if you ever forget your password, or 
               suffer from hardware failure.
               <br><br>
               Are you sure that you want to leave this wizard without backing 
               up your wallet?"""), \
                  QMessageBox.Yes | QMessageBox.No)
            if reply == QMessageBox.No:
                # Stay in the wizard
                return None
        return super(WalletWizard, self).done(event)

    def createNewWalletFromWizard(self):
        self.newWallet = PyBtcWallet().createNewWallet( \
                       securePassphrase=self.setPassphrasePage.pageFrame.getPassphrase(), \
                       kdfTargSec=self.walletCreationPage.pageFrame.getKdfSec(), \
                       kdfMaxMem=self.walletCreationPage.pageFrame.getKdfBytes(), \
                       shortLabel=self.walletCreationPage.pageFrame.getName(), \
                       longLabel=self.walletCreationPage.pageFrame.getDescription(), \
                       doRegisterWithBDM=False, \
                       extraEntropy=self.main.getExtraEntropyForKeyGen())

        self.newWallet.unlock(securePassphrase=SecureBinaryData(
            self.setPassphrasePage.pageFrame.getPassphrase()))
        # We always want to fill the address pool, right away.
        fillpool = lambda: self.newWallet.fillAddressPool(doRegister=False)
        DlgExecLongProcess(fillpool, 'Creating Wallet...', self, self).exec_()

        # Reopening from file helps make sure everything is correct -- don't
        # let the user use a wallet that triggers errors on reading it
        wltpath = self.newWallet.walletPath
        walletFromDisk = PyBtcWallet().readWalletFile(wltpath)
        self.main.addWalletToApplication(walletFromDisk, walletIsNew=True)
        if TheBDM.getBDMState() in ('Uninitialized', 'Offline'):
            TheBDM.registerWallet(walletFromDisk, isFresh=True, wait=False)
        else:
            self.main.newWalletList.append([walletFromDisk, True])

    def cleanupPage(self, *args, **kwargs):
        if self.hasCWOWPage and self.currentPage() == self.createWOWPage:
            self.setButtonLayout(
                [QWizard.Stretch, QWizard.NextButton, QWizard.FinishButton])
        else:
            self.setButtonLayout([
                QWizard.BackButton, QWizard.Stretch, QWizard.NextButton,
                QWizard.FinishButton
            ])
コード例 #4
0
ファイル: Wizards.py プロジェクト: aburan28/BitcoinArmory
class WalletWizard(ArmoryWizard):
   def __init__(self, parent, main):
      super(WalletWizard,self).__init__(parent, main)
      self.newWallet = None
      self.isBackupCreated = False
      self.setWindowTitle(tr("Wallet Creation Wizard"))
      self.setOption(QWizard.HaveFinishButtonOnEarlyPages, on=True)
      self.setOption(QWizard.IgnoreSubTitles, on=True)
      
      # Page 1: Create Wallet
      self.walletCreationPage = WalletCreationPage(self)
      self.addPage(self.walletCreationPage)
      
      # Page 2: Set Passphrase
      self.setPassphrasePage = SetPassphrasePage(self)
      self.addPage(self.setPassphrasePage)
      
      # Page 3: Verify Passphrase
      self.verifyPassphrasePage = VerifyPassphrasePage(self)
      self.addPage(self.verifyPassphrasePage)
      
      # Page 4: Create Paper Backup
      self.walletBackupPage = WalletBackupPage(self)
      self.addPage(self.walletBackupPage)
      
      # Page 5: Create Watching Only Wallet -- but only if expert, or offline
      self.hasCWOWPage = False
      if self.main.usermode==USERMODE.Expert or not self.main.internetAvail:
         self.hasCWOWPage = True
         self.createWOWPage = CreateWatchingOnlyWalletPage(self)
         self.addPage(self.createWOWPage)

      self.setButtonLayout([QWizard.BackButton,
                            QWizard.Stretch,
                            QWizard.NextButton,
                            QWizard.FinishButton])

   def initializePage(self, *args, **kwargs):

      if self.currentPage() == self.verifyPassphrasePage:
         self.verifyPassphrasePage.setPassphrase(
               self.setPassphrasePage.pageFrame.getPassphrase())
      elif self.hasCWOWPage and self.currentPage() == self.createWOWPage:
         self.createWOWPage.pageFrame.setWallet(self.newWallet)
         
      if self.currentPage() == self.walletBackupPage:
         self.createNewWalletFromWizard()
         self.walletBackupPage.pageFrame.setPassphrase(
                  self.setPassphrasePage.pageFrame.getPassphrase())         
         self.walletBackupPage.pageFrame.setWallet(self.newWallet)
         
         # Only hide the back button on wallet backup page  
         self.setButtonLayout([QWizard.Stretch,
                                QWizard.NextButton,
                                QWizard.FinishButton])
      else:
         self.setButtonLayout([QWizard.BackButton,
                                QWizard.Stretch,
                                QWizard.NextButton,
                                QWizard.FinishButton])
   def done(self, event):
      if self.newWallet and not self.walletBackupPage.pageFrame.isBackupCreated:
         reply = QMessageBox.question(self, tr('Wallet Backup Warning'), tr("""
               You have not made a backup for your new wallet.  You only have 
               to make a backup of your wallet <u>one time</u> to protect 
               all the funds held by this wallet <i>any time in the future</i>
               (it is a backup of the signing keys, not the coins themselves).
               <br><br>
               If you do not make a backup, you will <u>permanently</u> lose
               the money in this wallet if you ever forget your password, or 
               suffer from hardware failure.
               <br><br>
               Are you sure that you want to leave this wizard without backing 
               up your wallet?"""), \
               QMessageBox.Yes | QMessageBox.No)
         if reply == QMessageBox.No:
            # Stay in the wizard
            return None
      return super(WalletWizard, self).done(event)
             
   def createNewWalletFromWizard(self):
      self.newWallet = PyBtcWallet().createNewWallet( \
                     securePassphrase=self.setPassphrasePage.pageFrame.getPassphrase(), \
                     kdfTargSec=self.walletCreationPage.pageFrame.getKdfSec(), \
                     kdfMaxMem=self.walletCreationPage.pageFrame.getKdfBytes(), \
                     shortLabel=self.walletCreationPage.pageFrame.getName(), \
                     longLabel=self.walletCreationPage.pageFrame.getDescription(), \
                     doRegisterWithBDM=False, \
                     extraEntropy=self.main.getExtraEntropyForKeyGen())

      self.newWallet.unlock(securePassphrase=
               SecureBinaryData(self.setPassphrasePage.pageFrame.getPassphrase()))
      # We always want to fill the address pool, right away.  
      fillpool = lambda: self.newWallet.fillAddressPool(doRegister=False)
      DlgExecLongProcess(fillpool, 'Creating Wallet...', self, self).exec_()

      # Reopening from file helps make sure everything is correct -- don't
      # let the user use a wallet that triggers errors on reading it
      wltpath = self.newWallet.walletPath
      walletFromDisk = PyBtcWallet().readWalletFile(wltpath)
      self.main.addWalletToApplication(walletFromDisk, walletIsNew=True)
      if TheBDM.getBDMState() in ('Uninitialized', 'Offline'):
         TheBDM.registerWallet(walletFromDisk, isFresh=True, wait=False)
      else:
         self.main.newWalletList.append([walletFromDisk, True])
   
   def cleanupPage(self, *args, **kwargs):
      if self.hasCWOWPage and self.currentPage() == self.createWOWPage:
         self.setButtonLayout([QWizard.Stretch,
                               QWizard.NextButton,
                               QWizard.FinishButton])
      else:
         self.setButtonLayout([QWizard.BackButton,
                               QWizard.Stretch,
                               QWizard.NextButton,
                               QWizard.FinishButton])