txcatcher 0.1.82 → 0.1.83

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: 7518a090998953f9b02635bee16b9ac739a1c4ac
4
- data.tar.gz: c08a48ffa8b4e0e2cdf2c4453afb36de9fa7021b
3
+ metadata.gz: c2490c3456737004783bc9d04fb086c0c13cabe5
4
+ data.tar.gz: 813de1fef0f9d0c28e5dbdcf227bab4ead700c24
5
5
  SHA512:
6
- metadata.gz: 5c1e95aad5c87d63714184a95a52beb87718f4272c86eb513ce827651e76b428d044358a729405047f6ffab4a44f4f4193feea922cb760bc11889018ea62d2ea
7
- data.tar.gz: eb99b5cdffafc0509c322997d1bd259a5aaf79e32f31cc81a07b77920ea868fe3c0993d788b448f4b6d82c11fe4ef0b10e9f9167517c8826f7dab66bfa7546cf
6
+ metadata.gz: 2ed2e03aee0673dc2a44774d7d4bd49d71ec70f9f6c60fca564bcb91d5a956ae730802deb208c55e16bf74f9a45c39c507b93f0088e2411f034c946fdcf6ff32
7
+ data.tar.gz: c420a2f8c1276a6379448a79461b7c181884cb7512ce29c0d8f0ddabe90083ac9e409cb3998c92292c646640213230eba9e596f5b069c6f911009326d0c4a084
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
  gem "goliath"
4
4
  gem "sequel"
5
5
  gem "ffi-rzmq"
6
- gem "satoshi-unit"
6
+ gem "crypto-unit"
7
7
  gem "sentry-raven"
8
8
 
9
9
  group :development do
data/Gemfile.lock CHANGED
@@ -5,6 +5,7 @@ GEM
5
5
  async-rack (0.5.1)
6
6
  rack (~> 1.1)
7
7
  builder (3.2.3)
8
+ crypto-unit (0.3.3)
8
9
  descendants_tracker (0.0.4)
9
10
  thread_safe (~> 0.3, >= 0.3.1)
10
11
  diff-lcs (1.3)
@@ -93,7 +94,6 @@ GEM
93
94
  diff-lcs (>= 1.2.0, < 2.0)
94
95
  rspec-support (~> 3.7.0)
95
96
  rspec-support (3.7.1)
96
- satoshi-unit (0.2.2)
97
97
  semver2 (3.4.2)
98
98
  sentry-raven (2.6.3)
99
99
  faraday (>= 0.7.6, < 1.0)
@@ -106,11 +106,11 @@ PLATFORMS
106
106
 
107
107
  DEPENDENCIES
108
108
  bundler
109
+ crypto-unit
109
110
  ffi-rzmq
110
111
  goliath
111
112
  jeweler
112
113
  rspec
113
- satoshi-unit
114
114
  sentry-raven
115
115
  sequel
116
116
  sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.82
1
+ 0.1.83
@@ -40,7 +40,7 @@ module TxCatcher
40
40
  @queue[channel].pop.call
41
41
  rescue Sequel::ValidationFailed => e
42
42
  Logger.report e, :warn, timestamp: true
43
- rescue StandardError => e
43
+ rescue Exception => e
44
44
  Logger.report e, :error, timestamp: true
45
45
  end
46
46
  end
@@ -76,13 +76,12 @@ module TxCatcher
76
76
 
77
77
  def handle_rawtx(txhex)
78
78
  Logger.report "received tx hex: #{txhex[0..50]}..."
79
-
80
79
  @queue["rawtx"] << ( Proc.new {
81
80
  tx = TxCatcher::Transaction.new(hex: txhex)
82
81
  tx.save
83
82
  Logger.report "tx #{tx.txid} saved (id: #{tx.id}), deposits (outputs):"
84
83
  tx.deposits.each do |d|
85
- Logger.report " id: #{d.id}, addr: #{d.address.address}, amount: #{Satoshi.new(d.amount, from_unit: :satoshi).to_btc}"
84
+ Logger.report " id: #{d.id}, addr: #{d.address.address}, amount: #{CryptoUnit.new(Config["currency"], d.amount, from_unit: :primary).to_standart}"
86
85
  end
87
86
  })
88
87
  end
@@ -4,7 +4,7 @@ module TxCatcher
4
4
  one_to_many :deposits
5
5
 
6
6
  def received_in_btc
7
- Satoshi.new(self.received, from_unit: :satoshi).to_btc
7
+ CryptoUnit.new(Config["currency"], self.received, from_unit: :primary).to_standart
8
8
  end
