tapyrus 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/{.prettierrc.yaml → .prettierrc.yml} +0 -1
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -2
  6. data/README.md +1 -1
  7. data/Rakefile +2 -2
  8. data/exe/tapyrus-script-debugger +5 -5
  9. data/exe/tapyrusrb-cli +1 -1
  10. data/exe/tapyrusrbd +18 -17
  11. data/lib/openassets/payload.rb +2 -2
  12. data/lib/openassets/util.rb +2 -2
  13. data/lib/openassets.rb +4 -4
  14. data/lib/schnorr/sign_to_contract.rb +4 -4
  15. data/lib/schnorr/signature.rb +5 -5
  16. data/lib/schnorr.rb +14 -14
  17. data/lib/tapyrus/base58.rb +8 -8
  18. data/lib/tapyrus/bip175.rb +5 -5
  19. data/lib/tapyrus/block_header.rb +2 -2
  20. data/lib/tapyrus/bloom_filter.rb +1 -1
  21. data/lib/tapyrus/chain_params.rb +5 -5
  22. data/lib/tapyrus/constants.rb +1 -1
  23. data/lib/tapyrus/errors.rb +9 -9
  24. data/lib/tapyrus/ext/ecdsa.rb +4 -4
  25. data/lib/tapyrus/ext/json_parser.rb +1 -1
  26. data/lib/tapyrus/ext.rb +3 -3
  27. data/lib/tapyrus/ext_key.rb +21 -21
  28. data/lib/tapyrus/jws.rb +76 -0
  29. data/lib/tapyrus/key.rb +48 -20
  30. data/lib/tapyrus/key_path.rb +3 -3
  31. data/lib/tapyrus/logger.rb +4 -11
  32. data/lib/tapyrus/merkle_tree.rb +1 -1
  33. data/lib/tapyrus/message/addr.rb +2 -2
  34. data/lib/tapyrus/message/base.rb +2 -2
  35. data/lib/tapyrus/message/block.rb +1 -1
  36. data/lib/tapyrus/message/block_txn.rb +1 -1
  37. data/lib/tapyrus/message/cmpct_block.rb +1 -1
  38. data/lib/tapyrus/message/fee_filter.rb +3 -3
  39. data/lib/tapyrus/message/filter_add.rb +1 -1
  40. data/lib/tapyrus/message/filter_clear.rb +2 -2
  41. data/lib/tapyrus/message/filter_load.rb +7 -7
  42. data/lib/tapyrus/message/get_addr.rb +2 -2
  43. data/lib/tapyrus/message/get_block_txn.rb +1 -1
  44. data/lib/tapyrus/message/get_blocks.rb +1 -1
  45. data/lib/tapyrus/message/get_data.rb +1 -1
  46. data/lib/tapyrus/message/get_headers.rb +1 -1
  47. data/lib/tapyrus/message/header_and_short_ids.rb +6 -6
  48. data/lib/tapyrus/message/headers.rb +1 -1
  49. data/lib/tapyrus/message/headers_parser.rb +2 -2
  50. data/lib/tapyrus/message/inv.rb +1 -1
  51. data/lib/tapyrus/message/inventory.rb +3 -3
  52. data/lib/tapyrus/message/mem_pool.rb +2 -2
  53. data/lib/tapyrus/message/merkle_block.rb +3 -3
  54. data/lib/tapyrus/message/network_addr.rb +9 -9
  55. data/lib/tapyrus/message/not_found.rb +1 -1
  56. data/lib/tapyrus/message/ping.rb +3 -3
  57. data/lib/tapyrus/message/pong.rb +3 -3
  58. data/lib/tapyrus/message/reject.rb +6 -6
  59. data/lib/tapyrus/message/send_cmpct.rb +4 -4
  60. data/lib/tapyrus/message/send_headers.rb +2 -2
  61. data/lib/tapyrus/message/tx.rb +1 -1
  62. data/lib/tapyrus/message/ver_ack.rb +2 -2
  63. data/lib/tapyrus/message/version.rb +7 -7
  64. data/lib/tapyrus/message.rb +37 -37
  65. data/lib/tapyrus/mnemonic.rb +18 -16
  66. data/lib/tapyrus/network/connection.rb +2 -2
  67. data/lib/tapyrus/network/message_handler.rb +11 -11
  68. data/lib/tapyrus/network/peer.rb +1 -1
  69. data/lib/tapyrus/network/peer_discovery.rb +1 -1
  70. data/lib/tapyrus/network/pool.rb +4 -4
  71. data/lib/tapyrus/network.rb +6 -6
  72. data/lib/tapyrus/node/cli.rb +34 -34
  73. data/lib/tapyrus/node/configuration.rb +3 -3
  74. data/lib/tapyrus/node/spv.rb +2 -2
  75. data/lib/tapyrus/node.rb +3 -3
  76. data/lib/tapyrus/opcodes.rb +7 -7
  77. data/lib/tapyrus/out_point.rb +2 -2
  78. data/lib/tapyrus/rpc/http_server.rb +6 -6
  79. data/lib/tapyrus/rpc/request_handler.rb +5 -5
  80. data/lib/tapyrus/rpc/tapyrus_core_client.rb +10 -10
  81. data/lib/tapyrus/rpc.rb +4 -4
  82. data/lib/tapyrus/script/color.rb +3 -3
  83. data/lib/tapyrus/script/debugger.rb +9 -9
  84. data/lib/tapyrus/script/multisig.rb +2 -2
  85. data/lib/tapyrus/script/script.rb +28 -28
  86. data/lib/tapyrus/script/script_error.rb +42 -42
  87. data/lib/tapyrus/script/script_interpreter.rb +9 -9
  88. data/lib/tapyrus/script/tx_checker.rb +2 -2
  89. data/lib/tapyrus/secp256k1/native.rb +23 -23
  90. data/lib/tapyrus/secp256k1/rfc6979.rb +7 -7
  91. data/lib/tapyrus/secp256k1/ruby.rb +2 -2
  92. data/lib/tapyrus/secp256k1.rb +3 -3
  93. data/lib/tapyrus/slip39/share.rb +7 -7
  94. data/lib/tapyrus/slip39/sss.rb +24 -24
  95. data/lib/tapyrus/slip39.rb +514 -37
  96. data/lib/tapyrus/store/db/level_db.rb +2 -2
  97. data/lib/tapyrus/store/db.rb +1 -1
  98. data/lib/tapyrus/store/spv_chain.rb +7 -7
  99. data/lib/tapyrus/store.rb +3 -3
  100. data/lib/tapyrus/tip0137.rb +201 -0
  101. data/lib/tapyrus/tx.rb +12 -12
  102. data/lib/tapyrus/tx_builder.rb +3 -3
  103. data/lib/tapyrus/tx_in.rb +3 -3
  104. data/lib/tapyrus/tx_out.rb +3 -3
  105. data/lib/tapyrus/util.rb +21 -21
  106. data/lib/tapyrus/validation.rb +9 -9
  107. data/lib/tapyrus/version.rb +1 -1
  108. data/lib/tapyrus/wallet/account.rb +12 -12
  109. data/lib/tapyrus/wallet/base.rb +9 -8
  110. data/lib/tapyrus/wallet/db.rb +11 -11
  111. data/lib/tapyrus/wallet/master_key.rb +13 -13
  112. data/lib/tapyrus/wallet.rb +4 -4
  113. data/lib/tapyrus.rb +62 -59
  114. data/tapyrusrb.gemspec +33 -31
  115. metadata +30 -14
