├── 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 |
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.
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 |
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 |
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 || MerkleRoot | @Model.MerkleRoot |
|---|---|
| Script | @Model.Script |
| Size | @Model.FullScriptSize |
| String | @Model.DecomposedScripts[i].Script |
|---|---|
| Bytes | @Model.DecomposedScripts[i].Bytes |
| Hash | @Model.DecomposedScripts[i].Hash |
| PartialMerkleTree | @Model.DecomposedScripts[i].PartialMerkleTree |
| 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 % |
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 |
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 |
24 | new edition
25 | old edition
26 | 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 |
29 | 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 || Position | 40 |Address | 41 |Amount | 42 |Kind Words | 43 |Transaction Id | 44 ||
|---|---|---|---|---|---|
| @maker.Position | 50 |@maker.Address | 51 |@maker.Amount | 52 |@maker.KindWords | 53 |Link | 54 | @*Unlock Part 2 | *@ 55 |
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