Skip to content

Commit 5cda967

Browse files
committed
Added new coin TOU
1 parent 0e80fe9 commit 5cda967

20 files changed

+48121
-14
lines changed

app/assets/javascripts/funds/models/withdraw.js.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Withdraw extends PeatioModel.Model
2121
when 'doge' then 'doges'
2222
when 'ltc' then 'ltcs'
2323
when 'eth' then 'ethers'
24+
when 'tou' then 'touristcoins'
2425
when 'psd' then 'poseidons'
2526
when 'phc' then 'profithunters'
2627
when 'xgc' then 'xgoldcoins'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module Admin
2+
module Deposits
3+
class TouristcoinsController < ::Admin::Deposits::BaseController
4+
load_and_authorize_resource :class => '::Deposits::Touristcoin'
5+
6+
def index
7+
start_at = DateTime.now.ago(60 * 60 * 24 * 365)
8+
@touristcoins = @touristcoins.includes(:member).
9+
where('created_at > ?', start_at).
10+
order('id DESC').page(params[:page]).per(20)
11+
end
12+
13+
def update
14+
@touristcoin.accept! if @touristcoin.may_accept?
15+
redirect_to :back, notice: t('.notice')
16+
end
17+
end
18+
end
19+
end

app/controllers/private/assets_controller.rb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def index
88
@doge_proof = Proof.current :doge
99
@ltc_proof = Proof.current :ltc
1010
@eth_proof = Proof.current :eth
11+
@tou_proof = Proof.current :tou
1112
@psd_proof = Proof.current :psd
1213
@phc_proof = Proof.current :phc
1314
@xgc_proof = Proof.current :xgc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Private
2+
module Deposits
3+
class TouristcoinsController < ::Private::Deposits::BaseController
4+
include ::Deposits::CtrlCoinable
5+
end
6+
end
7+
end

app/controllers/webhooks_controller.rb

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def eth
1212
AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "ether")
1313
render :json => { :status => "queued" }
1414
end
15+
end
16+
def eth
17+
if params[:type] == "transaction" && params[:hash].present?
18+
AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "touristcoin")
19+
render :json => { :status => "queued" }
20+
end
1521
end
1622
def mix
1723
if params[:type] == "transaction" && params[:hash].present?

app/models/admin/ability.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def initialize(user)
1919
can :manage, ::Deposits::Bank
2020
can :manage, ::Deposits::Satoshi
2121
can :manage, ::Deposits::Gravio
22-
can :manage, ::Deposits::Doge
2322
can :manage, ::Deposits::Ltc
2423
can :manage, ::Deposits::Ether
24+
can :manage, ::Deposits::Touristcoin
2525
# can :manage, ::Deposits::Poseidon
2626
# can :manage, ::Deposits::Profithunter
2727
# can :manage, ::Deposits::Xgoldcoin
@@ -185,6 +185,7 @@ def initialize(user)
185185
can :manage, ::Withdraws::Doge
186186
can :manage, ::Withdraws::Ltc
187187
can :manage, ::Withdraws::Ether
188+
can :manage, ::Withdraws::Touristcoin
188189
# can :manage, ::Withdraws::Poseidon
189190
# can :manage, ::Withdraws::Profithunter
190191
# can :manage, ::Withdraws::Xgoldcoin

app/models/deposits/touristcoin.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Deposits
2+
class Touristcoin < ::Deposit
3+
include ::AasmAbsolutely
4+
include ::Deposits::Coinable
5+
6+
validates_uniqueness_of :txout, scope: :txid
7+
end
8+
end

app/models/withdraws/touristcoin.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Withdraws
2+
class Touristcoin < ::Withdraw
3+
include ::AasmAbsolutely
4+
include ::Withdraws::Coinable
5+
include ::FundSourceable
6+
end
7+
end

app/services/coin_rpc.rb

+51
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def self.[](currency)
3030
name = 'CNT'
3131
elsif c.proto == 'FNT'
3232
name = 'FNT'
33+
elsif c.proto == 'TOU'
34+
name = 'TOU'
3335
else
3436
name = c[:handler]
3537
end
@@ -253,6 +255,55 @@ def getblockchaininfo
253255
end
254256
end
255257

258+
class TOU < self
259+
def handle(name, *args)
260+
post_body = {"jsonrpc" => "2.0", 'method' => name, 'params' => args, 'id' => '1' }.to_json
261+
Rails.logger.info "TOU " + post_body
262+
resp = JSON.parse( http_post_request(post_body) )
263+
Rails.logger.info resp
264+
raise JSONRPCError, resp['error'] if resp['error']
265+
result = resp['result']
266+
if result == nil
267+
return result
268+
end
269+
result.symbolize_keys! if result.is_a? Hash
270+
result
271+
end
272+
def http_post_request(post_body)
273+
http = Net::HTTP.new(@uri.host, @uri.port)
274+
request = Net::HTTP::Post.new(@uri.request_uri)
275+
request.basic_auth @uri.user, @uri.password
276+
request.content_type = 'application/json'
277+
request.body = post_body
278+
@reply = http.request(request).body
279+
# Rails.logger.info @reply
280+
return @reply
281+
rescue Errno::ECONNREFUSED => e
282+
raise ConnectionRefusedError
283+
end
284+
285+
def safe_getbalance
286+
begin
287+
#Rails.logger.info @rest + " -> " + "#{@rest}/cgi-bin/total.cgi"
288+
(open("#{@rest}/cgi-bin/total.cgi").read.rstrip.to_f)
289+
rescue => ex
290+
Rails.logger.info "[error]: " + ex.message + "\n" + ex.backtrace.join("\n") + "\n"
291+
'N/A'
292+
end
293+
end
294+
295+
def getblockchaininfo
296+
@lastBlock = eth_getBlockByNumber("latest", true)
297+
#Rails.logger.info @lastBlock
298+
#Rails.logger.info "number = " + Integer(@lastBlock[:number]).to_s + ", timestamp = " + Integer(@lastBlock[:timestamp]).to_s
299+
300+
{
301+
blocks: Integer(@lastBlock[:number]),
302+
headers: 0,
303+
mediantime: Integer(@lastBlock[:timestamp])
304+
}
305+
end
306+
end
256307
class LISK < self
257308
def handle(name, *args)
258309
post_body = {"jsonrpc" => "2.0", 'method' => name, 'params' => args, 'id' => '1' }.to_json

config/deposit_channels.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
currency: eth
2525
min_confirm: 5
2626
max_confirm: 6
27-
27+
- id: 2000
28+
key: touristcoin
29+
currency: tou
30+
min_confirm: 5
31+
max_confirm: 6
2832
# - id: 1200
2933
# key: poseidon
3034
# currency: psd

config/locales/client.en.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ en:
6363
doge: DOGE
6464
ltc: LTC
6565
eth: ETH
66+
tou: TOU
6667
psd: PSD
6768
phc: PHC
6869
xgc: XGC
@@ -253,7 +254,8 @@ en:
253254

254255
deposit_eth:
255256
title: ETH Deposit
256-
257+
deposit_tou:
258+
title: TOU Deposit
257259
deposit_psd:
258260
title: PSD Deposit
259261

@@ -780,7 +782,8 @@ en:
780782

781783
withdraw_eth:
782784
title: ETH Withdraw
783-
785+
withdraw_tou:
786+
title: TOU Withdraw
784787
withdraw_psd:
785788
title: PSD Withdraw
786789

@@ -1252,6 +1255,7 @@ en:
12521255
withdraw_limit_doge: Withdraw day limit is 1 000 000 for an unverified account.
12531256
withdraw_limit_ltc: Withdraw day limit is 1 000 for an unverified account.
12541257
withdraw_limit_eth: Withdraw day limit is 10 for an unverified account.
1258+
withdraw_limit_tou: Withdraw day limit is 10 for an unverified account.
12551259
withdraw_limit_psd: Withdraw day limit is 200 000 for an unverified account.
12561260
withdraw_limit_phc: Withdraw day limit is 100 000 for an unverified account.
12571261
withdraw_limit_xgc: Withdraw day limit is 10 000 for an unverified account.
@@ -1463,6 +1467,7 @@ en:
14631467
doge: DOGE Market
14641468
ltc: LTC Market
14651469
eth: ETH Market
1470+
tou: TOU Market
14661471
psd: PSD Market
14671472
phc: PHC Market
14681473
xgc: XGC Market

0 commit comments

Comments
 (0)