keoken 0.0.4 → 0.1.0
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.
- checksums.yaml +4 -4
- data/.yardoc/checksums +8 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -39
- data/doc/Bitcoin/Script.html +190 -0
- data/doc/Keoken/Backend/BitcoinRuby/Transaction.html +760 -0
- data/doc/Keoken/Backend/BitcoinRuby.html +115 -0
- data/doc/Keoken/Backend.html +115 -0
- data/doc/Keoken/Bitprim/Transaction.html +354 -0
- data/doc/Keoken/Bitprim.html +115 -0
- data/doc/Keoken/IdNotFound.html +202 -0
- data/doc/Keoken/NameNotFound.html +202 -0
- data/doc/Keoken/Token.html +732 -0
- data/doc/Keoken.html +180 -0
- data/doc/_index.html +210 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +162 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +162 -0
- data/doc/js/app.js +292 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +171 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/keoken/backend/bitcoin_ruby/transaction.rb +117 -11
- data/lib/keoken/bitprim/transaction.rb +57 -7
- data/lib/keoken/errors/id_not_found.rb +1 -1
- data/lib/keoken/errors/name_not_found.rb +1 -1
- data/lib/keoken/errors/output_not_found.rb +8 -0
- data/lib/keoken/token.rb +18 -0
- data/lib/keoken/version.rb +2 -2
- data/spec/keoken_spec.rb +50 -68
- metadata +31 -1
@@ -5,17 +5,100 @@ module Keoken
|
|
5
5
|
attr_accessor :to_json, :raw
|
6
6
|
extend Bitcoin::Builder
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# Create the transaction to broadcast in order to create tokens.
|
9
|
+
#
|
10
|
+
# @param address [String] Address that will contain the token.
|
11
|
+
# @param key [Bitcoin::Key] The key obtained from Bitcoin Ruby.
|
12
|
+
# @param script [String] The token script.
|
13
|
+
#
|
14
|
+
# @return [Keoken::Backend::BitcoinRuby::Transaction] An object instanciated with the transaction to broadcast.
|
15
|
+
#
|
16
|
+
def self.build_for_creation(address, key, script)
|
17
|
+
build(address, nil, key, script, :create)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create the transaction to broadcast in order to send amount between tokens.
|
21
|
+
#
|
22
|
+
# @param address [String] Address that will contain the token.
|
23
|
+
# @param address_dest [String] Address to receive the tokens.
|
24
|
+
# @param key [Bitcoin::Key] The key obtained from Bitcoin Ruby.
|
25
|
+
# @param script [String] The token script.
|
26
|
+
#
|
27
|
+
# @return [Keoken::Backend::BitcoinRuby::Transaction] An object instanciated with the transaction to broadcast.
|
28
|
+
#
|
29
|
+
def self.build_for_send_amount(address, address_dest, key, script)
|
30
|
+
build(address, address_dest, key, script, :send)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Invoke the methods creating the transaction automatically.
|
34
|
+
#
|
35
|
+
# @param address [String] Address that will contain the token.
|
36
|
+
# @param addr2 [String] Address to receive the tokens.
|
37
|
+
# @param key [Bitcoin::Key] The key obtained from Bitcoin Ruby.
|
38
|
+
# @param script [String] The token script.
|
39
|
+
# @param type [Symbol] :create for creation and :send to send tokens.
|
40
|
+
#
|
41
|
+
# @return [Keoken::Backend::BitcoinRuby::Transaction] An object instanciated with the transaction to broadcast.
|
42
|
+
#
|
43
|
+
def self.build(address, addr2, key, script, type)
|
44
|
+
bitprim_transaction = Keoken::Bitprim::Transaction.new
|
45
|
+
utxos = bitprim_transaction.utxos(address)
|
46
|
+
inputs = []
|
47
|
+
utxos.each do |utxo|
|
48
|
+
txid = utxo['txid']
|
49
|
+
transaction = bitprim_transaction.tx(txid)
|
50
|
+
outputs = transaction['vout'].select do |vout|
|
51
|
+
addresses = vout['scriptPubKey']['addresses']
|
52
|
+
if addresses
|
53
|
+
addresses.any? { |vout_address| vout_address == address }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
raise Keoken::OutputNotFound if outputs.empty?
|
57
|
+
output = outputs.first
|
58
|
+
inputs.push(
|
59
|
+
tx_id: txid,
|
60
|
+
position: output['n'],
|
61
|
+
input_script: output['scriptPubKey']['hex'],
|
62
|
+
input_amount: output['value'].sub!(/\./, '').sub!(/^0+/, '').to_i
|
63
|
+
)
|
64
|
+
end
|
65
|
+
total = inputs.map { |input| input[:input_amount].to_i }.inject(:+)
|
66
|
+
estimate_fee = bitprim_transaction.estimate_fee.to_f
|
67
|
+
fee = ((10 + 149 * inputs.length + 35 * output_length(type)) * estimate_fee).to_s.sub!(/\./, '').sub!(/^0+/, '')
|
68
|
+
case type
|
69
|
+
when :create
|
70
|
+
output_amount = total - fee.to_i
|
71
|
+
create(inputs, output_amount, key.addr, key, script)
|
72
|
+
when :send
|
73
|
+
output_amount = total - (fee.to_i * 2)
|
74
|
+
output_amount_to_addr2 = fee.to_i
|
75
|
+
send_amount(inputs, output_amount, key.addr, output_amount_to_addr2, addr2, key, script)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create the transaction to broadcast in order to create tokens.
|
80
|
+
#
|
81
|
+
# @param inputs [Array] Inputs to sign.
|
82
|
+
# @param output_amount [Number] Amount to send to output, should be enough for feed.
|
83
|
+
# @param output_address [String] Address that will contain the token.
|
84
|
+
# @param key [Bitcoin::Key] The key obtained from Bitcoin Ruby.
|
85
|
+
# @param script [String] The token script.
|
86
|
+
#
|
87
|
+
# @return [Keoken::Backend::BitcoinRuby::Transaction] An object instanciated with the transaction to broadcast.
|
88
|
+
#
|
89
|
+
def self.create(inputs, output_amount, output_address, key, script)
|
90
|
+
token = new
|
10
91
|
tx = build_tx do |t|
|
11
|
-
|
12
|
-
|
13
|
-
|
92
|
+
inputs.each do |input|
|
93
|
+
t.input do |i|
|
94
|
+
i.prev_out(input[:tx_id], input[:position], input[:input_script].htb, input[:input_amount], 0)
|
95
|
+
i.signature_key(key)
|
96
|
+
end
|
14
97
|
end
|
15
98
|
t.output do |o|
|
16
99
|
o.value output_amount
|
17
100
|
o.script do |s|
|
18
|
-
s.recipient(
|
101
|
+
s.recipient(output_address)
|
19
102
|
end
|
20
103
|
end
|
21
104
|
t.output do |o|
|
@@ -28,12 +111,26 @@ module Keoken
|
|
28
111
|
token
|
29
112
|
end
|
30
113
|
|
31
|
-
|
114
|
+
# Create the transaction to broadcast in order to send amount between tokens.
|
115
|
+
#
|
116
|
+
# @param inputs [Array] Inputs to sign.
|
117
|
+
# @param output_amount [Number] Amount to send to output, should be enough for feed.
|
118
|
+
# @param output_address [String] Address that will contain the token.
|
119
|
+
# @param output_amount_to_addr2 [Number] Amount to send to the output address to receive the tokens, should be low enough for feed.
|
120
|
+
# @param addr2 [String] Address to receive the tokens.
|
121
|
+
# @param key [Bitcoin::Key] The key obtained from Bitcoin Ruby.
|
122
|
+
# @param script [String] The token script.
|
123
|
+
#
|
124
|
+
# @return [Keoken::Backend::BitcoinRuby::Transaction] An object instanciated with the transaction to broadcast.
|
125
|
+
#
|
126
|
+
def self.send_amount(inputs, output_amount, output_address, output_amount_to_addr2, addr2, key, script)
|
32
127
|
token = self.new
|
33
128
|
tx = build_tx do |t|
|
34
|
-
|
35
|
-
|
36
|
-
|
129
|
+
inputs.each do |input|
|
130
|
+
t.input do |i|
|
131
|
+
i.prev_out(input[:tx_id], input[:position], input[:input_script].htb, input[:input_amount], 0)
|
132
|
+
i.signature_key(key)
|
133
|
+
end
|
37
134
|
end
|
38
135
|
t.output do |o|
|
39
136
|
o.value output_amount_to_addr2
|
@@ -44,7 +141,7 @@ module Keoken
|
|
44
141
|
t.output do |o|
|
45
142
|
o.value output_amount
|
46
143
|
o.script do |s|
|
47
|
-
s.recipient(
|
144
|
+
s.recipient(output_address)
|
48
145
|
end
|
49
146
|
end
|
50
147
|
t.output do |o|
|
@@ -56,6 +153,15 @@ module Keoken
|
|
56
153
|
token.raw = tx.to_payload.bth
|
57
154
|
token
|
58
155
|
end
|
156
|
+
|
157
|
+
def self.output_length(type)
|
158
|
+
case type
|
159
|
+
when :create
|
160
|
+
2
|
161
|
+
when :send
|
162
|
+
3
|
163
|
+
end
|
164
|
+
end
|
59
165
|
end
|
60
166
|
end
|
61
167
|
end
|
@@ -5,19 +5,31 @@ require 'net/http'
|
|
5
5
|
module Keoken
|
6
6
|
module Bitprim
|
7
7
|
class Transaction
|
8
|
+
# Broadcast a raw transaction.
|
9
|
+
#
|
10
|
+
# @param raw [String] The raw transaction.
|
11
|
+
#
|
12
|
+
# @return [String] Value from response.
|
13
|
+
#
|
8
14
|
def send_tx(raw)
|
9
15
|
uri = URI("#{root_node_url}/tx/send")
|
10
|
-
|
11
|
-
request.set_form_data(rawtx: raw)
|
16
|
+
response = Net::HTTP.post_form(uri, 'rawtx' => raw)
|
12
17
|
|
13
|
-
response
|
14
|
-
|
18
|
+
case response
|
19
|
+
when Net::HTTPSuccess then
|
20
|
+
JSON.parse(response.body)
|
21
|
+
else
|
22
|
+
response.body
|
15
23
|
end
|
16
|
-
|
17
|
-
response.value
|
18
24
|
end
|
19
25
|
|
20
|
-
|
26
|
+
# Get tokens from address.
|
27
|
+
#
|
28
|
+
# @param address [String] The address that contains the tokens.
|
29
|
+
#
|
30
|
+
# @return [Array] Detailed info from tokens associated to the address.
|
31
|
+
#
|
32
|
+
def assets_by_address(address)
|
21
33
|
uri = URI("#{root_keoken_url}/get_assets_by_address")
|
22
34
|
params = { address: address }
|
23
35
|
uri.query = URI.encode_www_form(params)
|
@@ -26,6 +38,44 @@ module Keoken
|
|
26
38
|
JSON.parse(response.body.tr('\'', '"'))
|
27
39
|
end
|
28
40
|
|
41
|
+
# Get utxos from address.
|
42
|
+
#
|
43
|
+
# @param address [String] The address that contains the utxos.
|
44
|
+
#
|
45
|
+
# @return [Array] Detailed info from utxos.
|
46
|
+
#
|
47
|
+
def utxos(address)
|
48
|
+
uri = URI("#{root_node_url}/addr/#{address}/utxo")
|
49
|
+
response = Net::HTTP.get_response(uri)
|
50
|
+
|
51
|
+
JSON.parse(response.body)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Get transaction details from transaction hash.
|
55
|
+
#
|
56
|
+
# @param txid [String] The transaction id to get the info.
|
57
|
+
#
|
58
|
+
# @return [Array] Detailed info from transaction.
|
59
|
+
#
|
60
|
+
def tx(txid)
|
61
|
+
uri = URI("#{root_node_url}/tx/#{txid}")
|
62
|
+
response = Net::HTTP.get_response(uri)
|
63
|
+
|
64
|
+
JSON.parse(response.body)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get estimate fee.
|
68
|
+
#
|
69
|
+
# @return [Json] Fee estimated per kb.
|
70
|
+
#
|
71
|
+
def estimate_fee
|
72
|
+
uri = URI("#{root_node_url}/utils/estimatefee")
|
73
|
+
response = Net::HTTP.get_response(uri)
|
74
|
+
|
75
|
+
result = JSON.parse(response.body)
|
76
|
+
result['2']
|
77
|
+
end
|
78
|
+
|
29
79
|
private
|
30
80
|
|
31
81
|
def root_node_url
|
data/lib/keoken/token.rb
CHANGED
@@ -2,11 +2,23 @@ module Keoken
|
|
2
2
|
class Token
|
3
3
|
attr_accessor :hex, :name, :id
|
4
4
|
|
5
|
+
# Creates a new token object.
|
6
|
+
#
|
7
|
+
# @param options [Hash] options parameters to create the token.
|
8
|
+
# @option options [String] :name The name of token to create.
|
9
|
+
# @option options [Number] :id The id of token to obtain an amount to send to another address.
|
10
|
+
#
|
5
11
|
def initialize(options = {})
|
6
12
|
@name = options[:name]
|
7
13
|
@id = options[:id]
|
8
14
|
end
|
9
15
|
|
16
|
+
# Generate the script to create a token.
|
17
|
+
#
|
18
|
+
# @param amount [Number] The token amount limit.
|
19
|
+
#
|
20
|
+
# @return [Keoken::Token] An object with the data needed to crate the token.
|
21
|
+
#
|
10
22
|
def create(amount)
|
11
23
|
raise Keoken::NameNotFound unless @name
|
12
24
|
data_script =
|
@@ -23,6 +35,12 @@ module Keoken
|
|
23
35
|
self
|
24
36
|
end
|
25
37
|
|
38
|
+
# Generate the script to send an amount from one address to another.
|
39
|
+
#
|
40
|
+
# @param amount [Number] The amount to send.
|
41
|
+
#
|
42
|
+
# @return [Keoken::Token] An object with the data needed to send the amount.
|
43
|
+
#
|
26
44
|
def send_amount(amount)
|
27
45
|
raise Keoken::IdNotFound unless @id
|
28
46
|
data_script =
|
data/lib/keoken/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Keoken
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '0.1.0'
|
3
|
+
end
|
data/spec/keoken_spec.rb
CHANGED
@@ -45,18 +45,13 @@ describe Keoken do
|
|
45
45
|
|
46
46
|
describe "creates token" do
|
47
47
|
before(:each) do
|
48
|
+
mock_requests
|
48
49
|
Bitcoin.network = :testnet3
|
49
|
-
token = Keoken::Token.new(name:
|
50
|
+
token = Keoken::Token.new(name: 'test-keoken')
|
50
51
|
token.create(1_000_000)
|
51
|
-
|
52
|
-
input_script = "76a9147bb97684cc43e2f8ea0ed1d50dddce3ebf80063888ac"
|
53
|
-
position = 0
|
52
|
+
key = Bitcoin::Key.from_base58('cShKfHoHVf6iKKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2oxBU')
|
54
53
|
script = token.hex
|
55
|
-
|
56
|
-
output_amount = 4_9991_0000
|
57
|
-
key = Bitcoin::Key.from_base58("cShKfHoHVf6iKKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2oxBU")
|
58
|
-
|
59
|
-
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.create(tx_id, position, input_script, input_amount, output_amount, key, script)
|
54
|
+
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.build_for_creation(key.addr, key, script)
|
60
55
|
end
|
61
56
|
|
62
57
|
it "format to_json" do
|
@@ -65,7 +60,7 @@ describe Keoken do
|
|
65
60
|
eq(
|
66
61
|
[
|
67
62
|
{
|
68
|
-
"value" => "
|
63
|
+
"value" => "0.08752190",
|
69
64
|
"scriptPubKey" => "OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG",
|
70
65
|
},
|
71
66
|
{
|
@@ -79,13 +74,13 @@ describe Keoken do
|
|
79
74
|
|
80
75
|
it "raw transaction" do
|
81
76
|
raw = @transaction_token.raw
|
82
|
-
expect(raw).to start_with("
|
77
|
+
expect(raw).to start_with("0100000001dae8143d5422d5e1018c43732baa74ac3114d4399a1f58a9ea7e31f656938a44010000006")
|
83
78
|
expect(raw).to end_with("6a0400004b501800000000746573742d6b656f6b656e00000000000100000000000000")
|
84
79
|
end
|
85
80
|
|
86
81
|
it "broadcast transaction" do
|
87
|
-
stub_request(:post, "
|
88
|
-
.with(:body => {"rawtx" => /
|
82
|
+
stub_request(:post, "https://tbch.blockdozer.com/insight-api/tx/send")
|
83
|
+
.with(:body => {"rawtx" => /0100000001dae8143d5422d5e1018c43732baa74ac3114d4399a1f58a9ea7e31f656938a44010000006/},
|
89
84
|
headers: {
|
90
85
|
"Accept" => "*/*",
|
91
86
|
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
@@ -93,35 +88,23 @@ describe Keoken do
|
|
93
88
|
"Host" => "tbch.blockdozer.com",
|
94
89
|
"User-Agent" => "Ruby",
|
95
90
|
})
|
96
|
-
.to_return(status: 200, body: "", headers: {})
|
91
|
+
.to_return(status: 200, body: "{\"txid\":\"f410c773d079327b8283c175b08a84faa6ffcfbde40b5939b85f07f0dfde2eb8\"}", headers: {})
|
97
92
|
transaction = Keoken::Bitprim::Transaction.new
|
98
|
-
expect(transaction.send_tx(@transaction_token.raw)).to
|
93
|
+
expect(transaction.send_tx(@transaction_token.raw)).to eq({"txid" => "f410c773d079327b8283c175b08a84faa6ffcfbde40b5939b85f07f0dfde2eb8"})
|
99
94
|
end
|
100
95
|
end
|
101
96
|
|
102
97
|
describe "send money token" do
|
103
98
|
before(:each) do
|
99
|
+
mock_requests
|
104
100
|
Bitcoin.network = :testnet3
|
105
|
-
|
101
|
+
bitprim_transaction = Keoken::Bitprim::Transaction.new
|
102
|
+
assets = bitprim_transaction.assets_by_address('mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA')
|
103
|
+
token = Keoken::Token.new(id: assets.first['asset_id'])
|
106
104
|
token.send_amount(500_000)
|
107
|
-
|
108
|
-
input_script = "76a9147bb97684cc43e2f8ea0ed1d50dddce3ebf80063888ac"
|
109
|
-
position = 0
|
105
|
+
key = Bitcoin::Key.from_base58('cShKfHoHVf6iKKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2oxBU')
|
110
106
|
script = token.hex
|
111
|
-
|
112
|
-
output_amount = 4_9991_0000
|
113
|
-
output_amount_address = 20_000
|
114
|
-
output_address = "mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi"
|
115
|
-
key = Bitcoin::Key.from_base58("cShKfHoHVf6iKKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2oxBU")
|
116
|
-
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.send_amount(tx_id,
|
117
|
-
position,
|
118
|
-
input_script,
|
119
|
-
input_amount,
|
120
|
-
output_amount,
|
121
|
-
output_amount_address,
|
122
|
-
output_address,
|
123
|
-
key,
|
124
|
-
script)
|
107
|
+
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.build_for_send_amount(key.addr, 'mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi', key, script)
|
125
108
|
end
|
126
109
|
|
127
110
|
it "format to_json" do
|
@@ -130,16 +113,16 @@ describe Keoken do
|
|
130
113
|
eq(
|
131
114
|
[
|
132
115
|
{
|
133
|
-
"value" => "0.
|
116
|
+
"value" => "0.00269544",
|
134
117
|
"scriptPubKey" => "OP_DUP OP_HASH160 4c2791f07c046ef21d688f12296f91ad7b44d2bb OP_EQUALVERIFY OP_CHECKSIG",
|
135
118
|
},
|
136
119
|
{
|
137
|
-
"value" => "
|
120
|
+
"value" => "0.08446911",
|
138
121
|
"scriptPubKey" => "OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG",
|
139
122
|
},
|
140
123
|
{
|
141
124
|
"value" => "0.00000000",
|
142
|
-
"scriptPubKey" => "OP_RETURN 00004b50
|
125
|
+
"scriptPubKey" => "OP_RETURN 00004b50 00000001000001230000000000500000",
|
143
126
|
},
|
144
127
|
]
|
145
128
|
)
|
@@ -148,42 +131,41 @@ describe Keoken do
|
|
148
131
|
|
149
132
|
it "raw transaction" do
|
150
133
|
raw = @transaction_token.raw
|
151
|
-
expect(raw).to start_with("
|
152
|
-
expect(raw).to end_with("
|
134
|
+
expect(raw).to start_with("0100000001dae8143d5422d5e1018c43732baa74ac3114d4399a1f58a9ea7e31f656938a4401000000")
|
135
|
+
expect(raw).to end_with("6a0400004b50100000000100000123000000000050000000000000")
|
153
136
|
end
|
154
137
|
end
|
138
|
+
end
|
155
139
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
it "get assets by address mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi" do
|
162
|
-
body_response = "[{'amount': 100000, 'asset_creator': 'mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi', 'asset_id': 123, 'asset_name': 'keoken-token'}]"
|
163
|
-
stub_request(:get, "https://explorer.testnet.keoken.io/api/get_assets_by_address?address=mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi")
|
164
|
-
.with(
|
165
|
-
headers: {
|
140
|
+
def mock_requests
|
141
|
+
body_request = "[{\"address\":\"mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA\",\"txid\":\"448a9356f6317eeaa9581f9a39d41431ac74aa2b73438c01e1d522543d14e8da\",\"vout\":1,\"scriptPubKey\":\"76a9147bb97684cc43e2f8ea0ed1d50dddce3ebf80063888ac\",\"amount\":0.08985999,\"satoshis\":8985999,\"height\":1282589,\"confirmations\":1356}]"
|
142
|
+
stub_request(:get, "https://tbch.blockdozer.com/insight-api/addr/mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA/utxo").
|
143
|
+
with(:headers => {
|
166
144
|
"Accept" => "*/*",
|
167
145
|
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
168
|
-
"Host" => "
|
146
|
+
"Host" => "tbch.blockdozer.com",
|
169
147
|
"User-Agent" => "Ruby",
|
170
|
-
}
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
148
|
+
}).
|
149
|
+
to_return(:status => 200, :body => body_request, :headers => {})
|
150
|
+
|
151
|
+
body_request = "{\"txid\":\"448a9356f6317eeaa9581f9a39d41431ac74aa2b73438c01e1d522543d14e8da\",\"version\":1,\"locktime\":0,\"vin\":[{\"txid\":\"48c158109ca432e109971ca61e4bccbdc2b51053c02f8183f5ca7f60a55df4d0\",\"vout\":0,\"sequence\":4294967295,\"n\":0,\"scriptSig\":{\"hex\":\"483045022100a64b8798d783d1fb7ea306cfdc2aa09cae972cbfed3fcd92a4501e54035f869b022004da604a3dd52cecd8b89200065b96bdf7c3684e6ec983ed3dceed1bf8d3a480412102bd2af43b8c683f7bb5c5dc4aad7c5a2961252676d85c2547de9767e1a6252455\",\"asm\":\"3045022100a64b8798d783d1fb7ea306cfdc2aa09cae972cbfed3fcd92a4501e54035f869b022004da604a3dd52cecd8b89200065b96bdf7c3684e6ec983ed3dceed1bf8d3a480[ALL|FORKID] 02bd2af43b8c683f7bb5c5dc4aad7c5a2961252676d85c2547de9767e1a6252455\"},\"addr\":\"mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA\",\"valueSat\":9991999,\"value\":0.09991999,\"doubleSpentTxID\":null}],\"vout\":[{\"value\":\"0.01000000\",\"n\":0,\"scriptPubKey\":{\"hex\":\"76a9141a53f3efae04708754ca1c5382085249c0ff597d88ac\",\"asm\":\"OP_DUP OP_HASH160 1a53f3efae04708754ca1c5382085249c0ff597d OP_EQUALVERIFY OP_CHECKSIG\",\"addresses\":[\"mhvASBxPioT6eLPtSA5u1SNoT49RsME3BJ\"],\"type\":\"pubkeyhash\"},\"spentTxId\":null,\"spentIndex\":null,\"spentHeight\":null},{\"value\":\"0.08985999\",\"n\":1,\"scriptPubKey\":{\"hex\":\"76a9147bb97684cc43e2f8ea0ed1d50dddce3ebf80063888ac\",\"asm\":\"OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG\",\"addresses\":[\"mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA\"],\"type\":\"pubkeyhash\"},\"spentTxId\":null,\"spentIndex\":null,\"spentHeight\":null},{\"value\":\"0.00000000\",\"n\":2,\"scriptPubKey\":{\"hex\":\"6a0400004b501000000001000000170000000000000064\",\"asm\":\"OP_RETURN 1347092480 00000001000000170000000000000064\"},\"spentTxId\":null,\"spentIndex\":null,\"spentHeight\":null}],\"blockhash\":\"0000000000009505e41c238f88f5c9b5591e92f7eb68545962a5dd71cd075525\",\"blockheight\":1282589,\"confirmations\":1356,\"time\":1548360176,\"blocktime\":1548360176,\"valueOut\":0.09985999,\"size\":258,\"valueIn\":0.09991999,\"fees\":0.00006}"
|
152
|
+
stub_request(:get, "https://tbch.blockdozer.com/insight-api/tx/448a9356f6317eeaa9581f9a39d41431ac74aa2b73438c01e1d522543d14e8da").
|
153
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'tbch.blockdozer.com', 'User-Agent'=>'Ruby'}).
|
154
|
+
to_return(:status => 200, :body => body_request, :headers => {})
|
155
|
+
|
156
|
+
stub_request(:get, "https://tbch.blockdozer.com/insight-api/utils/estimatefee").
|
157
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'tbch.blockdozer.com', 'User-Agent'=>'Ruby'}).
|
158
|
+
to_return(:status => 200, :body => "{\"2\":0.0001021}", :headers => {})
|
159
|
+
|
160
|
+
body_response = "[{'amount': 100000, 'asset_creator': 'mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA', 'asset_id': 123, 'asset_name': 'keoken-token'}]"
|
161
|
+
stub_request(:get, "https://explorer.testnet.keoken.io/api/get_assets_by_address?address=mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA")
|
162
|
+
.with(
|
163
|
+
headers: {
|
164
|
+
"Accept" => "*/*",
|
165
|
+
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
166
|
+
"Host" => "explorer.testnet.keoken.io",
|
167
|
+
"User-Agent" => "Ruby",
|
168
|
+
},
|
169
|
+
)
|
170
|
+
.to_return(status: 200, body: body_response, headers: {})
|
189
171
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keoken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bitex
|
@@ -117,10 +117,39 @@ files:
|
|
117
117
|
- ".gitignore"
|
118
118
|
- ".rspec"
|
119
119
|
- ".travis.yml"
|
120
|
+
- ".yardoc/checksums"
|
121
|
+
- ".yardoc/complete"
|
122
|
+
- ".yardoc/object_types"
|
123
|
+
- ".yardoc/objects/root.dat"
|
124
|
+
- ".yardoc/proxy_types"
|
120
125
|
- Gemfile
|
121
126
|
- Gemfile.lock
|
122
127
|
- README.md
|
123
128
|
- Rakefile
|
129
|
+
- doc/Bitcoin/Script.html
|
130
|
+
- doc/Keoken.html
|
131
|
+
- doc/Keoken/Backend.html
|
132
|
+
- doc/Keoken/Backend/BitcoinRuby.html
|
133
|
+
- doc/Keoken/Backend/BitcoinRuby/Transaction.html
|
134
|
+
- doc/Keoken/Bitprim.html
|
135
|
+
- doc/Keoken/Bitprim/Transaction.html
|
136
|
+
- doc/Keoken/IdNotFound.html
|
137
|
+
- doc/Keoken/NameNotFound.html
|
138
|
+
- doc/Keoken/Token.html
|
139
|
+
- doc/_index.html
|
140
|
+
- doc/class_list.html
|
141
|
+
- doc/css/common.css
|
142
|
+
- doc/css/full_list.css
|
143
|
+
- doc/css/style.css
|
144
|
+
- doc/file.README.html
|
145
|
+
- doc/file_list.html
|
146
|
+
- doc/frames.html
|
147
|
+
- doc/index.html
|
148
|
+
- doc/js/app.js
|
149
|
+
- doc/js/full_list.js
|
150
|
+
- doc/js/jquery.js
|
151
|
+
- doc/method_list.html
|
152
|
+
- doc/top-level-namespace.html
|
124
153
|
- keoken.gemspec
|
125
154
|
- lib/keoken.rb
|
126
155
|
- lib/keoken/backend/bitcoin_ruby/transaction.rb
|
@@ -128,6 +157,7 @@ files:
|
|
128
157
|
- lib/keoken/bitprim/transaction.rb
|
129
158
|
- lib/keoken/errors/id_not_found.rb
|
130
159
|
- lib/keoken/errors/name_not_found.rb
|
160
|
+
- lib/keoken/errors/output_not_found.rb
|
131
161
|
- lib/keoken/extensions/bitcoin/script.rb
|
132
162
|
- lib/keoken/token.rb
|
133
163
|
- lib/keoken/version.rb
|