Class: Bitcoin

Inherits:
Base
  • Object
show all
Defined in:
lib/blocksdk_ruby/bitcoin.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



60
61
62
63
64
65
# File 'lib/blocksdk_ruby/bitcoin.rb', line 60

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

#createWalletAddress(request = {}) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/blocksdk_ruby/bitcoin.rb', line 92

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","/btc/wallet/"+(request['wallet_id']).to_s + "/address",{
		"seed_wif" => request['seed_wif'],
		"password" => request['password']
	})
end

#getAddressBalance(request = {}) ⇒ Object



46
47
48
# File 'lib/blocksdk_ruby/bitcoin.rb', line 46

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

#getAddressInfo(request = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/blocksdk_ruby/bitcoin.rb', line 31

def getAddressInfo(request = {})

	request["reverse"].to_s.empty? ? request['reverse'] = true : request["reverse"]
	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","/btc/address/" + (request['address']).to_s,{
		"reverse" => request['reverse'],
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getBlock(request = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/blocksdk_ruby/bitcoin.rb', line 7

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","/btc/block/"+ (request['block']).to_s, {
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getBlockChain(request = {}) ⇒ Object



4
5
6
# File 'lib/blocksdk_ruby/bitcoin.rb', line 4

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

#getMemPool(request = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/blocksdk_ruby/bitcoin.rb', line 19

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","/btc/mempool",{
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getTransaction(request = {}) ⇒ Object



159
160
161
# File 'lib/blocksdk_ruby/bitcoin.rb', line 159

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

#getTransactionTracking(request = {}) ⇒ Object



163
164
165
# File 'lib/blocksdk_ruby/bitcoin.rb', line 163

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

#getWalletBalance(request = {}) ⇒ Object



103
104
105
# File 'lib/blocksdk_ruby/bitcoin.rb', line 103

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

#getWalletTransaction(request = {}) ⇒ Object



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

def getWalletTransaction(request = {})

	request["order"].to_s.empty? ? request['order'] = 'desc' : request["order"]
	request["category"].to_s.empty? ? request['category'] = 'all' : request["category"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]

	return request("GET","/btc/wallet/"+(request['wallet_id']).to_s + "/transaction",{
		"category" => request['category'],
		"order" => request['order'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#listWallet(request = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/blocksdk_ruby/bitcoin.rb', line 50

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","/btc/wallet",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#listWalletAddress(request = {}) ⇒ Object



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

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

#loadWallet(request = {}) ⇒ Object



67
68
69
70
71
72
# File 'lib/blocksdk_ruby/bitcoin.rb', line 67

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

#sendMany(request = {}) ⇒ Object



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

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","/btc/wallet/"+     (request['wallet_id']).to_s + "/sendmany",{
		"to" => request['to'],
		"seed_wif" => request['seed_wif'],
		"password" => request['password']
	})
end

#sendToAddress(request = {}) ⇒ Object



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

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","/btc/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

#sendTransaction(request = {}) ⇒ Object



153
154
155
156
157
# File 'lib/blocksdk_ruby/bitcoin.rb', line 153

def sendTransaction(request = {})
	return request("POST","/btc/transaction",{
		"sign_hex" => request['sign_hex']
	})
end

#unLoadWallet(request = {}) ⇒ Object



74
75
76
# File 'lib/blocksdk_ruby/bitcoin.rb', line 74

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