blocksdk 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 62a3ed99380a507e3ebc773eab64b9fbe2f11f52a1fd80e9f0580b0fb2dd6397
4
+ data.tar.gz: 50ecedb8221cdfc9ad413c5f18bacf4ccb10b6a4171900218baba6fd43fcd6ba
5
+ SHA512:
6
+ metadata.gz: a155c9fa1aba70124c600d7a55aa2866cfe18f51f609d46e751af6f6d62d6be019afed1ad9df529ca2eae4307ac328f5e11bff07774061187cf946f629acb0a2
7
+ data.tar.gz: 712b673b52070b7da171a12ac5689a92b7458512bbb74559ba3cbc71804020c798680682ac16e58451eac774c4ea0aa01e6f45904398c3e9f39edd80f53af28a
@@ -0,0 +1,81 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ class Base
5
+
6
+ attr_accessor :api_token
7
+ def initialize(api_token)
8
+ @api_token = api_token
9
+ end
10
+
11
+ def listPrice(request = {})
12
+ return request("GET","/price")
13
+ end
14
+
15
+ def getHashType(request = {})
16
+ return request("GET","/auto/" + request['hash'] + "/type")
17
+ end
18
+
19
+ def getUsage(request = {})
20
+
21
+ if request["start_date"].to_s.empty?
22
+ d = Time.now - 604800
23
+ request['start_date'] = d.strftime("%Y-%m-%d")
24
+ end
25
+
26
+ if request["end_date"].to_s.empty?
27
+ d = Time.now
28
+ request['end_date'] = d.strftime("%Y-%m-%d")
29
+ end
30
+
31
+ return request("GET","/usage",{"start_date"=> request['start_date'],"end_date"=> request['end_date']})
32
+ end
33
+
34
+
35
+ def request(method,path,data = {})
36
+ url = "https://api.blocksdk.com/v1" + path
37
+ if method == "GET" and data.size > 0
38
+ url += "?"
39
+ data.each do |key, value|
40
+ if value == true
41
+ url += key + "=true&"
42
+ elsif value == false
43
+ url += key + "=false&"
44
+ else
45
+ url += key+ "=" + value.to_s + "&"
46
+ end
47
+ end
48
+ end
49
+
50
+ if method == "POST"
51
+ response = HTTParty.post(url, :data => data, :headers => { 'Content-Type': 'application/json','x-api-key': @api_token})
52
+ else
53
+ response = HTTParty.get(url,:headers => { 'Content-Type': 'application/json','x-api-key': @api_token})
54
+ end
55
+
56
+ header_dict = response.headers
57
+ body = JSON.parse(response.body)
58
+
59
+ header_dict["statusCode"] = response.code
60
+
61
+ begin
62
+ body["HTTP_HEADER"] = header_dict
63
+ rescue
64
+ body_dict = {}
65
+ for i in 0..(body.length - 1)
66
+ ind = i.to_s
67
+ body_dict[ind] = body[i]
68
+ end
69
+ body = body_dict
70
+ body["HTTP_HEADER".to_s] = header_dict
71
+ end
72
+
73
+ return body
74
+ end
75
+
76
+ end
77
+
78
+ #baseInstance = Base.new("ad38QFTevz8fEEAG4fKsf4T5L8pwqgcy6LXMHpqU")
79
+ #puts baseInstance.listPrice()
80
+ #puts baseInstance.getHashType({'hash'=>'000000000000000089d2938df30be807844feea4c3340ad32873bb1b692b7f1a'})
81
+ #puts baseInstance.getUsage({})
@@ -0,0 +1,166 @@
1
+ require_relative 'base'
2
+
3
+ class Bitcoin < Base
4
+ def getBlockChain(request = {})
5
+ return request("GET","/btc/block")
6
+ end
7
+ def getBlock(request = {})
8
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
9
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
10
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
11
+
12
+ return request("GET","/btc/block/"+ (request['block']).to_s, {
13
+ "rawtx" => request['rawtx'],
14
+ "offset" => request['offset'],
15
+ "limit" => request['limit']
16
+ })
17
+ end
18
+
19
+ def getMemPool(request = {})
20
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
21
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
22
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
23
+
24
+ return request("GET","/btc/mempool",{
25
+ "rawtx" => request['rawtx'],
26
+ "offset" => request['offset'],
27
+ "limit" => request['limit']
28
+ })
29
+ end
30
+
31
+ def getAddressInfo(request = {})
32
+
33
+ request["reverse"].to_s.empty? ? request['reverse'] = true : request["reverse"]
34
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
35
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
36
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
37
+
38
+ return request("GET","/btc/address/" + (request['address']).to_s,{
39
+ "reverse" => request['reverse'],
40
+ "rawtx" => request['rawtx'],
41
+ "offset" => request['offset'],
42
+ "limit" => request['limit']
43
+ })
44
+ end
45
+
46
+ def getAddressBalance(request = {})
47
+ return request("GET","/btc/address/" + (request['address']).to_s + "/balance")
48
+ end
49
+
50
+ def listWallet(request = {})
51
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
52
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
53
+
54
+ return request("GET","/btc/wallet",{
55
+ "offset" => request['offset'],
56
+ "limit" => request['limit']
57
+ })
58
+ end
59
+
60
+ def createWallet(request = {})
61
+ request["limit"].to_s.empty? ? request['limit'] = nil : request["limit"]
62
+ return request("POST","/btc/wallet",{
63
+ "name" => request['name']
64
+ })
65
+ end
66
+
67
+ def loadWallet(request = {})
68
+ return request("POST","/btc/wallet/"+ (request['wallet_id']).to_s + "/load",{
69
+ "seed_wif" => request['seed_wif'],
70
+ "password" => request['password']
71
+ })
72
+ end
73
+
74
+ def unLoadWallet(request = {})
75
+ return request("POST","/btc/wallet/"+(request['wallet_id']).to_s + "/unload")
76
+ end
77
+
78
+ def listWalletAddress(request = {})
79
+ request["address"].to_s.empty? ? request['address'] = nil : request["address"]
80
+ request["hdkeypath"].to_s.empty? ? request['hdkeypath'] = nil : request["hdkeypath"]
81
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
82
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
83
+
84
+ return request("GET","/btc/wallet/"+(request['wallet_id']).to_s + "/address",{
85
+ "address" => request['address'],
86
+ "hdkeypath" => request['hdkeypath'],
87
+ "offset" => request['offset'],
88
+ "limit" => request['limit']
89
+ })
90
+ end
91
+
92
+ def createWalletAddress(request = {})
93
+
94
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
95
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
96
+
97
+ return request("POST","/btc/wallet/"+(request['wallet_id']).to_s + "/address",{
98
+ "seed_wif" => request['seed_wif'],
99
+ "password" => request['password']
100
+ })
101
+ end
102
+
103
+ def getWalletBalance(request = {})
104
+ return request("GET","/btc/wallet/"+(request['wallet_id']).to_s + "/balance")
105
+ end
106
+
107
+ def getWalletTransaction(request = {})
108
+
109
+ request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
110
+ request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
111
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
112
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
113
+
114
+ return request("GET","/btc/wallet/"+(request['wallet_id']).to_s + "/transaction",{
115
+ "category" => request['category'],
116
+ "order" => request['order'],
117
+ "offset" => request['offset'],
118
+ "limit" => request['limit']
119
+ })
120
+ end
121
+
122
+ def sendToAddress(request = {})
123
+
124
+ if request["kbfee"].to_s.empty?
125
+ blockChain = getBlockChain()
126
+ request['kbfee'] = blockChain['medium_fee_per_kb']
127
+ end
128
+
129
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
130
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
131
+
132
+ return request("POST","/btc/wallet/"+ (request['wallet_id']).to_s + "/sendtoaddress",{
133
+ "address" => request['address'],
134
+ "amount" => request['amount'],
135
+ "seed_wif" => request['seed_wif'],
136
+ "password" => request['password'],
137
+ "kbfee" => request['kbfee']
138
+ })
139
+ end
140
+
141
+ def sendMany(request = {})
142
+
143
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
144
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
145
+
146
+ return request("POST","/btc/wallet/"+ (request['wallet_id']).to_s + "/sendmany",{
147
+ "to" => request['to'],
148
+ "seed_wif" => request['seed_wif'],
149
+ "password" => request['password']
150
+ })
151
+ end
152
+
153
+ def sendTransaction(request = {})
154
+ return request("POST","/btc/transaction",{
155
+ "sign_hex" => request['sign_hex']
156
+ })
157
+ end
158
+
159
+ def getTransaction(request = {})
160
+ return request("GET","/btc/transaction/"+ (request['hash']).to_s + "")
161
+ end
162
+
163
+ def getTransactionTracking(request = {})
164
+ return request("GET","/btc/transaction/"+ (request['hash']).to_s + "/tracking")
165
+ end
166
+ end
@@ -0,0 +1,158 @@
1
+ require_relative 'base'
2
+
3
+ class BitcoinCash < Base
4
+
5
+ def getBlockChain(request = {})
6
+ return request("GET","/bch/block")
7
+ end
8
+
9
+ def getBlock(request = {})
10
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
11
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
12
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
13
+
14
+ return request("GET","/bch/block/" + (request['block']).to_s + "",{
15
+ "rawtx" => request['rawtx'],
16
+ "offset" => request['offset'],
17
+ "limit" => request['limit']
18
+ })
19
+ end
20
+
21
+ def getMemPool(request = {})
22
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
23
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
24
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
25
+
26
+ return request("GET","/bch/mempool",{
27
+ "rawtx" => request['rawtx'],
28
+ "offset" => request['offset'],
29
+ "limit" => request['limit']
30
+ })
31
+ end
32
+
33
+ def getAddressInfo(request = {})
34
+
35
+ request["reverse"].to_s.empty? ? request['reverse'] = true : request['reverse']
36
+ request["rawtx"].to_s.empty? ? request['rawtx'] = nil : request['rawtx']
37
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
38
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
39
+
40
+ return request("GET","/bch/address/" + (request['address']).to_s + "",{
41
+ "reverse" => request['reverse'],
42
+ "rawtx" => request['rawtx'],
43
+ "offset" => request['offset'],
44
+ "limit" => request['limit']
45
+ })
46
+ end
47
+
48
+ def getAddressBalance(request = {})
49
+ return request("GET","/bch/address/" + (request['address']).to_s + "/balance")
50
+ end
51
+
52
+ def listWallet(request = {})
53
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
54
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
55
+ return request("GET","/bch/wallet",{
56
+ "offset" => request['offset'],
57
+ "limit" => request['limit']
58
+ })
59
+ end
60
+
61
+ def createWallet(request = {})
62
+ request["name"].to_s.empty? ? request['name'] = 0 : request["name"]
63
+ return request("POST","/bch/wallet",{
64
+ "name" => request['name']
65
+ })
66
+ end
67
+
68
+ def loadWallet(request = {})
69
+ return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/load",{
70
+ "seed_wif" => request['seed_wif'],
71
+ "password" => request['password']
72
+ })
73
+ end
74
+
75
+ def unLoadWallet(request = {})
76
+ return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/unload")
77
+ end
78
+
79
+ def listWalletAddress(request = {})
80
+
81
+ request["hdkeypath"].to_s.empty? ? request['hdkeypath'] = nil : request["hdkeypath"]
82
+ request["address"].to_s.empty? ? request['address'] = nil : request["address"]
83
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
84
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
85
+
86
+ return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/address",{
87
+ "address" => request['address'],
88
+ "hdkeypath" => request['hdkeypath'],
89
+ "offset" => request['offset'],
90
+ "limit" => request['limit']
91
+ })
92
+ end
93
+
94
+ def createWalletAddress(request = {})
95
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
96
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
97
+
98
+ return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/address",{
99
+ "seed_wif" => request['seed_wif'],
100
+ "password" => request['password']
101
+ })
102
+ end
103
+
104
+ def getWalletBalance(request = {})
105
+ return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/balance")
106
+ end
107
+
108
+ def getWalletTransaction(request = {})
109
+
110
+ request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
111
+ request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
112
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
113
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
114
+
115
+ return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/transaction",{
116
+ "category" => request['category'],
117
+ "order" => request['order'],
118
+ "offset" => request['offset'],
119
+ "limit" => request['limit']
120
+ })
121
+ end
122
+
123
+ def sendToAddress(request = {})
124
+
125
+ if request["kbfee"].to_s.empty?
126
+ blockChain = getBlockChain()
127
+ request['kbfee'] = blockChain['medium_fee_per_kb']
128
+ end
129
+
130
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
131
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
132
+
133
+ return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/sendtoaddress",{
134
+ "address" => request['address'],
135
+ "amount" => request['amount'],
136
+ "seed_wif" => request['seed_wif'],
137
+ "password" => request['password'],
138
+ "kbfee" => request['kbfee']
139
+ })
140
+ end
141
+
142
+ def sendMany(request = {})
143
+
144
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
145
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
146
+
147
+ return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/sendmany",{
148
+ "to" => request['to'],
149
+ "seed_wif" => request['seed_wif'],
150
+ "password" => request['password']
151
+ })
152
+ end
153
+
154
+ def getTransaction(request = {})
155
+ return request("GET","/bch/transaction/" + (request['hash']).to_s + "")
156
+ end
157
+
158
+ end
@@ -0,0 +1,49 @@
1
+ require_relative 'base'
2
+ require_relative 'dash'
3
+ require_relative 'bitcoin'
4
+ require_relative 'ethereum'
5
+ require_relative 'bitcoincash'
6
+ require_relative 'monero'
7
+ require_relative 'webhook'
8
+ require_relative 'litecoin'
9
+ require_relative 'price'
10
+
11
+ class BlockSDK < Base
12
+ attr_accessor :api_token
13
+
14
+ def initialize(api_token)
15
+ @api_token = api_token
16
+ end
17
+
18
+ def createBitcoin()
19
+ return Bitcoin.new(@api_token)
20
+ end
21
+
22
+ def createEthereum()
23
+ return Ethereum.new(@api_token)
24
+ end
25
+
26
+ def createLitecoin()
27
+ return Litecoin.new(@api_token)
28
+ end
29
+
30
+ def createMonero()
31
+ return Monero.new(@api_token)
32
+ end
33
+
34
+ def createPrice()
35
+ return Price.new(@api_token)
36
+ end
37
+
38
+ def createWebHook()
39
+ return WebHook.new(@api_token)
40
+ end
41
+
42
+ def createDash()
43
+ return Dash.new(@api_token)
44
+ end
45
+
46
+ def createBitcoinCash()
47
+ return BitcoinCash.new(@api_token)
48
+ end
49
+ end
@@ -0,0 +1,136 @@
1
+ require_relative 'base'
2
+
3
+ class Dash < Base
4
+
5
+ def getBlockChain(request = {})
6
+ return request("GET","/dash/block")
7
+ end
8
+
9
+ def getBlock(request = {})
10
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
11
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
12
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
13
+
14
+ return request("GET","/dash/block/" + (request['block']).to_s, {"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
15
+ end
16
+
17
+ def getMemPool(request = {})
18
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
19
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
20
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
21
+ return request("GET","/dash/mempool",{"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
22
+ end
23
+
24
+ def getAddressInfo(request = {})
25
+
26
+ request["rawtx"].to_s.empty? ? request['rawtx'] = nil : request['rawtx']
27
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
28
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
29
+
30
+ return request("GET","/dash/address/" + (request['address']).to_s, {"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
31
+ end
32
+
33
+
34
+ def getAddressBalance(request = {})
35
+ return request("GET","/dash/address/" + (request['address']).to_s + "/balance")
36
+ end
37
+
38
+
39
+ def listWallet(request = {})
40
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
41
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
42
+
43
+ return request("GET","/dash/wallet",{
44
+ "offset" => request['offset'],
45
+ "limit" => request['limit']
46
+ })
47
+ end
48
+
49
+ def createWallet(request = {})
50
+
51
+ request["limit"].to_s.empty? ? request['limit'] = nil : request["limit"]
52
+
53
+ return request("POST","/dash/wallet",{
54
+ "name" => request['name']
55
+ })
56
+ end
57
+
58
+ def loadWallet(request = {})
59
+ return request("POST","/dash/wallet/" + (request['wallet_id']).to_s + "/load",{"seed_wif" => request['seed_wif'],"password" => request['password']})
60
+ end
61
+
62
+ def unLoadWallet(request = {})
63
+ return request("POST","/dash/wallet/" + (request['wallet_id']).to_s + "/unload")
64
+ end
65
+
66
+ def listWalletAddress(request = {})
67
+ request["address"].to_s.empty? ? request['address'] = nil : request['address']
68
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
69
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
70
+ request["hdkeypath"].to_s.empty? ? request['hdkeypath'] = nil : request["hdkeypath"]
71
+
72
+ return request("GET","/dash/wallet/" + (request['wallet_id']).to_s + "/address",{
73
+ "address" => request['address'],
74
+ "hdkeypath" => request['hdkeypath'],
75
+ "offset" => request['offset'],
76
+ "limit" => request['limit']
77
+ })
78
+ end
79
+
80
+ def createWalletAddress(request = {})
81
+
82
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
83
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
84
+
85
+ return request("POST","/dash/wallet/" + (request['wallet_id']).to_s + "/address",{
86
+ "seed_wif" => request['seed_wif'],
87
+ "password" => request['password']
88
+ })
89
+ end
90
+
91
+ def getWalletBalance(request = {})
92
+ return request("GET","/dash/wallet/" + (request['wallet_id']).to_s + "/balance")
93
+ end
94
+
95
+ def getWalletTransaction(request = {})
96
+ request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
97
+ request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
98
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
99
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
100
+
101
+ return request("GET","/dash/wallet/" + (request['wallet_id']).to_s + "/transaction",{
102
+ "category" => request['category'],
103
+ "order" => request['order'],
104
+ "offset" => request['offset'],
105
+ "limit" => request['limit']
106
+ })
107
+ end
108
+
109
+ def sendToAddress(request = {})
110
+ if request["kbfee"].to_s.empty?
111
+ blockChain = getBlockChain()
112
+ request['kbfee'] = blockChain['medium_fee_per_kb']
113
+ end
114
+
115
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
116
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
117
+
118
+ return request("POST","/dash/wallet/" + (request['wallet_id']).to_s + "/sendtoaddress",{"address" => request['address'],"amount" => request['amount'],"seed_wif" => request['seed_wif'],"password" => request['password'],"kbfee" => request['kbfee']})
119
+ end
120
+
121
+ def sendMany(request = {})
122
+
123
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
124
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
125
+
126
+ return request("POST","/dash/wallet/" + (request['wallet_id']).to_s + "/sendmany",{"to" => request['to'],"seed_wif" => request['seed_wif'],"password" => request['password']})
127
+ end
128
+
129
+ def sendTransaction(request = {})
130
+ return request("POST","/dash/transaction",{"sign_hex" => request['sign_hex']})
131
+ end
132
+
133
+ def getTransaction(request = {})
134
+ return request("GET","/dash/transaction/" + (request['hash']).to_s)
135
+ end
136
+ end
@@ -0,0 +1,80 @@
1
+ require_relative 'base'
2
+
3
+ class Ethereum < Base
4
+ def getBlockChain(request = {})
5
+ return request("GET","/eth/block")
6
+ end
7
+
8
+ def getBlock(request = {})
9
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
10
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
11
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
12
+
13
+ return request("GET","/eth/block/" + (request['block']).to_s,{"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
14
+ end
15
+
16
+ def getMemPool(request = {})
17
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
18
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
19
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
20
+
21
+ return request("GET","/eth/mempool",{"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
22
+ end
23
+
24
+ def listAddress(request = {})
25
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
26
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
27
+
28
+ return request("GET","/eth/address",{
29
+ "offset" => request['offset'],
30
+ "limit" => request['limit']
31
+ })
32
+ end
33
+
34
+ def loadAddress(request = {})
35
+ return request("POST","/eth/address/" + (request['address']).to_s + "/load",{"seed_wif" => request['seed_wif'],"password" => request['password']})
36
+ end
37
+
38
+ def unLoadAddress(request = {})
39
+ return request("POST","/eth/address/" + (request['address']).to_s + "/unload")
40
+ end
41
+
42
+ def createAddress(request = {})
43
+ request["name"].to_s.empty? ? request['name'] = 0 : request["name"]
44
+ return request("POST","/eth/address",{"name" => request['name']})
45
+ end
46
+
47
+ def getAddressInfo(request = {})
48
+
49
+ request["reverse"].to_s.empty? ? request['reverse'] = true : request['reverse']
50
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
51
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
52
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
53
+
54
+ return request("GET","/eth/address/" + (request['address']).to_s ,{"reverse" => request['reverse'],"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
55
+ end
56
+
57
+ def getAddressBalance(request = {})
58
+ return request("GET","/eth/address/" + (request['address']).to_s + "/balance")
59
+ end
60
+
61
+ def sendToAddress(request = {})
62
+ if request["gwei"].to_s.empty?
63
+ blockChain = getBlockChain()
64
+ request['gwei'] = blockChain['medium_gwei']
65
+ end
66
+ request["private_spend_key"].to_s.empty? ? request['private_spend_key'] = nil : request["private_spend_key"]
67
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
68
+
69
+ return request("POST","/eth/address/" + (request['from']).to_s + "/sendtoaddress",{"address" => request['to'],"amount" => request['amount'],"private_key" => request['private_key'],"password" => request['password'],"gwei" => request['gwei']})
70
+ end
71
+
72
+ def sendTransaction(request = {})
73
+ return request("POST","/eth/transaction",{"sign_hex" => request['sign_hex']})
74
+ end
75
+
76
+ def getTransaction(request = {})
77
+ return request("GET","/eth/transaction/" + (request['hash']).to_s)
78
+ end
79
+
80
+ end
@@ -0,0 +1,171 @@
1
+ require_relative 'base'
2
+
3
+ class Litecoin < Base
4
+ def getBlockChain(request = {})
5
+ return request("GET","/ltc/block")
6
+ end
7
+
8
+ def getBlock(request = {})
9
+
10
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
11
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
12
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
13
+
14
+ return request("GET","/ltc/block/" + (request['block']).to_s ,{
15
+ "rawtx" => request['rawtx'],
16
+ "offset" => request['offset'],
17
+ "limit" => request['limit']
18
+ })
19
+ end
20
+
21
+
22
+ def getMemPool(request = {})
23
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
24
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
25
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
26
+
27
+ return request("GET","/ltc/mempool",{
28
+ "rawtx" => request['rawtx'],
29
+ "offset" => request['offset'],
30
+ "limit" => request['limit']
31
+ })
32
+ end
33
+
34
+ def getAddressInfo(request = {})
35
+ request["reverse"].to_s.empty? ? request['reverse'] = true : request['reverse']
36
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
37
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
38
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
39
+
40
+ return request("GET","/ltc/address/" + (request['address']).to_s+ "",{
41
+ "reverse" => request['reverse'],
42
+ "rawtx" => request['rawtx'],
43
+ "offset" => request['offset'],
44
+ "limit" => request['limit']
45
+ })
46
+ end
47
+
48
+ def getAddressBalance(request = {})
49
+ return request("GET","/ltc/address/" + (request['address']).to_s+ "/balance")
50
+ end
51
+
52
+ def listWallet(request = {})
53
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
54
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
55
+
56
+ return request("GET","/ltc/wallet",{
57
+ "offset" => request['offset'],
58
+ "limit" => request['limit']
59
+ })
60
+ end
61
+
62
+ def createWallet(request = {})
63
+ request["name"].to_s.empty? ? request['name'] = nil : request["name"]
64
+ return request("POST","/ltc/wallet",{
65
+ "name" => request['name']
66
+ })
67
+ end
68
+
69
+ def loadWallet(request = {})
70
+ return request("POST","/ltc/wallet/" + (request['wallet_id']).to_s+ "/load",{
71
+ "seed_wif" => request['seed_wif'],
72
+ "password" => request['password']
73
+ })
74
+ end
75
+
76
+ def unLoadWallet(request = {})
77
+ return request("POST","/ltc/wallet/" + (request['wallet_id']).to_s+ "/unload")
78
+ end
79
+
80
+ def listWalletAddress(request = {})
81
+
82
+ request["address"].to_s.empty? ? request['address'] = nil : request["address"]
83
+ request["hdkeypath"].to_s.empty? ? request['hdkeypath'] = nil : request["hdkeypath"]
84
+
85
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
86
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
87
+
88
+ return request("GET","/ltc/wallet/" + (request['wallet_id']).to_s+ "/address",{
89
+ "address" => request['address'],
90
+ "hdkeypath" => request['hdkeypath'],
91
+ "offset" => request['offset'],
92
+ "limit" => request['limit']
93
+ })
94
+ end
95
+
96
+ def createWalletAddress(request = {})
97
+
98
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
99
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
100
+
101
+ return request("POST","/ltc/wallet/" + (request['wallet_id']).to_s+ "/address",{
102
+ "seed_wif" => request['seed_wif'],
103
+ "password" => request['password']
104
+ })
105
+ end
106
+
107
+ def getWalletBalance(request = {})
108
+ return request("GET","/ltc/wallet/" + (request['wallet_id']).to_s+ "/balance")
109
+ end
110
+
111
+ def getWalletTransaction(request = {})
112
+
113
+ request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
114
+ request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
115
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
116
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
117
+
118
+ return request("GET","/ltc/wallet/" + (request['wallet_id']).to_s+ "/transaction",{
119
+ "category" => request['category'],
120
+ "order" => request['order'],
121
+ "offset" => request['offset'],
122
+ "limit" => request['limit']
123
+ })
124
+ end
125
+
126
+ def sendToAddress(request = {})
127
+
128
+ if request["kbfee"].to_s.empty?
129
+ blockChain = getBlockChain()
130
+ request['kbfee'] = blockChain['medium_fee_per_kb']
131
+ end
132
+
133
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
134
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
135
+
136
+ return request("POST","/ltc/wallet/" + (request['wallet_id']).to_s+ "/sendtoaddress",{
137
+ "address" => request['address'],
138
+ "amount" => request['amount'],
139
+ "seed_wif" => request['seed_wif'],
140
+ "password" => request['password'],
141
+ "kbfee" => request['kbfee']
142
+ })
143
+ end
144
+
145
+ def sendTransaction(request = {})
146
+ return request("POST","/ltc/transaction",{
147
+ "sign_hex" => request['sign_hex']
148
+ })
149
+ end
150
+
151
+ def getTransaction(request = {})
152
+ return request("GET","/ltc/transaction/" + (request['hash']).to_s+ "")
153
+ end
154
+
155
+ def sendMany(request = {})
156
+
157
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : nil
158
+ request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : nil
159
+ request["password"].to_s.empty? ? request['password'] = nil : nil
160
+
161
+ return request("POST","/ltc/wallet/" + (request['wallet_id']).to_s+ "/sendmany",{
162
+ "to" => request['to'],
163
+ "seed_wif" => request['seed_wif'],
164
+ "password" => request['password']
165
+ })
166
+ end
167
+
168
+ end
169
+
170
+ #baseInstance = Litecoin.new("ad38QFTevz8fEEAG4fKsf4T5L8pwqgcy6LXMHpqU")
171
+ #puts baseInstance.getTransaction({"hash" => "892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506"})
@@ -0,0 +1,99 @@
1
+ require_relative 'base'
2
+
3
+ class Monero < Base
4
+ def getBlockChain(request = {})
5
+ return request("GET","/xmr/block")
6
+ end
7
+
8
+ def getBlock(request = {})
9
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
10
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
11
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
12
+
13
+ return request("GET","/xmr/block/" + (request['block']).to_s+ "",{
14
+ "rawtx" => request['rawtx'],
15
+ "offset" => request['offset'],
16
+ "limit" => request['limit']
17
+ })
18
+ end
19
+
20
+ def getMemPool(request = {})
21
+ request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
22
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
23
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
24
+
25
+ return request("GET","/xmr/mempool",{
26
+ "rawtx" => request['rawtx'],
27
+ "offset" => request['offset'],
28
+ "limit" => request['limit']
29
+ })
30
+ end
31
+
32
+ def listAddress(request = {})
33
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
34
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
35
+
36
+ return request("GET","/xmr/address",{
37
+ "offset" => request['offset'],
38
+ "limit" => request['limit']
39
+ })
40
+ end
41
+
42
+ def createAddress(request = {})
43
+ request["name"].to_s.empty? ? request['name'] = nil : request["name"]
44
+ return request("POST","/xmr/address",{
45
+ "name" => request['name']
46
+ })
47
+ end
48
+
49
+ def getAddressInfo(request = {})
50
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
51
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
52
+
53
+ return request("GET","/xmr/address/" + (request['address_id']).to_s+ "",{
54
+ "offset" => request['offset'],
55
+ "limit" => request['limit'],
56
+ "private_spend_key" => request['private_spend_key'],
57
+ })
58
+ end
59
+
60
+ def getAddressBalance(request = {})
61
+ return request("GET","/xmr/address/" + (request['address_id']).to_s+ "/balance",{
62
+ "private_spend_key" => request['private_spend_key'],
63
+ })
64
+ end
65
+
66
+ def loadAddress(request = {})
67
+ return request("POST","/xmr/address/" + (request['address_id']).to_s+ "/load",{
68
+ "private_spend_key" => request['private_spend_key'],
69
+ "password" => request['password']
70
+ })
71
+ end
72
+
73
+ def unLoadAddress(request = {})
74
+ return request("POST","/xmr/address/" + (request['address_id']).to_s+ "/unload")
75
+ end
76
+
77
+ def sendToAddress(request = {})
78
+
79
+ if request["kbfee"].to_s.empty?
80
+ blockChain = getBlockChain()
81
+ request['kbfee'] = blockChain['medium_fee_per_kb']
82
+ end
83
+
84
+ request["private_spend_key"].to_s.empty? ? request['private_spend_key'] = nil : request["private_spend_key"]
85
+ request["password"].to_s.empty? ? request['password'] = nil : request["password"]
86
+
87
+ return request("POST","/xmr/address/" + (request['address_id']).to_s+ "/sendtoaddress",{
88
+ "address" => request['address'],
89
+ "amount" => request['amount'],
90
+ "private_spend_key" => request['private_spend_key'],
91
+ "password" => request['password'],
92
+ "kbfee" => request['kbfee']
93
+ })
94
+ end
95
+
96
+ def getTransaction(request = {})
97
+ return request("GET","/xmr/transaction/" + (request['hash']).to_s+ "")
98
+ end
99
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'base'
2
+
3
+ class Price < Base
4
+ def listPrice(request = {})
5
+ return request("GET","/price")
6
+ end
7
+ end
8
+
9
+ # priceInstance = Price.new("ad38QFTevz8fEEAG4fKsf4T5L8pwqgcy6LXMHpqU")
10
+ # puts priceInstance.listPrice()
@@ -0,0 +1,34 @@
1
+ require_relative 'base'
2
+
3
+ class WebHook < Base
4
+
5
+ def create(request={})
6
+ return request("POST","/hook",{"callback"=>request['callback'],"category"=>request['category'],"address"=>request['address']})
7
+ end
8
+
9
+ def list(request = {})
10
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
11
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
12
+ return request("GET","/hook",{"offset"=>request['offset'],"limit"=>request['limit']})
13
+ end
14
+
15
+ def get(request={})
16
+ return request("GET","/hook/" + (request['hook_id']).to_s)
17
+ end
18
+
19
+ def delete(request={})
20
+ return request("POST","/hook/" + (request['hook_id']).to_s + "/delete")
21
+ end
22
+
23
+ def listResponse(request = {})
24
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
25
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
26
+ return request("GET","/hook/response",{"offset"=>request['offset'],"limit"=>request['limit']})
27
+ end
28
+
29
+ def getResponse(request={})
30
+ request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
31
+ request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
32
+ return request("GET","/hook/" + (request['hook_id']).to_s + "/response",{"offset"=>request['offset'],"limit"=>request['limit']})
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'blocksdk'
2
+
3
+ blockSDK = BlockSDK.new('YOU TOKEN')
4
+
5
+ # btcClient = blockSDK.createBitcoin()
6
+ # output = btcClient.getBlockChain()
7
+
8
+ #dashClient = blockSDK.createDash()
9
+ # output = dashClient.getTransaction({ "hash" => "fa6c191a429d65552b9f0a572e24d8edbfb5e08ab4c41afc1914e60d14be14fc"})
10
+
11
+ # ethereumClient = blockSDK.createEthereum()
12
+ # output = ethereumClient.getBlockChain()
13
+
14
+ # xmrClient = blockSDK.createMonero()
15
+ # output = xmrClient.getBlockChain()
16
+
17
+ # webhookClient = blockSDK.createWebHook()
18
+ # output = webhookClient.list()
19
+
20
+ # output = blockSDK.listPrice()
21
+
22
+ # bchClient = blockSDK.createBitcoinCash()
23
+ # output = bchClient.getBlockChain()
24
+
25
+ ltcClient = blockSDK.createLitecoin()
26
+ output = ltcClient.getBlockChain()
27
+
28
+ puts output
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blocksdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - BlockSDK
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Ruby library to help you build your crypto application on BlockSDK
28
+ email: contact@blocksdk.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/blocksdk_ruby/base.rb
34
+ - lib/blocksdk_ruby/bitcoin.rb
35
+ - lib/blocksdk_ruby/bitcoincash.rb
36
+ - lib/blocksdk_ruby/blocksdk.rb
37
+ - lib/blocksdk_ruby/dash.rb
38
+ - lib/blocksdk_ruby/ethereum.rb
39
+ - lib/blocksdk_ruby/litecoin.rb
40
+ - lib/blocksdk_ruby/monero.rb
41
+ - lib/blocksdk_ruby/price.rb
42
+ - lib/blocksdk_ruby/webhook.rb
43
+ - lib/main.rb
44
+ homepage: http://www.blocksdk.com
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.1.2
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Ruby library to help you build your crypto application on BlockSDK
67
+ test_files: []