iota-ruby 1.1.6 → 1.1.7

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
  SHA1:
3
- metadata.gz: 001faa9697735af3ccb7dc1b9e853808a09d9ebc
4
- data.tar.gz: 46f4cb83b7559dad8265ec8b3b4e080467c180db
3
+ metadata.gz: 1e5423f9645a1fceef2e926f77101b6d28a2e837
4
+ data.tar.gz: 55d897d2dec4177927a57e90f7e5570c79d95604
5
5
  SHA512:
6
- metadata.gz: f9057f008b0a7647b49ff7d9a3bd11e5c719f42f39922d4ae819ce214377fd2ff1d3b7f06e63115a6b01b5723966d3f1f4e4e250cd929e5a351d078228593df1
7
- data.tar.gz: a6209e6d04d1295017d4e738cd8770e0e18036cdf45be69ffc6155227655685fa815f6b4dd60bee1ff1418d881da17f738a35eda07ca58493df2b8c9ae9dc7d1
6
+ metadata.gz: 16ccbc15b79c844294c81ab21146e6fb848dd1db5d2e3e6b8b56b8096f3aed43d117a607f046b3b7ddd4fcb2e7770284662df7246ea5649c94498f03ceb5e3d9
7
+ data.tar.gz: 077a3b55befc66196a5bfa9e2ceab5074d5d42afd856a245a90c4c15d701b7b4f6446973e604c53c748acc1263d549dca8f48df232c826a0b1c42b681c6ba2f1
@@ -1,5 +1,10 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ os:
4
+ - linux
5
+ - osx
3
6
  rvm:
7
+ - ruby-head
8
+ - 2.5.1
4
9
  - 2.4.1
5
10
  before_install: gem install bundler -v 1.15.0
