ampercoin 0.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3d9be3dc610f3f71c845adf93f00e1b361ffe80
4
+ data.tar.gz: 40ae15ed634cc1376e9222fb445a27e79e0a548b
5
+ SHA512:
6
+ metadata.gz: 950966df0011002f8bf329a20ddbacb78990caf54f4e6150a90c98f82fcf10ec6cf1473e00e367c6a76b87dba980a712b49e274f1f621f5d5c35749aac80e607
7
+ data.tar.gz: fe12aad30682bc8b780a717b579fff7ee46bfebdfa09a784e4405aa3e7d1420634fe4aa41874c9aa5b5c661e4dccaac642773ae91d22dd19788d7d9adb504e9b
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'json'
7
+ gem 'rspec'
8
+ gem 'rack-test', require: 'rack/test'
9
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Ampercoin
2
+
3
+ A Ruby Library for interacting with the Ampercoin network.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ampercoin'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ampercoin
20
+
21
+
22
+ ## Contributing
23
+
24
+ 1. Fork it ( https://github.com/[my-github-username]/ampercoin/fork )
25
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
26
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
27
+ 4. Push to the branch (`git push origin my-new-feature`)
28
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ampercoin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ampercoin"
8
+ spec.version = Ampercoin::VERSION
9
+ spec.authors = ["Mason Fischer"]
10
+ spec.email = ["mason@thoughtbot.com"]
11
+ spec.summary = %q{A simple cyptocurrency based on bitcoin}
12
+ spec.description = %q{A simple cyptocurrency based on bitcoin}
13
+ spec.homepage = "http://www.ampercoin.com/"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "rspec"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency "sqlite3"
25
+ spec.add_dependency "activemodel"
26
+ spec.add_dependency "activerecord"
27
+ end
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table :accounts do |t|
3
+ t.string :public_key
4
+ t.string :private_key
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'pry'
2
+ require 'openssl'
3
+ require 'base58'
4
+ require 'active_model'
5
+ require 'active_record'
6
+ require 'sqlite3'
7
+
8
+ db_file = File.join(Dir.home, ".ampercoin/db.sqlite3")
9
+ schema_file = File.join(File.dirname(__FILE__), "../db/schema.rb")
10
+
11
+ if File.exists?(db_file)
12
+ ActiveRecord::Base.establish_connection(
13
+ adapter: :sqlite3,
14
+ database: db_file
15
+ )
16
+ else
17
+ ActiveRecord::Base.establish_connection(
18
+ adapter: :sqlite3,
19
+ database: db_file
20
+ )
21
+
22
+ ActiveRecord::Tasks::DatabaseTasks.load_schema(:ruby, schema_file)
23
+ end
24
+ module Ampercoin
25
+ autoload :Account, 'ampercoin/account'
26
+ end
@@ -0,0 +1,35 @@
1
+ module Ampercoin
2
+ class Account < ActiveRecord::Base
3
+ after_initialize :set_keys
4
+
5
+ def set_keys
6
+ key = OpenSSL::PKey::EC.new('secp521r1')
7
+ key.generate_key
8
+ self.public_key ||= key.public_key.to_bn.to_i.to_s(16)
9
+ self.private_key ||= key.private_key.to_i.to_s(16)
10
+ end
11
+
12
+ def to_s
13
+ address
14
+ end
15
+
16
+ def balance
17
+ 0
18
+ end
19
+
20
+ def address
21
+ "&#{readably_encode(hashed_key)}"
22
+ end
23
+
24
+ def readably_encode(data)
25
+ Base58.encode(data)
26
+ end
27
+
28
+ def hashed_key
29
+ Digest::RMD160.new.hexdigest(public_key).hex
30
+ end
31
+
32
+ def sign
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ module Ampercoin
2
+ class Transaction
3
+ def initialize(options={})
4
+ @sender = options[:sender]
5
+ @receiver = options[:receiver]
6
+ @amount = options[:amount]
7
+ end
8
+
9
+ def mine
10
+
11
+ end
12
+
13
+ def id
14
+ "1"
15
+ end
16
+
17
+ def magic_number
18
+ 4
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Ampercoin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler.require(:default)
4
+ require 'ampercoin'
5
+
6
+ get '/' do
7
+ "Hello World #{params[:name]}".strip
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Account#initalize' do
4
+ it 'assigns an address' do
5
+ puts Ampercoin::Account.new.address
6
+ expect(Ampercoin::Account.new.address.length).to be > 12
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ require_relative '../lib/ampercoin'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ampercoin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mason Fischer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activemodel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activerecord
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A simple cyptocurrency based on bitcoin
98
+ email:
99
+ - mason@thoughtbot.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - ampercoin.gemspec
110
+ - db/schema.rb
111
+ - lib/ampercoin.rb
112
+ - lib/ampercoin/account.rb
113
+ - lib/ampercoin/transaction.rb
114
+ - lib/ampercoin/version.rb
115
+ - server.rb
116
+ - spec/account_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: http://www.ampercoin.com/
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A simple cyptocurrency based on bitcoin
142
+ test_files:
143
+ - spec/account_spec.rb
144
+ - spec/spec_helper.rb