Class: BitcoinCash

Inherits:
Base
  • Object
show all
Defined in:
lib/blocksdk_ruby/bitcoincash.rb

Instance Attribute Summary

Attributes inherited from Base

#api_token

Instance Method Summary collapse

Methods inherited from Base

#getHashType, #getUsage, #initialize, #listPrice, #request

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#createWallet(request = {}) ⇒ Object



61
62
63
64
65
66
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 61

def createWallet(request = {})
	request["name"].to_s.empty? ? request['name'] = 0 : request["name"]		
	return request("POST","/bch/wallet",{
		"name" => request['name']
	})
end

#createWalletAddress(request = {}) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 94

def createWalletAddress(request = {})
	request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]
	
	return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/address",{
		"seed_wif" => request['seed_wif'],
		"password" => request['password']
	})
end

#getAddressBalance(request = {}) ⇒ Object



48
49
50
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 48

def getAddressBalance(request = {})
	return request("GET","/bch/address/" +    (request['address']).to_s + "/balance")
end

#getAddressInfo(request = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 33

def getAddressInfo(request = {})

	request["reverse"].to_s.empty? ? request['reverse'] = true : request['reverse']
	request["rawtx"].to_s.empty? ? request['rawtx'] = nil : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/bch/address/" +    (request['address']).to_s + "",{
		"reverse" => request['reverse'],
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getBlock(request = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 9

def getBlock(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/bch/block/" + (request['block']).to_s + "",{
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getBlockChain(request = {}) ⇒ Object



5
6
7
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 5

def getBlockChain(request = {})		
	return request("GET","/bch/block")
end

#getMemPool(request = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 21

def getMemPool(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/bch/mempool",{
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getTransaction(request = {}) ⇒ Object



154
155
156
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 154

def getTransaction(request = {})
	return request("GET","/bch/transaction/" + (request['hash']).to_s + "")
end

#getWalletBalance(request = {}) ⇒ Object



104
105
106
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 104

def getWalletBalance(request = {})
	return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/balance")
end

#getWalletTransaction(request = {}) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 108

def getWalletTransaction(request = {})

	request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
	request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/transaction",{
		"category" => request['category'],
		"order" => request['order'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#listWallet(request = {}) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 52

def listWallet(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	return request("GET","/bch/wallet",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#listWalletAddress(request = {}) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 79

def listWalletAddress(request = {})

	request["hdkeypath"].to_s.empty? ? request['hdkeypath'] = nil : request["hdkeypath"]
	request["address"].to_s.empty? ? request['address'] = nil : request["address"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/bch/wallet/" + (request['wallet_id']).to_s + "/address",{
		"address" => request['address'],
		"hdkeypath" => request['hdkeypath'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#loadWallet(request = {}) ⇒ Object



68
69
70
71
72
73
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 68

def loadWallet(request = {})
	return request("POST","/bch/wallet/" +    (request['wallet_id']).to_s + "/load",{
		"seed_wif" => request['seed_wif'],
		"password" => request['password']
	})
end

#sendMany(request = {}) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 142

def sendMany(request = {})
	
	request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]

	return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/sendmany",{
		"to" => request['to'],
		"seed_wif" => request['seed_wif'],
		"password" => request['password']
	})
end

#sendToAddress(request = {}) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 123

def sendToAddress(request = {})
	
	if request["kbfee"].to_s.empty?
		blockChain = getBlockChain()
		request['kbfee'] = blockChain['medium_fee_per_kb']
	end

	request["seed_wif"].to_s.empty? ? request['seed_wif'] = nil : request["seed_wif"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]
	
	return request("POST","/bch/wallet/" + (request['wallet_id']).to_s + "/sendtoaddress",{
		"address" => request['address'],
		"amount" => request['amount'],
		"seed_wif" => request['seed_wif'],
		"password" => request['password'],
		"kbfee" => request['kbfee']
	})
end

#unLoadWallet(request = {}) ⇒ Object



75
76
77
# File 'lib/blocksdk_ruby/bitcoincash.rb', line 75

def unLoadWallet(request = {})
	return request("POST","/bch/wallet/" +    (request['wallet_id']).to_s + "/unload")
end