@@ -1,4 +1,4 @@
1
- require 'leveldb-native'
1
+ require "leveldb-native"
2
2
 
3
3
  module Tapyrus
4
4
  module Wallet
@@ -24,10 +24,10 @@ module Tapyrus
24
24
  w = self.new(wallet_id, path_prefix)
25
25
 
26
26
  # generate seed
27
- raise RuntimeError, 'the seed already exist.' if w.db.registered_master?
27
+ raise RuntimeError, "the seed already exist." if w.db.registered_master?
28
28
  master = Tapyrus::Wallet::MasterKey.generate
29
29
  w.db.register_master_key(master)
30
- w.create_account('Default')
30
+ w.create_account("Default")
31
31
  w
32
32
  end
33
33
 
@@ -48,8 +48,8 @@ module Tapyrus
48
48
  def self.current_wallet(path_prefix = default_path_prefix)
49
49
  path = wallet_paths(path_prefix).first # TODO default wallet selection
50
50
  return nil unless path
51
- path.slice!(path_prefix + 'wallet')
52
- path.slice!('/')
51
+ path.slice!(path_prefix + "wallet")
52
+ path.slice!("/")
53
53
  self.load(path.to_i, path_prefix)
54
54
  end
55
55
 
@@ -70,7 +70,7 @@ module Tapyrus
70
70
  # @param [String] name a account name.
