def searchItem():
    searchString = str(self.searchEntry.text())
    if len(searchString) > 0:
       likelyDataType = isLikelyDataType(searchString)    
       for wltID, wlt in self.main.walletMap.iteritems():
          if wlt.hasAddr(searchString):
             searchHash = searchString if likelyDataType == DATATYPE.Hex \
                   else addrStr_to_hash160(searchString)[1]
             dialog = DlgAddressInfo(wlt, searchHash, main=self.main)
             dialog.exec_()
             break
          if likelyDataType == DATATYPE.Hex:
             walletLedger = wlt.cppWallet.getTxLedger()
             txHashToFind = hex_to_binary(searchString, endOut=BIGENDIAN)
             txFound = False
             for entry in walletLedger:
                if entry.getTxHash() ==  txHashToFind:
                   cppTx = TheBDM.getTxByHash(txHashToFind)
                   serializedCppTx = cppTx.serialize()
                   pytx = PyTx().unserialize(serializedCppTx)
                   DlgDispTxInfo(pytx, wlt, self.main, self.main).exec_()
                   txFound = True
                   break
             if txFound:
                break
Esempio n. 2
0
    def data(self, index, role=Qt.DisplayRole):
        row, col = index.row(), index.column()
        txout = self.dustTxOutlist[row]
        addrStr = script_to_addrStr(txout.getScript())
        pyAddr = self.wlt.addrMap[addrStr_to_hash160(addrStr)[1]]
        chainIndex = pyAddr.chainIndex + 1
        if role == Qt.DisplayRole:
            if col == DUSTCOLS.chainIndex: return QVariant(chainIndex)
            if col == DUSTCOLS.AddrStr: return QVariant(addrStr)
            if col == DUSTCOLS.Btc:
                return QVariant(coin2str(txout.getValue(), maxZeros=8))
        elif role == Qt.TextAlignmentRole:
            if col == DUSTCOLS.chainIndex:
                return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
            if col == DUSTCOLS.AddrStr:
                return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
            if col == DUSTCOLS.Btc:
                return QVariant(int(Qt.AlignRight | Qt.AlignVCenter))
        elif role == Qt.ForegroundRole:
            return QVariant(Colors.Foreground)
        elif role == Qt.FontRole:
            if col == DUSTCOLS.Btc:
                return GETFONT('Fixed')

        return QVariant()
Esempio n. 3
0
 def getCommentFromWallet(self, val):
     if len(val) != 32:
         try:
             prefix, val = addrStr_to_hash160(val)
         except:
             pass
     return self.wallet.getComment(val)
    def data(self, index, role=Qt.DisplayRole):
        row, col = index.row(), index.column()
        txout = self.dustTxOutlist[row]
        addrStr = script_to_addrStr(txout.getScript())
        pyAddr = self.wlt.addrMap[addrStr_to_hash160(addrStr)[1]]
        chainIndex = pyAddr.chainIndex + 1
        if role == Qt.DisplayRole:
            if col == DUSTCOLS.chainIndex:
                return QVariant(chainIndex)
            if col == DUSTCOLS.AddrStr:
                return QVariant(addrStr)
            if col == DUSTCOLS.Btc:
                return QVariant(coin2str(txout.getValue(), maxZeros=8))
        elif role == Qt.TextAlignmentRole:
            if col == DUSTCOLS.chainIndex:
                return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
            if col == DUSTCOLS.AddrStr:
                return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
            if col == DUSTCOLS.Btc:
                return QVariant(int(Qt.AlignRight | Qt.AlignVCenter))
        elif role == Qt.ForegroundRole:
            return QVariant(Colors.Foreground)
        elif role == Qt.FontRole:
            if col == DUSTCOLS.Btc:
                return GETFONT("Fixed")

        return QVariant()
