本文整理汇总了C++中CKey::GetPrivKey_256方法的典型用法代码示例。如果您正苦于以下问题:C++ CKey::GetPrivKey_256方法的具体用法?C++ CKey::GetPrivKey_256怎么用?C++ CKey::GetPrivKey_256使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKey
的用法示例。
在下文中一共展示了CKey::GetPrivKey_256方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: walletdb
CzPIVWallet::CzPIVWallet(std::string strWalletFile)
{
this->strWalletFile = strWalletFile;
CWalletDB walletdb(strWalletFile);
uint256 hashSeed;
bool fFirstRun = !walletdb.ReadCurrentSeedHash(hashSeed);
//Check for old db version of storing zpiv seed
if (fFirstRun) {
uint256 seed;
if (walletdb.ReadZPIVSeed_deprecated(seed)) {
//Update to new format, erase old
seedMaster = seed;
hashSeed = Hash(seed.begin(), seed.end());
if (pwalletMain->AddDeterministicSeed(seed)) {
if (walletdb.EraseZPIVSeed_deprecated()) {
LogPrintf("%s: Updated zPIV seed databasing\n", __func__);
fFirstRun = false;
} else {
LogPrintf("%s: failed to remove old zpiv seed\n", __func__);
}
}
}
}
//Don't try to do anything if the wallet is locked.
if (pwalletMain->IsLocked()) {
seedMaster = 0;
nCountLastUsed = 0;
this->mintPool = CMintPool();
return;
}
//First time running, generate master seed
uint256 seed;
if (fFirstRun) {
// Borrow random generator from the key class so that we don't have to worry about randomness
CKey key;
key.MakeNewKey(true);
seed = key.GetPrivKey_256();
seedMaster = seed;
LogPrintf("%s: first run of zpiv wallet detected, new seed generated. Seedhash=%s\n", __func__, Hash(seed.begin(), seed.end()).GetHex());
} else if (!pwalletMain->GetDeterministicSeed(hashSeed, seed)) {
LogPrintf("%s: failed to get deterministic seed for hashseed %s\n", __func__, hashSeed.GetHex());
return;
}
if (!SetMasterSeed(seed)) {
LogPrintf("%s: failed to save deterministic seed for hashseed %s\n", __func__, hashSeed.GetHex());
return;
}
this->mintPool = CMintPool(nCountLastUsed);
}
示例2: addr
void Bip38ToolDialog::on_encryptKeyButton_ENC_clicked()
{
if (!model)
return;
QString qstrPassphrase = ui->passphraseIn_ENC->text();
QString strInvalid;
if (!isValidPassphrase(qstrPassphrase, strInvalid)) {
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("The entered passphrase is invalid. ") + strInvalid + QString(" is not valid") + QString(" ") + tr("Allowed: 0-9,a-z,A-Z,") + specialChar);
return;
}
CBitcoinAddress addr(ui->addressIn_ENC->text().toStdString());
if (!addr.IsValid()) {
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
return;
}
CKeyID keyID;
if (!addr.GetKeyID(keyID)) {
ui->addressIn_ENC->setValid(false);
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
return;
}
WalletModel::UnlockContext ctx(model->requestUnlock(AskPassphraseDialog::Context::BIP_38, true));
if (!ctx.isValid()) {
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("Wallet unlock was cancelled."));
return;
}
CKey key;
if (!pwalletMain->GetKey(keyID, key)) {
ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }");
ui->statusLabel_ENC->setText(tr("Private key for the entered address is not available."));
return;
}
std::string encryptedKey = BIP38_Encrypt(addr.ToString(), qstrPassphrase.toStdString(), key.GetPrivKey_256(), key.IsCompressed());
ui->encryptedKeyOut_ENC->setText(QString::fromStdString(encryptedKey));
}