本文整理汇总了C++中CBitcoinAddress::GetKeyID方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitcoinAddress::GetKeyID方法的具体用法?C++ CBitcoinAddress::GetKeyID怎么用?C++ CBitcoinAddress::GetKeyID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitcoinAddress
的用法示例。
在下文中一共展示了CBitcoinAddress::GetKeyID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpprivkey
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey <luckycoinaddress>\n"
"Reveals the private key corresponding to <luckycoinaddress>.");
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(-5, "Invalid Luckycoin address");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(-3, "Address does not refer to a key");
CSecret vchSecret;
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret, fCompressed).ToString();
}
示例2: dumpprivkey
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey <universalmoleculeaddress>\n"
"Reveals the private key corresponding to <universalmoleculeaddress>.");
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid UniversalMolecule address");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
CSecret vchSecret;
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret, fCompressed).ToString();
}
示例3: dumpprivkey
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey <Ascentcoinaddress>\n"
"Reveals the private key corresponding to <Ascentcoinaddress>.");
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Ascentcoin address");
if (fWalletUnlockMintOnly) // ppcoin: no dumpprivkey in mint-only mode
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for minting only.");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
CSecret vchSecret;
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret, fCompressed).ToString();
}
示例4: dumpprivkey
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey <peercoinaddress>\n"
"Reveals the private key corresponding to <peercoinaddress>.");
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(-5, "Invalid Minermind address");
if (pwalletMain->IsLocked())
throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first.");
if (fWalletUnlockMintOnly) // minermind: no dumpprivkey in mint-only mode
throw JSONRPCError(-102, "Wallet is unlocked for minting only.");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(-3, "Address does not refer to a key");
CSecret vchSecret;
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret, fCompressed).ToString();
}
示例5: RunSerialiseTests
void RunSerialiseTests()
{
int64_t nTest;
int64_t nTest0 = 0l;
int64_t nTest4 = 1432035740l;
int64_t nTest4_1 = 2189410940l; // 2039
int64_t nTest5 = 4294967298l; // 2106
int64_t nTest8 = -3l;
BOOST_CHECK(0 == GetNumBytesReqForInt(nTest0));
BOOST_CHECK(4 == GetNumBytesReqForInt(nTest4));
BOOST_CHECK(4 == GetNumBytesReqForInt(nTest4_1)); // expect 4, no sign bit
BOOST_CHECK(5 == GetNumBytesReqForInt(nTest5));
BOOST_CHECK(8 == GetNumBytesReqForInt(nTest8));
//BOOST_TEST_MESSAGE(GetNumBytesReqForInt(nTest5));
std::vector<uint8_t> v;
SetCompressedInt64(v, nTest0);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest0 == nTest);
SetCompressedInt64(v, nTest5);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest5 == nTest);
SetCompressedInt64(v, nTest8);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest8 == nTest);
CStoredExtKey sk, sk_;
CStoredExtKey skInvalid, skInvalid_;
CExtKey58 eKey58;
BOOST_CHECK(0 == eKey58.Set58("moivYMcZoUdupxqBNASoNKWbyBzKFPzYA3ZauZhCyQGcUhdvxhgsYNdqBkCbspTmaXWtW68Ha7gjMBjb5gbudrictnzw9KAVKogAXC8FsqiSzRp"));
sk.kp = eKey58.GetKey();
sk.sLabel = "sk label";
sk.nGenerated = 5;
sk.nHGenerated = 6;
sk.mapValue[EKVT_CREATED_AT] = SetCompressedInt64(v, nTest8);
eKey58.SetKey(sk.kp, CChainParams::EXT_PUBLIC_KEY);
BOOST_CHECK(eKey58.ToString() == "moipXY9njTPCnsVV8vPCLA1xKp2NXdRtPVyGABKcbshkKQUadnrk2XPccZcSDjefRX64mNjYpS33SAy97UHGWs9WoAufi9pdow9gsYMvVEcmgSk");
eKey58.SetKeyV(sk.kp);
BOOST_CHECK(eKey58.ToString() == "moivYMcZoUdupxqBNASoNKWbyBzKFPzYA3ZauZhCyQGcUhdvxhgsYNdqBkCbspTmaXWtW68Ha7gjMBjb5gbudrictnzw9KAVKogAXC8FsqiSzRp");
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << sk << skInvalid;
ss >> sk_;
ss >> skInvalid_;
BOOST_CHECK(sk.kp == sk_.kp);
BOOST_CHECK(1 == sk_.kp.IsValidV());
BOOST_CHECK(1 == sk_.kp.IsValidP());
BOOST_CHECK(sk.sLabel == sk_.sLabel);
BOOST_CHECK(sk.nGenerated == sk_.nGenerated);
BOOST_CHECK(sk.nHGenerated == sk_.nHGenerated);
BOOST_CHECK(nTest8 == GetCompressedInt64(sk_.mapValue[EKVT_CREATED_AT], (uint64_t&)nTest));
BOOST_CHECK(0 == skInvalid.kp.IsValidV());
BOOST_CHECK(0 == skInvalid.kp.IsValidP());
// path
std::vector<uint8_t> vPath;
PushUInt32(vPath, 1);
PushUInt32(vPath, 3);
PushUInt32(vPath, 2);
PushUInt32(vPath, 4294967295);
std::string sPath;
BOOST_CHECK(0 == PathToString(vPath, sPath, 'h'));
BOOST_CHECK(sPath == "m/1/3/2/2147483647h");
vPath.resize(0);
PushUInt32(vPath, 1);
PushUInt32(vPath, 4294967294);
PushUInt32(vPath, 30);
BOOST_CHECK(0 == PathToString(vPath, sPath));
BOOST_CHECK(sPath == "m/1/2147483646'/30");
// id
CBitcoinAddress addr;
CKeyID id = sk.GetID();
CKeyID idTest;
BOOST_CHECK(true == addr.Set(id, CChainParams::EXT_KEY_HASH)
&& addr.IsValid(CChainParams::EXT_KEY_HASH)
&& addr.GetKeyID(idTest, CChainParams::EXT_KEY_HASH));
//.........这里部分代码省略.........
示例6: RunSerialiseTests
void RunSerialiseTests()
{
int64_t nTest;
int64_t nTest0 = 0l;
int64_t nTest4 = 1432035740l;
int64_t nTest4_1 = 2189410940l; // 2039
int64_t nTest5 = 4294967298l; // 2106
int64_t nTest8 = -3l;
BOOST_CHECK(0 == GetNumBytesReqForInt(nTest0));
BOOST_CHECK(4 == GetNumBytesReqForInt(nTest4));
BOOST_CHECK(4 == GetNumBytesReqForInt(nTest4_1)); // expect 4, no sign bit
BOOST_CHECK(5 == GetNumBytesReqForInt(nTest5));
BOOST_CHECK(8 == GetNumBytesReqForInt(nTest8));
//BOOST_MESSAGE(GetNumBytesReqForInt(nTest5));
std::vector<uint8_t> v;
SetCompressedInt64(v, nTest0);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest0 == nTest);
SetCompressedInt64(v, nTest5);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest5 == nTest);
SetCompressedInt64(v, nTest8);
GetCompressedInt64(v, (uint64_t&)nTest);
BOOST_CHECK(nTest8 == nTest);
CStoredExtKey sk, sk_;
CStoredExtKey skInvalid, skInvalid_;
CExtKey58 eKey58;
BOOST_CHECK(0 == eKey58.Set58("sdcvmnKmFxG9k6UnN3wyLpTv83G1wgYEz1m21rZTUUimoDrYYMrZXUycudse21EZJTmkBBPN3k6Qhfzx5td8xzd9W893YhNozA3bZW3yVLVdrZU2"));
sk.kp = eKey58.GetKey();
sk.sLabel = "sk label";
sk.nGenerated = 5;
sk.nHGenerated = 6;
sk.mapValue[EKVT_CREATED_AT] = SetCompressedInt64(v, nTest8);
eKey58.SetKey(sk.kp, CChainParams::EXT_PUBLIC_KEY);
BOOST_CHECK(eKey58.ToString() == "sdcpmphCJNSUos9rNqn6FNi3ztvMW1wft1PVbifvBrwhm6JnhD9yk8rSNFTGfozGbmBsr8vZv9mGYSTfmEMpbfTTMb8TQfj7JRABmvBFKgA2xG8J");
eKey58.SetKeyV(sk.kp);
BOOST_CHECK(eKey58.ToString() == "sdcvmnKmFxG9k6UnN3wyLpTv83G1wgYEz1m21rZTUUimoDrYYMrZXUycudse21EZJTmkBBPN3k6Qhfzx5td8xzd9W893YhNozA3bZW3yVLVdrZU2");
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << sk << skInvalid;
ss >> sk_;
ss >> skInvalid_;
BOOST_CHECK(sk.kp == sk_.kp);
BOOST_CHECK(1 == sk_.kp.IsValidV());
BOOST_CHECK(1 == sk_.kp.IsValidP());
BOOST_CHECK(sk.sLabel == sk_.sLabel);
BOOST_CHECK(sk.nGenerated == sk_.nGenerated);
BOOST_CHECK(sk.nHGenerated == sk_.nHGenerated);
BOOST_CHECK(nTest8 == GetCompressedInt64(sk_.mapValue[EKVT_CREATED_AT], (uint64_t&)nTest));
BOOST_CHECK(0 == skInvalid.kp.IsValidV());
BOOST_CHECK(0 == skInvalid.kp.IsValidP());
// path
std::vector<uint8_t> vPath;
PushUInt32(vPath, 1);
PushUInt32(vPath, 3);
PushUInt32(vPath, 2);
PushUInt32(vPath, 4294967295);
std::string sPath;
BOOST_CHECK(0 == PathToString(vPath, sPath, 'h'));
BOOST_CHECK(sPath == "m/1/3/2/2147483647h");
vPath.resize(0);
PushUInt32(vPath, 1);
PushUInt32(vPath, 4294967294);
PushUInt32(vPath, 30);
BOOST_CHECK(0 == PathToString(vPath, sPath));
BOOST_CHECK(sPath == "m/1/2147483646'/30");
// id
CBitcoinAddress addr;
CKeyID id = sk.GetID();
CKeyID idTest;
BOOST_CHECK(true == addr.Set(id, CChainParams::EXT_KEY_HASH)
&& addr.IsValid(CChainParams::EXT_KEY_HASH)
&& addr.GetKeyID(idTest, CChainParams::EXT_KEY_HASH));
//.........这里部分代码省略.........