Member-only story
Bitcoin Wallet in C#
implement bitcoin application in C#
Create project folder and initial project folder
mkdir MyProjectcd MyProjectdotnet new consoledotnet add package NBitcoindotnet restore
Bitcoin Address
This is how you generate a private key with NBitcoin:
Key privateKey = new Key(); // generate a random private keyPublic key
PubKey publicKey = privateKey.PubKey;Console.WriteLine(publicKey); //output
03179195d8f1e0491f46d95baf853c63890b946b6a52807b7e74d467e1e5584b41
Address
Console.WriteLine(publicKey.GetAddress(ScriptPubKeyType.Legacy,Network.Main));
// 1ATCfxNw1Pdig3XanUxqBqXzNPurqPsM9Console.WriteLine(publicKey.GetAddress(ScriptPubKeyType.Legacy,Network.TestNet));
// mfgQVj3Mk2ptVnX9JMTLf73rrMzcj6XVS5
Private Key
Private keys are often represented in Base58Check called a Bitcoin Secret (also known as Wallet Import Format or simply WIF), like Bitcoin Addresses.
Key privateKey2 = new Key(); //…








