returned.  If you are in asynchronous mode, and don't want to ever wait 
   for anything, always check TheBDM.getState()==BDM_BLOCKCHAIN_READY before
   requesting data that will force blocking.
   """
   start = RightNow()
   TheBDM.setBlocking(False)
   TheBDM.setOnlineMode(True)
   sleep(2)
   print 'Waiting for blockchain loading to finish',
   while not TheBDM.getState()==BDM_BLOCKCHAIN_READY:
      print '.',
      sys.stdout.flush()
      sleep(2)
   print 'Loading blockchain took %0.1f sec' % (RightNow() - start)

   topBlock = TheBDM.getTopBlockHeight()
   print '\n\nCurrent Top Block is:', topBlock
   TheBDM.blockchain().top().pprint()

################################################################################
if run_LoadBlockchain_Block:
   start = RightNow()
   TheBDM.setBlocking(True)
   TheBDM.setOnlineMode(True)
   # The setOnlineMode should block until blockchain loading is complete
   print 'Loading blockchain took %0.1f sec' % (RightNow() - start)

   topBlock = TheBDM.getTopBlockHeight()
   print '\n\nCurrent Top Block is:', topBlock
   TheBDM.blockchain().top().pprint()
Exemplo n.º 2
0
    def __init__(self, parent, main, layoutDir=VERTICAL, spendFromLBID=None):
        super(LockboxSelectFrame, self).__init__(parent, main)

        self.lbox = self.main.getLockboxByID(spendFromLBID)
        self.cppWlt = self.main.cppLockboxWltMap[spendFromLBID]

        if not self.lbox:
            QMessageBox.warning(
                self, tr("Invalid Lockbox"),
                tr(""" There was 
         an error loading the specified lockbox (%s).""") % spendFromLBID,
                QMessageBox.Ok)
            self.reject()
            return

        lblSpendFromLB = QRichLabel(tr(""" <font color="%s" size=4><b><u>Lockbox   
         %s (%d-of-%d)</u></b></font>""") % (htmlColor('TextBlue'), \
           self.lbox.uniqueIDB58, self.lbox.M, self.lbox.N))
        lblSpendFromLB.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        lbls = []
        lbls.append(QRichLabel("Lockbox ID:", doWrap=False))
        lbls.append(QRichLabel("Name:", doWrap=False))
        lbls.append(QRichLabel("Description:", doWrap=False))
        lbls.append(QRichLabel("Spendable BTC:", doWrap=False))

        layoutDetails = QGridLayout()
        for i, lbl in enumerate(lbls):
            lbl.setAlignment(Qt.AlignLeft | Qt.AlignTop)
            lbl.setText('<b>' + str(lbls[i].text()) + '</b>')
            layoutDetails.addWidget(lbl, i + 1, 0)

        # LockboxID
        self.dispID = QRichLabel(spendFromLBID)

        # Lockbox Short Description/Name
        self.dispName = QRichLabel(self.lbox.shortName)
        self.dispName.setWordWrap(True)
        self.dispName.setSizePolicy(QSizePolicy.Preferred,
                                    QSizePolicy.Preferred)

        # Lockbox long descr
        dispDescr = self.lbox.longDescr[:253]
        if len(self.lbox.longDescr) > 253:
            dispDescr += '...'
        self.dispDescr = QRichLabel(dispDescr)
        self.dispDescr.setWordWrap(True)
        self.dispDescr.setSizePolicy(QSizePolicy.Preferred,
                                     QSizePolicy.Preferred)
        bal = self.cppWlt.getSpendableBalance(TheBDM.getTopBlockHeight(),
                                              IGNOREZC)
        self.dispBal = QMoneyLabel(bal, wBold=True)
        self.dispBal.setTextFormat(Qt.RichText)

        layoutDetails.addWidget(self.dispID, 1, 1)
        layoutDetails.addWidget(self.dispName, 2, 1)
        layoutDetails.addWidget(self.dispDescr, 3, 1)
        layoutDetails.addWidget(self.dispBal, 4, 1)
        layoutDetails.setColumnStretch(0, 0)
        layoutDetails.setColumnStretch(1, 1)
        frmDetails = QFrame()
        frmDetails.setLayout(layoutDetails)
        frmDetails.setFrameStyle(STYLE_SUNKEN)

        layout = QVBoxLayout()
        layout.addWidget(lblSpendFromLB)
        layout.addWidget(frmDetails)

        self.setLayout(layout)
Exemplo n.º 3
0
   def __init__(self, parent, main, layoutDir=VERTICAL, spendFromLBID=None):
      super(LockboxSelectFrame, self).__init__(parent, main)

      self.lbox = self.main.getLockboxByID(spendFromLBID)
      self.cppWlt = self.main.cppLockboxWltMap[spendFromLBID]

      if not self.lbox:
         QMessageBox.warning(self, tr("Invalid Lockbox"), tr(""" There was 
         an error loading the specified lockbox (%s).""") % spendFromLBID, 
         QMessageBox.Ok)
         self.reject()
         return

      lblSpendFromLB = QRichLabel(tr(""" <font color="%s" size=4><b><u>Lockbox   
         %s (%d-of-%d)</u></b></font>""") % (htmlColor('TextBlue'), \
         self.lbox.uniqueIDB58, self.lbox.M, self.lbox.N))
      lblSpendFromLB.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

      lbls = []
      lbls.append(QRichLabel("Lockbox ID:", doWrap=False))
      lbls.append(QRichLabel("Name:", doWrap=False))
      lbls.append(QRichLabel("Description:", doWrap=False))
      lbls.append(QRichLabel("Spendable GRS:", doWrap=False))

      layoutDetails = QGridLayout()
      for i,lbl in enumerate(lbls):
         lbl.setAlignment(Qt.AlignLeft | Qt.AlignTop)
         lbl.setText('<b>' + str(lbls[i].text()) + '</b>')
         layoutDetails.addWidget(lbl, i+1, 0)
         
      # LockboxID
      self.dispID = QRichLabel(spendFromLBID)

      # Lockbox Short Description/Name
      self.dispName = QRichLabel(self.lbox.shortName)
      self.dispName.setWordWrap(True)
      self.dispName.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)

      # Lockbox long descr
      dispDescr = self.lbox.longDescr[:253]
      if len(self.lbox.longDescr)>253:
         dispDescr += '...'
      self.dispDescr = QRichLabel(dispDescr)
      self.dispDescr.setWordWrap(True)
      self.dispDescr.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
      bal = self.cppWlt.getSpendableBalance(TheBDM.getTopBlockHeight(), IGNOREZC)
      self.dispBal = QMoneyLabel(bal, wBold=True)
      self.dispBal.setTextFormat(Qt.RichText)

      layoutDetails.addWidget(self.dispID, 1, 1)
      layoutDetails.addWidget(self.dispName, 2, 1)
      layoutDetails.addWidget(self.dispDescr, 3, 1)
      layoutDetails.addWidget(self.dispBal, 4, 1)
      layoutDetails.setColumnStretch(0,0)
      layoutDetails.setColumnStretch(1,1)
      frmDetails = QFrame()
      frmDetails.setLayout(layoutDetails)
      frmDetails.setFrameStyle(STYLE_SUNKEN)

      layout = QVBoxLayout()
      layout.addWidget(lblSpendFromLB)
      layout.addWidget(frmDetails)

      self.setLayout(layout)
Exemplo n.º 4
0
 def verifyBlockHeight(self):
    blockHeight = TheBDM.getTopBlockHeight()
    self.assertEqual(blockHeight, TOP_TIAB_BLOCK, NEED_TIAB_MSG + str(blockHeight))
   returned.  If you are in asynchronous mode, and don't want to ever wait 
   for anything, always check TheBDM.getState()==BDM_BLOCKCHAIN_READY before
   requesting data that will force blocking.
   """
    start = RightNow()
    TheBDM.setBlocking(False)
    TheBDM.setOnlineMode(True)
    sleep(2)
    print 'Waiting for blockchain loading to finish',
    while not TheBDM.getState() == BDM_BLOCKCHAIN_READY:
        print '.',
        sys.stdout.flush()
        sleep(2)
    print 'Loading blockchain took %0.1f sec' % (RightNow() - start)

    topBlock = TheBDM.getTopBlockHeight()
    print '\n\nCurrent Top Block is:', topBlock
    TheBDM.blockchain().top().pprint()

################################################################################
if run_LoadBlockchain_Block:
    start = RightNow()
    TheBDM.setBlocking(True)
    TheBDM.setOnlineMode(True)
    # The setOnlineMode should block until blockchain loading is complete
    print 'Loading blockchain took %0.1f sec' % (RightNow() - start)

    topBlock = TheBDM.getTopBlockHeight()
    print '\n\nCurrent Top Block is:', topBlock
    TheBDM.blockchain().top().pprint()