Author

Topic: NBitcoin: public key to address? (Read 165 times)

legendary
Activity: 2317
Merit: 2318
December 06, 2020, 10:38:52 AM
#2
string hex -> PubKey -> Address

Code:
String strPubKey = "03d322a42421f709d1b6253ecd0c442059534644544276ac3f964154e4b1ca56f4";
var pubKey = new PubKey(strPubKey);
var addr = pubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
Console.WriteLine(addr.ToString());
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
December 06, 2020, 06:59:41 AM
#1
I have a hex string (66 chars long) and I want to convert it to a legacy address. I'm searching for a simple way that is already implemented on NBitcoin, so I won't have to spend time writing this on C#. The problem I face is that I can only convert a private key hex to address and not a public key hex. Is there any simple way to do it?

string hex -> PubKey -> Address
Jump to: