bitcoinrb 0.0.1 → 0.1.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.
data/lib/bitcoin.rb CHANGED
@@ -4,6 +4,7 @@ require 'ecdsa'
4
4
  require 'securerandom'
5
5
  require 'json'
6
6
  require 'bech32'
7
+ require 'ffi'
7
8
 
8
9
  module Bitcoin
9
10
 
@@ -30,6 +31,9 @@ module Bitcoin
30
31
  autoload :Base58, 'bitcoin/base58'
31
32
  autoload :Secp256k1, 'bitcoin/secp256k1'
32
33
  autoload :Mnemonic, 'bitcoin/mnemonic'
34
+ autoload :ValidationState, 'bitcoin/validation'
35
+
36
+ require_relative 'bitcoin/constants'
33
37
 
34
38
  extend Util
35
39
 
@@ -57,7 +61,7 @@ module Bitcoin
57
61
 
58
62
  # base dir path that store blockchain data and wallet data
59
63
  def self.base_dir
60
- "#{Dir.home}/.bitcoinrb"
64
+ "#{Dir.home}/.bitcoinrb/#{@chain_param}"
61
65
  end
62
66
 
63
67
  # get secp implementation module
@@ -99,7 +103,7 @@ module Bitcoin
99
103
 
100
104
  # whether data push only?
101
105
  def pushdata?
102
- opcode <= Bitcoin::Opcodes::OP_PUSHDATA4
106
+ opcode <= Bitcoin::Opcodes::OP_PUSHDATA4 && opcode > Bitcoin::Opcodes::OP_0
103
107
  end
104
108
 
105
109
  def pushed_data
@@ -118,4 +122,29 @@ module Bitcoin
118
122
 
119
123
  end
120
124
 
125
+ class ::Object
126
+
127
+ def build_json
128
+ if self.is_a?(Array)
129
+ "[#{self.map{|o|o.to_h.to_json}.join(',')}]"
130
+ else
131
+ to_h.to_json
132
+ end
133
+ end
134
+
135
+ def to_h
136
+ instance_variables.inject({}) do |result, var|
137
+ key = var.to_s
138
+ key.slice!(0) if key.start_with?('@')
139
+ value = instance_variable_get(var)
140
+ if value.is_a?(Array)
141
+ result.update(key => value.map{|v|v.to_h})
142
+ else
143
+ result.update(key => value)
144
+ end
145
+ end
146
+ end
147
+
148
+ end
149
+
121
150
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitcoinrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2017-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ffi
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -168,6 +182,7 @@ files:
168
182
  - lib/bitcoin/chainparams/regtest.yml
169
183
  - lib/bitcoin/chainparams/testnet.yml
170
184
  - lib/bitcoin/connection.rb
185
+ - lib/bitcoin/constants.rb
171
186
  - lib/bitcoin/ext_key.rb
172
187
  - lib/bitcoin/key.rb
173
188
  - lib/bitcoin/logger.rb
@@ -228,6 +243,7 @@ files:
228
243
  - lib/bitcoin/tx_in.rb
229
244
  - lib/bitcoin/tx_out.rb
230
245
  - lib/bitcoin/util.rb
246
+ - lib/bitcoin/validation.rb
231
247
  - lib/bitcoin/version.rb
232
248
  homepage: https://github.com/haw-itn/bitcoinrb
233
249
  licenses:
@@ -249,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
265
  version: '0'
250
266
  requirements: []
251
267
  rubyforge_project:
252
- rubygems_version: 2.6.11
268
+ rubygems_version: 2.6.13
253
269
  signing_key:
254
270
  specification_version: 4
255
271
  summary: "[WIP]The implementation of Bitcoin Protocol for Ruby."