@@ -0,0 +1,7 @@
1
+ --protected
2
+ --no-private
3
+ --embed-mixin ClassMethods
4
+ -
5
+ README.md
6
+ CHANGELOG.md
7
+ LICENSE
@@ -1,3 +1,7 @@
1
+ ## [1.1.7] - 2018-12-02
2
+ - adding `user` & `password` options to client
3
+ - [Local PoW Support](https://github.com/vivekmarakana/iota.lib.rb#local-pow-support)
4
+
1
5
  ## [1.1.6] - 2018-07-22
2
6
  ### Added
3
7
  - `wasAddressSpentFrom` API
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # IOTA Ruby Gem
2
2
 
3
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vivekmarakana/iota.lib.rb/master/LICENSE) [![Gem Version](https://badge.fury.io/rb/iota-ruby.svg)](https://badge.fury.io/rb/iota-ruby)
3
+ [![Build Status](https://travis-ci.org/vivekmarakana/iota.lib.rb.svg?branch=master)](https://travis-ci.org/vivekmarakana/iota.lib.rb) [![Gem Version](https://badge.fury.io/rb/iota-ruby.svg)](https://badge.fury.io/rb/iota-ruby) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vivekmarakana/iota.lib.rb/master/LICENSE)
4
4
 
5
5
  This is the **unofficial** Ruby gem for the IOTA Core. It implements both the [official API](https://iota.readme.io/), as well as newly proposed functionality (such as signing, bundles, utilities, conversion, multi signature support and reattch/promote).
6
6
 
@@ -33,10 +33,15 @@ After you've successfully installed the library, it is fairly easy to get starte
33
33
  The optional settings object can have the following values:
34
34
 
35
35
  1. **`host`**: `String` Host you want to connect to. Can be DNS, IPv4 or IPv6. Defaults to `localhost `
36
- 2. **`port`**: `Int` port of the host you want to connect to. Defaults to 14265.
36
+ 2. **`port`**: `Integer` port of the host you want to connect to. Defaults to 14265.
37
+ 2. **`user`**: `String` username for host if required.
38
+ 2. **`password`**: `String` password for host if required.
37
39
  3. **`provider`**: `String` If you don't provide host and port, you can supply the full provider value to connect to
38
- 4. **`sandbox`**: `Bool` Optional value to determine if your provider is the IOTA Sandbox or not.
40
+ 4. **`sandbox`**: `Boolean` Optional value to determine if your provider is the IOTA Sandbox or not.
39
41
  5. **`token`**: `String` Token string in case you are using sandbox.
42
+ 5. **`timeout`**: `Integer` Timeout in seconds for api requests to full node. Defaults to 120.
43
+ 5. **`batch_size`**: `Integer` Batch size for apis like `getTrytes`, `getBalances` etc. Defaults to 500.
44
+ 5. **`local_pow`**: `Boolean` Should PoW be done local machine or not. Defaults to `false` i.e. remote PoW.
40
45
 
41
46
  You can either supply the remote node directly via the `provider` option, or individually with `host` and `port`, as can be seen in the example below:
42
47
 
@@ -87,4 +92,18 @@ else
87
92
  end
88
93
  ```
89
94
 
90
- If you'd like to support development, please consider donating to my IOTA address: **SGBYR9DXPBPGTFLILQWAYIMINZ9MQAFKGDBHQSXGLKNIHCQZEDYPVNRMDVWFPXQTAIVKWCVWXVXZVZ9R9HIKTZWUAC**
95
+ ## Local PoW Support
96
+
97
+ If you want to use this gem with public full node which does not support remote PoW on host, you can set `local_pow` to `true` when initialising the client.
98
+
99
+ ```ruby
100
+ require 'iota'
101
+
102
+ # With remote PoW
103
+ client = IOTA::Client.new(provider: 'https://node.iota-tangle.io:14265')
104
+ # If you use `client.api.attachToTangle` api here, you'll get error saying that attachToTangle command is not allowed
105
+
106
+ # With local pow
107
+ client = IOTA::Client.new(provider: 'https://node.iota-tangle.io:14265', local_pow: true)
108
+ # Now you can use `client.api.attachToTangle` api, which will do the proof-of-work on transaction and return the trytes that needs to be broadcasted
109
+ ```
@@ -1,5 +1,4 @@
1
1
  can_compile_extensions = false
2
- want_extensions = true
3
2
 
4
3
  begin
5
4
  require 'mkmf'
@@ -9,7 +8,7 @@ rescue Exception
9
8
  $stderr.puts "Could not require 'mkmf'. Not fatal, the extensions are optional."
10
9
  end
11
10
 
12
- if can_compile_extensions && want_extensions
11
+ if can_compile_extensions && have_header('ruby.h')
13
12
  extension_name = 'ccurl'
14
13
  dir_config(extension_name) # The destination
15
14
  create_makefile(extension_name) # Create Makefile
Binary file
Binary file
@@ -19,9 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
  spec.extensions = ["ext/ccurl/extconf.rb"]
21
21
 
22
+ spec.required_ruby_version = '>= 2.4.0'
22
23
  spec.add_development_dependency "bundler", "~> 1.15"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
24
25
  spec.add_development_dependency "minitest", "~> 5.0"
25
26
  spec.add_development_dependency "rake-compiler", "~> 1.0.4"
26
27
  spec.add_dependency "digest-sha3", "~> 1.1"
28
+ spec.add_dependency "ffi", "~> 1.9.25"
27
29
  end
@@ -11,6 +11,7 @@ require "iota/api/wrappers"
11
11
  require "iota/api/transport"
12
12
  require "iota/api/api"
13
13
 
14
+ require "iota/crypto/pow_provider"
14
15
  require "iota/crypto/curl"
15
16
  require "iota/crypto/kerl"
16
17
  require "iota/crypto/converter"
@@ -58,14 +59,15 @@ module IOTA
58
59
  @token = settings[:token] || false
59
60
  @timeout = settings[:timeout] || 120
60
61
  @batch_size = settings[:batch_size] || 500
62
+ @local_pow = settings[:local_pow] || false
61
63
 
62
64
  if @sandbox
63
65
  @sandbox = @provider.gsub(/\/$/, '')
64
66
  @provider = @sandbox + '/commands'
65
67
  end
66
68
 
67
- @broker = IOTA::Utils::Broker.new(@provider, @token, @timeout)
68
- @api = IOTA::API::Api.new(@broker, @sandbox, @batch_size)
69
+ @broker = IOTA::Utils::Broker.new(@provider, @token, @timeout, user: settings[:user], password: settings[:password])
70
+ @api = IOTA::API::Api.new(@broker, @sandbox, @batch_size, @local_pow)
69
71
  end
70
72
 
71
73
  def symbolize_keys(hash)
@@ -4,13 +4,16 @@ module IOTA
4
4
  include Wrappers
5
5
  include Transport
6
6
 
7
- def initialize(broker, sandbox, batch_size = 500)
7
+ attr_reader :pow_provider
8
+
9
+ def initialize(broker, sandbox, batch_size = 500, local_pow = false)
8
10
  @broker = broker
9
11
  @sandbox = sandbox
10
12
  @commands = Commands.new
11
13
  @utils = IOTA::Utils::Utils.new
12
14
  @validator = @utils.validator
13
15
  @batch_size = batch_size
16
+ @pow_provider = local_pow ? IOTA::Crypto::PowProvider.new : nil
14
17
  end
15
18
 
16
19
  def findTransactions(searchValues, &callback)
@@ -149,7 +152,7 @@ module IOTA
149
152
 
150
153
  # Check if minweight is integer
151
154
  if !@validator.isValue(minWeightMagnitude)
152
- return sendData(false, "Invalid inputs provided", &callback)
155
+ return sendData(false, "Invalid minWeightMagnitude provided", &callback)
153
156
  end
154
157
 
155
158
  # Check if array of trytes
@@ -157,9 +160,49 @@ module IOTA
157
160
  return sendData(false, "Invalid Trytes provided", &callback)
158
161
  end
159
162
 
160
- command = @commands.attachToTangle(trunkTransaction, branchTransaction, minWeightMagnitude, trytes)
163
+ if @pow_provider.nil?
164
+ command = @commands.attachToTangle(trunkTransaction, branchTransaction, minWeightMagnitude, trytes)
165
+
166
+ sendCommand(command, &callback)
167
+ else
168
+ previousTxHash = nil
169
+ finalBundleTrytes = []
170
+
171
+ trytes.each do |current_trytes|
172
+ txObject = @utils.transactionObject(current_trytes)
173
+
174
+ if !previousTxHash
175
+ if txObject.lastIndex != txObject.currentIndex
176
+ return sendData(false, "Wrong bundle order. The bundle should be ordered in descending order from currentIndex", &callback)
177
+ end
178
+
179
+ txObject.trunkTransaction = trunkTransaction
180
+ txObject.branchTransaction = branchTransaction
181
+ else
182
+ txObject.trunkTransaction = previousTxHash
183
+ txObject.branchTransaction = trunkTransaction
184
+ end
161
185
 
162
- sendCommand(command, &callback)
186
+ txObject.attachmentTimestamp = (Time.now.to_f * 1000).to_i
187
+ txObject.attachmentTimestampLowerBound = 0
188
+ txObject.attachmentTimestampUpperBound = (3**27 - 1) / 2
189
+
190
+ newTrytes = @utils.transactionTrytes(txObject)
191
+
192
+ begin
193
+ returnedTrytes = @pow_provider.pow(newTrytes, minWeightMagnitude)
194
+
195
+ newTxObject= @utils.transactionObject(returnedTrytes)
196
+ previousTxHash = newTxObject.hash
197
+
198
+ finalBundleTrytes << returnedTrytes
199
+ rescue => e
200
+ return sendData(false, e.message, &callback)
201
+ end
202
+ end
203
+
204
+ sendData(true, finalBundleTrytes, &callback)
205
+ end
163
206
  end
164
207
 
165
208
  def interruptAttachingToTangle(&callback)
@@ -85,9 +85,8 @@ module IOTA
85
85
  return sendData(false, attached_data, &callback)
86
86
  end
87
87
 
88
- # If the user is connected to the sandbox, we have to monitor the POW queue
89
- # to check if the POW job was completed
90
- if @sandbox
88
+ # If the user is connected to the sandbox and local pow is not used, we have to monitor the POW queue to check if the POW job was completed
89
+ if @sandbox && @pow_provider.nil?
91
90
  # Implement sandbox processing
92
91
  jobUri = @sandbox + '/jobs/' + attached_data['id']
93
92
 
@@ -0,0 +1,27 @@
1
+ require 'ffi'
2
+
3
+ module IOTA
4
+ module Crypto
5
+ class PowProvider
6
+ extend FFI::Library
7
+
8
+ ccurl_version = '0.3.0'
9
+ lib_root = File.join(File.dirname(__FILE__), '../../../ext/pow')
10
+ if FFI::Platform.windows?
11
+ libccurl_path = "#{lib_root}/ccurl-#{ccurl_version}.dll"
12
+ elsif FFI::Platform.mac?
13
+ libccurl_path = "#{lib_root}/libccurl-#{ccurl_version}.dylib"
14
+ else
15
+ libccurl_path = "#{lib_root}/libccurl-#{ccurl_version}.so"
16
+ end
17
+
18
+ ffi_lib libccurl_path
19
+
20
+ attach_function :ccurl_pow, [ :string, :int ], :string
21
+ attach_function :ccurl_digest_transaction, [ :string ], :string
22
+
23
+ alias_method :pow, :ccurl_pow
24
+ alias_method :digest, :ccurl_digest_transaction
25
+ end
26
+ end
27
+ end
@@ -5,8 +5,8 @@ require 'json'
5
5
  module IOTA
6
6
  module Utils
7
7
  class Broker
8
- def initialize(provider, token, timeout = 120)
9
- @provider, @token = provider, token
8
+ def initialize(provider, token, timeout = 120, user: nil, password: nil)
9
+ @provider, @token, @user, @password = provider, token, user, password
10
10
  @timeout = timeout if timeout.to_i > 0
11
11
  end
12
12
 
@@ -83,7 +83,11 @@ module IOTA
83
83
  read_timeout: @timeout || 120
84
84
  }
85
85
 
86
- request["Authorization"] = "token #{@token}" if @token
86
+ if @token
87
+ request["Authorization"] = "token #{@token}"
88
+ elsif @user && @password
89
+ request.basic_auth @user, @password
90
+ end
87
91
 
88
92
  [uri, request, req_options]
89
93
  end
@@ -1,3 +1,3 @@
1
1
  module IOTA
2
- VERSION = "1.1.6"
2
+ VERSION = "1.1.7"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require "test_helper"
2
+
3
+ class PowProviderTest < Minitest::Test
4
+ def setup
5
+ @client = IOTA::Client.new(provider: 'http://localhost:14265', local_pow: true)
6
+ end
7
+
8
+ def test_that_digest_works
9
+ trytes = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999G9AIBZPUUIXPRDTUJNGAUSWPJMLJOCSJSPVGP9KDCABPQIWXYOAXJVMDYSCPAAIJNWOHUIUNKKOVJJASCHJYTXA999999999999999999999FOINFALCON99999999999999999RJFYLXD99999999999D99999999WCKBQGFJRFIYVJAZDYLNQZIUQGG9EKZKNUOBEEASPPJXUGCTAGHGWLQSWJKC9DRVEKKHDOUJLNEQCGYK9HKFPGUUIXFOZBXZIJAFPWBYUTIAZMYHGAC9QMRDJCGOW9VXVLVQKTKRLQFITNLDHPDXHDWIVRZQGZ9999OEMEOVATRLZWXXDXIX9AVNDCHRLC9WHB9IAUUYKHUGIFBKCCYN9LRGTTQISBQYPDHTXRTOYVZTLU99999COINFALCON99999999999999999Z9PSAGQJE999999999L99999999IQXMVTRNAQVADDX9ET9IAMVJDZV"
10
+ expected_hash = "QLMNETEZDOYSBQLRPRJIZNRRDZ9EKY9LCOLNIDQEZNUFWOVYR9SJLBCVIJWIOKGNPMPGWYTNFMOW99999"
11
+
12
+ start = Time.now
13
+ # generate the correct transaction hash
14
+ hash = @client.api.pow_provider.digest(trytes)
15
+ puts "Digest time: #{(Time.now - start) * 1000.0}ms"
16
+
17
+ assert expected_hash == hash
18
+ end
19
+
20
+ def test_that_pow_works
21
+ trunkTransaction = branchTransaction = "LLJDW9NTJHKYWIWEGIF9WDQCNHGGJOUHMYLGAOAUOFKWTFFFNSAJLBJTHWQAWFBNAPZAXKXWNL9K99999"
22
+ trytes = [
23
+ "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999A9RGRKVGWMWMKOLVMDFWJUHNUNYWZTJADGGPZGXNLERLXYWJE9WQHWWBMCPZMVVMJUMWWBLZLNMLDCGDJ999999999999999999999999999999999999999999999999999999YGYQIVD99999999999999999999TXEFLKNPJRBYZPORHZU9CEMFIFVVQBUSTDGSJCZMBTZCDTTJVUFPTCCVHHORPMGCURKTH9VGJIXUQJVHK999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999",
24
+ "BYSWEAUTWXHXZ9YBZISEK9LUHWGMHXCGEVNZHRLUWQFCUSDXZHOFHWHL9MQPVJXXZLIXPXPXF9KYEREFSKCPKYIIKPZVLHUTDFQKKVVBBN9ATTLPCNPJDWDEVIYYLGPZGCWXOBDXMLJC9VO9QXTTBLAXTTBFUAROYEGQIVB9MJWJKXJMCUPTWAUGFZBTZCSJVRBGMYXTVBDDS9MYUJCPZ9YDWWQNIPUAIJXXSNLKUBSCOIJPCLEFPOXFJREXQCUVUMKSDOVQGGHRNILCO9GNCLWFM9APMNMWYASHXQAYBEXF9QRIHIBHYEJOYHRQJAOKAQ9AJJFQ9WEIWIJOTZATIBOXQLBMIJU9PCGBLVDDVFP9CFFSXTDUXMEGOOFXWRTLFGV9XXMYWEMGQEEEDBTIJ9OJOXFAPFQXCDAXOUDMLVYRMRLUDBETOLRJQAEDDLNVIRQJUBZBO9CCFDHIX9MSQCWYAXJVWHCUPTRSXJDESISQPRKZAFKFRULCGVRSBLVFOPEYLEE99JD9SEBALQINPDAZHFAB9RNBH9AZWIJOTLBZVIEJIAYGMC9AZGNFWGRSWAXTYSXVROVNKCOQQIWGPNQZKHUNODGYADPYLZZZUQRTJRTODOUKAOITNOMWNGHJBBA99QUMBHRENGBHTH9KHUAOXBVIVDVYYZMSEYSJWIOGGXZVRGN999EEGQMCOYVJQRIRROMPCQBLDYIGQO9AMORPYFSSUGACOJXGAQSPDY9YWRRPESNXXBDQ9OZOXVIOMLGTSWAMKMTDRSPGJKGBXQIVNRJRFRYEZ9VJDLHIKPSKMYC9YEGHFDS9SGVDHRIXBEMLFIINOHVPXIFAZCJKBHVMQZEVWCOSNWQRDYWVAIBLSCBGESJUIBWZECPUCAYAWMTQKRMCHONIPKJYYTEGZCJYCT9ABRWTJLRQXKMWY9GWZMHYZNWPXULNZAPVQLPMYQZCYNEPOCGOHBJUZLZDPIXVHLDMQYJUUBEDXXPXFLNRGIPWBRNQQZJSGSJTTYHIGGFAWJVXWL9THTPWOOHTNQWCNYOYZXALHAZXVMIZE9WMQUDCHDJMIBWKTYH9AC9AFOT9DPCADCV9ZWUTE9QNOMSZPTZDJLJZCJGHXUNBJFUBJWQUEZDMHXGBPTNSPZBR9TGSKVOHMOQSWPGFLSWNESFKSAZY9HHERAXALZCABFYPOVLAHMIHVDBGKUMDXC9WHHTIRYHZVWNXSVQUWCR9M9RAGMFEZZKZ9XEOQGOSLFQCHHOKLDSA9QCMDGCGMRYJZLBVIFOLBIJPROKMHOYTBTJIWUZWJMCTKCJKKTR9LCVYPVJI9AHGI9JOWMIWZAGMLDFJA9WU9QAMEFGABIBEZNNAL9OXSBFLOEHKDGHWFQSHMPLYFCNXAAZYJLMQDEYRGL9QKCEUEJ9LLVUOINVSZZQHCIKPAGMT9CAYIIMTTBCPKWTYHOJIIY9GYNPAJNUJ9BKYYXSV9JSPEXYMCFAIKTGNRSQGUNIYZCRT9FOWENSZQPD9ALUPYYAVICHVYELYFPUYDTWUSWNIYFXPX9MICCCOOZIWRNJIDALWGWRATGLJXNAYTNIZWQ9YTVDBOFZRKO9CFWRPAQQRXTPACOWCPRLYRYSJARRKSQPR9TCFXDVIXLP9XVL99ERRDSOHBFJDJQQGGGCZNDQ9NYCTQJWVZIAELCRBJJFDMCNZU9FIZRPGNURTXOCDSQGXTQHKHUECGWFUUYS9J9NYQ9U9P9UUP9YMZHWWWCIASCFLCMSKTELZWUGCDE9YOKVOVKTAYPHDF9ZCCQAYPJIJNGSHUIHHCOSSOOBUDOKE9CJZGYSSGNCQJVBEFTZFJ9SQUHOASKRRGBSHWKBCBWBTJHOGQ9WOMQFHWJVEG9NYX9KWBTCAIXNXHEBDIOFO9ALYMFGRICLCKKLG9FOBOX9PDWNQRGHBKHGKKRLWTBEQMCWQRLHAVYYZDIIPKVQTHYTWQMTOACXZOQCDTJTBAAUWXSGJF9PNQIJ9AJRUMUVCPWYVYVARKR9RKGOUHHNKNVGGPDDLGKPQNOYHNKAVVKCXWXOQPZNSLATUJT9AUWRMPPSWHSTTYDFAQDXOCYTZHOYYGAIM9CELMZ9AZPWB9MJXGHOKDNNSZVUDAGXTJJSSZCPZVPZBYNNTUQABSXQWZCHDQSLGK9UOHCFKBIBNETK999999999999999999999999999999999999999999999999999999999999999999999999999999999NOXDXXKUDW99999999999999999PGDNLQOLQS99EQYKBIU9VHCJVIPFUYCQDNY9APGEVYLCENJIOBLWNB999999999XKBRHUD99C99999999NKZKEKWLDKMJCI9N9XQOLWEPAYWSH9999999999999999999999999KDDTGZLIPBNZKMLTOLOXQVNGLASESDQVPTXALEKRMIOHQLUHD9ELQDBQETS9QFGTYOYWLNTSKKMVJAUXSIROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999IROUICDOXKSYZTDPEDKOQENTJOWJONDEWROCEJIEWFWLUAACVSJFTMCHHXJBJRKAAPUDXXVXFWP9X9999"
25
+ ]
26
+
27
+ start = Time.now
28
+ # generate the correct transaction hash
29
+ status, trytes_with_pow = @client.api.attachToTangle(trunkTransaction, branchTransaction, 2, trytes)
30
+ puts "PoW time: #{(Time.now - start) * 1000.0}ms"
31
+
32
+ assert status == true
33
+ assert trytes_with_pow.class == Array
34
+ assert trytes_with_pow.length == trytes.length
35
+ end
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iota-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek Marakana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-22 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ffi
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.9.25
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.25
83
97
  description: Ruby gem for the IOTA core
84
98
  email:
85
99
  - vivek.marakana@gmail.com
@@ -92,6 +106,7 @@ files:
92
106
  - ".editorconfig"
93
107
  - ".gitignore"
94
108
  - ".travis.yml"
109
+ - ".yardopts"
95
110
  - CHANGELOG.md
96
111
  - Gemfile
97
112
  - LICENSE
@@ -101,6 +116,9 @@ files:
101
116
  - examples/multisig.rb
102
117
  - ext/ccurl/ccurl.c
103
118
  - ext/ccurl/extconf.rb
119
+ - ext/pow/ccurl-0.3.0.dll
120
+ - ext/pow/libccurl-0.3.0.dylib
121
+ - ext/pow/libccurl-0.3.0.so
104
122
  - iota-ruby.gemspec
105
123
  - lib/iota.rb
106
124
  - lib/iota/api/api.rb
@@ -114,6 +132,7 @@ files:
114
132
  - lib/iota/crypto/curl_ruby.rb
115
133
  - lib/iota/crypto/hmac.rb
116
134
  - lib/iota/crypto/kerl.rb
135
+ - lib/iota/crypto/pow_provider.rb
117
136
  - lib/iota/crypto/private_key.rb
118
137
  - lib/iota/crypto/signing.rb
119
138
  - lib/iota/models/account.rb
@@ -135,6 +154,7 @@ files:
135
154
  - test/curl_c_test.rb
136
155
  - test/curl_ruby_test.rb
137
156
  - test/kerl_test.rb
157
+ - test/pow_provider_test.rb
138
158
  - test/test_helper.rb
139
159
  - test/utils_test.rb
140
160
  homepage: https://github.com/vivekmarakana/iota.lib.rb
@@ -148,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
168
  requirements:
149
169
  - - ">="
150
170
  - !ruby/object:Gem::Version
151
- version: '0'
171
+ version: 2.4.0
152
172
  required_rubygems_version: !ruby/object:Gem::Requirement
153
173
  requirements:
154
174
  - - ">="
@@ -165,5 +185,6 @@ test_files:
165
185
  - test/curl_c_test.rb
166
186
  - test/curl_ruby_test.rb
167
187
  - test/kerl_test.rb
188
+ - test/pow_provider_test.rb
168
189
  - test/test_helper.rb
169
190
  - test/utils_test.rb