71
71
  # @return [Tapyrus::Wallet::Account]
72
72
  def create_account(purpose = Account::PURPOSE_TYPE[:native_segwit], name)
73
- raise ArgumentError.new('Account already exists.') if find_account(name, purpose)
73
+ raise ArgumentError.new("Account already exists.") if find_account(name, purpose)
74
74
  index = accounts.size
75
75
  path = "m/#{purpose}'/#{Tapyrus.chain_params.bip44_coin_type}'/#{index}'"
76
76
  account_key = master_key.derive(path).ext_pubkey
@@ -92,7 +92,7 @@ module Tapyrus
92
92
  # @return [String] generated address.
93
93
  def generate_new_address(account_name)
94
94
  account = find_account(account_name)
95
- raise ArgumentError.new('Account does not exist.') unless account
95
+ raise ArgumentError.new("Account does not exist.") unless account
96
96
  account.create_receive.addr
97
97
  end
98
98
 
@@ -121,7 +121,8 @@ module Tapyrus
121
121
 
122
122
  # decrypt wallet
123
123
  # @param [String] passphrase the wallet passphrase
124
- def decrypt(passphrase); end
124
+ def decrypt(passphrase)
125
+ end
125
126
 
126
127
  # wallet information
127
128
  def to_h
@@ -2,10 +2,10 @@ module Tapyrus
2
2
  module Wallet
3
3
  class DB
4
4
  KEY_PREFIX = {
5
- account: 'a', # key: account index, value: Account raw data.
6
- master: 'm', # value: wallet seed.
7
- version: 'v', # value: wallet version
8
- key: 'k' # key: path to the key, value: public key
5
+ account: "a", # key: account index, value: Account raw data.
6
+ master: "m", # value: wallet seed.
7
+ version: "v", # value: wallet version
8
+ key: "k" # key: path to the key, value: public key
9
9
  }
10
10
 
11
11
  attr_reader :level_db
@@ -23,14 +23,14 @@ module Tapyrus
23
23
 
24
24
  # get accounts raw data.
25
25
  def accounts
26
- from = KEY_PREFIX[:account] + '00000000'
27
- to = KEY_PREFIX[:account] + 'ffffffff'
26
+ from = KEY_PREFIX[:account] + "00000000"
27
+ to = KEY_PREFIX[:account] + "ffffffff"
28
28
  level_db.each(from: from, to: to).map { |k, v| v }
29
29
  end
30
30
 
31
31
  def save_account(account)
32
32
  level_db.batch do
33
- id = [account.purpose, account.index].pack('I*').bth
33
+ id = [account.purpose, account.index].pack("I*").bth
34
34
  key = KEY_PREFIX[:account] + id
35
35
  level_db.put(key, account.to_payload)
36
36
  end
@@ -38,16 +38,16 @@ module Tapyrus
38
38
 
39
39
  def save_key(account, purpose, index, key)
40
40
  pubkey = key.pub
41
- id = [account.purpose, account.index, purpose, index].pack('I*').bth
41
+ id = [account.purpose, account.index, purpose, index].pack("I*").bth
42
42
  k = KEY_PREFIX[:key] + id
43
43
  level_db.put(k, pubkey)
44
44
  key
45
45
  end
46
46
 
47
47
  def get_keys(account)
