Hi
I m IOS developer and I m working on bitcoin wallet.
for Private key generate I am using core bitcoin lib, and I successfully generate that key
here is code to generate key
NSUInteger length = 32;
NSMutableData *secret = [NSMutableData dataWithLength:length];
OSStatus sanityCheck = noErr;
sanityCheck = SecRandomCopyBytes(kSecRandomDefault, length, secret.mutableBytes);
if (sanityCheck != noErr) {
NSLog(@"Issue generating a private key.");
}
NSAssert(secret.length == 32, @"secret must be 32 bytes long");
BTCKey *key = [[BTCKey alloc] initWithPrivateKey:secret];
NSLog(@"%@",key.WIF);
now I need to use that private key using JSONrpc command
importprivkey here is code to import private key is
{
"jsonrpc":"2.0",
"params":{
"privkey":"5K1PvchJcWx1fay7PQ2DGGXoZLDfZw7htVdbFrEjjDVS8MCag8h",
"rescan":true
},
"method":"importprivkey"
}
but after run that command I got error of
{
"result": null,
"error": {
"code": -5,
"message": "Invalid private key encoding"
},
"id": null
}
Please help me, I read lots of code but didn't find solution.
thanks in advance