Esempio n. 5
0
 def searchItem():
     searchString = str(self.searchEntry.text())
     if len(searchString) > 0:
         likelyDataType = isLikelyDataType(searchString)
         for wltID, wlt in self.main.walletMap.iteritems():
             if wlt.hasAddr(searchString):
                 searchHash = searchString if likelyDataType == DATATYPE.Hex \
                       else addrStr_to_hash160(searchString)[1]
                 dialog = DlgAddressInfo(wlt,
                                         searchHash,
                                         main=self.main)
                 dialog.exec_()
                 break
             if likelyDataType == DATATYPE.Hex:
                 walletLedger = wlt.cppWallet.getTxLedger()
                 txHashToFind = hex_to_binary(searchString,
                                              endOut=BIGENDIAN)
                 txFound = False
                 for entry in walletLedger:
                     if entry.getTxHash() == txHashToFind:
                         cppTx = TheBDM.getTxByHash(txHashToFind)
                         serializedCppTx = cppTx.serialize()
                         pytx = PyTx().unserialize(serializedCppTx)
                         DlgDispTxInfo(pytx, wlt, self.main,
                                       self.main).exec_()
                         txFound = True
                         break
                 if txFound:
                     break
Esempio n. 6
0
 def getCommentFromWallet(self, val):
    if len(val) != 32:
       try:
          prefix, val = addrStr_to_hash160(val)
       except: 
          pass
    return self.wallet.getComment(val)
Esempio n. 7
0
def hw4Exercise2():
   print "Block Chain Parser HW #4 Exercise #2: "
   addrHistory = getAddrHistory(addrStr_to_hash160(TEST_ARMORY))
   for key in sorted(addrHistory, key=lambda outpoint: outpoint.blkNum):
      print binary_to_hex(key.txHash, BIGENDIAN)[:8]+'...', key.txOutIndex,
      print coin2str(addrHistory[key].totalAccumulated, 4),
      print coin2str(addrHistory[key].balance, 4),
      print "Unspent" if addrHistory[key].txIn == None else "Spent"
Esempio n. 8
0
 def jsonrpc_setaddressmetadata(self, newAddressMetaData):
    # Loop once to check the addresses
    # Don't add any meta data if one of the addresses wrong.
    for addr in newAddressMetaData.keys():
       if not checkAddrStrValid(addr):
          raise InvalidBitcoinAddress
       if not self.wallet.addrMap.has_key(addrStr_to_hash160(addr, False)[1]):
          raise AddressNotInWallet
    self.addressMetaData.update(newAddressMetaData)
Esempio n. 9
0
   def jsonrpc_getreceivedbyaddress(self, address):
      if CLI_OPTIONS.offline:
         raise ValueError('Cannot get received amount when offline')
      # Only gets correct amount for addresses in the wallet, otherwise 0
      atype, addr160 = addrStr_to_hash160(address, False)

      txs = self.wallet.getAddrTxLedger(addr160)
      balance = sum([x.getValue() for x in txs if x.getValue() > 0])
      return AmountToJSON(balance)
Esempio n. 10
0
 def reportTxFromAddrInNewBlock(pyHeader, pyTxList):
    result = ''
    for pyTx in pyTxList:
       for pyTxIn in pyTx.inputs:
          sendingAddrStr = TxInExtractAddrStrIfAvail(pyTxIn)
          if len(sendingAddrStr) > 0:
             sendingAddrHash160 = addrStr_to_hash160(sendingAddrStr, False)[1]
             if self.wallet.addrMap.has_key(sendingAddrHash160):
                sendingAddr = self.wallet.addrMap[sendingAddrHash160]
                result = ''.join([result, '\n', sendingAddr.toString(), '\n'])
                # print the meta data
                if sendingAddrStr in self.addressMetaData:
                   result = ''.join([result, "\nMeta Data: ", str(self.addressMetaData[sendingAddrStr]), '\n'])
                result = ''.join([result, '\n', pyTx.toString()])
    return result
Esempio n. 11
0
   def jsonrpc_dumpprivkey(self, addr58):
      # Cannot dump the private key for a locked wallet
      if self.wallet.isLocked:
         raise WalletUnlockNeeded
      # The first byte must be the correct net byte, and the
      # last 4 bytes must be the correct checksum
      if not checkAddrStrValid(addr58):
         raise InvalidBitcoinAddress

      atype, addr160 = addrStr_to_hash160(addr58, False)

      pyBtcAddress = self.wallet.getAddrByHash160(addr160)
      if pyBtcAddress == None:
         raise PrivateKeyNotFound
      return pyBtcAddress.serializePlainPrivateKey()