shilling 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+
2
+
3
+ class Transaction
4
+
5
+ attr_reader :from, :to, :amount, :id
6
+
7
+ def initialize( from, to, amount, id=SecureRandom.uuid )
8
+ @from = from
9
+ @to = to
10
+ @amount = amount
11
+ @id = id
12
+ end
13
+
14
+ def self.from_h( hash )
15
+ self.new *hash.values_at( 'from', 'to', 'amount', 'id' )
16
+ end
17
+
18
+ def to_h
19
+ { from: @from, to: @to, amount: @amount, id: @id }
20
+ end
21
+
22
+
23
+ def valid?
24
+ ## check signature in the future; for now always true
25
+ true
26
+ end
27
+
28
+ end # class Transaction
29
+
30
+ Tx = Transaction ## add Tx shortcut / alias
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ module Shilling
4
+
5
+ VERSION = '0.1.0'
6
+
7
+ def self.root
8
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
9
+ end
10
+
11
+ end # module Shilling
@@ -0,0 +1,37 @@
1
+ <div class="blockchain">
2
+ <h2>
3
+ Blockchain<br>
4
+ <span><%= @node.bank.chain.size %> blocks</span>
5
+ </h2>
6
+ <form action="/mine" method="post">
7
+ <input type="submit" class="button" value="Mine a Block">
8
+ </form>
9
+
10
+ <div class="blocks">
11
+ <% @node.bank.chain.last(10).reverse.each do |block| %>
12
+ <div class="block">
13
+ <div class="header">
14
+ <%= block.index %> — <%= block.timestamp %><br>
15
+ </div>
16
+ <table>
17
+ <% block.transactions.each do |tx| %>
18
+ <tr>
19
+ <td class="id">
20
+ <%= tx.id[0..2] %>
21
+ </td>
22
+ <td>
23
+ $<%= tx.amount %>
24
+ </td>
25
+ <td>
26
+ <%= tx.from[0..15] %> → <%= tx.to[0..15] %>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </table>
31
+ </div>
32
+ <% end %>
33
+ </div>
34
+ <p>
35
+ †: Miner Transaction - New $$ on the Market!
36
+ </p>
37
+ </div>
@@ -0,0 +1,15 @@
1
+ <div class="ledger">
2
+ <h2>Ledger</h2>
3
+ <table>
4
+ <tr>
5
+ <th>Address</th>
6
+ <th>Balance</th>
7
+ </tr>
8
+ <% @node.bank.ledger.wallets.each do |address, amount| %>
9
+ <tr>
10
+ <td><%= address[0..15] %></td>
11
+ <td>$<%= amount %></td>
12
+ </tr>
13
+ <% end %>
14
+ </table>
15
+ </div>
@@ -0,0 +1,24 @@
1
+ <div class="peers">
2
+ <h2>Peers</h2>
3
+ <% if @node.peers.any? %>
4
+ <ul>
5
+ <% @node.peers.each_with_index do |(host, port), i| %>
6
+ <li>
7
+ http://<%= host %>:<%= port %>
8
+ <form action="/peers/<%= i %>/delete" method="post">
9
+ <input type="submit" class="small" value="Remove" />
10
+ </form>
11
+ </li>
12
+ <% end %>
13
+ </ul>
14
+ <% else %>
15
+ <i>No peers</i>
16
+ <% end %>
17
+ <form action="/peers" method="post" class="peers-form">
18
+ <label for="host">http://</label>
19
+ <input type="text" name="host" id="host" placeholder="host" />
20
+ <label for="port">Port</label>
21
+ <input type="text" name="port" id="port" />
22
+ <input type="submit" class="button" value="Add Peer" />
23
+ </form>
24
+ </div>
@@ -0,0 +1,23 @@
1
+ <div class="pending-transactions">
2
+ <h2>Pending Transactions</h2>
3
+ <% if @node.bank.pending.any? %>
4
+ <table>
5
+ <tr>
6
+ <th>From</th>
7
+ <th>To</th>
8
+ <th>$</th>
9
+ <th>Id</th>
10
+ </tr>
11
+ <% @node.bank.pending.each do |tx| %>
12
+ <tr>
13
+ <td><%= tx.from[0..15] %></td>
14
+ <td><%= tx.to[0..15] %></td>
15
+ <td><%= tx.amount %></td>
16
+ <td><%= tx.id[0..2] %></td>
17
+ </tr>
18
+ <% end %>
19
+ </table>
20
+ <% else %>
21
+ <i>No pending transactions</i>
22
+ <% end %>
23
+ </div>
@@ -0,0 +1,16 @@
1
+
2
+ <div class="wallet">
3
+ <div class="details">
4
+ <h2>Address</h2>
5
+ <div><%= @node.wallet.address %></div>
6
+ <h2>Balance</h2>
7
+ <div class="balance">$<%= @node.bank.ledger.wallets[@node.wallet.address] || 0 %></div>
8
+ </div>
9
+ <form action="/send" method="post" class="transaction-form">
10
+ <label for="to">To</label>
11
+ <input type="text" name="to" id="to" placeholder="address" />
12
+ <label for="amount">Amount</label>
13
+ <input type="text" name="amount" id="amount" />
14
+ <input type="submit" class="button" value="Send" /><br>
15
+ </form>
16
+ </div>
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Central Bank Node</title>
5
+ <link rel="stylesheet" href="style.css">
6
+ </head>
7
+ <body>
8
+
9
+ <h1>Central Bank Node</h1>
10
+
11
+ <div class="columns">
12
+ <div class="left">
13
+ <%= erb :'_wallet' %>
14
+ <%= erb :'_pending_transactions' %>
15
+ <%= erb :'_peers' %>
16
+ <%= erb :'_ledger' %>
17
+ </div>
18
+
19
+ <div class="right">
20
+ <%= erb :'_blockchain' %>
21
+ </div>
22
+ </div>
23
+
24
+ <script>
25
+ var es = new EventSource('/events');
26
+ es.onmessage = function(e) { window.location.reload(false); };
27
+ </script>
28
+
29
+ </body>
30
+ </html>
@@ -0,0 +1,172 @@
1
+
2
+ body {
3
+ padding: 0;
4
+ margin: 0;
5
+ min-width: 960px;
6
+
7
+ font-family: 'menlo', monospace;
8
+ font-size: 14px;
9
+
10
+ background: #fff;
11
+ color: #2B2D2F;
12
+ }
13
+
14
+
15
+ .columns {
16
+ display: flex;
17
+
18
+ .left {
19
+ width: 66%;
20
+ }
21
+
22
+ .right {
23
+ width: 34%;
24
+ }
25
+ }
26
+
27
+
28
+ h1 {
29
+ font-size: 24px;
30
+ font-weight: normal;
31
+ padding-left: 15px;
32
+ margin-bottom: 20px;
33
+ }
34
+
35
+
36
+ h2 {
37
+ font-size: 16px;
38
+ }
39
+
40
+ h2 span {
41
+ font-size: 14px;
42
+ color: #597898;
43
+ font-weight: normal;
44
+ }
45
+
46
+ label {
47
+ display: inline-block;
48
+ width: 80px;
49
+ text-align: right;
50
+ padding-right: 10px;
51
+ }
52
+
53
+ input[type=text] {
54
+ display: inline-block;
55
+ font-size: 14px;
56
+ padding: 8px;
57
+ border-radius: 0;
58
+ border: 0;
59
+ }
60
+
61
+ table {
62
+ border-spacing: 0;
63
+ border-collapse: collapse;
64
+
65
+ th {
66
+ text-align: left;
67
+ }
68
+
69
+ td {
70
+ vertical-align: top;
71
+ padding: 5px 15px 5px 0;
72
+ }
73
+ }
74
+
75
+
76
+ ul {
77
+ list-style: none;
78
+ padding: 0;
79
+ margin: 0;
80
+ }
81
+
82
+ input[type=submit] {
83
+ font-size: 14px;
84
+ font-family: menlo, monospace;
85
+ border-radius: 5px;
86
+ padding: 8px 20px;
87
+ background: #FFDC00;
88
+ color: #2B2D2F;
89
+ border: 0;
90
+ }
91
+
92
+ input[type=submit].small {
93
+ font-size: 10px;
94
+ padding: 4px 10px;
95
+ }
96
+
97
+
98
+
99
+ .wallet {
100
+ padding: 15px;
101
+ background: #7FDBFF;
102
+
103
+ h2 {
104
+ margin-bottom: 0;
105
+ }
106
+
107
+ .balance {
108
+ font-size: 30px;
109
+ }
110
+ }
111
+
112
+
113
+ .pending-transactions {
114
+ padding: 15px;
115
+ background: #A3E6FF;
116
+ }
117
+
118
+ .peers {
119
+ padding: 15px;
120
+ background: #C6EFFF;
121
+
122
+ li form {
123
+ display: inline;
124
+ }
125
+
126
+ li {
127
+ padding: 5px 0px;
128
+ }
129
+ }
130
+
131
+
132
+ .ledger {
133
+ padding: 15px;
134
+ background: #E3F7FF;
135
+ }
136
+
137
+
138
+ .blockchain {
139
+ padding: 15px;
140
+ position: relative;
141
+ background: #001F3F;
142
+ color: #fff;
143
+
144
+ form {
145
+ position: absolute;
146
+ top: 30px;
147
+ right: 15px;
148
+ }
149
+
150
+ .blocks {
151
+ border: 1px solid #597898;
152
+ border-bottom: 0;
153
+
154
+ .block {
155
+ margin: 0;
156
+ border-bottom: 2px dashed #597898;
157
+ padding: 10px;
158
+
159
+ .header {
160
+ text-align: center;
161
+ padding: 0 8px 8px 8px;
162
+ color: #597898;
163
+ border-bottom: 1px solid #354c63;
164
+ margin-bottom: 10px;
165
+ }
166
+
167
+ .id {
168
+ color: #597898;
169
+ }
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,15 @@
1
+ ###########
2
+ # Single Address Wallet
3
+
4
+ class Wallet
5
+ attr_reader :address
6
+
7
+ def initialize( address )
8
+ @address = address
9
+ end
10
+
11
+ def generate_transaction( to, amount )
12
+ Tx.new( address, to, amount )
13
+ end
14
+
15
+ end # class Wallet
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shilling
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sass
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: blockchain-lite
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.16'
83
+ description: shilling (or schilling) on the blockchain! rock-solid alpine dollar from
84
+ austria; print (mine) your own shillings; run your own federated shilling central
85
+ bank nodes w/ public distributed (hyper) ledger book on the blockchain peer-to-peer
86
+ over HTTP; revolutionize the world one block at a time with cryptos
87
+ email: ruby-talk@ruby-lang.org
88
+ executables:
89
+ - shilling
90
+ extensions: []
91
+ extra_rdoc_files:
92
+ - HISTORY.md
93
+ - LICENSE.md
94
+ - Manifest.txt
95
+ - README.md
96
+ files:
97
+ - HISTORY.md
98
+ - LICENSE.md
99
+ - Manifest.txt
100
+ - README.md
101
+ - Rakefile
102
+ - bin/shilling
103
+ - lib/shilling.rb
104
+ - lib/shilling/bank.rb
105
+ - lib/shilling/block.rb
106
+ - lib/shilling/blockchain.rb
107
+ - lib/shilling/cache.rb
108
+ - lib/shilling/ledger.rb
109
+ - lib/shilling/node.rb
110
+ - lib/shilling/pool.rb
111
+ - lib/shilling/service.rb
112
+ - lib/shilling/tool.rb
113
+ - lib/shilling/transaction.rb
114
+ - lib/shilling/version.rb
115
+ - lib/shilling/views/_blockchain.erb
116
+ - lib/shilling/views/_ledger.erb
117
+ - lib/shilling/views/_peers.erb
118
+ - lib/shilling/views/_pending_transactions.erb
119
+ - lib/shilling/views/_wallet.erb
120
+ - lib/shilling/views/index.erb
121
+ - lib/shilling/views/style.scss
122
+ - lib/shilling/wallet.rb
123
+ homepage: https://github.com/blockchainaustria/shilling.tools
124
+ licenses:
125
+ - Public Domain
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options:
129
+ - "--main"
130
+ - README.md
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '2.3'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.5.2
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: shilling (or schilling) on the blockchain! rock-solid alpine dollar from
149
+ austria; print (mine) your own shillings; run your own federated shilling central
150
+ bank nodes w/ public distributed (hyper) ledger book on the blockchain peer-to-peer
151
+ over HTTP; revolutionize the world one block at a time with cryptos
152
+ test_files: []