Skip to content

Commit c6a58cf

Browse files
committedMay 14, 2016
New chapters added
1 parent acf7208 commit c6a58cf

24 files changed

+539
-26
lines changed
 

‎BitcoinAddress/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎GetBitcoinAddress/GetBitcoinAddress.csproj renamed to ‎BitcoinAddress/BitcoinAddress.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{73C6A268-DD15-40F2-9385-F5D949F92CAC}</ProjectGuid>
7+
<ProjectGuid>{E8594880-7F0B-424C-9205-1F9E84A072ED}</ProjectGuid>
88
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>GetBitcoinAddress</RootNamespace>
11-
<AssemblyName>GetBitcoinAddress</AssemblyName>
10+
<RootNamespace>BitcoinAddress</RootNamespace>
11+
<AssemblyName>BitcoinAddress</AssemblyName>
1212
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

‎BitcoinAddress/Program.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using NBitcoin;
3+
// ReSharper disable All
4+
5+
namespace BitcoinAddress
6+
{
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
Key privateKey = new Key(); // generate a random private key
12+
13+
PubKey publicKey = privateKey.PubKey;
14+
Console.WriteLine(publicKey); // 0251036303164f6c458e9f7abecb4e55e5ce9ec2b2f1d06d633c9653a07976560c
15+
16+
Console.WriteLine(publicKey.GetAddress(Network.Main)); // 1PUYsjwfNmX64wS368ZR5FMouTtUmvtmTY
17+
Console.WriteLine(publicKey.GetAddress(Network.TestNet)); // n3zWAo2eBnxLr3ueohXnuAa8mTVBhxmPhq
18+
19+
var publicKeyHash = publicKey.Hash;
20+
Console.WriteLine(publicKeyHash); // f6889b21b5540353a29ed18c45ea0031280c42cf
21+
var mainNetAddress = publicKeyHash.GetAddress(Network.Main);
22+
var testNetAddress = publicKeyHash.GetAddress(Network.TestNet);
23+
24+
Console.WriteLine(mainNetAddress); // 1PUYsjwfNmX64wS368ZR5FMouTtUmvtmTY
25+
Console.WriteLine(testNetAddress); // n3zWAo2eBnxLr3ueohXnuAa8mTVBhxmPhq
26+
27+
Console.ReadLine();
28+
}
29+
}
30+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("BitcoinAddress")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("BitcoinAddress")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("e8594880-7f0b-424c-9205-1f9e84a072ed")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎GetBitcoinAddress/packages.config renamed to ‎BitcoinAddress/packages.config

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
32
<packages>
43
<package id="NBitcoin" version="3.0.0.30" targetFramework="net452" />
54
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net452" />

‎BitcoinSecret/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎BitcoinSecret/BitcoinSecret.csproj

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C7292492-E914-4168-B555-854CF48DB00B}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>BitcoinSecret</RootNamespace>
11+
<AssemblyName>BitcoinSecret</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="NBitcoin, Version=3.0.0.30, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="NBitcoin.BouncyCastle, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.BouncyCastle.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Net.Http" />
55+
<Reference Include="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="App.config" />
63+
<None Include="packages.config" />
64+
</ItemGroup>
65+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
66+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
67+
Other similar extension points exist, see Microsoft.Common.targets.
68+
<Target Name="BeforeBuild">
69+
</Target>
70+
<Target Name="AfterBuild">
71+
</Target>
72+
-->
73+
</Project>

‎BitcoinSecret/Program.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using NBitcoin;
3+
// ReSharper disable All
4+
5+
namespace BitcoinAddress
6+
{
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
Key privateKey = new Key(); // generate a random private key
12+
var mainNetPrivateKey = privateKey.GetBitcoinSecret(Network.Main); // get our private key for the mainnet
13+
var testNetPrivateKey = privateKey.GetBitcoinSecret(Network.TestNet); // get our private key for the testnet
14+
Console.WriteLine(mainNetPrivateKey); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvn
15+
Console.WriteLine(testNetPrivateKey); // cVY5auviDh8LmYUW8AfafseD6p6uFoZrP7GjS3rzAerpRKE9Wmuz
16+
17+
Console.ReadLine();
18+
}
19+
}
20+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("BitcoinSecret")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("BitcoinSecret")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("c7292492-e914-4168-b555-854cf48db00b")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎BitcoinSecret/packages.config

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NBitcoin" version="3.0.0.30" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net452" />
5+
</packages>