48
- id = [account.purpose, account.index].pack('I*').bth
49
- from = KEY_PREFIX[:key] + id + '00000000'
50
- to = KEY_PREFIX[:key] + id + 'ffffffff'
48
+ id = [account.purpose, account.index].pack("I*").bth
49
+ from = KEY_PREFIX[:key] + id + "00000000"
50
+ to = KEY_PREFIX[:key] + id + "ffffffff"
51
51
  level_db.each(from: from, to: to).map { |k, v| v }
52
52
  end
53
53
 
@@ -12,7 +12,7 @@ module Tapyrus
12
12
  attr_accessor :encrypted
13
13
  attr_accessor :mnemonic # ephemeral data existing only at initialization
14
14
 
15
- def initialize(seed, salt: '', encrypted: false, mnemonic: nil)
15
+ def initialize(seed, salt: "", encrypted: false, mnemonic: nil)
16
16
  @mnemonic = mnemonic
17
17
  @seed = seed
18
18
  @encrypted = encrypted
@@ -23,7 +23,7 @@ module Tapyrus
23
23
  # @return Tapyrus::Wallet::MasterKey
24
24
  def self.generate
25
25
  entropy = SecureRandom.hex(32)
26
- mnemonic = Tapyrus::Mnemonic.new('english')
26
+ mnemonic = Tapyrus::Mnemonic.new("english")
27
27
  self.recover_from_words(mnemonic.to_mnemonic(entropy))
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ module Tapyrus
31
31
  # @param [Array] words the mnemonic word list.
32
32
  # @return Tapyrus::Wallet::MasterKey
33
33
  def self.recover_from_words(words)
34
- mnemonic = Tapyrus::Mnemonic.new('english')
34
+ mnemonic = Tapyrus::Mnemonic.new("english")
35
35
  seed = mnemonic.to_seed(words)
36
36
  self.new(seed, mnemonic: words)
37
37
  end
@@ -41,9 +41,9 @@ module Tapyrus
41
41
  # @return [Tapyrus::Wallet::MasterKey]
42
42
  def self.parse_from_payload(payload)
43
43
  flag, payload = unpack_var_int(payload)
44
- raise 'encrypted flag is invalid.' unless [0, 1].include?(flag)
44
+ raise "encrypted flag is invalid." unless [0, 1].include?(flag)
45
45
  salt, payload = unpack_var_string(payload)
46
- salt = '' unless salt
46
+ salt = "" unless salt
47
47
  seed, payload = unpack_var_string(payload)
48
48
  self.new(seed.bth, salt: salt.bth, encrypted: flag == 1)
49
49
  end
@@ -58,7 +58,7 @@ module Tapyrus
58
58
  # get master key
59
59
  # @return [Tapyrus::ExtKey] the master key
60
60
  def key
61
- raise 'seed is encrypted. please decrypt the seed.' if encrypted
61
+ raise "seed is encrypted. please decrypt the seed." if encrypted
62
62
  Tapyrus::ExtKey.generate_master(seed)
63
63
  end
64
64
 
@@ -72,12 +72,12 @@ module Tapyrus
72
72
 
73
73
  # encrypt seed
74
74
  def encrypt(passphrase)
75
- raise 'The wallet is already encrypted.' if encrypted
75
+ raise "The wallet is already encrypted." if encrypted
76
76
  @salt = SecureRandom.hex(16)
77
- enc = OpenSSL::Cipher.new('AES-256-CBC')
77
+ enc = OpenSSL::Cipher.new("AES-256-CBC")
78
78
  enc.encrypt
79
79
  enc.key, enc.iv = key_iv(enc, passphrase)
80
- encrypted_data = ''
80
+ encrypted_data = ""
81
81
  encrypted_data << enc.update(seed)
82
82
  encrypted_data << enc.final
83
83
  @seed = encrypted_data
@@ -86,16 +86,16 @@ module Tapyrus
86
86
 
87
87
  # decrypt seed
88
88
  def decrypt(passphrase)
89
- raise 'The wallet is not encrypted.' unless encrypted
90
- dec = OpenSSL::Cipher.new('AES-256-CBC')
89
+ raise "The wallet is not encrypted." unless encrypted
90
+ dec = OpenSSL::Cipher.new("AES-256-CBC")
91
91
  dec.decrypt
