void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
            {
                const CRoscoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = IsMine(*wallet, address.Get());
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString())));
            }

            std::set<CStealthAddress>::iterator it;
            for (it = wallet->stealthAddresses.begin(); it != wallet->stealthAddresses.end(); ++it)
            {
                bool fMine = !(it->scan_secret.size() < 1);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(it->label),
                                  QString::fromStdString(it->Encoded()),
                                  true));
            };
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#2
0
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = IsMine(*wallet, address.Get());

                if (fMine) {
                    std::string addr;
                    if (wallet->HasScrapeAddress(address.ToString()))
                        wallet->ReadScrapeAddress(address.ToString(), addr);

                    cachedAddressTable.append(AddressTableEntry(AddressTableEntry::Receiving,
                                      QString::fromStdString(strName),
                                      QString::fromStdString(address.ToString()),
                                      QString::fromStdString(addr)));
                } else {
                    cachedAddressTable.append(AddressTableEntry(AddressTableEntry::Sending,
                                      QString::fromStdString(strName),
                                      QString::fromStdString(address.ToString())));
                }
            }
        }
    }
示例#3
0
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                bool fMine = IsMine(*wallet, address.Get());
                AddressTableEntry::Type addressType = translateTransactionType(
                        QString::fromStdString(item.second.purpose), fMine);
                const std::string& strName = item.second.name;
                cachedAddressTable.append(AddressTableEntry(addressType,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString())));
            }

            std::set<CStealthAddress>::iterator it;
            for (it = wallet->stealthAddresses.begin(); it != wallet->stealthAddresses.end(); ++it)
            {
                bool fMine = !(it->scan_secret.size() < 1);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(it->label),
                                  QString::fromStdString(it->Encoded()),
                                  true));
            };
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        // Even though the map is already sorted this re-sorting step is needed because the originating map
        // is sorted by binary address, not by base58() address.
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#4
0
    void refreshAddressTable()
    {
        std::vector<TxInfoRecord> vecRecord;
        
        {
            TRY_LOCK(cs_main, lockMain);
            
            if (lockMain)
            {
                vecRecord = ptxinfoStore->RecordsWithKey(TxInfoKey(INFO_ID, "n"));
            }
        }
        
        if (!vecRecord.empty())
        {
            cachedAddressTable.clear();
        }
        else
        {
            QMutableListIterator<AddressTableEntry> iter(cachedAddressTable);
            while (iter.hasNext())
            {
                if (iter.next().type != AddressTableEntry::Directory)
                {
                    iter.remove();
                }
            }
        }
        
        {
            LOCK(wallet->cs_wallet);
            
            BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = wallet->HaveKey(address);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString())));
            }

            BOOST_FOREACH(const TxInfoRecord &record, vecRecord)
            {
                if (wallet->mapAddressBook.count(record.addr) > 0)
                {
                    continue;
                }
                
                cachedAddressTable.append(AddressTableEntry(AddressTableEntry::Directory, "",
                                                            QString::fromStdString(record.addr.ToString())));
            }
        }
    }
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
            {
                const CMnemonicAddress& address = item.first;
                bool fMine = IsMine(*wallet, address.Get());
                AddressTableEntry::Type addressType = translateTransactionType(
                        QString::fromStdString(item.second.purpose), fMine);
                const std::string& strName = item.second.name;

			CMnemonicAddress bitcoinAddress;

			bitcoinAddress.SetString( address.ToString() );
			CKeyID keyID;
			bitcoinAddress.GetKeyID(keyID);

				//common::CPeriodicActionExecutor< client::DimsResponse >::getInstance()->addAction( new client::CSendBalanceInfoAction( address.ToString() ), 6000 );

                cachedAddressTable.append(AddressTableEntry(addressType,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString()),
								  CDimsUnits::format(0, wallet->AvailableCoinsAmount(keyID)) ));
            }
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        // Even though the map is already sorted this re-sorting step is needed because the originating map
        // is sorted by binary address, not by base58() address.
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#6
0
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = IsMine(*wallet, address.Get());
                bool fMyShare = IsMyShare(*wallet, address.Get());
                AddressTableEntry::Type type = fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;
                AddressTableEntry::Category cate = AddressTableEntry::Normal;
                if ( fMyShare )
                {
                    cate = AddressTableEntry::MultiSig;
                    type = AddressTableEntry::Sending;
                }

                cachedAddressTable.append(AddressTableEntry(type,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString()), cate));
            }
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#7
0
    void updateEntry(const QString &address, const QString &label, bool isMine, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;

        switch(status)
        {
        case CT_NEW:
        {
            if(inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NEW, but entry is already in model\n");
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);

            std::string pmkey = "";
            std::string a;
            a = address.toStdString();
            int i;
            if (isMine)
            {
                i = SecureMsgGetLocalPublicKey(a, pmkey);
                if (i)
                    printf("Can't get PM Key for some reason\n");
            }

            cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address, QString::fromStdString(pmkey)));
            parent->endInsertRows();
            break;
        }
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
示例#8
0
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;

                AddressTableEntry::Type addressType;
                const std::string& strPurpose = item.second.purpose;
                if (strPurpose == "send") addressType = AddressTableEntry::Sending;
                else if (strPurpose == "receive") addressType = AddressTableEntry::Receiving;
                else if (strPurpose == "unknown") {
                    bool fMine = IsMine(*wallet, address.Get());
                    addressType = (fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending);
                }
                else continue; // "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all.

                const std::string& strName = item.second.name;
                cachedAddressTable.append(AddressTableEntry(addressType,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString())));
            }
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        // Even though the map is already sorted this re-sorting step is needed because the originating map
        // is sorted by binary address, not by base58() address.
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#9
0
    void refreshAddressTable()
    {
        cachedAddressTable.clear();
        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = IsMine(*wallet, address.Get());

                std::string a;
                std::string PMKey = "";
                a = address.ToString();

                if (fMine)
                {
                    int i = SecureMsgGetLocalPublicKey(a, PMKey);
                    if (i == 4)
                        PMKey = "Wallet is Locked.";
                    else if (i)
                        printf("Error getting PM Key %i\n", i);
                }

                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString()),
                                  QString::fromStdString(PMKey)));
            }

            std::set<CStealthAddress>::iterator it;
            for (it = wallet->stealthAddresses.begin(); it != wallet->stealthAddresses.end(); ++it)
            {
                bool fMine = !(it->scan_secret.size() < 1);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(it->label),
                                  QString::fromStdString(it->Encoded()),
                                  QString::fromStdString(""),
                                  true));
            };
        }
        // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
        qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
    }
