├── ProgrammingBitcoinWebsite ├── Views │ ├── _ViewStart.cshtml │ ├── Home │ │ ├── Redeem.cshtml │ │ ├── AboutMe.cshtml │ │ ├── MAST.cshtml │ │ ├── Index.cshtml │ │ ├── ScriptCheck.cshtml │ │ └── TransactionCheck.cshtml │ ├── Web.config │ └── Shared │ │ └── _Layout.cshtml ├── favicon.ico ├── Global.asax ├── Content │ ├── Octocat.png │ ├── BlockchainProgramming.png │ └── Site.css ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── Scripts │ ├── _references.js │ ├── respond.min.js │ ├── respond.matchmedia.addListener.min.js │ ├── jquery.validate.unobtrusive.min.js │ ├── respond.js │ ├── respond.matchmedia.addListener.js │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.min.js ├── Startup.cs ├── Global.asax.cs ├── App_Start │ └── RouteConfig.cs ├── Models │ ├── RedeemModel.cs │ ├── MakersModel.cs │ ├── MASTModel.cs │ ├── ScriptCheckModel.cs │ └── TransactionCheckModel.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ ├── AssemblyInfo.cs │ └── PublishProfiles │ │ └── blockchainprogramming - Web Deploy.pubxml ├── ScriptRepository.cs ├── ScriptExtensions.cs ├── Web.config ├── packages.config └── ApplicationInsights.config ├── .nuget └── packages.config ├── ProgrammingBitcoin ├── Service References │ └── ServiceReference1 │ │ ├── ProgrammingBitcoin.ServiceReference1.TriangleType.datasource │ │ ├── RedPill1.xsd │ │ ├── Reference.svcmap │ │ ├── RedPill2.xsd │ │ ├── configuration.svcinfo │ │ ├── RedPill.xsd │ │ ├── Reference.cs │ │ ├── RedPill.wsdl │ │ └── RedPill1.wsdl ├── packages.config ├── ClassDiagram1.cd ├── Properties │ └── AssemblyInfo.cs ├── App.config └── ProgrammingBitcoin.csproj ├── ProgrammingBitcoin.sln └── .gitignore /ProgrammingBitcoinWebsite/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/favicon.ico -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="ProgrammingBitcoinFunding.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Content/Octocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/Content/Octocat.png -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Content/BlockchainProgramming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/Content/BlockchainProgramming.png -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NicolasDorier/BlockchainProgramming/HEAD/ProgrammingBitcoinWebsite/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Scripts/_references.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Owin; 2 | using Owin; 3 | 4 | [assembly: OwinStartupAttribute(typeof(ProgrammingBitcoinFunding.Startup))] 5 | namespace ProgrammingBitcoinFunding 6 | { 7 | public partial class Startup 8 | { 9 | public void Configuration(IAppBuilder app) 10 | { 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Home/Redeem.cshtml: -------------------------------------------------------------------------------- 1 | @model ProgrammingBitcoinFunding.Models.RedeemModel 2 | @{ 3 | ViewBag.Title = "Redeem"; 4 | } 5 | 6 |

Redeem

7 |
8 |

Sign the following challenge :

9 |

Your response : @Html.TextBoxFor(o=>o.Signature) @Html.ValidationMessageFor(o=>o.Signature)

10 | @Html.HiddenFor(o=>o.Address) 11 | 12 |
13 | @Model.Message 14 | @if(!String.IsNullOrEmpty(Model.Link)) 15 | { 16 | Link to Part II 17 | } 18 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using ProgrammingBitcoinFunding.App_Start; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Web; 6 | using System.Web.Http; 7 | using System.Web.Mvc; 8 | using System.Web.Optimization; 9 | using System.Web.Routing; 10 | 11 | namespace ProgrammingBitcoinFunding 12 | { 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | RouteConfig.RegisterRoutes(RouteTable.Routes); 19 | new ScriptRepository().CreateIfNotExistsAsync(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/ProgrammingBitcoin.ServiceReference1.TriangleType.datasource: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | ProgrammingBitcoin.ServiceReference1.TriangleType, Service References.ServiceReference1.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 10 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.Routing; 7 | using System.Web.Mvc.Routing; 8 | using System.Web.Mvc; 9 | 10 | namespace ProgrammingBitcoinFunding.App_Start 11 | { 12 | class RouteConfig 13 | { 14 | internal static void RegisterRoutes(RouteCollection routes) 15 | { 16 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 17 | routes.MapMvcAttributeRoutes(); 18 | routes.MapRoute( 19 | name: "Default", 20 | url: "{controller}/{action}/{id}", 21 | defaults: new 22 | { 23 | controller = "Home", 24 | action = "Index", 25 | id = UrlParameter.Optional 26 | } 27 | ); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Models/RedeemModel.cs: -------------------------------------------------------------------------------- 1 | using NBitcoin; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace ProgrammingBitcoinFunding.Models 10 | { 11 | public class RedeemModel 12 | { 13 | public string Address 14 | { 15 | get; 16 | set; 17 | } 18 | 19 | 20 | public string Challenge 21 | { 22 | get; 23 | set; 24 | } 25 | [Required(ErrorMessage="what ?")] 26 | public string Signature 27 | { 28 | get; 29 | set; 30 | } 31 | public string Message 32 | { 33 | get; 34 | set; 35 | } 36 | 37 | public string Link 38 | { 39 | get; 40 | set; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Override the default bootstrap behavior where horizontal description lists 13 | will truncate terms that are too long to fit in the left column 14 | */ 15 | .dl-horizontal dt { 16 | white-space: normal; 17 | } 18 | 19 | /* Set width on the form input elements since they're 100% wide by default */ 20 | input, 21 | select, 22 | textarea { 23 | max-width: 280px; 24 | } 25 | 26 | a img 27 | { 28 | border-color: lightgray; 29 | } 30 | 31 | .field-validation-error { 32 | color: red; 33 | } 34 | 35 | 36 | .navbar-inverse{ 37 | background-color: white; 38 | } 39 | 40 | .navbar-inverse .navbar-nav > li > a{ 41 | color: hsl(0, 0%, 40%); 42 | } 43 | 44 | .navbar-inverse .navbar-nav > li > a:hover { 45 | color: hsl(0, 0%, 0%); 46 | background-color: transparent; 47 | } 48 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Home/AboutMe.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "AboutMe"; 3 | } 4 | 5 |

About Me

6 |

I am an independant .NET Developer and Trainer. More info.

7 |

I started working on Bitcoin shortly after MtGox disaster and created NBitcoin, the .NET Bitcoin Framework Compatible Mono.
8 | The first reason I did that was for learning about Bitcoin. But what used to be an hobby became obsession and took the priority over my other activities.

9 |

I saw that by connecting the dots between my past knowledge about cloud computing, embedded devices, .NET and Bitcoin, I could make something different.

10 |

So here I am, now helping Bitcoin companies to ship full time. Stopping all non-bitcoin activities I had.

11 |

However, coffee is not enough to get more than 24H per days. Even if I want to help for every projects, this is sadly not possible. Writing this book is my solution to empower other developers.

12 |

Happy Coding,

13 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/ClassDiagram1.cd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 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("ProgrammingBitcoinFunding")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("ProgrammingBitcoinFunding")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 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("06e1cb92-87af-4091-a130-65e0847269da")] 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 Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 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("ProgrammingBitcoin")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("ProgrammingBitcoin")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 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("7de966a1-df3b-4830-a8a7-6fcf585ddb4d")] 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")] 37 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Models/MakersModel.cs: -------------------------------------------------------------------------------- 1 | using NBitcoin; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProgrammingBitcoinFunding.Models 9 | { 10 | public class Maker 11 | { 12 | public BitcoinAddress Address 13 | { 14 | get; 15 | set; 16 | } 17 | public Uri AddressUri 18 | { 19 | get; 20 | set; 21 | } 22 | public string KindWords 23 | { 24 | get; 25 | set; 26 | } 27 | public Money Amount 28 | { 29 | get; 30 | set; 31 | } 32 | 33 | public int Position 34 | { 35 | get; 36 | set; 37 | } 38 | public Uri TransactionUri 39 | { 40 | get; 41 | set; 42 | } 43 | public uint256 TransactionId 44 | { 45 | get; 46 | set; 47 | } 48 | } 49 | public class MakersModel 50 | { 51 | public MakersModel() 52 | { 53 | Makers = new List(); 54 | } 55 | public List Makers 56 | { 57 | get; 58 | set; 59 | } 60 | 61 | public int Height 62 | { 63 | get; 64 | set; 65 | } 66 | 67 | public string Time 68 | { 69 | get; 70 | set; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Models/MASTModel.cs: -------------------------------------------------------------------------------- 1 | using NBitcoin; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProgrammingBitcoinFunding.Models 9 | { 10 | public class MASTModel 11 | { 12 | public String Script 13 | { 14 | get; 15 | set; 16 | } 17 | 18 | public List DecomposedScripts 19 | { 20 | get; 21 | set; 22 | } 23 | 24 | public uint256 MerkleRoot 25 | { 26 | get; 27 | set; 28 | } 29 | 30 | public int FullScriptSize 31 | { 32 | get; 33 | set; 34 | } 35 | } 36 | 37 | public class DecomposedScript 38 | { 39 | 40 | public string Script 41 | { 42 | get; 43 | set; 44 | } 45 | 46 | public uint256 Hash 47 | { 48 | get; 49 | set; 50 | } 51 | 52 | public string Bytes 53 | { 54 | get; 55 | set; 56 | } 57 | 58 | public string PartialMerkleTree 59 | { 60 | get; 61 | set; 62 | } 63 | 64 | public int Size 65 | { 66 | get; 67 | set; 68 | } 69 | 70 | public decimal Saving 71 | { 72 | get; 73 | set; 74 | } 75 | 76 | public int Size160 77 | { 78 | get; 79 | set; 80 | } 81 | 82 | public decimal Saving160 83 | { 84 | get; 85 | set; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /ProgrammingBitcoin.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammingBitcoin", "ProgrammingBitcoin\ProgrammingBitcoin.csproj", "{090CE034-56C0-4294-8220-426FFC804220}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProgrammingBitcoinWebsite", "ProgrammingBitcoinWebsite\ProgrammingBitcoinFunding.csproj", "{C40D8071-95EA-4489-9439-428E47A25EEB}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0231CFC4-5083-448A-AB6F-94E96453E2EF}" 11 | ProjectSection(SolutionItems) = preProject 12 | .nuget\packages.config = .nuget\packages.config 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {090CE034-56C0-4294-8220-426FFC804220}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {090CE034-56C0-4294-8220-426FFC804220}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {090CE034-56C0-4294-8220-426FFC804220}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {090CE034-56C0-4294-8220-426FFC804220}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {C40D8071-95EA-4489-9439-428E47A25EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {C40D8071-95EA-4489-9439-428E47A25EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {C40D8071-95EA-4489-9439-428E47A25EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {C40D8071-95EA-4489-9439-428E47A25EEB}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | EndGlobal 34 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/RedPill1.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/Reference.svcmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | true 6 | 7 | false 8 | false 9 | false 10 | 11 | 12 | true 13 | Auto 14 | true 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/RedPill2.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/configuration.svcinfo: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Properties/PublishProfiles/blockchainprogramming - Web Deploy.pubxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | MSDeploy 9 | Release 10 | Any CPU 11 | http://n.bitcoin.ninja/ 12 | True 13 | False 14 | blockchainprogramming.scm.azurewebsites.net:443 15 | blockchainprogramming 16 | 17 | True 18 | WMSVC 19 | True 20 | $blockchainprogramming 21 | <_SavePWD>True 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | False 37 | AzureWebSite 38 | <_DestinationType>AzureWebSite 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ProgrammingBitcoin/Service References/ServiceReference1/RedPill.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/ScriptRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.WindowsAzure.Storage; 2 | using Microsoft.WindowsAzure.Storage.Table; 3 | using NBitcoin; 4 | using NBitcoin.DataEncoders; 5 | using Newtonsoft.Json; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Configuration; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace ProgrammingBitcoinFunding 14 | { 15 | public class SavedScript 16 | { 17 | public SavedScript() 18 | { 19 | Id = Guid.NewGuid(); 20 | } 21 | public Guid Id 22 | { 23 | get; 24 | set; 25 | } 26 | public string ScriptSig 27 | { 28 | get; 29 | set; 30 | } 31 | public string ScriptPubKey 32 | { 33 | get; 34 | set; 35 | } 36 | } 37 | public class ScriptRepository 38 | { 39 | public ScriptRepository() 40 | { 41 | 42 | } 43 | 44 | public CloudTable GetTable() 45 | { 46 | return CloudStorageAccount.Parse(ConfigurationManager.AppSettings["AzureStorage"]).CreateCloudTableClient().GetTableReference("SavedScripts"); 47 | } 48 | 49 | public Task CreateIfNotExistsAsync() 50 | { 51 | return GetTable().CreateIfNotExistsAsync(); 52 | } 53 | public void InsertScript(SavedScript script) 54 | { 55 | var table = GetTable(); 56 | var entity = new DynamicTableEntity(); 57 | entity.ETag = "*"; 58 | entity.PartitionKey = "1"; 59 | entity.RowKey = script.Id.ToString(); 60 | entity.Properties.Add("Script", new EntityProperty(Serialize(script))); 61 | table.Execute(TableOperation.Insert(entity)); 62 | } 63 | 64 | private string Serialize(SavedScript script) 65 | { 66 | return JsonConvert.SerializeObject(script); 67 | } 68 | private T Deserialize(string script) 69 | { 70 | return JsonConvert.DeserializeObject(script); 71 | } 72 | public SavedScript GetScript(Guid id) 73 | { 74 | var table = GetTable(); 75 | var entity = table.ExecuteQuery(new TableQuery() 76 | { 77 | FilterString = TableQuery.CombineFilters 78 | ( 79 | TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "1"), 80 | TableOperators.And, 81 | TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, id.ToString()) 82 | ) 83 | }).FirstOrDefault(); 84 | if(entity == null) 85 | return null; 86 | return Deserialize(entity["Script"].StringValue); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewBag.Title - Blockchain Programming in C# 7 | 8 | 9 | 10 | 11 | 12 | 66 | 67 |
68 | @RenderBody() 69 |
70 |
71 |

© @DateTime.Now.Year - Nicolas Dorier

72 |
73 |
74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Models/ScriptCheckModel.cs: -------------------------------------------------------------------------------- 1 | using NBitcoin; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Web.Mvc; 8 | 9 | namespace ProgrammingBitcoinFunding.Models 10 | { 11 | public class ScriptCheckModel 12 | { 13 | [AllowHtml] 14 | public string ScriptSig 15 | { 16 | get; 17 | set; 18 | } 19 | public string SavedScriptLink 20 | { 21 | get; 22 | set; 23 | } 24 | 25 | public string Run 26 | { 27 | get; 28 | set; 29 | } 30 | public string Share 31 | { 32 | get; 33 | set; 34 | } 35 | [AllowHtml] 36 | public string ScriptPubKey 37 | { 38 | get; 39 | set; 40 | } 41 | 42 | public Script ExecutedScriptSig 43 | { 44 | get; 45 | set; 46 | } 47 | public Script ExecutedScriptPubKey 48 | { 49 | get; 50 | set; 51 | } 52 | public ScriptResultModel Result 53 | { 54 | get; 55 | set; 56 | } 57 | 58 | public string Transaction 59 | { 60 | get; 61 | set; 62 | } 63 | } 64 | 65 | public class ScriptResultModel 66 | { 67 | 68 | public bool Success 69 | { 70 | get; 71 | set; 72 | } 73 | 74 | public string Error 75 | { 76 | get; 77 | set; 78 | } 79 | 80 | public StackValueModel[] StackValues 81 | { 82 | get; 83 | set; 84 | } 85 | 86 | public CheckSigsModel[] CheckSigs 87 | { 88 | get; 89 | set; 90 | } 91 | } 92 | 93 | public class StackValueModel 94 | { 95 | public string Hex 96 | { 97 | get; 98 | set; 99 | } 100 | public string Bool 101 | { 102 | get; 103 | set; 104 | } 105 | public string Number 106 | { 107 | get; 108 | set; 109 | } 110 | } 111 | 112 | public class CheckSigsModel 113 | { 114 | 115 | public SigHash SigHash 116 | { 117 | get; 118 | set; 119 | } 120 | 121 | public Script ScriptCode 122 | { 123 | get; 124 | set; 125 | } 126 | 127 | public uint256 SignedHash 128 | { 129 | get; 130 | set; 131 | } 132 | 133 | public string Signature 134 | { 135 | get; 136 | set; 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Models/TransactionCheckModel.cs: -------------------------------------------------------------------------------- 1 | using NBitcoin; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace ProgrammingBitcoinFunding.Models 9 | { 10 | public class TransactionCheckModel 11 | { 12 | public string Transaction 13 | { 14 | get; 15 | set; 16 | } 17 | public int CoreSize 18 | { 19 | get; 20 | set; 21 | } 22 | 23 | public int WitnessSize 24 | { 25 | get; 26 | set; 27 | } 28 | 29 | public int TransactionCost 30 | { 31 | get; 32 | set; 33 | } 34 | public CheckResult Result 35 | { 36 | get; 37 | set; 38 | } 39 | 40 | public bool HasWitness 41 | { 42 | get; 43 | set; 44 | } 45 | 46 | public int EstimatedCostNoWit 47 | { 48 | get; 49 | set; 50 | } 51 | public int EstimatedCostWit 52 | { 53 | get; 54 | set; 55 | } 56 | 57 | public int ScriptSigSize 58 | { 59 | get; 60 | set; 61 | } 62 | 63 | public int Saving 64 | { 65 | get; 66 | set; 67 | } 68 | } 69 | 70 | public class InputCheckResult 71 | { 72 | public SignedHash SignatureHash 73 | { 74 | get; 75 | set; 76 | } 77 | public string ScriptError 78 | { 79 | get; 80 | set; 81 | } 82 | 83 | public WitScript Witness 84 | { 85 | get; 86 | set; 87 | } 88 | 89 | public Script ScriptSig 90 | { 91 | get; 92 | set; 93 | } 94 | 95 | public Script ScriptPubKey 96 | { 97 | get; 98 | set; 99 | } 100 | 101 | public OutPoint PrevOut 102 | { 103 | get; 104 | set; 105 | } 106 | 107 | public Script P2SHRedeemScript 108 | { 109 | get; 110 | set; 111 | } 112 | 113 | public Money Amount 114 | { 115 | get; 116 | set; 117 | } 118 | } 119 | public class CheckResult 120 | { 121 | public CheckResult() 122 | { 123 | InputResults = new List(); 124 | } 125 | public bool Success 126 | { 127 | get; 128 | set; 129 | } 130 | 131 | public List InputResults 132 | { 133 | get; 134 | set; 135 | } 136 | 137 | public uint256 Id 138 | { 139 | get; 140 | set; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Home/MAST.cshtml: -------------------------------------------------------------------------------- 1 | @model ProgrammingBitcoinFunding.Models.MASTModel 2 | @{ 3 | ViewBag.Title = "MAST"; 4 | } 5 | 6 |

MAST

7 |

8 | An example of MAST implementation in 100 lines of code (https://www.irccloud.com/pastebin/0ZNKfNvC/ )
9 | The idea is to decompose all the possible execution paths of a script, and make merkle tree from that.
10 | The wit commitment would need only the executed path and the partial merkle tree to it. 11 |

12 |

Saving may be negative, but none executed sigops will not be counted for the block, and saving can be done by using Hash160 instead of Hash256 for the merkle tree.

13 |
14 |
15 |
16 |
17 | @Html.LabelFor(m => m.Script, new 18 | { 19 | @class = "col-md-3 control-label" 20 | }) 21 |
22 | @Html.TextAreaFor(o => o.Script, 25, 300, null) 23 |
24 |
25 |
26 |
27 | 28 |
29 |
30 |
31 |
32 |
33 | @if(Model.DecomposedScripts != null) 34 | { 35 |

Script decomposition

36 | 37 | 38 | 39 | 40 |
MerkleRoot@Model.MerkleRoot
Script@Model.Script
Size@Model.FullScriptSize
41 | for(int i = 0; i < Model.DecomposedScripts.Count; i++) 42 | { 43 |

Script @i

44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
String@Model.DecomposedScripts[i].Script
Bytes
@Model.DecomposedScripts[i].Bytes
Hash@Model.DecomposedScripts[i].Hash
PartialMerkleTree@Model.DecomposedScripts[i].PartialMerkleTree
56 |

Size of commitment (Merkle Tree + Script)

57 | 58 | 59 | 60 | 61 | 62 |
Size with HASH256@Model.DecomposedScripts[i].Size
Saving with HASH256@Model.DecomposedScripts[i].Saving %
Size with HASH160@Model.DecomposedScripts[i].Size160
Saving with HASH160@Model.DecomposedScripts[i].Saving160 %
63 | } 64 | } 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/DeployClient.proj 15 | [Bb]in/ 16 | [Oo]bj/ 17 | NBitcoin.Indexer.Tests/LocalSettings.config 18 | NBitcoin.Indexer.Console/LocalSettings.config 19 | 20 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 21 | !packages/*/build/ 22 | 23 | # MSTest test Results 24 | [Tt]est[Rr]esult*/ 25 | [Bb]uild[Ll]og.* 26 | 27 | *_i.c 28 | *_p.c 29 | *.ilk 30 | *.meta 31 | *.obj 32 | *.pch 33 | *.pdb 34 | *.pgc 35 | *.pgd 36 | *.rsp 37 | *.sbr 38 | *.tlb 39 | *.tli 40 | *.tlh 41 | *.tmp 42 | *.tmp_proj 43 | *.log 44 | *.vspscc 45 | *.vssscc 46 | .builds 47 | *.pidb 48 | *.log 49 | *.scc 50 | 51 | # Visual C++ cache files 52 | ipch/ 53 | *.aps 54 | *.ncb 55 | *.opensdf 56 | *.sdf 57 | *.cachefile 58 | 59 | # Visual Studio profiler 60 | *.psess 61 | *.vsp 62 | *.vspx 63 | 64 | # Guidance Automation Toolkit 65 | *.gpState 66 | 67 | # ReSharper is a .NET coding add-in 68 | _ReSharper*/ 69 | *.[Rr]e[Ss]harper 70 | 71 | # TeamCity is a build add-in 72 | _TeamCity* 73 | 74 | # DotCover is a Code Coverage Tool 75 | *.dotCover 76 | 77 | # NCrunch 78 | *.ncrunch* 79 | .*crunch*.local.xml 80 | 81 | # Installshield output folder 82 | [Ee]xpress/ 83 | 84 | # DocProject is a documentation generator add-in 85 | DocProject/buildhelp/ 86 | DocProject/Help/*.HxT 87 | DocProject/Help/*.HxC 88 | DocProject/Help/*.hhc 89 | DocProject/Help/*.hhk 90 | DocProject/Help/*.hhp 91 | DocProject/Help/Html2 92 | DocProject/Help/html 93 | 94 | # Click-Once directory 95 | publish/ 96 | 97 | # Publish Web Output 98 | *.Publish.xml 99 | 100 | # NuGet Packages Directory 101 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 102 | packages/ 103 | 104 | # Windows Azure Build Output 105 | csx 106 | *.build.csdef 107 | 108 | # Windows Store app package directory 109 | AppPackages/ 110 | 111 | # Others 112 | sql/ 113 | *.Cache 114 | ClientBin/ 115 | [Ss]tyle[Cc]op.* 116 | ~$* 117 | *~ 118 | *.dbmdl 119 | *.[Pp]ublish.xml 120 | *.pfx 121 | *.publishsettings 122 | 123 | # RIA/Silverlight projects 124 | Generated_Code/ 125 | 126 | # Backup & report files from converting an old project file to a newer 127 | # Visual Studio version. Backup files are not needed, because we have git ;-) 128 | _UpgradeReport_Files/ 129 | Backup*/ 130 | UpgradeLog*.XML 131 | UpgradeLog*.htm 132 | 133 | # SQL Server files 134 | App_Data/*.mdf 135 | App_Data/*.ldf 136 | 137 | 138 | #LightSwitch generated files 139 | GeneratedArtifacts/ 140 | _Pvt_Extensions/ 141 | ModelManifest.xml 142 | 143 | # ========================= 144 | # Windows detritus 145 | # ========================= 146 | 147 | # Windows image file caches 148 | Thumbs.db 149 | ehthumbs.db 150 | 151 | # Folder config file 152 | Desktop.ini 153 | 154 | # Recycle Bin used on file shares 155 | $RECYCLE.BIN/ 156 | 157 | # Mac desktop service store files 158 | .DS_Store 159 | 160 | Build/DeployClient.proj 161 | /.vs/config/applicationhost.config 162 | /.vs/ 163 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model ProgrammingBitcoinFunding.Models.MakersModel 2 | @{ 3 | ViewBag.Title = "Home"; 4 | } 5 | 15 |

Blockchain Programming in C#

16 |

Dear developers, and Bitcoin addicts,

17 |

18 | I wrote Blockchain Programming in C#, so I hope you too, hobbyist, startup and big corporation will move the block forwards.
19 | I get too much questions and requests for helping everyone to build on the Blockchain. 20 | But sadly, I only have 24H per day, no matter how much coffee I drink. 21 |

22 |

Writing is the most scalable way to share my knowledge. And coherently with such a goal my work is under CC (ASA 3U), so you are free to share. (and encouraged to do so)

23 | download 24 | new edition 25 | old edition 26 |

Code examples

27 |

The book contains multiple example about how to use NBitcoin. Moreover, this website is itself open source, so you can take a look and play with it by yourself.

28 | source 29 |

Hall of the Makers

30 |

As you will read the book, you will have some challenges.

31 |

For the first challenge, you need to send me at least 0.0004 BTC on 1KF8kUVHK42XzgcmJF4Lxz4wcL5WDL97PB with some kind words in the OP_RETURN of your transaction.

32 |

This money goes into my "Coffee and Sushi Wallet" that will keep me fed and compliant while writing the rest of the book.

33 |

You can download the first part of the book for free to know how.

34 |

Here are the true makers that cleared the task, ordered by success, generosity then time (confirmed only):

35 |

Current block height: @Model.Height (@Model.Time)

36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | @foreach(var maker in Model.Makers) 46 | { 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | @**@ 55 | 56 | } 57 | 58 |
PositionAddressAmountKind WordsTransaction Id
@maker.Position@maker.Address@maker.Amount@maker.KindWordsLinkUnlock Part 2
59 | 60 |
61 |

PS: I've seen some people sending 0.0004 BTC but forgetting the OP_RETURN. If you want me to return the BTC, ask me with your signature to refund it on BTC Talk.

62 |

63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /ProgrammingBitcoinWebsite/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl 2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT 3 | * */ 4 | 5 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b vfExec; 15 | public List executionPath; 16 | public long position; 17 | public Op op; 18 | } 19 | public static Script[] Decompose(this Script script) 20 | { 21 | List