92
92
  dec.key, dec.iv = key_iv(dec, passphrase)
93
- decrypted_data = ''
93
+ decrypted_data = ""
94
94
  decrypted_data << dec.update(seed)
95
95
  decrypted_data << dec.final
96
96
  @seed = decrypted_data
97
97
  @encrypted = false
98
- @salt = ''
98
+ @salt = ""
99
99
  end
100
100
 
101
101
  private
@@ -1,8 +1,8 @@
1
1
  module Tapyrus
2
2
  module Wallet
3
- autoload :Base, 'tapyrus/wallet/base'
4
- autoload :Account, 'tapyrus/wallet/account'
5
- autoload :DB, 'tapyrus/wallet/db'
6
- autoload :MasterKey, 'tapyrus/wallet/master_key'
3
+ autoload :Base, "tapyrus/wallet/base"
4
+ autoload :Account, "tapyrus/wallet/account"
5
+ autoload :DB, "tapyrus/wallet/db"
6
+ autoload :MasterKey, "tapyrus/wallet/master_key"
7
7
  end
8
8
  end
data/lib/tapyrus.rb CHANGED
@@ -1,60 +1,63 @@
1
1
  # Porting part of the code from bitcoin-ruby. see the license.
2
2
  # https://github.com/lian/bitcoin-ruby/blob/master/COPYING
3
3
 
4
- require 'tapyrus/version'
5
- require 'eventmachine'
6
- require 'ecdsa'
7
- require 'securerandom'
8
- require 'json'
9
- require 'ffi'
10
- require 'observer'
11
- require 'tmpdir'
12
- require_relative 'openassets'
13
- require_relative 'schnorr'
4
+ require "tapyrus/version"
5
+ require "eventmachine"
6
+ require "ecdsa"
7
+ require "securerandom"
8
+ require "json"
9
+ require "jwt"
10
+ require "ffi"
11
+ require "observer"
12
+ require "tmpdir"
13
+ require_relative "openassets"
14
+ require_relative "schnorr"
14
15
 
15
16
  module Tapyrus