示例#10
0
    void updateEntry(const QString &address, const QString &label, bool isMine, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            {
                CBitcoinAddress addr(address.toStdString());
                AddressTableEntry::Category cate = IsMyShare(*wallet, addr.Get()) ? AddressTableEntry::MultiSig : AddressTableEntry::Normal;

                parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
                cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address, cate));
                parent->endInsertRows();
            }
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
示例#11
0
 void refreshAddressTable()
 {
     cachedAddressTable.clear();
     {
         LOCK(wallet->cs_wallet);
         BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
         {
             const CNaanayamAddress& address = item.first;
             const std::string& strName = item.second;
             bool fMine = IsMine(*wallet, address.Get());
             cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                               QString::fromStdString(strName),
                               QString::fromStdString(address.ToString())));
         }
     }
 }
示例#12
0
    void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model";
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
            cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
    void refreshAddressTable()
    {
        cachedAddressTable.clear();

        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress& address = item.first;
                const std::string& strName = item.second;
                bool fMine = wallet->HaveKey(address);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString())));
            }
        }
    }
 void refreshAddressTable()
 {
     cachedAddressTable.clear();
     {
         LOCK(wallet->cs_wallet);
         BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
         {
             const CTalkcoinAddress& address = item.first;
             const std::string& strName = item.second;
             bool fMine = IsMine(*wallet, address.Get());
             cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                               QString::fromStdString(strName),
                               QString::fromStdString(address.ToString())));
         }
     }
     // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
     qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
 }
示例#15
0
 void refreshAddressTable(interfaces::Wallet& wallet)
 {
     cachedAddressTable.clear();
     {
         for (const auto& address : wallet.getAddresses())
         {
             AddressTableEntry::Type addressType = translateTransactionType(
                     QString::fromStdString(address.purpose), address.is_mine);
             cachedAddressTable.append(AddressTableEntry(addressType,
                               QString::fromStdString(address.name),
                               QString::fromStdString(EncodeDestination(address.dest))));
         }
     }
     // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
     // Even though the map is already sorted this re-sorting step is needed because the originating map
     // is sorted by binary address, not by base58() address.
     qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
 }
    void refreshAddressTable()
    {
        cachedAddressTable.clear();

        {
            LOCK(wallet->cs_wallet);
            BOOST_FOREACH(const PAIRTYPE(CTxDestination, std::string)& item, wallet->mapAddressBook)
            {
                const CBitcoinAddress address(item.first, wallet->GetUnit());
                const std::string& strName = item.second;
                bool fMine = IsMine(*wallet, address.Get());
                CPeercoinAddress dividendAddress;
                if (wallet->GetUnit() == 'S')
                    dividendAddress = CPeercoinAddress(address);
                cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
                                  QString::fromStdString(strName),
                                  QString::fromStdString(address.ToString()),
                                  QString::fromStdString(dividendAddress.ToString())));
            }
        }
    }
示例#17
0
 void refreshAddressTable()
 {
     cachedAddressTable.clear();
     {
         LOCK(wallet->cs_wallet);
         BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
         {
             const CDeuscoinAddress& address = item.first;
             bool fMine = IsMine(*wallet, address.Get());
             AddressTableEntry::Type addressType = translateTransactionType(
                     QString::fromStdString(item.second.purpose), fMine);
             const std::string& strName = item.second.name;
             cachedAddressTable.append(AddressTableEntry(addressType,
                               QString::fromStdString(strName),
                               QString::fromStdString(address.ToString())));
         }
     }
     // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
     // Even though the map is already sorted this re-sorting step is needed because the originating map
     // is sorted by binary address, not by base58() address.
     qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan());
 }
    void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine);

		CMnemonicAddress bitcoinAddress;
		bitcoinAddress.SetString( address.toStdString() );
		CKeyID keyID;
		bitcoinAddress.GetKeyID(keyID);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_NOW, but entry is already in model";
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);

            cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address,QString::number ( wallet->AvailableCoinsAmount(keyID))));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
		case CT_BALANCE:
			if(!inModel)
			{
				qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
				break;
			}
			lower->balance = CDimsUnits::format(0, wallet->AvailableCoinsAmount(keyID));
			parent->emitDataChanged(lowerIndex);
			break;
        case CT_DELETED:
            if(!inModel)
            {
                qDebug() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }