bitcoinrb 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4890635391be36111da08563b43a42f02aeb51088c87a71431ed6b6f22cbe45b
4
- data.tar.gz: 75bbbc13e4244fdd40b1f8aef63a3759ff685d184abeb0867549fe6dbeab3248
3
+ metadata.gz: df5d412165565c3dde3e626417f6a08e08d8698f66712c080b967f5d1e4e1688
4
+ data.tar.gz: 305d2ffba9338edfb26364da1d76ed166c1d2bbb253a2f3337db346a565247ea
5
5
  SHA512:
6
- metadata.gz: d33ec224e5dd0fa03dd9adcd7e2caa78dd1c7021fc121e9431cb49e331e8176dfdae02420af3a6b6921018b9e17582eec225c26afde6ed733649b47c95340a68
7
- data.tar.gz: 76ac351103ff577d6e4acb07c35a0f00af1e3bb00a4eeac3035fb7471ce51d3df64d2ae2411d2cf34d775bea7b50181f7bc4086dfa61979b4926eb4bd4ab8b78
6
+ metadata.gz: 171bd45d707d1d49398d1f272ee7559bc88b5df66a8a4c15afbc107eb9c631eb243c3fad3ec3073d455c8e6c49048ddcd0bedbe96cb4c06b6af7daaad9d31c20
7
+ data.tar.gz: ef995e0e5db4d6b7352de9f7efa7d97bd2a6c0de39c811e352595c89a6b79966ab50304b7e0059bc7c2afff1826a37c99748233f79956d1dca80a745d6aec888
data/README.md CHANGED
@@ -36,10 +36,10 @@ If you use node features, please install level DB as follows.
36
36
 
37
37
  $ brew install leveldb
38
38
 
39
- and put `leveldb-ruby` in your Gemfile and run bundle install.
39
+ and put `leveldb-native` in your Gemfile and run bundle install.
40
40
 
41
41
  ```
42
- gem leveldb-ruby
42
+ gem leveldb-native
43
43
  ```
44
44
 
45
45
  ## Installation
data/bitcoinrb.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_runtime_dependency 'activesupport', '~> 5.2.3'
38
38
 
39
39
  # for options
40
- spec.add_development_dependency 'leveldb-ruby'
40
+ spec.add_development_dependency 'leveldb-native'
41
41
 
42
42
  spec.add_development_dependency 'bundler'
43
43
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -146,9 +146,9 @@ module Bitcoin
146
146
  SCRIPT_ERR_SIG_HIGH_S = 54
147
147
  SCRIPT_ERR_SIG_NULLDUMMY = 55
148
148
  SCRIPT_ERR_PUBKEYTYPE = 56
149
- SCRIPT_ERR_CLEANSTACK = 56
150
- SCRIPT_ERR_MINIMALIF = 57
151
- SCRIPT_ERR_SIG_NULLFAIL = 58
149
+ SCRIPT_ERR_CLEANSTACK = 57
150
+ SCRIPT_ERR_MINIMALIF = 58
151
+ SCRIPT_ERR_SIG_NULLFAIL = 59
152
152
 
153
153
  # softfork safeness
154
154
  SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS = 60
@@ -39,6 +39,11 @@ module Bitcoin
39
39
  tx_hash.rhex
40
40
  end
41
41
 
42
+ def to_s
43
+ return "[#{index}]" unless tx_hash
44
+ "#{txid}[#{index}]"
45
+ end
46
+
42
47
  end
43
48
 
44
49
  end
@@ -133,7 +133,7 @@ module Bitcoin
133
133
 
134
134
  return false unless eval_script(script_pubkey, :witness_v0)
135
135
 
136
- return set_error(SCRIPT_ERR_EVAL_FALSE) unless stack.size == 1
136
+ return set_error(SCRIPT_ERR_CLEANSTACK) unless stack.size == 1
137
137
  return set_error(SCRIPT_ERR_EVAL_FALSE) unless cast_to_bool(stack.last)
138
138
  true
139
139
  end
data/lib/bitcoin/store.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'leveldb'
1
+ require 'leveldb-native'
2
2
 
3
3
  module Bitcoin
4
4
  module Store
@@ -1,4 +1,4 @@
1
- require 'leveldb'
1
+ require 'leveldb-native'
2
2
 
3
3
  module Bitcoin
4
4
  module Store
@@ -12,7 +12,7 @@ module Bitcoin
12
12
  def initialize(path = "#{Bitcoin.base_dir}/db/spv")
13
13
  # @logger = Bitcoin::Logger.create(:debug)
14
14
  FileUtils.mkdir_p(path)
15
- @db = ::LevelDB::DB.new(path)
15
+ @db = ::LevelDBNative::DB.new(path)
16
16
  # logger.debug 'Opened LevelDB successfully.'
17
17
  end
18
18
 
data/lib/bitcoin/util.rb CHANGED
@@ -128,6 +128,18 @@ module Bitcoin
128
128
  OpenSSL::HMAC.digest(DIGEST_NAME_SHA256, key, data)
129
129
  end
130
130
 
131
+ # check whether +addr+ is valid address.
132
+ # @param [String] addr an address
133
+ # @return [Boolean] if valid address return true, otherwise false.
134
+ def valid_address?(addr)
135
+ begin
136
+ Bitcoin::Script.parse_from_addr(addr)
137
+ true
138
+ rescue Exception
139
+ false
140
+ end
141
+ end
142
+
131
143
  end
132
144
 
133
145
  end
@@ -1,3 +1,3 @@
1
1
  module Bitcoin
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'leveldb'
1
+ require 'leveldb-native'
2
2
  module Bitcoin
3
3
  module Wallet
4
4
 
@@ -15,7 +15,7 @@ module Bitcoin
15
15
 
16
16
  def initialize(path = "#{Bitcoin.base_dir}/db/wallet")
17
17
  FileUtils.mkdir_p(path)
18
- @level_db = ::LevelDB::DB.new(path)
18
+ @level_db = ::LevelDBNative::DB.new(path)
19
19
  end
20
20
 
21
21
  # close database
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
11
+ date: 2019-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -221,7 +221,7 @@ dependencies:
221
221
  - !ruby/object:Gem::Version
222
222
  version: 5.2.3
223
223
  - !ruby/object:Gem::Dependency
224
- name: leveldb-ruby
224
+ name: leveldb-native
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="