16
- autoload :Ext, 'tapyrus/ext'
17
- autoload :Util, 'tapyrus/util'
18
- autoload :ChainParams, 'tapyrus/chain_params'
19
- autoload :Message, 'tapyrus/message'
20
- autoload :Logger, 'tapyrus/logger'
21
- autoload :Block, 'tapyrus/block'
22
- autoload :BlockHeader, 'tapyrus/block_header'
23
- autoload :Tx, 'tapyrus/tx'
24
- autoload :Script, 'tapyrus/script/script'
25
- autoload :Multisig, 'tapyrus/script/multisig'
26
- autoload :ScriptInterpreter, 'tapyrus/script/script_interpreter'
27
- autoload :ScriptDebugger, 'tapyrus/script/debugger'
28
- autoload :ScriptError, 'tapyrus/script/script_error'
29
- autoload :TxChecker, 'tapyrus/script/tx_checker'
30
- autoload :TxIn, 'tapyrus/tx_in'
31
- autoload :TxOut, 'tapyrus/tx_out'
32
- autoload :OutPoint, 'tapyrus/out_point'
33
- autoload :MerkleTree, 'tapyrus/merkle_tree'
34
- autoload :Key, 'tapyrus/key'
35
- autoload :ExtKey, 'tapyrus/ext_key'
36
- autoload :ExtPubkey, 'tapyrus/ext_key'
37
- autoload :Opcodes, 'tapyrus/opcodes'
38
- autoload :Node, 'tapyrus/node'
39
- autoload :Base58, 'tapyrus/base58'
40
- autoload :Secp256k1, 'tapyrus/secp256k1'
41
- autoload :Mnemonic, 'tapyrus/mnemonic'
42
- autoload :ValidationState, 'tapyrus/validation'
43
- autoload :Network, 'tapyrus/network'
44
- autoload :Store, 'tapyrus/store'
45
- autoload :RPC, 'tapyrus/rpc'
46
- autoload :Wallet, 'tapyrus/wallet'
47
- autoload :BloomFilter, 'tapyrus/bloom_filter'
48
- autoload :KeyPath, 'tapyrus/key_path'
49
- autoload :SLIP39, 'tapyrus/slip39'
50
- autoload :Color, 'tapyrus/script/color'
51
- autoload :Errors, 'tapyrus/errors'
52
- autoload :TxBuilder, 'tapyrus/tx_builder'
53
- autoload :BIP175, 'tapyrus/bip175'
54
- autoload :Contract, 'tapyrus/contract'
55
-
56
- require_relative 'tapyrus/constants'
57
- require_relative 'tapyrus/ext/ecdsa'
17
+ autoload :Ext, "tapyrus/ext"
18
+ autoload :Util, "tapyrus/util"
19
+ autoload :ChainParams, "tapyrus/chain_params"
20
+ autoload :Message, "tapyrus/message"
21
+ autoload :Logger, "tapyrus/logger"
22
+ autoload :Block, "tapyrus/block"
23
+ autoload :BlockHeader, "tapyrus/block_header"
24
+ autoload :Tx, "tapyrus/tx"
25
+ autoload :Script, "tapyrus/script/script"
26
+ autoload :Multisig, "tapyrus/script/multisig"
27
+ autoload :ScriptInterpreter, "tapyrus/script/script_interpreter"
28
+ autoload :ScriptDebugger, "tapyrus/script/debugger"
29
+ autoload :ScriptError, "tapyrus/script/script_error"
30
+ autoload :TxChecker, "tapyrus/script/tx_checker"
31
+ autoload :TxIn, "tapyrus/tx_in"
32
+ autoload :TxOut, "tapyrus/tx_out"
33
+ autoload :OutPoint, "tapyrus/out_point"
34
+ autoload :MerkleTree, "tapyrus/merkle_tree"
35
+ autoload :Key, "tapyrus/key"
36
+ autoload :ExtKey, "tapyrus/ext_key"
37
+ autoload :ExtPubkey, "tapyrus/ext_key"
38
+ autoload :Opcodes, "tapyrus/opcodes"
39
+ autoload :Node, "tapyrus/node"
40
+ autoload :Base58, "tapyrus/base58"
41
+ autoload :Secp256k1, "tapyrus/secp256k1"
42
+ autoload :Mnemonic, "tapyrus/mnemonic"
43
+ autoload :ValidationState, "tapyrus/validation"
44
+ autoload :Network, "tapyrus/network"
45
+ autoload :Store, "tapyrus/store"
46
+ autoload :RPC, "tapyrus/rpc"
47
+ autoload :Wallet, "tapyrus/wallet"
48
+ autoload :BloomFilter, "tapyrus/bloom_filter"
49
+ autoload :KeyPath, "tapyrus/key_path"
50
+ autoload :SLIP39, "tapyrus/slip39"
51
+ autoload :Color, "tapyrus/script/color"
52
+ autoload :Errors, "tapyrus/errors"
53
+ autoload :TxBuilder, "tapyrus/tx_builder"
54
+ autoload :BIP175, "tapyrus/bip175"
55
+ autoload :Contract, "tapyrus/contract"
56
+ autoload :TIP0137, "tapyrus/tip0137"
57
+ autoload :JWS, "tapyrus/jws"
58
+
59
+ require_relative "tapyrus/constants"
60
+ require_relative "tapyrus/ext/ecdsa"
58
61
 
59
62
  extend Util
60
63
 
@@ -86,27 +89,27 @@ module Tapyrus
86
89
 
87
90
  # get secp implementation module
88
91
  def self.secp_impl
89
- path = ENV['SECP256K1_LIB_PATH']
92
+ path = ENV["SECP256K1_LIB_PATH"]
90
93
  (path && File.exist?(path)) ? Tapyrus::Secp256k1::Native : Tapyrus::Secp256k1::Ruby
91
94
  end
92
95
 
93
96
  def self.hmac_sha512(key, data)
94
- OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA512'), key, data)
97
+ OpenSSL::HMAC.digest(OpenSSL::Digest.new("SHA512"), key, data)
95
98
  end
96
99
 
97
100
  def self.hmac_sha256(key, data)
98
- OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), key, data)
101
+ OpenSSL::HMAC.digest(OpenSSL::Digest.new("SHA256"), key, data)
99
102
  end
100
103
 
101
104
  class ::String
102
105
  # binary convert to hex string
103
106
  def bth
104
- unpack('H*').first
107
+ unpack("H*").first
105
108
  end
106
109
 
107
110
  # hex string convert to binary
108
111
  def htb
109
- [self].pack('H*')
112
+ [self].pack("H*")
110
113
  end
111
114
 
112
115
  # binary convert to integer
@@ -161,7 +164,7 @@ module Tapyrus
161
164
  class ::Integer
162
165
  def to_even_length_hex
163
166
  hex = to_s(16)
164
- hex.rjust((hex.length / 2.0).ceil * 2, '0')
167
+ hex.rjust((hex.length / 2.0).ceil * 2, "0")
165
168
  end
166
169
 
167
170
  def itb
@@ -170,7 +173,7 @@ module Tapyrus
170
173
 
171
174
  # convert bit string
172
175
  def to_bits(length = nil)
173
- length ? to_s(2).rjust(length, '0') : to_s(2)
176
+ length ? to_s(2).rjust(length, "0") : to_s(2)
174
177
  end
175
178
  end
176
179
  end
data/tapyrusrb.gemspec CHANGED
@@ -1,45 +1,47 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'tapyrus/version'
4
+ require "tapyrus/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'tapyrus'
7
+ spec.name = "tapyrus"
8
8
  spec.version = Tapyrus::VERSION
9
- spec.authors = ['azuchi']
10
- spec.email = ['azuchi@chaintope.com']
9
+ spec.authors = ["azuchi"]
10
+ spec.email = ["azuchi@chaintope.com"]
11
11
 
12
- spec.summary = 'The implementation of Tapyrus Protocol for Ruby.'
13
- spec.description = 'The implementation of Tapyrus Protocol for Ruby.'
14
- spec.homepage = 'https://github.com/chaintope/tapyrusrb'
15
- spec.license = 'MIT'
12
+ spec.summary = "The implementation of Tapyrus Protocol for Ruby."
13
+ spec.description = "The implementation of Tapyrus Protocol for Ruby."
14
+ spec.homepage = "https://github.com/chaintope/tapyrusrb"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'exe'
19
+ spec.bindir = "exe"
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
21
+ spec.require_paths = ["lib"]
21
22
 
22
- spec.add_runtime_dependency 'ecdsa'
23
- spec.add_runtime_dependency 'eventmachine'
24
- spec.add_runtime_dependency 'murmurhash3'
25
- spec.add_runtime_dependency 'daemon-spawn'
26
- spec.add_runtime_dependency 'thor'
27
- spec.add_runtime_dependency 'ffi'
28
- spec.add_runtime_dependency 'leb128', '~> 1.0.0'
29
- spec.add_runtime_dependency 'eventmachine_httpserver'
30
- spec.add_runtime_dependency 'iniparse'
31
- spec.add_runtime_dependency 'siphash'
32
- spec.add_runtime_dependency 'activesupport', '>= 5.2.3'
33
- spec.add_runtime_dependency 'json_pure', '>= 2.3.1'
34
- spec.add_runtime_dependency 'terminal-table', '~> 3.0.2'
23
+ spec.add_runtime_dependency "ecdsa"
24
+ spec.add_runtime_dependency "eventmachine"
25
+ spec.add_runtime_dependency "murmurhash3"
26
+ spec.add_runtime_dependency "daemon-spawn"
27
+ spec.add_runtime_dependency "thor"
28
+ spec.add_runtime_dependency "ffi"
29
+ spec.add_runtime_dependency "leb128", "~> 1.0.0"
30
+ spec.add_runtime_dependency "eventmachine_httpserver"
31
+ spec.add_runtime_dependency "iniparse"
32
+ spec.add_runtime_dependency "siphash"
33
+ spec.add_runtime_dependency "activesupport", ">= 5.2.3"
34
+ spec.add_runtime_dependency "json_pure", "2.6.3"
35
+ spec.add_runtime_dependency "terminal-table", "~> 3.0.2"
36
+ spec.add_runtime_dependency "jwt"
35
37
 
