Bitcoin Forum
October 01, 2025, 05:30:39 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: CPubKey from pubkey string on: June 17, 2017, 04:26:30 AM
Thank you so much. Problem solved. "valid" was showed!

Code:
#include "utilstrencodings.h"

std::vector<unsigned char> vec = ParseHex("0396f8781a4900372a5d72d84718d146170d5983e67dff8b4a28fef80690c09767");

CPubKey pubkey(vec);
if (pubkey.IsValid()) {
    cout << "valid" << endl;
} else {
    cout << "invalid" << endl;
}
2  Bitcoin / Development & Technical Discussion / CPubKey from pubkey string on: June 16, 2017, 01:45:29 PM
I'm reading bitcoin core source code. Is it possible to instantiate a CPubKey object with pubkey? I want to get bitcoin address from the pubkey by using bitcoin core's source. I can't find a good way.

I tried it like following but "invalid" is showed.

Code:
const char *cstr = "0396f8781a4900372a5d72d84718d146170d5983e67dff8b4a28fef80690c09767";
std::vector<unsigned char> vec(cstr, cstr + strlen(cstr));

CPubKey pubkey(vec);
if (pubkey.IsValid()) {
    cout << "valid" << endl;   
} else {
    cout << "invalid" << endl;
}
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!