9
9
 
10
10
  end
@@ -15,7 +15,7 @@ module TxCatcher
15
15
  end
16
16
 
17
17
  def amount_in_btc
18
- Satoshi.new(self.amount, from_unit: :satoshi).to_btc
18
+ CryptoUnit.new(Config["currency"], self.amount, from_unit: :primary).to_standart
19
19
  end
20
20
 
21
21
  end
@@ -10,7 +10,7 @@ module TxCatcher
10
10
  parse_transaction
11
11
  assign_transaction_attrs
12
12
  @tx_hash["vout"].uniq { |out| out["n"] }.each do |out|
13
- amount = Satoshi.new(out["value"], from_unit: :btc).to_i if out["value"]
13
+ amount = CryptoUnit.new(Config["currency"], out["value"], from_unit: :standart).to_i if out["value"]
14
14
  address = out["scriptPubKey"]["addresses"]&.first
15
15
  # Do not create a new deposit unless it actually makes sense to create one
16
16
  if address && amount && amount > 0
@@ -0,0 +1,15 @@
1
+ module TxCatcher
2
+
3
+ class CryptoUnit
4
+
5
+ def self.new(type, amount, *args)
6
+ if type == :ltc || type == :litecoin
7
+ return LitoshiUnit.new(amount, *args)
8
+ else
9
+ return SatoshiUnit.new(amount, *args)
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ end
data/lib/txcatcher.rb CHANGED
@@ -2,11 +2,12 @@ require 'rubygems'
2
2
  require 'yaml'
3
3
  require 'json'
4
4
  require 'thread'
5
- require 'satoshi-unit'
5
+ require 'crypto-unit'
6
6
  require 'sequel'
7
7
  require 'sentry-raven'
8
8
  Sequel.extension :migration
9
9
 
10
+ require_relative 'txcatcher/utils/crypto_unit'
10
11
  require_relative 'txcatcher/utils/hash_string_to_sym_keys'
11
12
  require_relative 'txcatcher/bitcoin_rpc'
12
13
  require_relative 'txcatcher/config'
@@ -22,12 +22,11 @@ logger:
22
22
  stdout_level: info
23
23
  logfile_level: info
24
24
  sentry_level: info
25
- sentry:
26
- dsn: null
27
- client_dsn: null
25
+ sentry_dsn: null
28
26
 
29
- # zeromq: bitcoind
27
+ zeromq: bitcoind
30
28
  max_db_transactions_stored: 10
31
29
  db_clean_period_seconds: 300
32
30
  protected_transactions: true
33
31
  environment: development
32
+ currency: bitcoin
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'yaml'
3
3
  require 'json'
4
- require 'satoshi-unit'
4
+ require 'crypto-unit'
5
5
  require 'sequel'
6
6
  require 'sentry-raven'
7
7
  Sequel.extension :migration
@@ -11,6 +11,7 @@ File.delete(db_file) if File.exists?(db_file)
11
11
 
12
12
  require_relative '../lib/txcatcher/logger'
13
13
  require_relative '../lib/txcatcher/utils/hash_string_to_sym_keys'
14
+ require_relative '../lib/txcatcher/utils/crypto_unit'
14
15
  require_relative '../lib/txcatcher/config'
15
16
  require_relative '../lib/txcatcher/initializer'
16
17
  require_relative '../lib/txcatcher/bitcoin_rpc'
data/templates/config.yml CHANGED
@@ -32,3 +32,4 @@ db_clean_period_seconds: 300
32
32
  server_port: 9498
33
33
  daemonize: false
34
34
  environment: production
35
+ currency: bitcoin
data/txcatcher.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: txcatcher 0.1.82 ruby lib
5
+ # stub: txcatcher 0.1.83 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "txcatcher"
9
- s.version = "0.1.82"
9
+ s.version = "0.1.83"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txcatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.82
4
+ version: 0.1.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: goliath
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: satoshi-unit
56
+ name: crypto-unit
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -149,6 +149,7 @@ files:
149
149
  - lib/txcatcher/models/deposit.rb
150
150
  - lib/txcatcher/models/transaction.rb
151
151
  - lib/txcatcher/server.rb
152
+ - lib/txcatcher/utils/crypto_unit.rb
152
153
  - lib/txcatcher/utils/hash_string_to_sym_keys.rb
153
154
  - spec/catcher_spec.rb
154
155
  - spec/cleaner_spec.rb