Skip to content

Instantly share code, notes, and snippets.

@ohac
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohac/9598132 to your computer and use it in GitHub Desktop.
Save ohac/9598132 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include "key.h"
#include "base58.h"
#undef printf
#define printf printf
bool fTestNet = false;
// usage: g++ keygen.cpp key.cpp -lcrypto -lboost_system && ./a.out
LockedPageManager LockedPageManager::instance;
int main(int argc, char** argv)
{
CKey mykey;
mykey.MakeNewKey(true);
CPubKey pubkey = mykey.GetPubKey();
const unsigned char *p = pubkey.begin();
unsigned int size = pubkey.size();
puts("pubkey:");
for (int i = 0; i < size; i++) {
printf("%02x", p[i]);
}
puts("\n");
p = mykey.begin();
size = mykey.size();
puts("privkey:");
for (int i = 0; i < size; i++) {
printf("%02x", p[i]);
}
puts("\n");
CBitcoinAddress btcaddr;
btcaddr.Set(pubkey.GetID());
printf("%s\n", btcaddr.ToString().c_str());
CBitcoinSecret btcsecret;
btcsecret.SetKey(mykey);
printf("%s\n", btcsecret.ToString().c_str());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment