I did find a bit of a hackish way to check if a vector of unsigned chars is a "prefix" of a CKeyID:
CKeyID keyid = vchPubKey.GetID();
std::vector vchID = ParseHex(strID);
bool isprefix=true;
unsigned char* keyidarr = (unsigned char*) &keyid;
for (unsigned int i = 0; i < vchID.size() && isprefix; ++i) {
if (vchID[i] != keyidarr[i])
isprefix=false;
}
This rejects the old register (since it uses the checksum instead of a prefix) and accepts the new one. As a result there's one pubkey registered. I have commands "listrpubkeys" and "getrpubkey":
cct listrpubkeys
[
{
"id" : "73",
"pubkey" : "039df70c1c46425ae4d3be53892949e17bebcbe30f419132441faab92677b220f5",
"txid" : "8690cfc9b0e40b7fb328da478e2523071ac759eea7cac729038b47b8f180948d",
"confirmations" : 446
}
]
cct getrpubkey 73
{
"pid" : "73",
"id" : "73",
"pubkey" : "039df70c1c46425ae4d3be53892949e17bebcbe30f419132441faab92677b220f5",
"txid" : "8690cfc9b0e40b7fb328da478e2523071ac759eea7cac729038b47b8f180948d",
"confirmations" : 446
}
The "pid" field given in response to "getrpubkey" shouldn't be there. I'll track it down later.
I'm saying "rpubkey" for "registered pubkey" to avoid confusing with ordinary public keys.
If someone has a suggestion for how I should've done it, I'd be happy to listen.