‎GetBitcoinAddress/App.config

-7
This file was deleted.

‎GetBitcoinAddress/Program.cs

-9
This file was deleted.

‎GetBitcoinAddress/Properties/AssemblyInfo.cs

Whitespace-only changes.

‎PaymentScript/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎PaymentScript/PaymentScript.csproj

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{4A71F9D4-6017-4429-8771-7657C7027288}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PaymentScript</RootNamespace>
11+
<AssemblyName>PaymentScript</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="NBitcoin, Version=3.0.0.30, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="NBitcoin.BouncyCastle, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.BouncyCastle.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Net.Http" />
55+
<Reference Include="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="App.config" />
63+
<None Include="packages.config" />
64+
</ItemGroup>
65+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
66+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
67+
Other similar extension points exist, see Microsoft.Common.targets.
68+
<Target Name="BeforeBuild">
69+
</Target>
70+
<Target Name="AfterBuild">
71+
</Target>
72+
-->
73+
</Project>

‎PaymentScript/Program.cs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using NBitcoin;
3+
// ReSharper disable All
4+
5+
namespace PaymentScript
6+
{
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
var publicKeyHash = new KeyId("14836dbe7f38c5ac3d49e8d790af808a4ee9edcf");
12+
13+
var testNetAddress = publicKeyHash.GetAddress(Network.TestNet);
14+
var mainNetAddress = publicKeyHash.GetAddress(Network.Main);
15+
16+
Console.WriteLine(mainNetAddress.ScriptPubKey); // OP_DUP OP_HASH160 14836dbe7f38c5ac3d49e8d790af808a4ee9edcf OP_EQUALVERIFY OP_CHECKSIG
17+
Console.WriteLine(testNetAddress.ScriptPubKey); // OP_DUP OP_HASH160 14836dbe7f38c5ac3d49e8d790af808a4ee9edcf OP_EQUALVERIFY OP_CHECKSIG
18+
19+
20+
var paymentScript = publicKeyHash.ScriptPubKey;
21+
var sameMainNetAddress = paymentScript.GetDestinationAddress(Network.Main);
22+
Console.WriteLine(mainNetAddress == sameMainNetAddress); // True
23+
24+
25+
var samePublicKeyHash = (KeyId)paymentScript.GetDestination();
26+
Console.WriteLine(publicKeyHash == samePublicKeyHash); // True
27+
var sameMainNetAddress2 = new BitcoinPubKeyAddress(samePublicKeyHash, Network.Main);
28+
Console.WriteLine(mainNetAddress == sameMainNetAddress2); // True
29+
30+
31+
Console.ReadLine();
32+
}
33+
}
34+
}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PaymentScript")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PaymentScript")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("4a71f9d4-6017-4429-8771-7657c7027288")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎PaymentScript/packages.config

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NBitcoin" version="3.0.0.30" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net452" />
5+
</packages>

‎PrivateKey/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>

‎PrivateKey/PrivateKey.csproj

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{8F4F2562-A2CA-4885-8638-F71CC44F5648}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>PrivateKey</RootNamespace>
11+
<AssemblyName>PrivateKey</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="NBitcoin, Version=3.0.0.30, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="NBitcoin.BouncyCastle, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
41+
<HintPath>..\packages\NBitcoin.3.0.0.30\lib\net45\NBitcoin.BouncyCastle.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
45+
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Net.Http" />
55+
<Reference Include="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
</ItemGroup>
61+
<ItemGroup>
62+
<None Include="App.config" />
63+
<None Include="packages.config" />
64+
</ItemGroup>
65+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
66+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
67+
Other similar extension points exist, see Microsoft.Common.targets.
68+
<Target Name="BeforeBuild">
69+
</Target>
70+
<Target Name="AfterBuild">
71+
</Target>
72+
-->
73+
</Project>

