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.
- checksums.yaml +4 -4
- data/bitcoinrb.gemspec +1 -0
- data/lib/bitcoin/connection.rb +7 -5
- data/lib/bitcoin/constants.rb +157 -0
- data/lib/bitcoin/key.rb +15 -3
- data/lib/bitcoin/message/base.rb +0 -12
- data/lib/bitcoin/message/handler.rb +27 -14
- data/lib/bitcoin/message/version.rb +1 -1
- data/lib/bitcoin/message.rb +10 -1
- data/lib/bitcoin/opcodes.rb +2 -2
- data/lib/bitcoin/out_point.rb +5 -1
- data/lib/bitcoin/script/script.rb +117 -38
- data/lib/bitcoin/script/script_error.rb +0 -61
- data/lib/bitcoin/script/script_interpreter.rb +164 -154
- data/lib/bitcoin/script/tx_checker.rb +48 -12
- data/lib/bitcoin/secp256k1/native.rb +139 -5
- data/lib/bitcoin/secp256k1/ruby.rb +2 -13
- data/lib/bitcoin/tx.rb +115 -18
- data/lib/bitcoin/tx_in.rb +23 -4
- data/lib/bitcoin/tx_out.rb +1 -1
- data/lib/bitcoin/validation.rb +93 -0
- data/lib/bitcoin/version.rb +1 -1
- data/lib/bitcoin.rb +31 -2
- metadata +19 -3
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.
|
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
|
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.
|
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."
|