Skip to content

Commit b0c0102

Browse files
committed
4.2, 4.3 projects added
1 parent 7e91da3 commit b0c0102

File tree

11 files changed

+425
-0
lines changed

11 files changed

+425
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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>{6B7205A0-1D0C-425F-9429-E29DE0E9C6FD}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>_4._2LiquidDemocracy</RootNamespace>
11+
<AssemblyName>4.2LiquidDemocracy</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.Numerics" />
51+
<Reference Include="System.Xml.Linq" />
52+
<Reference Include="System.Data.DataSetExtensions" />
53+
<Reference Include="Microsoft.CSharp" />
54+
<Reference Include="System.Data" />
55+
<Reference Include="System.Net.Http" />
56+
<Reference Include="System.Xml" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<Compile Include="Program.cs" />
60+
<Compile Include="Properties\AssemblyInfo.cs" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<None Include="App.config" />
64+
<None Include="packages.config" />
65+
</ItemGroup>
66+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
67+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
68+
Other similar extension points exist, see Microsoft.Common.targets.
69+
<Target Name="BeforeBuild">
70+
</Target>
71+
<Target Name="AfterBuild">
72+
</Target>
73+
-->
74+
</Project>

4.2LiquidDemocracy/App.config

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

4.2LiquidDemocracy/Program.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
//ReSharper disable All
2+
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using NBitcoin;
7+
using NBitcoin.OpenAsset;
8+
9+
namespace _4._2LiquidDemocracy
10+
{
11+
internal class Program
12+
{
13+
private static void Main()
14+
{
15+
var powerCoin = new Key();
16+
var alice = new Key();
17+
var bob = new Key();
18+
var satoshi = new Key();
19+
var init = new Transaction()
20+
{
21+
Outputs =
22+
{
23+
new TxOut(Money.Coins(1.0m), powerCoin),
24+
new TxOut(Money.Coins(1.0m), alice),
25+
new TxOut(Money.Coins(1.0m), bob),
26+
new TxOut(Money.Coins(1.0m), satoshi),
27+
}
28+
};
29+
30+
var repo = new NoSqlColoredTransactionRepository();
31+
repo.Transactions.Put(init);
32+
33+
var issuance = GetCoins(init, powerCoin)
34+
.Select(c => new IssuanceCoin(c))
35+
.ToArray();
36+
var builder = new TransactionBuilder();
37+
var toAlice =
38+
builder
39+
.AddCoins(issuance)
40+
.AddKeys(powerCoin)
41+
.IssueAsset(alice, new AssetMoney(powerCoin, 2))
42+
.SetChange(powerCoin)
43+
.Then()
44+
.AddCoins(GetCoins(init, alice))
45+
.AddKeys(alice)
46+
.Send(alice, Money.Coins(0.2m))
47+
.SetChange(alice)
48+
.BuildTransaction(true);
49+
repo.Transactions.Put(toAlice);
50+
51+
var votingCoin = new Key();
52+
var init2 = new Transaction()
53+
{
54+
Outputs =
55+
{
56+
new TxOut(Money.Coins(1.0m), votingCoin),
57+
}
58+
};
59+
repo.Transactions.Put(init2);
60+
61+
issuance = GetCoins(init2, votingCoin).Select(c => new IssuanceCoin(c)).ToArray();
62+
builder = new TransactionBuilder();
63+
var toVoters =
64+
builder
65+
.AddCoins(issuance)
66+
.AddKeys(votingCoin)
67+
.IssueAsset(alice, new AssetMoney(votingCoin, 1))
68+
.IssueAsset(satoshi, new AssetMoney(votingCoin, 1))
69+
.SetChange(votingCoin)
70+
.BuildTransaction(true);
71+
repo.Transactions.Put(toVoters);
72+
73+
var aliceVotingCoin = ColoredCoin.Find(toVoters, repo)
74+
.Where(c => c.ScriptPubKey == alice.ScriptPubKey)
75+
.ToArray();
76+
builder = new TransactionBuilder();
77+
var toBob =
78+
builder
79+
.AddCoins(aliceVotingCoin)
80+
.AddKeys(alice)
81+
.SendAsset(bob, new AssetMoney(votingCoin, 1))
82+
.BuildTransaction(true);
83+
repo.Transactions.Put(toBob);
84+
85+
var bobVotingCoin = ColoredCoin.Find(toVoters, repo)
86+
.Where(c => c.ScriptPubKey == bob.ScriptPubKey)
87+
.ToArray();
88+
89+
builder = new TransactionBuilder();
90+
var vote =
91+
builder
92+
.AddCoins(bobVotingCoin)
93+
.AddKeys(bob)
94+
.SendAsset(BitcoinAddress.Create("1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN"),
95+
new AssetMoney(votingCoin, 1))
96+
.BuildTransaction(true);
97+
98+
issuance = GetCoins(init2, votingCoin).Select(c => new IssuanceCoin(c)).ToArray();
99+
issuance[0].DefinitionUrl = new Uri("http://boss.com/vote01.json");
100+
builder = new TransactionBuilder();
101+
toVoters =
102+
builder
103+
.AddCoins(issuance)
104+
.AddKeys(votingCoin)
105+
.IssueAsset(alice, new AssetMoney(votingCoin, 1))
106+
.IssueAsset(satoshi, new AssetMoney(votingCoin, 1))
107+
.SetChange(votingCoin)
108+
.BuildTransaction(true);
109+
repo.Transactions.Put(toVoters);
110+
111+
Console.ReadLine();
112+
}
113+
114+
private static IEnumerable<Coin> GetCoins(Transaction tx, Key owner)
115+
{
116+
return tx.Outputs.AsCoins().Where(c => c.ScriptPubKey == owner.ScriptPubKey);
117+
}
118+
119+
}
120+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
8+
[assembly: AssemblyTitle("4.2LiquidDemocracy")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("4.2LiquidDemocracy")]
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+
21+
[assembly: ComVisible(false)]
22+
23+
// The following GUID is for the ID of the typelib if this project is exposed to COM
24+
25+
[assembly: Guid("6b7205a0-1d0c-425f-9429-e29de0e9c6fd")]
26+
27+
// Version information for an assembly consists of the following four values:
28+
//
29+
// Major Version
30+
// Minor Version
31+
// Build Number
32+
// Revision
33+
//
34+
// You can specify all the values or you can default the Build and Revision Numbers
35+
// by using the '*' as shown below:
36+
// [assembly: AssemblyVersion("1.0.*")]
37+
38+
[assembly: AssemblyVersion("1.0.0.0")]
39+
[assembly: AssemblyFileVersion("1.0.0.0")]

4.2LiquidDemocracy/packages.config

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

4.3ProofOfBurn/4.3ProofOfBurn.csproj

Lines changed: 73 additions & 0 deletions
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>{7EEE7CFF-5CBC-4B56-9430-A56CE2D887ED}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>_4._3ProofOfBurn</RootNamespace>
11+
<AssemblyName>4.3ProofOfBurn</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>

4.3ProofOfBurn/App.config

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

4.3ProofOfBurn/Program.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Linq;
3+
using System.Text;
4+
using NBitcoin;
5+
6+
namespace _4._3ProofOfBurn
7+
{
8+
internal class Program
9+
{
10+
private static void Main()
11+
{
12+
var alice = new Key();
13+
14+
//Giving some money to alice
15+
var init = new Transaction
16+
{
17+
Outputs =
18+
{
19+
new TxOut(Money.Coins(1.0m), alice)
20+
}
21+
};
22+
23+
var coin = init.Outputs.AsCoins().First();
24+
25+
//Burning the coin
26+
var burn = new Transaction();
27+
burn.Inputs.Add(new TxIn(coin.Outpoint)
28+
{
29+
ScriptSig = coin.ScriptPubKey
30+
}); //Spend the previous coin
31+
32+
const string message = "Burnt for \"Alice Bakery\"";
33+
var opReturn = TxNullDataTemplate
34+
.Instance
35+
.GenerateScriptPubKey(Encoding.UTF8.GetBytes(message));
36+
burn.Outputs.Add(new TxOut(Money.Coins(1.0m), opReturn));
37+
burn.Sign(alice, false);
38+
39+
Console.WriteLine(burn);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)