36
38
  # for options
37
- spec.add_development_dependency 'leveldb-native'
39
+ spec.add_development_dependency "leveldb-native"
38
40
 
39
- spec.add_development_dependency 'bundler'
40
- spec.add_development_dependency 'prettier', '2.0.0'
41
- spec.add_development_dependency 'rake', '>= 12.3.3'
42
- spec.add_development_dependency 'rspec', '~> 3.0'
43
- spec.add_development_dependency 'timecop'
44
- spec.add_development_dependency 'webmock', '~> 3.0'
41
+ spec.add_development_dependency "bundler"
42
+ spec.add_development_dependency "prettier", "4.0.4"
43
+ spec.add_development_dependency "rake", ">= 12.3.3"
44
+ spec.add_development_dependency "rspec", "~> 3.0"
45
+ spec.add_development_dependency "timecop"
46
+ spec.add_development_dependency "webmock", "~> 3.0"
45
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapyrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2024-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ecdsa
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: json_pure
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: 2.3.1
173
+ version: 2.6.3
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: 2.3.1
180
+ version: 2.6.3
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: terminal-table
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 3.0.2
195
+ - !ruby/object:Gem::Dependency
196
+ name: jwt
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: leveldb-native
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +240,14 @@ dependencies:
226
240
  requirements:
227
241
  - - '='
228
242
  - !ruby/object:Gem::Version
229
- version: 2.0.0
243
+ version: 4.0.4
230
244
  type: :development
231
245
  prerelease: false
232
246
  version_requirements: !ruby/object:Gem::Requirement
233
247
  requirements:
234
248
  - - '='
235
249
  - !ruby/object:Gem::Version
236
- version: 2.0.0
250
+ version: 4.0.4
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: rake
239
253
  requirement: !ruby/object:Gem::Requirement
@@ -303,7 +317,7 @@ files:
303
317
  - ".github/workflows/ruby.yml"
304
318
  - ".gitignore"
305
319
  - ".prettierignore"
306
- - ".prettierrc.yaml"
320
+ - ".prettierrc.yml"
307
321
  - ".rspec"
308
322
  - ".ruby-gemset"
309
323
  - ".ruby-version"
@@ -339,6 +353,7 @@ files:
339
353
  - lib/tapyrus/ext/ecdsa.rb
340
354
  - lib/tapyrus/ext/json_parser.rb
341
355
  - lib/tapyrus/ext_key.rb
356
+ - lib/tapyrus/jws.rb
342
357
  - lib/tapyrus/key.rb
343
358
  - lib/tapyrus/key_path.rb
344
359
  - lib/tapyrus/logger.rb
@@ -424,6 +439,7 @@ files:
424
439
  - lib/tapyrus/store/db.rb
425
440
  - lib/tapyrus/store/db/level_db.rb
426
441
  - lib/tapyrus/store/spv_chain.rb
442
+ - lib/tapyrus/tip0137.rb
427
443
  - lib/tapyrus/tx.rb
428
444
  - lib/tapyrus/tx_builder.rb
429
445
  - lib/tapyrus/tx_in.rb
@@ -442,7 +458,7 @@ homepage: https://github.com/chaintope/tapyrusrb
442
458
  licenses:
443
459
  - MIT
444
460
  metadata: {}
445
- post_install_message:
461
+ post_install_message:
446
462
  rdoc_options: []
447
463
  require_paths:
448
464
  - lib
@@ -450,15 +466,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
450
466
  requirements:
451
467
  - - ">="
452
468
  - !ruby/object:Gem::Version
453
- version: '0'
469
+ version: 3.0.0
454
470
  required_rubygems_version: !ruby/object:Gem::Requirement
455
471
  requirements:
456
472
  - - ">="
457
473
  - !ruby/object:Gem::Version
458
474
  version: '0'
459
475
  requirements: []
460
- rubygems_version: 3.3.23
461
- signing_key:
476
+ rubygems_version: 3.5.3
477
+ signing_key:
462
478
  specification_version: 4
463
479
  summary: The implementation of Tapyrus Protocol for Ruby.
464
480
  test_files: []