当前位置: 首页>>代码示例>>C++>>正文


C++ CKey::GetSecret方法代码示例

本文整理汇总了C++中CKey::GetSecret方法的典型用法代码示例。如果您正苦于以下问题:C++ CKey::GetSecret方法的具体用法?C++ CKey::GetSecret怎么用?C++ CKey::GetSecret使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CKey的用法示例。


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

示例1: EncryptKeys

bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
{
    {
        LOCK(cs_KeyStore);
        if (!mapCryptedKeys.empty() || IsCrypted())
            return false;

        fUseCrypto = true;
        BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys)
        {
            //const CKey &key = mKey.second;
            //CPubKey vchPubKey = key.GetPubKey();
            //CKeyingMaterial vchSecret(key.begin(), key.end());
            CKey key;
            if (!key.SetSecret(mKey.second.first, mKey.second.second))
                return false;
            const CPubKey vchPubKey = key.GetPubKey();
            std::vector<unsigned char> vchCryptedSecret;
            //if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret))
            bool fCompressed;
            if (!EncryptSecret(vMasterKeyIn, key.GetSecret(fCompressed), vchPubKey.GetHash(), vchCryptedSecret))
                return false;
            if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
                return false;
        }
        mapKeys.clear();
    }
开发者ID:TheBitcoin,项目名称:Feathercoin2,代码行数:27,代码来源:crypter.cpp

示例2: AddKey

//bool CCryptoKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
bool CCryptoKeyStore::AddKey(const CKey& key)
{
    {
        LOCK(cs_KeyStore);
        if (!IsCrypted())
            //return CBasicKeyStore::AddKeyPubKey(key, pubkey);
            return CBasicKeyStore::AddKey(key);

        if (IsLocked())
            return false;

        std::vector<unsigned char> vchCryptedSecret;
        //CKeyingMaterial vchSecret(key.begin(), key.end());
        CPubKey vchPubKey = key.GetPubKey();
        bool fCompressed;
        //if (!EncryptSecret(vMasterKey, vchSecret, pubkey.GetHash(), vchCryptedSecret))
        if (!EncryptSecret(vMasterKey, key.GetSecret(fCompressed), vchPubKey.GetHash(), vchCryptedSecret))
            return false;

        //if (!AddCryptedKey(pubkey, vchCryptedSecret))
        if (!AddCryptedKey(key.GetPubKey(), vchCryptedSecret))
            return false;
    }
    return true;
}
开发者ID:TheBitcoin,项目名称:Feathercoin2,代码行数:26,代码来源:crypter.cpp

示例3: AddKey

bool CCryptoKeyStore::AddKey(const CKey& key)
{
    {
        LOCK(cs_KeyStore);

        CTxDestination address = key.GetPubKey().GetID();
        if (HaveWatchOnly(address))
            return false;

        if (!IsCrypted())
            return CBasicKeyStore::AddKey(key);

        if (IsLocked())
            return false;

        std::vector<unsigned char> vchCryptedSecret;
        CPubKey vchPubKey = key.GetPubKey();
        bool fCompressed;
        if (!EncryptSecret(vMasterKey, key.GetSecret(fCompressed), vchPubKey.GetHash(), vchCryptedSecret))
            return false;

        if (!AddCryptedKey(key.GetPubKey(), vchCryptedSecret))
            return false;
    }
    return true;
}
开发者ID:cryptogenicbonds,项目名称:novacoin,代码行数:26,代码来源:keystore.cpp

示例4: AddKey

bool CBasicKeyStore::AddKey(const CKey& key)
{
    bool fCompressed = false;
    CSecret secret = key.GetSecret(fCompressed);
    CRITICAL_BLOCK(cs_KeyStore)
        mapKeys[CBitshekelAddress(key.GetPubKey())] = make_pair(secret, fCompressed);
    return true;
}
开发者ID:BitShekel,项目名称:BitShekel,代码行数:8,代码来源:keystore.cpp

示例5: AddKey

bool CBasicKeyStore::AddKey(const CKey& key)
{
    bool fCompressed = false;
    CSecret secret = key.GetSecret(fCompressed);
    {
        LOCK(cs_KeyStore);
        mapKeys[key.GetPubKey().GetID()] = make_pair(secret, fCompressed);
    }
    return true;
}
开发者ID:ColoradoPay,项目名称:CPAY,代码行数:10,代码来源:keystore.cpp

示例6: AddKey

bool CBasicKeyStore::AddKey(const CKey& key)
{
    CRITICAL_BLOCK(cs_KeyStore)
        mapKeys[CBitcoinAddress(key.GetPubKey())] = key.GetSecret();
    return true;
}
开发者ID:FuzzyBearBTC,项目名称:CoiledCoin,代码行数:6,代码来源:keystore.cpp

示例7: on_okButton_clicked

void AddEditAdrenalineNode::on_okButton_clicked()
{
    if(ui->aliasLineEdit->text() == "")
    {
	QMessageBox msg;
        msg.setText("Please enter an alias.");
	msg.exec();
	return;
    }
    else if(ui->addressLineEdit->text() == "")
    {
	QMessageBox msg;
        msg.setText("Please enter an address.");
	msg.exec();
	return;
    }
    else
    {
	CAdrenalineNodeConfig c;
        c.sAlias = ui->aliasLineEdit->text().toStdString();
	c.sAddress = ui->addressLineEdit->text().toStdString();
        CKey secret;
        secret.MakeNewKey(false);

	CBitcoinSecret s;
	bool fCompressedOut;
	s.SetSecret(secret.GetSecret(fCompressedOut), false);

        c.sMasternodePrivKey = s.ToString();
	
        CWalletDB walletdb(pwalletMain->strWalletFile);
        CAccount account;
        walletdb.ReadAccount(c.sAlias, account);
        bool bKeyUsed = false;
	bool bForceNew = false;

        // Check if the current key has been used
        if (account.vchPubKey.IsValid())
        {
            CScript scriptPubKey;
            scriptPubKey.SetDestination(account.vchPubKey.GetID());
            for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin();
                 it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid();
                 ++it)
            {
                const CWalletTx& wtx = (*it).second;
                BOOST_FOREACH(const CTxOut& txout, wtx.vout)
                    if (txout.scriptPubKey == scriptPubKey)
                        bKeyUsed = true;
            }
        }

        // Generate a new key
        if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed)
        {
            if (!pwalletMain->GetKeyFromPool(account.vchPubKey))
            {
		QMessageBox msg;
                msg.setText("Keypool ran out, please call keypoolrefill first.");
		msg.exec();
		return;
	    }
            pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), c.sAlias);
            walletdb.WriteAccount(c.sAlias, account);
        }

        c.sCollateralAddress = CBitcoinAddress(account.vchPubKey.GetID()).ToString();

        pwalletMain->mapMyAdrenalineNodes.insert(make_pair(c.sAddress, c));
	walletdb.WriteAdrenalineNodeConfig(c.sAddress, c);
        uiInterface.NotifyAdrenalineNodeChanged(c);

        accept();
    }
开发者ID:Infernoman,项目名称:Neutroncoin,代码行数:74,代码来源:addeditadrenalinenode.cpp


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