‎PrivateKey/Program.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using NBitcoin;
3+
// ReSharper disable All
4+
5+
namespace PrivateKey
6+
{
7+
class Program
8+
{
9+
static void Main()
10+
{
11+
Key privateKey = new Key(); // generate a random private key
12+
BitcoinSecret mainNetPrivateKey = privateKey.GetBitcoinSecret(Network.Main); // get our private key for the mainnet
13+
BitcoinSecret testNetPrivateKey = privateKey.GetBitcoinSecret(Network.TestNet); // get our private key for the testnet
14+
Console.WriteLine(mainNetPrivateKey); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvn
15+
Console.WriteLine(testNetPrivateKey); // cVY5auviDh8LmYUW8AfafseD6p6uFoZrP7GjS3rzAerpRKE9Wmuz
16+
17+
bool WifIsBitcoinSecret = mainNetPrivateKey == privateKey.GetWif(Network.Main);
18+
Console.WriteLine(WifIsBitcoinSecret); // True
19+
20+
21+
BitcoinSecret bitcoinPrivateKey = privateKey.GetWif(Network.Main); // L5B67zvrndS5c71EjkrTJZ99UaoVbMUAK58GKdQUfYCpAa6jypvn
22+
Key samePrivateKey = bitcoinPrivateKey.PrivateKey;
23+
Console.WriteLine(privateKey == samePrivateKey); // True
24+
25+
PubKey publicKey = privateKey.PubKey;
26+
BitcoinPubKeyAddress bitcoinPubicKey = publicKey.GetAddress(Network.Main); // 1PUYsjwfNmX64wS368ZR5FMouTtUmvtmTY
27+
//PubKey samePublicKey = bitcoinPubicKey.ItIsNotPossible;
28+
29+
Console.ReadLine();
30+
}
31+
}
32+
}

‎PrivateKey/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("PrivateKey")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("PrivateKey")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8f4f2562-a2ca-4885-8638-f71cc44f5648")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

‎PrivateKey/packages.config

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NBitcoin" version="3.0.0.30" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net452" />
5+
</packages>

‎ProgrammingTheBlockchain.sln

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,36 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.25123.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetBitcoinAddress", "GetBitcoinAddress\GetBitcoinAddress.csproj", "{73C6A268-DD15-40F2-9385-F5D949F92CAC}"
7-
EndProject
86
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CreateTransaction", "CreateTransaction\CreateTransaction.csproj", "{B57B9E0E-83D0-4339-B20C-D234175AA6D8}"
97
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitcoinAddress", "BitcoinAddress\BitcoinAddress.csproj", "{E8594880-7F0B-424C-9205-1F9E84A072ED}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaymentScript", "PaymentScript\PaymentScript.csproj", "{4A71F9D4-6017-4429-8771-7657C7027288}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrivateKey", "PrivateKey\PrivateKey.csproj", "{8F4F2562-A2CA-4885-8638-F71CC44F5648}"
13+
EndProject
1014
Global
1115
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1216
Debug|Any CPU = Debug|Any CPU
1317
Release|Any CPU = Release|Any CPU
1418
EndGlobalSection
1519
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{73C6A268-DD15-40F2-9385-F5D949F92CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{73C6A268-DD15-40F2-9385-F5D949F92CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{73C6A268-DD15-40F2-9385-F5D949F92CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{73C6A268-DD15-40F2-9385-F5D949F92CAC}.Release|Any CPU.Build.0 = Release|Any CPU
2020
{B57B9E0E-83D0-4339-B20C-D234175AA6D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2121
{B57B9E0E-83D0-4339-B20C-D234175AA6D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
2222
{B57B9E0E-83D0-4339-B20C-D234175AA6D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
2323
{B57B9E0E-83D0-4339-B20C-D234175AA6D8}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{E8594880-7F0B-424C-9205-1F9E84A072ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25+
{E8594880-7F0B-424C-9205-1F9E84A072ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
26+
{E8594880-7F0B-424C-9205-1F9E84A072ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
27+
{E8594880-7F0B-424C-9205-1F9E84A072ED}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{4A71F9D4-6017-4429-8771-7657C7027288}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{4A71F9D4-6017-4429-8771-7657C7027288}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{4A71F9D4-6017-4429-8771-7657C7027288}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{4A71F9D4-6017-4429-8771-7657C7027288}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{8F4F2562-A2CA-4885-8638-F71CC44F5648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{8F4F2562-A2CA-4885-8638-F71CC44F5648}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{8F4F2562-A2CA-4885-8638-F71CC44F5648}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{8F4F2562-A2CA-4885-8638-F71CC44F5648}.Release|Any CPU.Build.0 = Release|Any CPU
2436
EndGlobalSection
2537
GlobalSection(SolutionProperties) = preSolution
2638
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)
Please sign in to comment.