本文整理汇总了C++中CBitcoinSecret::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitcoinSecret::ToString方法的具体用法?C++ CBitcoinSecret::ToString怎么用?C++ CBitcoinSecret::ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitcoinSecret
的用法示例。
在下文中一共展示了CBitcoinSecret::ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpKeyInfo
void dumpKeyInfo(uint256 privkey)
{
CKey key;
key.resize(32);
memcpy(&secret[0], &privkey, 32);
vector<unsigned char> sec;
sec.resize(32);
memcpy(&sec[0], &secret[0], 32);
printf(" * secret (hex): %s\n", HexStr(sec).c_str());
for (int nCompressed=0; nCompressed<2; nCompressed++)
{
bool fCompressed = nCompressed == 1;
printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed");
CBitcoinSecret bsecret;
bsecret.SetSecret(secret, fCompressed);
printf(" * secret (base58): %s\n", bsecret.ToString().c_str());
CKey key;
key.SetSecret(secret, fCompressed);
vector<unsigned char> vchPubKey = key.GetPubKey();
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
}
}
示例2: 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();
}