Bitcoin Forum
June 23, 2024, 02:30:44 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Re: importprivkey Invalid private key encoding on: April 12, 2018, 06:26:01 AM
thanks, thanks a lot reply

thanks for confirmation that my private key code generation Is correct.
let me check my code for import private key
2  Bitcoin / Bitcoin Technical Support / importprivkey Invalid private key encoding on: April 11, 2018, 10:26:51 AM
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

Code:
  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
Code:
 {
"jsonrpc":"2.0",
    "params":{
    "privkey":"5K1PvchJcWx1fay7PQ2DGGXoZLDfZw7htVdbFrEjjDVS8MCag8h",
    "rescan":true
    },
     "method":"importprivkey"
 }

but after run that command I got error of
Code:
{
    "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
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!