您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ExtractDestination函数代码示例

51自学网 2021-06-01 20:40:09
  C++
这篇教程C++ ExtractDestination函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中ExtractDestination函数的典型用法代码示例。如果您正苦于以下问题:C++ ExtractDestination函数的具体用法?C++ ExtractDestination怎么用?C++ ExtractDestination使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ExtractDestination函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: on_transactionOutput_currentIndexChanged

void MultisigInputEntry::on_transactionOutput_currentIndexChanged(int index){    if(ui->transactionOutput->itemText(index).isEmpty())        return;    CTransaction tx;    uint256 blockHash = 0;    if(!GetTransaction(txHash, tx, blockHash))        return;    const CTxOut& txOut = tx.vout[index];    CScript script = txOut.scriptPubKey;    if(script.IsPayToScriptHash())    {        ui->redeemScript->setEnabled(true);        if(model)        {            // Try to find the redeem script            CTxDestination dest;            if(ExtractDestination(script, dest))                {                    CScriptID scriptID = boost::get<CScriptID>(dest);                    CScript redeemScript;                    if(model->getWallet()->GetCScript(scriptID, redeemScript))                        ui->redeemScript->setText(HexStr(redeemScript.begin(), redeemScript.end()).c_str());                }        }    }    else    {        ui->redeemScript->setEnabled(false);    }    emit updateAmount();}
开发者ID:tomasmartins,项目名称:TRMWallet,代码行数:36,


示例2: LOCK

std::string CSuperblockManager::GetRequiredPaymentsString(int nBlockHeight){    LOCK(governance.cs);    std::string ret = "Unknown";    // GET BEST SUPERBLOCK    CSuperblock_sptr pSuperblock;    if (!GetBestSuperblock(pSuperblock, nBlockHeight)) {        LogPrint("gobject", "CSuperblockManager::GetRequiredPaymentsString -- Can't find superblock for height %d/n", nBlockHeight);        return "error";    }    // LOOP THROUGH SUPERBLOCK PAYMENTS, CONFIGURE OUTPUT STRING    for (int i = 0; i < pSuperblock->CountPayments(); i++) {        CGovernancePayment payment;        if (pSuperblock->GetPayment(i, payment)) {            // PRINT NICE LOG OUTPUT FOR SUPERBLOCK PAYMENT            CTxDestination address1;            ExtractDestination(payment.script, address1);            CBitcoinAddress address2(address1);            // RETURN NICE OUTPUT FOR CONSOLE            if (ret != "Unknown") {                ret += ", " + address2.ToString();            } else {                ret = address2.ToString();            }        }    }    return ret;}
开发者ID:dashpay,项目名称:dash,代码行数:36,


示例3: TRY_LOCK

void MasternodeManager::updateNodeList(){    TRY_LOCK(cs_masternodes, lockMasternodes);    if(!lockMasternodes)        return;    ui->countLabel->setText("Updating...");    ui->tableWidget->clearContents();    ui->tableWidget->setRowCount(0);    BOOST_FOREACH(CMasterNode mn, vecMasternodes)    {        int mnRow = 0;        ui->tableWidget->insertRow(0); 	// populate list	// Address, Rank, Active, Active Seconds, Last Seen, Pub Key	QTableWidgetItem *activeItem = new QTableWidgetItem(QString::number(mn.IsEnabled()));	QTableWidgetItem *addressItem = new QTableWidgetItem(QString::fromStdString(mn.addr.ToString()));	QTableWidgetItem *rankItem = new QTableWidgetItem(QString::number(GetMasternodeRank(mn.vin, pindexBest->nHeight)));	QTableWidgetItem *activeSecondsItem = new QTableWidgetItem(seconds_to_DHMS((qint64)(mn.lastTimeSeen - mn.now)));	QTableWidgetItem *lastSeenItem = new QTableWidgetItem(QString::fromStdString(DateTimeStrFormat(mn.lastTimeSeen)));	CScript pubkey;        pubkey =GetScriptForDestination(mn.pubkey.GetID());        CTxDestination address1;        ExtractDestination(pubkey, address1);        CBitcoinAddress address2(address1);	QTableWidgetItem *pubkeyItem = new QTableWidgetItem(QString::fromStdString(address2.ToString()));	ui->tableWidget->setItem(mnRow, 0, addressItem);	ui->tableWidget->setItem(mnRow, 1, rankItem);	ui->tableWidget->setItem(mnRow, 2, activeItem);	ui->tableWidget->setItem(mnRow, 3, activeSecondsItem);	ui->tableWidget->setItem(mnRow, 4, lastSeenItem);	ui->tableWidget->setItem(mnRow, 5, pubkeyItem);    }
开发者ID:GridMasterDev,项目名称:GMC,代码行数:36,


示例4: sub

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64_t nTime = wtx.GetTxTime();    CAmount nCredit = wtx.GetCredit(ISMINE_ALL);    CAmount nDebit = wtx.GetDebit(ISMINE_ALL);    CAmount nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash();    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (nNet > 0 || wtx.IsCoinBase())    {        //        // Credit        //        for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)        {            const CTxOut& txout = wtx.tx->vout[i];            isminetype mine = wallet->IsMine(txout);            if(mine)            {                TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = i; // vout index                sub.credit = txout.nValue;                sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                {                    // Received by Bitcoin Address                    sub.type = TransactionRecord::RecvWithAddress;                    sub.address = EncodeDestination(address);                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                if (wtx.IsCoinBase())                {                    // Generated                    sub.type = TransactionRecord::Generated;                }                parts.append(sub);            }        }    }    else    {        bool involvesWatchAddress = false;        isminetype fAllFromMe = ISMINE_SPENDABLE;        for (const CTxIn& txin : wtx.tx->vin)        {            isminetype mine = wallet->IsMine(txin);            if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;            if(fAllFromMe > mine) fAllFromMe = mine;        }        isminetype fAllToMe = ISMINE_SPENDABLE;        for (const CTxOut& txout : wtx.tx->vout)        {            isminetype mine = wallet->IsMine(txout);            if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;            if(fAllToMe > mine) fAllToMe = mine;        }        if (fAllFromMe && fAllToMe)        {            // Payment to self            CAmount nChange = wtx.GetChange();            parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",                            -(nDebit - nChange), nCredit - nChange));            parts.last().involvesWatchAddress = involvesWatchAddress;   // maybe pass to TransactionRecord as constructor argument        }        else if (fAllFromMe)        {            //            // Debit            //            CAmount nTxFee = nDebit - wtx.tx->GetValueOut();            for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)            {                const CTxOut& txout = wtx.tx->vout[nOut];                TransactionRecord sub(hash, nTime);                sub.idx = nOut;                sub.involvesWatchAddress = involvesWatchAddress;                if(wallet->IsMine(txout))                {                    // Ignore parts sent to self, as this is usually the change                    // from a transaction sent back to our own address.                    continue;                }//.........这里部分代码省略.........
开发者ID:21E14,项目名称:bitcoin,代码行数:101,


示例5: CCoinControlWidgetItem

void CoinControlDialog::updateView(){    if (!model || !model->getOptionsModel() || !model->getAddressTableModel())        return;    bool treeMode = ui->radioTreeMode->isChecked();    ui->treeWidget->clear();    ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be called for every checked checkbox    ui->treeWidget->setAlternatingRowColors(!treeMode);    QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;    QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;    int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();    std::map<QString, std::vector<COutput> > mapCoins;    model->listCoins(mapCoins);    for (const std::pair<QString, std::vector<COutput>>& coins : mapCoins) {        CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem();        itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);        QString sWalletAddress = coins.first;        QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAddress);        if (sWalletLabel.isEmpty())            sWalletLabel = tr("(no label)");        if (treeMode)        {            // wallet address            ui->treeWidget->addTopLevelItem(itemWalletAddress);            itemWalletAddress->setFlags(flgTristate);            itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);            // label            itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel);            // address            itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);        }        CAmount nSum = 0;        int nChildren = 0;        for (const COutput& out : coins.second) {            nSum += out.tx->tx->vout[out.i].nValue;            nChildren++;            CCoinControlWidgetItem *itemOutput;            if (treeMode)    itemOutput = new CCoinControlWidgetItem(itemWalletAddress);            else             itemOutput = new CCoinControlWidgetItem(ui->treeWidget);            itemOutput->setFlags(flgCheckbox);            itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);            // address            CTxDestination outputAddress;            QString sAddress = "";            if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, outputAddress))            {                sAddress = QString::fromStdString(CWiFicoinAddress(outputAddress).ToString());                // if listMode or change => show wificoin address. In tree mode, address is not shown again for direct wallet address outputs                if (!treeMode || (!(sAddress == sWalletAddress)))                    itemOutput->setText(COLUMN_ADDRESS, sAddress);            }            // label            if (!(sAddress == sWalletAddress)) // change            {                // tooltip from where the change comes from                itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWalletLabel).arg(sWalletAddress));                itemOutput->setText(COLUMN_LABEL, tr("(change)"));            }            else if (!treeMode)            {                QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress);                if (sLabel.isEmpty())                    sLabel = tr("(no label)");                itemOutput->setText(COLUMN_LABEL, sLabel);            }            // amount            itemOutput->setText(COLUMN_AMOUNT, WiFicoinUnits::format(nDisplayUnit, out.tx->tx->vout[out.i].nValue));            itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.tx->tx->vout[out.i].nValue)); // padding so that sorting works correctly            // date            itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.tx->GetTxTime()));            itemOutput->setData(COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.tx->GetTxTime()));            // confirmations            itemOutput->setText(COLUMN_CONFIRMATIONS, QString::number(out.nDepth));            itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.nDepth));            // transaction hash            uint256 txhash = out.tx->GetHash();            itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex()));            // vout index            itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i));             // disable locked coins//.........这里部分代码省略.........
开发者ID:Airche,项目名称:wificoin,代码行数:101,


示例6: sub

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64_t nTime = wtx.GetTxTime();    int64_t nCredit = wtx.GetCredit(true);    int64_t nDebit = wtx.GetDebit();    int64_t nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash(), hashPrev = 0;    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())    {        //        // Credit - Calculate Net from CryptoLottery Rob Halford - 4-3-2015-1        //        for (auto const& txout : wtx.vout)        {            if(wallet->IsMine(txout))            {                TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = parts.size(); // sequence number                sub.credit = txout.nValue;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                {                    // Received by Bitcoin Address                    sub.type = TransactionRecord::RecvWithAddress;                    sub.address = CBitcoinAddress(address).ToString();                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                if (wtx.IsCoinBase())                {                    // Generated (proof-of-work)                    sub.type = TransactionRecord::Generated;                }                if (wtx.IsCoinStake())                {                    // Generated (proof-of-stake)			        if (hashPrev == hash)                        continue; // last coinstake output					if (wtx.vout.size()==2)					{  						//Standard POR CoinStake						sub.type = TransactionRecord::Generated;						sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;						hashPrev = hash;					}					else					{						//CryptoLottery - CoinStake - 4-3-2015						sub.type = TransactionRecord::Generated;						if (nDebit == 0)						{							sub.credit = GetMyValueOut(wallet,wtx);							sub.RemoteFlag = 1;						}						else						{							sub.credit = nNet > 0 ? nNet : GetMyValueOut(wallet,wtx) - nDebit;						}													hashPrev = hash;					}                }                parts.append(sub);            }        }    }    else    {        bool fAllFromMe = true;        for (auto const& txin : wtx.vin)            fAllFromMe = fAllFromMe && wallet->IsMine(txin);        bool fAllToMe = true;        for (auto const& txout : wtx.vout)            fAllToMe = fAllToMe && wallet->IsMine(txout);        if (fAllFromMe && fAllToMe)        {            // Payment to self            int64_t nChange = wtx.GetChange();            parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "",                            -(nDebit - nChange), nCredit - nChange));        }        else if (fAllFromMe)        {            //            // Debit//.........这里部分代码省略.........
开发者ID:Lederstrumpf,项目名称:Gridcoin-Research,代码行数:101,


示例7: sub

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64_t nTime = wtx.GetTxTime();    int64_t nCredit = wtx.GetCredit(true);    int64_t nDebit = wtx.GetDebit();    int64_t nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash(), hashPrev = 0;    std::map<std::string, std::string> mapValue = wtx.mapValue;		char cbuf[256];    if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())    {        //        // Credit        //        for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)        {            const CTxOut& txout = wtx.vout[nOut];			if(wallet->IsMine(txout))            {                TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = parts.size(); // sequence number                sub.credit = txout.nValue;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                {                    // Received by CannabisDarkcoin Address                    sub.type = TransactionRecord::RecvWithAddress;                    sub.address = CCannabisDarkcoinAddress(address).ToString();                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                snprintf(cbuf, sizeof(cbuf), "n_%u", nOut);                mapValue_t::const_iterator mi = wtx.mapValue.find(cbuf);                if (mi != wtx.mapValue.end() && !mi->second.empty())                    sub.narration = mi->second;				if (wtx.IsCoinBase())                {                    // Generated (proof-of-work)                    sub.type = TransactionRecord::Generated;                }                if (wtx.IsCoinStake())                {                    // Generated (proof-of-stake)                    if (hashPrev == hash)                        continue; // last coinstake output                    sub.type = TransactionRecord::Generated;                    sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;                    hashPrev = hash;                }                parts.append(sub);            }        }    }    else    {        bool fAllFromMe = true;        BOOST_FOREACH(const CTxIn& txin, wtx.vin)            fAllFromMe = fAllFromMe && wallet->IsMine(txin);        bool fAllToMe = true;        BOOST_FOREACH(const CTxOut& txout, wtx.vout)            fAllToMe = fAllToMe && wallet->IsMine(txout);        if (fAllFromMe && fAllToMe)        {            // Payment to self            int64_t nChange = wtx.GetChange();            std::string narration("");            mapValue_t::const_iterator mi;            for (mi = wtx.mapValue.begin(); mi != wtx.mapValue.end(); ++mi)            {                if (mi->first.compare(0, 2, "n_") != 0)                    continue;                narration = mi->second;                break;            };                        parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", narration,                            -(nDebit - nChange), nCredit - nChange));        }        else if (fAllFromMe)        {            //            // Debit            //            int64_t nTxFee = nDebit - wtx.GetValueOut();//.........这里部分代码省略.........
开发者ID:cannabisdark,项目名称:cannabisdarkcoin,代码行数:101,


示例8: while

void MultisigDialog::on_transaction_textChanged(){    ui->fee->setStyleSheet("");    ui->statusLabel->setText("");    while(ui->inputs->count())        delete ui->inputs->takeAt(0)->widget();    while(ui->outputs->count())        delete ui->outputs->takeAt(0)->widget();    if(ui->transaction->text().size() > 0)        ui->signTransactionButton->setEnabled(true);    else        ui->signTransactionButton->setEnabled(false);    // Decode the raw transaction    std::vector<unsigned char> txData(ParseHex(ui->transaction->text().toStdString()));    CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION);    CTransaction tx;    try    {        ss >> tx;    }    catch(std::exception &e)    {        return;    }    // Fill input list    int index = -1;    BOOST_FOREACH(const CTxIn& txin, tx.vin)    {        uint256 prevoutHash = txin.prevout.hash;        addInput();        index++;        MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(index)->widget());        if(entry)        {            entry->setTransactionId(QString(prevoutHash.GetHex().c_str()));            entry->setTransactionOutputIndex(txin.prevout.n);        }    }    // Fill output list    index = -1;    BOOST_FOREACH(const CTxOut& txout, tx.vout)    {        CScript scriptPubKey = txout.scriptPubKey;        CTxDestination addr;        ExtractDestination(scriptPubKey, addr);        CBitcoinAddress address(addr);        SendCoinsRecipient recipient;        recipient.address = QString(address.ToString().c_str());        recipient.amount = txout.nValue;        addOutput();        index++;        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(index)->widget());        if(entry)        {            entry->setValue(recipient);        }    }    updateRemoveEnabled();    // Check the fee    int64_t transactionSize = ui->transaction->text().size() / 2;    if(transactionSize == 0)        return;    transactionSize += ui->inputs->count() * 73; // Future ECDSA signatures in DER format    int64_t fee = (int64_t ) (ui->fee->text().toDouble() * COIN);    int64_t minFee = MIN_TX_FEE * (1 + (int64_t) transactionSize / 1000);    if(fee < minFee)    {        ui->fee->setStyleSheet("color:red;");        ui->statusLabel->setText(tr("The transaction fee might be too small."));    }    else if(fee > minFee)    {        ui->fee->setStyleSheet("color:red;");        ui->statusLabel->setText(tr("The transaction fee might be too big. Don't forget to add an output for the change address."));    }}
开发者ID:DogeDefenseForce,项目名称:denarius,代码行数:83,


示例9: ProcessMessageMasternodePayments

void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv){    if(IsInitialBlockDownload()) return;    if (strCommand == "mnget") { //Masternode Payments Request Sync        if(fLiteMode) return; //disable all Darksend/Masternode related functionality        if(pfrom->HasFulfilledRequest("mnget")) {            LogPrintf("mnget - peer already asked me for the list/n");            Misbehaving(pfrom->GetId(), 20);            return;        }        pfrom->FulfilledRequest("mnget");        masternodePayments.Sync(pfrom);        LogPrintf("mnget - Sent Masternode winners to %s/n", pfrom->addr.ToString().c_str());    }    else if (strCommand == "mnw") { //Masternode Payments Declare Winner        LOCK(cs_masternodepayments);        //this is required in litemode        CMasternodePaymentWinner winner;        vRecv >> winner;        if(chainActive.Tip() == NULL) return;        CTxDestination address1;        ExtractDestination(winner.payee, address1);        CBitcoinAddress address2(address1);        uint256 hash = winner.GetHash();        if(mapSeenMasternodeVotes.count(hash)) {            if(fDebug) LogPrintf("mnw - seen vote %s Addr %s Height %d bestHeight %d/n", hash.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, chainActive.Tip()->nHeight);            return;        }        if(winner.nBlockHeight < chainActive.Tip()->nHeight - 10 || winner.nBlockHeight > chainActive.Tip()->nHeight+20){            LogPrintf("mnw - winner out of range %s Addr %s Height %d bestHeight %d/n", winner.vin.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, chainActive.Tip()->nHeight);            return;        }        if(winner.vin.nSequence != std::numeric_limits<unsigned int>::max()){            LogPrintf("mnw - invalid nSequence/n");            Misbehaving(pfrom->GetId(), 100);            return;        }        LogPrintf("mnw - winning vote - Vin %s Addr %s Height %d bestHeight %d/n", winner.vin.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, chainActive.Tip()->nHeight);        if(!masternodePayments.CheckSignature(winner)){            LogPrintf("mnw - invalid signature/n");            Misbehaving(pfrom->GetId(), 100);            return;        }        mapSeenMasternodeVotes.insert(make_pair(hash, winner));        if(masternodePayments.AddWinningMasternode(winner)){            masternodePayments.Relay(winner);        }    }
开发者ID:unpaybank,项目名称:unpaycore,代码行数:62,


示例10: getInputsCoinsViewCache

bool MultisigDialog::createMultisigTransaction(vector<CTxIn> vUserIn, vector<CTxOut> vUserOut, string& feeStringRet, string& errorRet){    try{        //attempt to access the given inputs        CCoinsViewCache view = getInputsCoinsViewCache(vUserIn);        //retrieve total input val and change dest        CAmount totalIn = 0;        vector<CAmount> vInputVals;        CScript changePubKey;        bool fFirst = true;        for(CTxIn in : vUserIn){            const CCoins* coins = view.AccessCoins(in.prevout.hash);            if(!coins->IsAvailable(in.prevout.n) || coins == NULL){                continue;            }            CTxOut prevout = coins->vout[in.prevout.n];            CScript privKey = prevout.scriptPubKey;            vInputVals.push_back(prevout.nValue);            totalIn += prevout.nValue;            if(!fFirst){                if(privKey != changePubKey){                    throw runtime_error("Address mismatch! Inputs must originate from the same multisignature address.");                }            }else{                fFirst = false;                changePubKey = privKey;            }        }        CAmount totalOut = 0;        //retrieve total output val        for(CTxOut out : vUserOut){            totalOut += out.nValue;        }        if(totalIn < totalOut){            throw runtime_error("Not enough PIV provided as input to complete transaction (including fee).");        }        //calculate change amount        CAmount changeAmount = totalIn - totalOut;        CTxOut change(changeAmount, changePubKey);        //generate random position for change        unsigned int changeIndex = rand() % (vUserOut.size() + 1);        //insert change into random position        if(changeIndex < vUserOut.size()){            vUserOut.insert(vUserOut.begin() + changeIndex, change);        }else{            vUserOut.emplace_back(change);        }        //populate tx        CMutableTransaction tx;        tx.vin = vUserIn;        tx.vout = vUserOut;        const CCoins* coins = view.AccessCoins(tx.vin[0].prevout.hash);        if(coins == NULL || !coins->IsAvailable(tx.vin[0].prevout.n)){            throw runtime_error("Coins unavailable (unconfirmed/spent)");        }        CScript prevPubKey = coins->vout[tx.vin[0].prevout.n].scriptPubKey;        //get payment destination        CTxDestination address;        if(!ExtractDestination(prevPubKey, address)){            throw runtime_error("Could not find address for destination.");        }        CScriptID hash = boost::get<CScriptID>(address);        CScript redeemScript;        if (!pwalletMain->GetCScript(hash, redeemScript)){            throw runtime_error("could not redeem");        }        txnouttype type;        vector<CTxDestination> addresses;        int nReq;        if(!ExtractDestinations(redeemScript, type, addresses, nReq)){            throw runtime_error("Could not extract destinations from redeem script.");        }        for(CTxIn& in : tx.vin){            in.scriptSig.clear();            //scale estimate to account for multisig scriptSig            for(unsigned int i = 0; i < 50*(nReq+addresses.size()); i++){                in.scriptSig << INT64_MAX;            }        }        //calculate fee        unsigned int nBytes = tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION);//.........这里部分代码省略.........
开发者ID:michaili,项目名称:PIVX,代码行数:101,


示例11: message

bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient){    if (!optionsModel)        return false;    if (request.IsInitialized()) {        // Payment request network matches client network?        if (!verifyNetwork(request.getDetails())) {            Q_EMIT message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."),                CClientUIInterface::MSG_ERROR);            return false;        }        // Make sure any payment requests involved are still valid.        // This is re-checked just before sending coins in WalletModel::sendCoins().        if (verifyExpired(request.getDetails())) {            Q_EMIT message(tr("Payment request rejected"), tr("Payment request expired."),                CClientUIInterface::MSG_ERROR);            return false;        }    } else {        Q_EMIT message(tr("Payment request error"), tr("Payment request is not initialized."),            CClientUIInterface::MSG_ERROR);        return false;    }    recipient.paymentRequest = request;    recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo());    request.getMerchant(certStore.get(), recipient.authenticatedMerchant);    QList<std::pair<CScript, CAmount> > sendingTos = request.getPayTo();    QStringList addresses;    for (const std::pair<CScript, CAmount>& sendingTo : sendingTos) {        // Extract and check destination addresses        CTxDestination dest;        if (ExtractDestination(sendingTo.first, dest)) {            // Append destination address            addresses.append(QString::fromStdString(EncodeDestination(dest)));        }        else if (!recipient.authenticatedMerchant.isEmpty()) {            // Unauthenticated payment requests to custom bitcoin addresses are not supported            // (there is no good way to tell the user where they are paying in a way they'd            // have a chance of understanding).            Q_EMIT message(tr("Payment request rejected"),                tr("Unverified payment requests to custom payment scripts are unsupported."),                CClientUIInterface::MSG_ERROR);            return false;        }        // Bitcoin amounts are stored as (optional) uint64 in the protobuf messages (see paymentrequest.proto),        // but CAmount is defined as int64_t. Because of that we need to verify that amounts are in a valid range        // and no overflow has happened.        if (!verifyAmount(sendingTo.second)) {            Q_EMIT message(tr("Payment request rejected"), tr("Invalid payment request."), CClientUIInterface::MSG_ERROR);            return false;        }        // Extract and check amounts        CTxOut txOut(sendingTo.second, sendingTo.first);        if (IsDust(txOut, ::dustRelayFee)) {            Q_EMIT message(tr("Payment request error"), tr("Requested payment amount of %1 is too small (considered dust).")                .arg(BitcoinUnits::formatWithUnit(optionsModel->getDisplayUnit(), sendingTo.second)),                CClientUIInterface::MSG_ERROR);            return false;        }        recipient.amount += sendingTo.second;        // Also verify that the final amount is still in a valid range after adding additional amounts.        if (!verifyAmount(recipient.amount)) {            Q_EMIT message(tr("Payment request rejected"), tr("Invalid payment request."), CClientUIInterface::MSG_ERROR);            return false;        }    }    // Store addresses and format them to fit nicely into the GUI    recipient.address = addresses.join("<br />");    if (!recipient.authenticatedMerchant.isEmpty()) {        qDebug() << "PaymentServer::processPaymentRequest: Secure payment request from " << recipient.authenticatedMerchant;    }    else {        qDebug() << "PaymentServer::processPaymentRequest: Insecure payment request to " << addresses.join(", ");    }    return true;}
开发者ID:TinyUlt,项目名称:bitcoin,代码行数:91,


示例12: while

void MultisigDialog::on_transaction_textChanged(){    while(ui->inputs->count())        delete ui->inputs->takeAt(0)->widget();    while(ui->outputs->count())        delete ui->outputs->takeAt(0)->widget();    if(ui->transaction->text().size() > 0)        ui->signTransactionButton->setEnabled(true);    else        ui->signTransactionButton->setEnabled(false);    // Decode the raw transaction    std::vector<unsigned char> txData(ParseHex(ui->transaction->text().toStdString()));    CDataStream ss(txData, SER_NETWORK, PROTOCOL_VERSION);    CTransaction tx;    try    {        ss >> tx;    }    catch(std::exception &e)    {        (void)e;        return;    }    // Fill input list    int index = -1;    BOOST_FOREACH(const CTxIn& txin, tx.vin)    {        uint256 prevoutHash = txin.prevout.hash;        addInput();        index++;        MultisigInputEntry *entry = qobject_cast<MultisigInputEntry *>(ui->inputs->itemAt(index)->widget());        if(entry)        {            entry->setTransactionId(QString(prevoutHash.GetHex().c_str()));            entry->setTransactionOutputIndex(txin.prevout.n);        }    }    // Fill output list    index = -1;    BOOST_FOREACH(const CTxOut& txout, tx.vout)    {        CScript scriptPubKey = txout.scriptPubKey;        CTxDestination addr;        ExtractDestination(scriptPubKey, addr);        CBitcoinAddress address(addr);        SendCoinsRecipient recipient;        recipient.address = QString(address.ToString().c_str());        recipient.amount = txout.nValue;        addOutput();        index++;        SendCoinsEntry *entry = qobject_cast<SendCoinsEntry *>(ui->outputs->itemAt(index)->widget());        if(entry)        {            entry->setValue(recipient);        }    }    updateRemoveEnabled();}
开发者ID:Bitcoin21,项目名称:V1.0,代码行数:63,


示例13: getblocktemplate

//.........这里部分代码省略.........                break;            case THRESHOLD_LOCKED_IN:                // Ensure bit is set in block version                pblock->nVersion |= VersionBitsMask(consensusParams, pos);                // FALL THROUGH to get vbavailable set...            case THRESHOLD_STARTED:            {                const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];                vbavailable.push_back(Pair(gbt_vb_name(pos), consensusParams.vDeployments[pos].bit));                if (setClientRules.find(vbinfo.name) == setClientRules.end()) {                    if (!vbinfo.gbt_force) {                        // If the client doesn't support this, don't indicate it in the [default] version                        pblock->nVersion &= ~VersionBitsMask(consensusParams, pos);                    }                }                break;            }            case THRESHOLD_ACTIVE:            {                // Add to rules only                const struct BIP9DeploymentInfo& vbinfo = VersionBitsDeploymentInfo[pos];                aRules.push_back(gbt_vb_name(pos));                if (setClientRules.find(vbinfo.name) == setClientRules.end()) {                    // Not supported by the client; make sure it's safe to proceed                    if (!vbinfo.gbt_force) {                        // If we do anything other than throw an exception here, be sure version/force isn't sent to old clients                        throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Support for '%s' rule requires explicit client support", vbinfo.name));                    }                }                break;            }        }    }    result.push_back(Pair("version", pblock->nVersion));    result.push_back(Pair("rules", aRules));    result.push_back(Pair("vbavailable", vbavailable));    result.push_back(Pair("vbrequired", int(0)));    if (nMaxVersionPreVB >= 2) {        // If VB is supported by the client, nMaxVersionPreVB is -1, so we won't get here        // Because BIP 34 changed how the generation transaction is serialized, we can only use version/force back to v2 blocks        // This is safe to do [otherwise-]unconditionally only because we are throwing an exception above if a non-force deployment gets activated        // Note that this can probably also be removed entirely after the first BIP9 non-force deployment (ie, probably segwit) gets activated        aMutable.push_back("version/force");    }    result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));    result.push_back(Pair("transactions", transactions));    result.push_back(Pair("coinbaseaux", aux));    result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0]->GetValueOut()));    result.push_back(Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));    result.push_back(Pair("target", hashTarget.GetHex()));    result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));    result.push_back(Pair("mutable", aMutable));    result.push_back(Pair("noncerange", "00000000ffffffff"));    result.push_back(Pair("sigoplimit", (int64_t)MaxBlockSigOps(fDIP0001ActiveAtTip)));    result.push_back(Pair("sizelimit", (int64_t)MaxBlockSize(fDIP0001ActiveAtTip)));    result.push_back(Pair("curtime", pblock->GetBlockTime()));    result.push_back(Pair("bits", strprintf("%08x", pblock->nBits)));    result.push_back(Pair("previousbits", strprintf("%08x", pblocktemplate->nPrevBits)));    result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));    UniValue masternodeObj(UniValue::VARR);    for (const auto& txout : pblocktemplate->voutMasternodePayments) {        CTxDestination address1;        ExtractDestination(txout.scriptPubKey, address1);        CBitcoinAddress address2(address1);        UniValue obj(UniValue::VOBJ);        obj.push_back(Pair("payee", address2.ToString().c_str()));        obj.push_back(Pair("script", HexStr(txout.scriptPubKey)));        obj.push_back(Pair("amount", txout.nValue));        masternodeObj.push_back(obj);    }    result.push_back(Pair("masternode", masternodeObj));    result.push_back(Pair("masternode_payments_started", pindexPrev->nHeight + 1 > consensusParams.nMasternodePaymentsStartBlock));    result.push_back(Pair("masternode_payments_enforced", deterministicMNManager->IsDeterministicMNsSporkActive() || sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT)));    UniValue superblockObjArray(UniValue::VARR);    if(pblocktemplate->voutSuperblockPayments.size()) {        for (const auto& txout : pblocktemplate->voutSuperblockPayments) {            UniValue entry(UniValue::VOBJ);            CTxDestination address1;            ExtractDestination(txout.scriptPubKey, address1);            CBitcoinAddress address2(address1);            entry.push_back(Pair("payee", address2.ToString().c_str()));            entry.push_back(Pair("script", HexStr(txout.scriptPubKey)));            entry.push_back(Pair("amount", txout.nValue));            superblockObjArray.push_back(entry);        }    }    result.push_back(Pair("superblock", superblockObjArray));    result.push_back(Pair("superblocks_started", pindexPrev->nHeight + 1 > consensusParams.nSuperblockStartBlock));    result.push_back(Pair("superblocks_enabled", sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED)));    result.push_back(Pair("coinbase_payload", HexStr(pblock->vtx[0]->vExtraPayload)));    return result;}
开发者ID:thephez,项目名称:dash,代码行数:101,


示例14: ProcessMessageAlphanodePayments

void ProcessMessageAlphanodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv){    if(!darkSendPool.IsBlockchainSynced()) return;    if (strCommand == "mnget") { //Alpha Node Payments Request Sync        if(pfrom->HasFulfilledRequest("mnget")) {            LogPrintf("mnget - peer already asked me for the list/n");            Misbehaving(pfrom->GetId(), 20);            return;        }        pfrom->FulfilledRequest("mnget");        alphanodePayments.Sync(pfrom);        LogPrintf("mnget - Sent Alpha Node winners to %s/n", pfrom->addr.ToString().c_str());    }    else if (strCommand == "mnw") { //Alpha Node Payments Declare Winner        LOCK(cs_alphanodepayments);        //this is required in litemode        CAlphanodePaymentWinner winner;        vRecv >> winner;        if(pindexBest == NULL) return;        CTxDestination address1;        ExtractDestination(winner.payee, address1);        CTaoAddress address2(address1);        uint256 hash = winner.GetHash();        if(mapSeenAlphanodeVotes.count(hash)) {            if(fDebug) LogPrintf("mnw - seen vote %s Addr %s Height %d bestHeight %d/n", hash.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight);            return;        }        if(winner.nBlockHeight < pindexBest->nHeight - 10 || winner.nBlockHeight > pindexBest->nHeight+20){            LogPrintf("mnw - winner out of range %s Addr %s Height %d bestHeight %d/n", winner.vin.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight);            return;        }        if(winner.vin.nSequence != std::numeric_limits<unsigned int>::max()){            LogPrintf("mnw - invalid nSequence/n");            Misbehaving(pfrom->GetId(), 100);            return;        }        LogPrintf("mnw - winning vote - Vin %s Addr %s Height %d bestHeight %d/n", winner.vin.ToString().c_str(), address2.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight);        if(!alphanodePayments.CheckSignature(winner)){            LogPrintf("mnw - invalid signature/n");            Misbehaving(pfrom->GetId(), 100);            return;        }        mapSeenAlphanodeVotes.insert(make_pair(hash, winner));        if(alphanodePayments.AddWinningAlphanode(winner)){            alphanodePayments.Relay(winner);        }    }
开发者ID:taoblockchain,项目名称:tao-core,代码行数:61,


示例15: sub

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet* wallet, const CWalletTx& wtx){    QList<TransactionRecord> parts;    int64_t nTime = wtx.GetComputedTxTime();    CAmount nCredit = wtx.GetCredit(ISMINE_ALL);    CAmount nDebit = wtx.GetDebit(ISMINE_ALL);    CAmount nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash();    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (wtx.IsCoinStake()) {        TransactionRecord sub(hash, nTime);        CTxDestination address;        if (!ExtractDestination(wtx.vout[1].scriptPubKey, address))            return parts;        if (!IsMine(*wallet, address)) {            //if the address is not yours then it means you have a tx sent to you in someone elses coinstake tx            for (unsigned int i = 1; i < wtx.vout.size(); i++) {                CTxDestination outAddress;                if (ExtractDestination(wtx.vout[i].scriptPubKey, outAddress)) {                    if (IsMine(*wallet, outAddress)) {                        isminetype mine = wallet->IsMine(wtx.vout[i]);                        sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;                        sub.type = TransactionRecord::MNReward;                        sub.address = CBitcoinAddress(outAddress).ToString();                        sub.credit = wtx.vout[i].nValue;                    }                }            }        } else {            //stake reward            isminetype mine = wallet->IsMine(wtx.vout[1]);            sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;            sub.type = TransactionRecord::StakeMint;            sub.address = CBitcoinAddress(address).ToString();            sub.credit = nNet;        }        parts.append(sub);    } else if (wtx.IsZerocoinSpend()) {        // a zerocoin spend that was created by this wallet        libzerocoin::CoinSpend zcspend = TxInToZerocoinSpend(wtx.vin[0]);        bool fSpendFromMe = wallet->IsMyZerocoinSpend(zcspend.getCoinSerialNumber());        //zerocoin spend outputs        bool fFeeAssigned = false;        for (const CTxOut txout : wtx.vout) {            // change that was reminted as zerocoins            if (txout.IsZerocoinMint()) {                // do not display record if this isn't from our wallet                if (!fSpendFromMe)                    continue;                TransactionRecord sub(hash, nTime);                sub.type = TransactionRecord::ZerocoinSpend_Change_zPiv;                sub.address = mapValue["zerocoinmint"];                sub.debit = -txout.nValue;                if (!fFeeAssigned) {                    sub.debit -= (wtx.GetZerocoinSpent() - wtx.GetValueOut());                    fFeeAssigned = true;                }                sub.idx = parts.size();                parts.append(sub);                continue;            }            string strAddress = "";            CTxDestination address;            if (ExtractDestination(txout.scriptPubKey, address))                strAddress = CBitcoinAddress(address).ToString();            // a zerocoinspend that was sent to an address held by this wallet            isminetype mine = wallet->IsMine(txout);            if (mine) {                TransactionRecord sub(hash, nTime);                sub.type = (fSpendFromMe ? TransactionRecord::ZerocoinSpend_FromMe : TransactionRecord::RecvFromZerocoinSpend);                sub.debit = txout.nValue;                sub.address = mapValue["recvzerocoinspend"];                if (strAddress != "")                    sub.address = strAddress;                sub.idx = parts.size();                parts.append(sub);                continue;            }            // spend is not from us, so do not display the spend side of the record            if (!fSpendFromMe)                continue;            // zerocoin spend that was sent to someone else            TransactionRecord sub(hash, nTime);            sub.debit = -txout.nValue;            sub.type = TransactionRecord::ZerocoinSpend;            sub.address = mapValue["zerocoinspend"];            if (strAddress != "")                sub.address = strAddress;            sub.idx = parts.size();//.........这里部分代码省略.........
开发者ID:michaili,项目名称:PIVX,代码行数:101,


示例16: sub

/* * Decompose CWallet transaction to model transaction records. */QList<Credits_TransactionRecord> Credits_TransactionRecord::decomposeTransaction(const Credits_CWallet *keyholder_wallet, const Credits_CWalletTx &wtx){    //The decomposed transactions should not be affected by prepared deposits. Passing in empty list.    map<uint256, set<int> > mapPreparedDepositTxInPoints;    QList<Credits_TransactionRecord> parts;    int64_t nTime = wtx.GetTxTime();    int64_t nCredit = wtx.GetCredit(mapPreparedDepositTxInPoints, keyholder_wallet);    int64_t nDebit = wtx.GetDebit(keyholder_wallet);    int64_t nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash();    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (nNet > 0 || wtx.IsCoinBase())    {        //        // Credit        //		for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)		{			const CTxOut& txout = wtx.vout[nOut];            if(keyholder_wallet->IsMine(txout))            {                Credits_TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = parts.size(); // sequence number                sub.credit = txout.nValue;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*keyholder_wallet, address))                {                    // Received by Credits Address                    sub.type = Credits_TransactionRecord::RecvWithAddress;                    sub.address = CBitcoinAddress(address).ToString();                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = Credits_TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                if (wtx.IsCoinBase())                {                    // Generated                    sub.type = Credits_TransactionRecord::Generated;                }                else if (wtx.IsDeposit())                {                	if(nOut == 0) {                		sub.type = Credits_TransactionRecord::Deposit;                	} else {                		sub.type = Credits_TransactionRecord::DepositChange;                	}                }                parts.append(sub);            }        }    }    else    {        bool fAllFromMe = true;        BOOST_FOREACH(const Credits_CTxIn& txin, wtx.vin)            fAllFromMe = fAllFromMe && keyholder_wallet->IsMine(txin);        bool fAllToMe = true;        BOOST_FOREACH(const CTxOut& txout, wtx.vout)            fAllToMe = fAllToMe && keyholder_wallet->IsMine(txout);        if (fAllFromMe && fAllToMe)        {            // Payment to self            int64_t nChange = wtx.GetChange(keyholder_wallet);            Credits_TransactionRecord sub(hash, nTime, Credits_TransactionRecord::SendToSelf, "", -(nDebit - nChange), nCredit - nChange);            SetupAllFromMeAllToMeDepositSub(wtx, 0, sub);            parts.append(sub);            if(wtx.IsDeposit() && wtx.vout.size() == 2) {                Credits_TransactionRecord sub(hash, nTime, Credits_TransactionRecord::SendToSelf, "", -(nDebit - nChange), nCredit - nChange);                SetupAllFromMeAllToMeDepositSub(wtx, 1, sub);                parts.append(sub);            }        }        else if (fAllFromMe)        {            //            // Debit            //            int64_t nTxFee = nDebit - wtx.GetValueOut();            for (unsigned int nOut = 0; nOut < wtx.vout.size(); nOut++)            {                const CTxOut& txout = wtx.vout[nOut];                Credits_TransactionRecord sub(hash, nTime);                sub.idx = parts.size();                if(!wtx.IsDeposit()) {					if(keyholder_wallet->IsMine(txout))//.........这里部分代码省略.........
开发者ID:credits-currency,项目名称:credits,代码行数:101,


示例17: LOCK2

QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, int vout, int unit){    QString strHTML;    LOCK2(cs_main, wallet->cs_wallet);    strHTML.reserve(4000);    strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";    int64_t nTime = wtx.GetTxTime();    int64_t nCredit = wtx.GetCredit();    int64_t nDebit = wtx.GetDebit();    int64_t nNet = nCredit - nDebit;    strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);    int nRequests = wtx.GetRequestCount();    if (nRequests != -1)    {        if (nRequests == 0)            strHTML += tr(", has not been successfully broadcast yet");        else if (nRequests > 0)            strHTML += tr(", broadcast through %n node(s)", "", nRequests);    }    strHTML += "<br>";    strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";    //    // From    //    if (wtx.IsCoinBase())    {        strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";    }    else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())    {        // Online transaction        strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";    }    else    {        // Offline transaction        if (nNet > 0)        {            // Credit            BOOST_FOREACH(const CTxOut& txout, wtx.vout)            {                if (wallet->IsMine(txout))                {                    CTxDestination address;                    if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                    {                        if (wallet->mapAddressBook.count(address))                        {                            strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";                            strHTML += "<b>" + tr("To") + ":</b> ";                            strHTML += GUIUtil::HtmlEscape(CAricoinAddress(address).ToString());                            if (!wallet->mapAddressBook[address].name.empty())                                strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address].name) + ")";                            else                                strHTML += " (" + tr("own address") + ")";                            strHTML += "<br>";                        }                    }                    break;                }            }        }    }
开发者ID:aricoin,项目名称:Aricoin,代码行数:68,


示例18: CheckProRegTx

bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state){    if (tx.nType != TRANSACTION_PROVIDER_REGISTER) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-type");    }    CProRegTx ptx;    if (!GetTxPayload(tx, ptx)) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-payload");    }    if (ptx.nVersion == 0 || ptx.nVersion > CProRegTx::CURRENT_VERSION) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-version");    }    if (ptx.nType != 0) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-type");    }    if (ptx.nMode != 0) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-mode");    }    if (ptx.keyIDOwner.IsNull() || !ptx.pubKeyOperator.IsValid() || ptx.keyIDVoting.IsNull()) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-key-null");    }    if (!ptx.scriptPayout.IsPayToPublicKeyHash() && !ptx.scriptPayout.IsPayToScriptHash()) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee");    }    CTxDestination payoutDest;    if (!ExtractDestination(ptx.scriptPayout, payoutDest)) {        // should not happen as we checked script types before        return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-dest");    }    // don't allow reuse of payout key for other keys (don't allow people to put the payee key onto an online server)    if (payoutDest == CTxDestination(ptx.keyIDOwner) || payoutDest == CTxDestination(ptx.keyIDVoting)) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-reuse");    }    // It's allowed to set addr to 0, which will put the MN into PoSe-banned state and require a ProUpServTx to be issues later    // If any of both is set, it must be valid however    if (ptx.addr != CService() && !CheckService(tx.GetHash(), ptx, state)) {        return false;    }    if (ptx.nOperatorReward > 10000) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-operator-reward");    }    CTxDestination collateralTxDest;    CKeyID keyForPayloadSig;    COutPoint collateralOutpoint;    if (!ptx.collateralOutpoint.hash.IsNull()) {        Coin coin;        if (!GetUTXOCoin(ptx.collateralOutpoint, coin) || coin.out.nValue != 1000 * COIN) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral");        }        if (!ExtractDestination(coin.out.scriptPubKey, collateralTxDest)) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-dest");        }        // Extract key from collateral. This only works for P2PK and P2PKH collaterals and will fail for P2SH.        // Issuer of this ProRegTx must prove ownership with this key by signing the ProRegTx        if (!CBitcoinAddress(collateralTxDest).GetKeyID(keyForPayloadSig)) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-pkh");        }        collateralOutpoint = ptx.collateralOutpoint;    } else {        if (ptx.collateralOutpoint.n >= tx.vout.size()) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-index");        }        if (tx.vout[ptx.collateralOutpoint.n].nValue != 1000 * COIN) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral");        }        if (!ExtractDestination(tx.vout[ptx.collateralOutpoint.n].scriptPubKey, collateralTxDest)) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-dest");        }        collateralOutpoint = COutPoint(tx.GetHash(), ptx.collateralOutpoint.n);    }    // don't allow reuse of collateral key for other keys (don't allow people to put the collateral key onto an online server)    // this check applies to internal and external collateral, but internal collaterals are not necessarely a P2PKH    if (collateralTxDest == CTxDestination(ptx.keyIDOwner) || collateralTxDest == CTxDestination(ptx.keyIDVoting)) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-reuse");    }    if (pindexPrev) {        auto mnList = deterministicMNManager->GetListForBlock(pindexPrev->GetBlockHash());        // only allow reusing of addresses when it's for the same collateral (which replaces the old MN)        if (mnList.HasUniqueProperty(ptx.addr) && mnList.GetUniquePropertyMN(ptx.addr)->collateralOutpoint != collateralOutpoint) {            return state.DoS(10, false, REJECT_DUPLICATE, "bad-protx-dup-addr");        }        // never allow duplicate keys, even if this ProTx would replace an existing MN        if (mnList.HasUniqueProperty(ptx.keyIDOwner) || mnList.HasUniqueProperty(ptx.pubKeyOperator)) {//.........这里部分代码省略.........
开发者ID:dashpay,项目名称:dash,代码行数:101,


示例19: oldVin

bool MultisigDialog::signMultisigTx(CMutableTransaction& tx, string& errorOut, QVBoxLayout* keyList){    //will be set false if all inputs are not fully signed(valid)    bool fComplete = true;    //if keyslist is not default value AND has items in list then true    bool fGivenKeys = (keyList != nullptr) && (keyList->count() > 0);    try{        //copy of vin for reference before vin is mutated        vector<CTxIn> oldVin(tx.vin);        CBasicKeyStore privKeystore;        //if keys were given, attempt to collect redeem and scriptpubkey        if(fGivenKeys){            for(int i = 0; i < keyList->count(); i++){                QWidget* keyFrame = qobject_cast<QWidget*>(keyList->itemAt(i)->widget());                QLineEdit* key = keyFrame->findChild<QLineEdit*>("key");                CBitcoinSecret vchSecret;                if (!vchSecret.SetString(key->text().toStdString()))                    throw runtime_error("Invalid private key");                CKey cKey = vchSecret.GetKey();                if (!cKey.IsValid())                    throw runtime_error("Private key outside allowed range");                privKeystore.AddKey(cKey);            }            for(CTxIn& txin : tx.vin){                //get inputs                CTransaction txVin;                uint256 hashBlock;                if (!GetTransaction(txin.prevout.hash, txVin, hashBlock, true))                    throw runtime_error("txin could not be found");                if (hashBlock == 0)                    throw runtime_error("txin is unconfirmed");                //get pubkey from input                CScript prevPubKey = txVin.vout[txin.prevout.n].scriptPubKey;                //get payment destination                CTxDestination address;                if(!ExtractDestination(prevPubKey, address)){                    throw runtime_error("Could not find address for destination.");                }                //get redeem script related to destination                CScriptID hash = boost::get<CScriptID>(address);                CScript redeemScript;                if (!pwalletMain->GetCScript(hash, redeemScript)){                    errorOut = "could not redeem";                }                privKeystore.AddCScript(redeemScript);            }        }else{            if (model->getEncryptionStatus() == model->Locked) {                if (!model->requestUnlock(true).isValid()) {                    // Unlock wallet was cancelled                    throw runtime_error("Error: Your wallet is locked. Please enter the wallet passphrase first.");                }            }        }        //choose between local wallet and provided        const CKeyStore& keystore = fGivenKeys ? privKeystore : *pwalletMain;        //attempt to sign each input from local wallet        int nIn = 0;        for(CTxIn& txin : tx.vin){            //get inputs            CTransaction txVin;            uint256 hashBlock;            if (!GetTransaction(txin.prevout.hash, txVin, hashBlock, true))                throw runtime_error("txin could not be found");            if (hashBlock == 0)                throw runtime_error("txin is unconfirmed");            txin.scriptSig.clear();            CScript prevPubKey = txVin.vout[txin.prevout.n].scriptPubKey;            //sign what we can            SignSignature(keystore, prevPubKey, tx, nIn);            //merge in any previous signatures            txin.scriptSig = CombineSignatures(prevPubKey, tx, nIn, txin.scriptSig, oldVin[nIn].scriptSig);            if (!VerifyScript(txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, MutableTransactionSignatureChecker(&tx, nIn))){                fComplete = false;            }            nIn++;        }        ui->signButtonStatus->setText(buildMultisigTxStatusString(fComplete, tx));    }catch(const runtime_error& e){        errorOut = string(e.what());        fComplete = false;//.........这里部分代码省略.........
开发者ID:michaili,项目名称:PIVX,代码行数:101,


示例20: LOCK2

QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx){    // individual tx do not affect any representation    static const bool fMultiSig = true;    QString strHTML;    LOCK2(cs_main, wallet->cs_wallet);    strHTML.reserve(4000);    strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";    int64_t nTime = wtx.GetTxTime();    std::map<int, int64_t> mapDebit, mapCredit, mapChange, mapNet;    // debits    wallet->FillDebits(wtx, mapDebit, fMultiSig);    // credits (mature)    wallet->FillMatures(wtx, mapCredit, fMultiSig);    // nets (mature - debits)    FillNets(mapDebit, mapCredit, mapNet);    strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);    int nRequests = wtx.GetRequestCount();    if (nRequests != -1)    {        if (nRequests == 0)            strHTML += tr(", has not been successfully broadcast yet");        else if (nRequests > 0)            strHTML += tr(", broadcast through %n node(s)", "", nRequests);    }    strHTML += "<br>";    strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";    //    // From    //    if (wtx.IsCoinBase() || wtx.IsCoinStake())    {        strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";    }    else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())    {        // Online transaction        strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";    }    else    {        // Offline transaction        if (ValueMapAllPositive(mapNet))        {            // Credit            BOOST_FOREACH(const CTxOut& txout, wtx.vout)            {                if (wallet->IsMine(txout, fMultiSig) & ISMINE_ALL)                {                    CTxDestination address;                    if (ExtractDestination(txout.scriptPubKey, address) &&                        (IsMine(*wallet, address, fMultiSig) & ISMINE_ALL))                    {                        if (wallet->mapAddressBook.count(address))                        {                            strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";                            strHTML += "<b>" + tr("To") + ":</b> ";                            CBitcoinAddress addr(address, txout.nColor);                            strHTML += GUIUtil::HtmlEscape(addr.ToString());                            // indicate distinction between own address and watch address                            if (IsMine(*wallet, address, fMultiSig) & ISMINE_SPENDABLE)                            {                                if (!wallet->mapAddressBook[address].empty())                                {                                    strHTML += " (" + tr("own address") + ", " + tr("label") + ": " +                                                   GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";                                }                                else                                {                                    strHTML += " (" + tr("own address") + ")";                                }                            }                            else                            {                                if (!wallet->mapAddressBook[address].empty())                                {                                    strHTML += " (" + tr("watch address") + ", " + tr("label") + ": " +                                                   GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";                                }                                else                                {                                    strHTML += " (" + tr("watch address") + ")";                                }                            }                            strHTML += "<br>";                        }                    }                    break;                }            }        }//.........这里部分代码省略.........
开发者ID:BreakoutCoin,项目名称:Breakout-Chain-Client,代码行数:101,


示例21: CheckProUpRegTx

bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state){    if (tx.nType != TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-type");    }    CProUpRegTx ptx;    if (!GetTxPayload(tx, ptx)) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-payload");    }    if (ptx.nVersion == 0 || ptx.nVersion > CProRegTx::CURRENT_VERSION) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-version");    }    if (ptx.nMode != 0) {        return state.DoS(100, false, REJECT_INVALID, "bad-protx-mode");    }    if (!ptx.pubKeyOperator.IsValid() || ptx.keyIDVoting.IsNull()) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-key-null");    }    if (!ptx.scriptPayout.IsPayToPublicKeyHash() && !ptx.scriptPayout.IsPayToScriptHash()) {        return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee");    }    CTxDestination payoutDest;    if (!ExtractDestination(ptx.scriptPayout, payoutDest)) {        // should not happen as we checked script types before        return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-dest");    }    if (pindexPrev) {        auto mnList = deterministicMNManager->GetListForBlock(pindexPrev->GetBlockHash());        auto dmn = mnList.GetMN(ptx.proTxHash);        if (!dmn) {            return state.DoS(100, false, REJECT_INVALID, "bad-protx-hash");        }        // don't allow reuse of payee key for other keys (don't allow people to put the payee key onto an online server)        if (payoutDest == CTxDestination(dmn->pdmnState->keyIDOwner) || payoutDest == CTxDestination(ptx.keyIDVoting)) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-payee-reuse");        }        Coin coin;        if (!GetUTXOCoin(dmn->collateralOutpoint, coin)) {            // this should never happen (there would be no dmn otherwise)            return state.DoS(100, false, REJECT_INVALID, "bad-protx-collateral");        }        // don't allow reuse of collateral key for other keys (don't allow people to put the collateral key onto an online server)        CTxDestination collateralTxDest;        if (!ExtractDestination(coin.out.scriptPubKey, collateralTxDest)) {            return state.DoS(100, false, REJECT_INVALID, "bad-protx-collateral-dest");        }        if (collateralTxDest == CTxDestination(dmn->pdmnState->keyIDOwner) || collateralTxDest == CTxDestination(ptx.keyIDVoting)) {            return state.DoS(10, false, REJECT_INVALID, "bad-protx-collateral-reuse");        }        if (mnList.HasUniqueProperty(ptx.pubKeyOperator)) {            auto otherDmn = mnList.GetUniquePropertyMN(ptx.pubKeyOperator);            if (ptx.proTxHash != otherDmn->proTxHash) {                return state.DoS(10, false, REJECT_DUPLICATE, "bad-protx-dup-key");            }        }        if (!deterministicMNManager->IsDIP3Enforced(pindexPrev->nHeight)) {            if (dmn->pdmnState->keyIDOwner != ptx.keyIDVoting) {                return state.DoS(10, false, REJECT_INVALID, "bad-protx-key-not-same");            }        }        if (!CheckInputsHash(tx, ptx, state)) {            return false;        }        if (!CheckHashSig(ptx, dmn->pdmnState->keyIDOwner, state)) {            return false;        }    }    return true;}
开发者ID:dashpay,项目名称:dash,代码行数:81,


示例22: if

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64 nTime = wtx.GetTxTime();    int64 nCredit = wtx.GetCredit(true);    int64 nDebit = wtx.GetDebit();    int64 nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash();    std::map<std::string, std::string> mapValue = wtx.mapValue;    const bool combineOutputs = (wtx.cUnit == 'S');    if (wtx.IsCoinStake()) // ppcoin: coinstake transaction    {        parts.append(TransactionRecord(hash, nTime, TransactionRecord::StakeMint, "", -nDebit, wtx.GetValueOut()));    }    else if (nNet > 0 || wtx.IsCoinBase())    {        //        // Credit        //        QMap<CScript, TransactionRecord*> outputParts;        BOOST_FOREACH(const CTxOut& txout, wtx.vout)        {            if(wallet->IsMine(txout))            {                TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = parts.size(); // sequence number                sub.credit = txout.nValue;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                {                    if (wtx.IsUnpark())                        sub.type = TransactionRecord::Unpark;                    else // Received by Bitcoin Address                        sub.type = TransactionRecord::RecvWithAddress;                    sub.address = CBitcoinAddress(address, wtx.cUnit).ToString();                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                if (wtx.IsCoinBase())                {                    // Generated                    sub.type = TransactionRecord::Generated;                }                if (combineOutputs)                {                    QMap<CScript, TransactionRecord*>::const_iterator it = outputParts.find(txout.scriptPubKey);                    if (it != outputParts.end())                    {                        TransactionRecord& previous = *it.value();                        previous.credit += sub.credit;                        continue;                    }                }                parts.append(sub);                if (combineOutputs)                    outputParts[txout.scriptPubKey] = &parts.back();            }        }    }
开发者ID:brossi,项目名称:nu-automake,代码行数:70,


示例23: sub

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64 nTime = wtx.GetTxTime();    int64 nCredit = wtx.GetCredit(true);    int64 nDebit = wtx.GetDebit();    int64 nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash();    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (showTransaction(wtx))    {        if (wtx.IsCoinStake()) // ppcoin: coinstake transaction        {            TransactionRecord sub(hash, nTime, TransactionRecord::StakeMint, "", -nDebit, wtx.GetValueOut());            CTxDestination address;            CTxOut txout = wtx.vout[1];            if(ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                sub.address = CBitcoinAddress(address).ToString();            parts.append(sub);        }        else if (nNet > 0 || wtx.IsCoinBase())        {            //            // Credit            //            BOOST_FOREACH(const CTxOut& txout, wtx.vout)            {                if(wallet->IsMine(txout))                {                    TransactionRecord sub(hash, nTime);                    CTxDestination address;                    sub.idx = parts.size(); // sequence number                    sub.credit = txout.nValue;                    if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                    {                        // Received by Bitcoin Address                        sub.type = TransactionRecord::RecvWithAddress;                        sub.address = CBitcoinAddress(address).ToString();                    }                    else                    {                        // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                        sub.type = TransactionRecord::RecvFromOther;                        sub.address = mapValue["from"];                    }                    if (wtx.IsCoinBase())                    {                        // Generated                        sub.type = TransactionRecord::Generated;                    }                    parts.append(sub);                }            }        }        else        {
开发者ID:CoinGame,项目名称:Peerunity,代码行数:64,


示例24: sub

//.........这里部分代码省略.........                && txout.IsAnonOutput())            {                const CScript &s = txout.scriptPubKey;                CKeyID ckidD = CPubKey(&s[2+1], 33).GetID();                if (wallet->HaveKey(ckidD))                {                    TransactionRecord sub(hash, nTime);                    sub.idx = parts.size(); // sequence number                    sub.credit = txout.nValue;                    sub.type = TransactionRecord::RecvMoinX;                    sub.address = CBitcoinAddress(ckidD).ToString();                    //sub.address = wallet->mapAddressBook[ckidD]                    snprintf(cbuf, sizeof(cbuf), "n_%u", nOut);                    mapValue_t::const_iterator mi = wtx.mapValue.find(cbuf);                    if (mi != wtx.mapValue.end() && !mi->second.empty())                        sub.narration = mi->second;                    parts.append(sub);                };            };            if (wallet->IsMine(txout))            {                TransactionRecord sub(hash, nTime);                sub.idx = parts.size(); // sequence number                CTxDestination address;                sub.credit = txout.nValue;                if (ExtractDestination(txout.scriptPubKey, address) && IsDestMine(*wallet, address))                {                    // Received by Bitcoin Address                    sub.type = TransactionRecord::RecvWithAddress;                    sub.address = CBitcoinAddress(address).ToString();                } else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                snprintf(cbuf, sizeof(cbuf), "n_%u", nOut);                mapValue_t::const_iterator mi = wtx.mapValue.find(cbuf);                if (mi != wtx.mapValue.end() && !mi->second.empty())                    sub.narration = mi->second;                if (wtx.IsCoinBase())                {                    // Generated (proof-of-work)                    sub.type = TransactionRecord::Generated;                };                if (wtx.IsCoinStake())                {                    // Generated (proof-of-stake)                    if (hashPrev == hash)                        continue; // last coinstake output                    sub.type = TransactionRecord::Generated;                    sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;                    hashPrev = hash;
开发者ID:MOIN,项目名称:moin,代码行数:67,


示例25: tr

//.........这里部分代码省略.........    {        isminetype fAllFromMe = ISMINE_SPENDABLE;        for (isminetype mine : wtx.txin_is_mine)        {            if(fAllFromMe > mine) fAllFromMe = mine;        }        isminetype fAllToMe = ISMINE_SPENDABLE;        for (isminetype mine : wtx.txout_is_mine)        {            if(fAllToMe > mine) fAllToMe = mine;        }        if (fAllFromMe)        {            if(fAllFromMe & ISMINE_WATCH_ONLY)                strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>";            //            // Debit            //            auto mine = wtx.txout_is_mine.begin();            for (const CTxOut& txout : wtx.tx->vout)            {                // Ignore change                isminetype toSelf = *(mine++);                if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))                    continue;                if (!wtx.value_map.count("to") || wtx.value_map["to"].empty())                {                    // Offline transaction                    CTxDestination address;                    if (ExtractDestination(txout.scriptPubKey, address))                    {                        strHTML += "<b>" + tr("To") + ":</b> ";                        std::string name;                        if (wallet.getAddress(                                address, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && !name.empty())                            strHTML += GUIUtil::HtmlEscape(name) + " ";                        strHTML += GUIUtil::HtmlEscape(EncodeDestination(address));                        if(toSelf == ISMINE_SPENDABLE)                            strHTML += " (own address)";                        else if(toSelf & ISMINE_WATCH_ONLY)                            strHTML += " (watch-only)";                        strHTML += "<br>";                    }                }                strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -txout.nValue) + "<br>";                if(toSelf)                    strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + "<br>";            }            if (fAllToMe)            {                // Payment to self                CAmount nChange = wtx.change;                CAmount nValue = nCredit - nChange;                strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + "<br>";                strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nValue) + "<br>";            }            CAmount nTxFee = nDebit - wtx.tx->GetValueOut();            if (nTxFee > 0)                strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) + "<br>";
开发者ID:hmel,项目名称:bitcoin,代码行数:67,


示例26: BOOST_FOREACH

/* * Decompose CWallet transaction to model transaction records. */QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx){    QList<TransactionRecord> parts;    int64_t nTime = wtx.GetTxTime();    CAmount nCredit = wtx.GetCredit(ISMINE_ALL);    CAmount nDebit = wtx.GetDebit(ISMINE_ALL);    CAmount nNet = nCredit - nDebit;    uint256 hash = wtx.GetHash(), hashPrev = 0;    std::map<std::string, std::string> mapValue = wtx.mapValue;    if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())    {        //        // Credit        //        BOOST_FOREACH(const CTxOut& txout, wtx.vout)        {            isminetype mine = wallet->IsMine(txout);            if(mine)            {                TransactionRecord sub(hash, nTime);                CTxDestination address;                sub.idx = parts.size(); // sequence number                sub.credit = txout.nValue;                sub.involvesWatchAddress = mine == ISMINE_WATCH_ONLY;                if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                {                    // Received by Bitcoin Address                    sub.type = TransactionRecord::RecvWithAddress;                    sub.address = CTurbogoldAddress(address).ToString();                }                else                {                    // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction                    sub.type = TransactionRecord::RecvFromOther;                    sub.address = mapValue["from"];                }                if (wtx.IsCoinBase())                {                    // Generated (proof-of-work)                    sub.type = TransactionRecord::Generated;                }                if (wtx.IsCoinStake())                {                    // Generated (proof-of-stake)                    if (hashPrev == hash)                        continue; // last coinstake output                    CAmount nValueOut = 0;                    BOOST_FOREACH(const CTxOut& txout, wtx.vout)                    {                        if (IsMine(*wallet,txout.scriptPubKey))                            nValueOut += txout.nValue;                        if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut))                            throw std::runtime_error("CTransaction::GetValueOut() : value out of range");                    }                    sub.type = TransactionRecord::Generated;                    sub.credit = nNet > 0 ? nNet : nValueOut - nDebit;                    hashPrev = hash;                }                parts.append(sub);            }        }    }
开发者ID:ultra-pool,项目名称:turbogold,代码行数:69,


示例27: SelectParams

//.........这里部分代码省略.........    // Validly signed, but by a CA not in our root CA list:    data = DecodeBase64(paymentrequest5_cert1_BASE64);    r = handleRequest(server, data);    r.paymentRequest.getMerchant(caStore, merchant);    QCOMPARE(merchant, QString(""));    // Try again with no root CA's, verifiedMerchant should be empty:    caStore = X509_STORE_new();    PaymentServer::LoadRootCAs(caStore);    data = DecodeBase64(paymentrequest1_cert1_BASE64);    r = handleRequest(server, data);    r.paymentRequest.getMerchant(caStore, merchant);    QCOMPARE(merchant, QString(""));    // Load second root certificate    caStore = X509_STORE_new();    X509_STORE_add_cert(caStore, parse_b64der_cert(caCert2_BASE64));    PaymentServer::LoadRootCAs(caStore);    QByteArray byteArray;    // For the tests below we just need the payment request data from    // paymentrequestdata.h parsed + stored in r.paymentRequest.    //    // These tests require us to bypass the following normal client execution flow    // shown below to be able to explicitly just trigger a certain condition!    //    // handleRequest()    // -> PaymentServer::eventFilter()    //   -> PaymentServer::handleURIOrFile()    //     -> PaymentServer::readPaymentRequestFromFile()    //       -> PaymentServer::processPaymentRequest()    // Contains a testnet paytoaddress, so payment request network doesn't match client network:    data = DecodeBase64(paymentrequest1_cert2_BASE64);    byteArray = QByteArray((const char*)data.data(), data.size());    r.paymentRequest.parse(byteArray);    // Ensure the request is initialized, because network "main" is default, even for    // uninitialized payment requests and that will fail our test here.    QVERIFY(r.paymentRequest.IsInitialized());    QCOMPARE(PaymentServer::verifyNetwork(r.paymentRequest.getDetails()), false);    // Expired payment request (expires is set to 1 = 1970-01-01 00:00:01):    data = DecodeBase64(paymentrequest2_cert2_BASE64);    byteArray = QByteArray((const char*)data.data(), data.size());    r.paymentRequest.parse(byteArray);    // Ensure the request is initialized    QVERIFY(r.paymentRequest.IsInitialized());    // compares 1 < GetTime() == false (treated as expired payment request)    QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true);    // Unexpired payment request (expires is set to 0x7FFFFFFFFFFFFFFF = max. int64_t):    // 9223372036854775807 (uint64), 9223372036854775807 (int64_t) and -1 (int32_t)    // -1 is 1969-12-31 23:59:59 (for a 32 bit time values)    data = DecodeBase64(paymentrequest3_cert2_BASE64);    byteArray = QByteArray((const char*)data.data(), data.size());    r.paymentRequest.parse(byteArray);    // Ensure the request is initialized    QVERIFY(r.paymentRequest.IsInitialized());    // compares 9223372036854775807 < GetTime() == false (treated as unexpired payment request)    QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), false);    // Unexpired payment request (expires is set to 0x8000000000000000 > max. int64_t, allowed uint64):    // 9223372036854775808 (uint64), -9223372036854775808 (int64_t) and 0 (int32_t)    // 0 is 1970-01-01 00:00:00 (for a 32 bit time values)    data = DecodeBase64(paymentrequest4_cert2_BASE64);    byteArray = QByteArray((const char*)data.data(), data.size());    r.paymentRequest.parse(byteArray);    // Ensure the request is initialized    QVERIFY(r.paymentRequest.IsInitialized());    // compares -9223372036854775808 < GetTime() == true (treated as expired payment request)    QCOMPARE(PaymentServer::verifyExpired(r.paymentRequest.getDetails()), true);    // Test BIP70 DoS protection:    unsigned char randData[BIP70_MAX_PAYMENTREQUEST_SIZE + 1];    GetRandBytes(randData, sizeof(randData));    // Write data to a temp file:    QTemporaryFile tempFile;    tempFile.open();    tempFile.write((const char*)randData, sizeof(randData));    tempFile.close();    // compares 50001 <= BIP70_MAX_PAYMENTREQUEST_SIZE == false    QCOMPARE(PaymentServer::verifySize(tempFile.size()), false);    // Payment request with amount overflow (amount is set to 21000001 BTC):    data = DecodeBase64(paymentrequest5_cert2_BASE64);    byteArray = QByteArray((const char*)data.data(), data.size());    r.paymentRequest.parse(byteArray);    // Ensure the request is initialized    QVERIFY(r.paymentRequest.IsInitialized());    // Extract address and amount from the request    QList<std::pair<CScript, CAmount> > sendingTos = r.paymentRequest.getPayTo();    for (const std::pair<CScript, CAmount>& sendingTo : sendingTos) {        CTxDestination dest;        if (ExtractDestination(sendingTo.first, dest))            QCOMPARE(PaymentServer::verifyAmount(sendingTo.second), false);    }    delete server;}
开发者ID:21E14,项目名称:bitcoin,代码行数:101,


示例28: explorer

QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx){    QString strHTML;    QString explorer(fTestNet ? "http://explorer.butterflycoin.info/" : "http://explorer.butterflycoin.info/");    LOCK2(cs_main, wallet->cs_wallet);    strHTML.reserve(4000);    strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";    int64_t nTime = wtx.GetTxTime();    int64_t nCredit = wtx.GetCredit();    int64_t nDebit = wtx.GetDebit();    int64_t nNet = nCredit - nDebit;    strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);    int nRequests = wtx.GetRequestCount();    if (nRequests != -1)    {        if (nRequests == 0)            strHTML += tr(", has not been successfully broadcast yet");        else if (nRequests > 0)            strHTML += tr(", broadcast through %n node(s)", "", nRequests);    };    strHTML += "<br>";    strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";    //    // From    //    if (wtx.IsCoinBase() || wtx.IsCoinStake())    {        strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";    } else    if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())    {        // Online transaction        strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";    } else    {        // Offline transaction        if (nNet > 0)        {            // Credit            BOOST_FOREACH(const CTxOut& txout, wtx.vout)            {                if (wtx.nVersion == ANON_TXN_VERSION                    && txout.IsAnonOutput())                {                    const CScript &s = txout.scriptPubKey;                    CKeyID ckidD = CPubKey(&s[2+1], 33).GetID();                    std::string sAnonPrefix("ao ");                    if (wallet->HaveKey(ckidD) && (wallet->mapAddressBook[ckidD].empty() || !wallet->mapAddressBook[ckidD].compare(0, sAnonPrefix.length(), sAnonPrefix) == 0))                    {                        strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";                        strHTML += "<b>" + tr("To") + ":</b> <a href='"+explorer+"address.asp?address=";                        strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(ckidD).ToString())+"' target='_blank'>";                        strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(ckidD).ToString());                        if (!wallet->mapAddressBook[ckidD].empty())                            strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[ckidD]) + ")";                        else                            strHTML += " (" + tr("own address") + ")";                        strHTML += "</a><br>";                    };                    continue;                }                if (wallet->IsMine(txout))                {                    CTxDestination address;                    if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                    {                        if (wallet->mapAddressBook.count(address))                        {                            strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";                            strHTML += "<b>" + tr("To") + ":</b> <a href='"+explorer+"address.asp?address=";                            strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString())+"' target='_blank'>";                            strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());                            if (!wallet->mapAddressBook[address].empty())                                strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";                            else                                strHTML += " (" + tr("own address") + ")";                            strHTML += "</a><br>";                        };                    };                    break;                };            };        };    };
开发者ID:butterflypay,项目名称:butterflymaster,代码行数:91,


示例29: LOCK

QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx){    QString strHTML;    {        LOCK(wallet->cs_wallet);        strHTML.reserve(4000);        strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";        int64 nTime = wtx.GetTxTime();        int64 nCredit = wtx.GetCredit();        int64 nDebit = wtx.GetDebit();        int64 nNet = nCredit - nDebit;        strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);        int nRequests = wtx.GetRequestCount();        if (nRequests != -1)        {            if (nRequests == 0)                strHTML += tr(", has not been successfully broadcast yet");            else if (nRequests > 0)                strHTML += tr(", broadcast through %n node(s)", "", nRequests);        }        strHTML += "<br>";        strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";        //        // From        //        if (wtx.IsCoinBase() || wtx.IsCoinStake())        {            strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";        }        else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())        {            // Online transaction            strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";        }        else        {            // Offline transaction            if (nNet > 0)            {                // Credit                BOOST_FOREACH(const CTxOut& txout, wtx.vout)                {                    if (wallet->IsMine(txout))                    {                        CTxDestination address;                        if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address))                        {                            if (wallet->mapAddressBook.count(address))                            {                                strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";                                strHTML += "<b>" + tr("To") + ":</b> ";                                strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString());                                if (!wallet->mapAddressBook[address].empty())                                    strHTML += " (" + tr("own address") + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";                                else                                    strHTML += " (" + tr("own address") + ")";                                strHTML += "<br>";                            }                        }                        break;                    }                }            }        }        //        // To        //        if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty())        {            // Online transaction            std::string strAddress = wtx.mapValue["to"];            strHTML += "<b>" + tr("To") + ":</b> ";            CTxDestination dest = CBitcoinAddress(strAddress).Get();            if (wallet->mapAddressBook.count(dest) && !wallet->mapAddressBook[dest].empty())                strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[dest]) + " ";            strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>";        }        //        // Amount        //        if (wtx.IsCoinBase() && nCredit == 0)        {            //            // Coinbase            //            int64 nUnmatured = 0;            BOOST_FOREACH(const CTxOut& txout, wtx.vout)                nUnmatured += wallet->GetCredit(txout);            strHTML += "<b>" + tr("Credit") + ":</b> ";            if (wtx.IsInMainChain())                strHTML += BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";            else                strHTML += "(" + tr("not accepted") + ")";//.........这里部分代码省略.........
开发者ID:bittotemdev,项目名称:BittoTem,代码行数:101,


示例30: txout

void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog){    if (!model)        return;    // nPayAmount    CAmount nPayAmount = 0;    bool fDust = false;    CMutableTransaction txDummy;    for (const CAmount &amount : CoinControlDialog::payAmounts)    {        nPayAmount += amount;        if (amount > 0)        {            CTxOut txout(amount, (CScript)std::vector<unsigned char>(24, 0));            txDummy.vout.push_back(txout);            fDust |= IsDust(txout, ::dustRelayFee);        }    }    CAmount nAmount             = 0;    CAmount nPayFee             = 0;    CAmount nAfterFee           = 0;    CAmount nChange             = 0;    unsigned int nBytes         = 0;    unsigned int nBytesInputs   = 0;    unsigned int nQuantity      = 0;    bool fWitness               = false;    std::vector<COutPoint> vCoinControl;    std::vector<COutput>   vOutputs;    coinControl->ListSelected(vCoinControl);    model->getOutputs(vCoinControl, vOutputs);    for (const COutput& out : vOutputs) {        // unselect already spent, very unlikely scenario, this could happen        // when selected are spent elsewhere, like rpc or another computer        uint256 txhash = out.tx->GetHash();        COutPoint outpt(txhash, out.i);        if (model->isSpent(outpt))        {            coinControl->UnSelect(outpt);            continue;        }        // Quantity        nQuantity++;        // Amount        nAmount += out.tx->tx->vout[out.i].nValue;        // Bytes        CTxDestination address;        int witnessversion = 0;        std::vector<unsigned char> witnessprogram;        if (out.tx->tx->vout[out.i].scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram))        {            nBytesInputs += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);            fWitness = true;        }        else if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, address))        {            CPubKey pubkey;            CKeyID *keyid = boost::get<CKeyID>(&address);            if (keyid && model->getPubKey(*keyid, pubkey))            {                nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);            }            else                nBytesInputs += 148; // in all error cases, simply assume 148 here        }        else nBytesInputs += 148;    }    // calculation    if (nQuantity > 0)    {        // Bytes        nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here        if (fWitness)        {            // there is some fudging in these numbers related to the actual virtual transaction size calculation that will keep this estimate from being exact.            // usually, the result will be an overestimate within a couple of satoshis so that the confirmation dialog ends up displaying a slightly smaller fee.            // also, the witness stack size value is a variable sized integer. usually, the number of stack items will be well under the single byte var int limit.            nBytes += 2; // account for the serialized marker and flag bytes            nBytes += nQuantity; // account for the witness byte that holds the number of stack items for each input.        }        // in the subtract fee from amount case, we can tell if zero change already and subtract the bytes, so that fee calculation afterwards is accurate        if (CoinControlDialog::fSubtractFeeFromAmount)            if (nAmount - nPayAmount == 0)                nBytes -= 34;        // Fee        nPayFee = CWallet::GetMinimumFee(nBytes, *coinControl, ::mempool, ::feeEstimator, nullptr /* FeeCalculation */);        if (nPayAmount > 0)        {            nChange = nAmount - nPayAmount;//.........这里部分代码省略.........
开发者ID:Airche,项目名称:wificoin,代码行数:101,



注:本文中的ExtractDestination函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ ExtractFile函数代码示例
C++ ExtractArgs函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。