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; } }
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; } }
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status) { OutputDebugStringF("NotifyTransactionChanged %s status=%i\n", hash.GetHex().c_str(), status); QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(hash.GetHex())), Q_ARG(int, status)); }
void updateEntry(const QString &address, const QString &label, const QString &nation, int status) { // Find address / label in model QList<VotingTableEntry>::iterator lower = qLowerBound( cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan()); QList<VotingTableEntry>::iterator upper = qUpperBound( cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan()); int lowerIndex = (lower - cachedVotingTable.begin()); int upperIndex = (upper - cachedVotingTable.begin()); bool inModel = (lower != upper); switch(status) { case CT_NEW: if(inModel) { OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n"); break; } parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); cachedVotingTable.insert(lowerIndex, VotingTableEntry(label, address, nation)); parent->endInsertRows(); break; case CT_UPDATED: if(!inModel) { OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n"); break; } lower->label = label; lower->nation = nation; parent->emitDataChanged(lowerIndex); break; case CT_DELETED: if(!inModel) { OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n"); break; } parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); cachedVotingTable.erase(lower, upper); parent->endRemoveRows(); break; } }
bool CMessageHeader::IsValid(int nHeight) const { bool fDebug = true; // Check start string //OutputDebugStringF("inIsValid: nHeight=%d, %x \n",nHeight,pchMessageStart[0]); if(nHeight <= HARD_FORK_HEIGHT){ if (memcmp(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)) != 0) { OutputDebugStringF("[ISVALID:memcmp:false] %d, %x : %x\n",nHeight,pchMessageStart[0], ::pchMessageStart[0]); return false; } }else{ if (memcmp(pchMessageStart, ::pchMessageStart2, sizeof(pchMessageStart2)) != 0) { OutputDebugStringF("[ISVALID2:memcmp:false] %d*, %x : %x\n",nHeight,pchMessageStart[0], ::pchMessageStart2[0]); return false; } } //OutputDebugStringF("inIsValid: MessageStart Validated.\n"); // Check the command string for errors for (const char* p1 = pchCommand; p1 < pchCommand + COMMAND_SIZE; p1++) { if (*p1 == 0) { // Must be all zeros after the first zero for (; p1 < pchCommand + COMMAND_SIZE; p1++) if (*p1 != 0) return false; } else if (*p1 < ' ' || *p1 > 0x7E) return false; } // Message size if (nMessageSize > MAX_SIZE) { printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize); return false; } return true; }
/* Query entire wallet anew from core. */ void refreshWallet() { OutputDebugStringF("refreshWallet\n"); cachedWallet.clear(); { LOCK(wallet->cs_wallet); for(std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it) { if(TransactionRecord::showTransaction(it->second)) cachedWallet.append(TransactionRecord::decomposeTransaction(wallet, it->second)); } } }
static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status) { OutputDebugStringF("NotifyAddressBookChanged %s %s isMine=%i purpose=%s status=%i\n", CBitcoinAddress(address).ToString().c_str(), label.c_str(), isMine, purpose.c_str(), status); QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection, Q_ARG(QString, QString::fromStdString(CBitcoinAddress(address).ToString())), Q_ARG(QString, QString::fromStdString(label)), Q_ARG(bool, isMine), Q_ARG(QString, QString::fromStdString(purpose)), Q_ARG(int, status)); }
void openDebugLogfile() { // If we are opening it, might as well fire up debugging for this session. if ( ! fWriteDebugLog ) { fWriteDebugLog = true; OutputDebugStringF("Starting debug session"); } boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; /* Open debug.log with the associated application */ if (boost::filesystem::exists(pathDebug)) QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(pathDebug.string()))); }
void PorkMarket::show_text(const std::string &message) { QString mes=QString::fromStdString(message); QStringList list = mes.split("|",QString::SkipEmptyParts); OutputDebugStringF("show_text"); printf("---"); QWidget* w = new QWidget(); QVBoxLayout* vbl = new QVBoxLayout(w); QDateTime current_date_time = QDateTime::currentDateTime(); QString current_date = current_date_time.toString("yyyy-MM-dd hh:mm:ss"); QLabel* lab_01 = new QLabel(current_date); QLabel* lab_02 = new QLabel(current_date); vbl->addWidget(lab_01); w->setLayout(vbl); // QListWidgetItem* lwi = new QListWidgetItem; // lwi->setSizeHint( w->sizeHint() ); // ui->listWidget->addItem(lwi); // ui->listWidget->setItemWidget(lwi, w); // return; QHBoxLayout* Hbl = new QHBoxLayout(w); Hbl->addWidget(lab_02); // Hbl->addWidget(lab_03); vbl->addLayout(Hbl); vbl->setSizeConstraint( QLayout::SetFixedSize ); QListWidgetItem* lwi = new QListWidgetItem; lwi->setSizeHint( w->sizeHint() ); ui->listWidget->addItem(lwi); ui->listWidget->setItemWidget(lwi, w); }
/* Update our model of the wallet incrementally, to synchronize our model of the wallet with that of the core. Call with transaction that was added, removed or changed. */ void updateWallet(const uint256 &hash, int status) { OutputDebugStringF("updateWallet %s %i\n", hash.ToString().c_str(), status); { LOCK(wallet->cs_wallet); // Find transaction in wallet std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash); bool inWallet = mi != wallet->mapWallet.end(); // Find bounds of this transaction in model QList<TransactionRecord>::iterator lower = qLowerBound( cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); QList<TransactionRecord>::iterator upper = qUpperBound( cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); int lowerIndex = (lower - cachedWallet.begin()); int upperIndex = (upper - cachedWallet.begin()); bool inModel = (lower != upper); // Determine whether to show transaction or not bool showTransaction = (inWallet && TransactionRecord::showTransaction(mi->second)); if(status == CT_UPDATED) { if(showTransaction && !inModel) status = CT_NEW; /* Not in model, but want to show, treat as new */ if(!showTransaction && inModel) status = CT_DELETED; /* In model, but want to hide, treat as deleted */ } OutputDebugStringF(" inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n", inWallet, inModel, lowerIndex, upperIndex, showTransaction, status); switch(status) { case CT_NEW: if(inModel) { OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is already in model\n"); break; } if(!inWallet) { OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n"); break; } if(showTransaction) { // Added -- insert at the right position QList<TransactionRecord> toInsert = TransactionRecord::decomposeTransaction(wallet, mi->second); if(!toInsert.isEmpty()) /* only if something to insert */ { parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); int insert_idx = lowerIndex; foreach(const TransactionRecord &rec, toInsert) { cachedWallet.insert(insert_idx, rec); insert_idx += 1; } parent->endInsertRows(); } } break; case CT_DELETED: if(!inModel) { OutputDebugStringF("Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n"); break; } // Removed -- remove entire transaction from table parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); cachedWallet.erase(lower, upper); parent->endRemoveRows(); break; case CT_UPDATED: // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for // visible transactions. break; }
// Handlers for core signals static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet) { OutputDebugStringF("NotifyKeyStoreStatusChanged\n"); QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection); }