xgt-ruby 0.1.3 → 0.1.4
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/.gitignore +2 -0
- data/Dockerfile +33 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +11 -5
- data/exe/xgt-wallet +135 -54
- data/lib/xgt/ruby/version.rb +1 -1
- data/xgt-ruby.gemspec +1 -1
- metadata +4 -6
- data/bin/.wallet.swp +0 -0
- data/bin/setup +0 -8
- data/lib/xgt/.ruby.rb.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d47a02d26c207945df14673e959a9c788814c9b1614d1ab937752dd2129b48
|
4
|
+
data.tar.gz: 027ea4b161bd535eb46b90eda33dc1d6ca573ee75ca4fa5790d0e7f0a914d7b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a497619dc1e6a1385905ee2eb9203bffe71db467280ec6c4768eb038b170846ab8413ef9d5bfd96a8a3d05a56644b721f22d0664069ea532aa8f23e71bf51c
|
7
|
+
data.tar.gz: '0503416839a39f1dde3f50fa871d17eaacc7a07ca1b7931d7cbc2b48a24ae3dc088220016081df7a1fdf04272dd6bc85d3629ea94ede7bf55fe38c948d4e94db'
|
data/.gitignore
CHANGED
data/Dockerfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
FROM ubuntu:20.04
|
2
|
+
|
3
|
+
WORKDIR /home/root
|
4
|
+
|
5
|
+
ENV DEBIAN_FRONTEND="noninteractive"
|
6
|
+
|
7
|
+
RUN apt-get clean && apt-get update
|
8
|
+
|
9
|
+
RUN apt-get install -y git curl build-essential
|
10
|
+
RUN apt-get install -y libssl-dev zlib1g-dev
|
11
|
+
|
12
|
+
RUN git clone https://github.com/sstephenson/rbenv.git /root/.rbenv
|
13
|
+
RUN git clone https://github.com/sstephenson/ruby-build.git /root/.rbenv/plugins/ruby-build
|
14
|
+
RUN /root/.rbenv/plugins/ruby-build/install.sh
|
15
|
+
ENV PATH /root/.rbenv/bin:$PATH
|
16
|
+
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh # or /etc/profile
|
17
|
+
RUN echo 'eval "$(rbenv init -)"' >> .bashrc
|
18
|
+
ENV CONFIGURE_OPTS --disable-install-doc
|
19
|
+
RUN rbenv install 2.7.2
|
20
|
+
RUN rbenv global 2.7.2
|
21
|
+
RUN rbenv rehash
|
22
|
+
|
23
|
+
RUN ["/bin/bash", "-c", "source /home/root/.bashrc && gem update --system"]
|
24
|
+
RUN ["/bin/bash", "-c", "source /home/root/.bashrc && gem install bundler rake"]
|
25
|
+
RUN ["/bin/bash", "-c", "source /home/root/.bashrc && rbenv rehash"]
|
26
|
+
|
27
|
+
COPY . /home/root/xgt-ruby
|
28
|
+
|
29
|
+
RUN ["/bin/bash", "-c", "source /home/root/.bashrc && cd xgt-ruby && bundle"]
|
30
|
+
|
31
|
+
CMD ["/bin/bash", "-c", "source /home/root/.bashrc && cd xgt-ruby && ./exe/xgt-wallet"]
|
32
|
+
|
33
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/raggi/bitcoin-ruby
|
3
|
+
revision: ee22140522b1ee75a363ff7aaa56d1925d5bde9d
|
4
|
+
specs:
|
5
|
+
bitcoin-ruby (0.0.20)
|
6
|
+
eventmachine
|
7
|
+
ffi
|
8
|
+
scrypt
|
9
|
+
|
1
10
|
PATH
|
2
11
|
remote: .
|
3
12
|
specs:
|
@@ -11,17 +20,13 @@ GEM
|
|
11
20
|
remote: https://rubygems.org/
|
12
21
|
specs:
|
13
22
|
base58 (0.2.3)
|
14
|
-
bitcoin-ruby (0.0.20)
|
15
|
-
eventmachine
|
16
|
-
ffi
|
17
|
-
scrypt
|
18
23
|
diff-lcs (1.3)
|
19
24
|
eventmachine (1.2.7)
|
20
25
|
faraday (0.15.4)
|
21
26
|
multipart-post (>= 1.2, < 3)
|
22
27
|
faraday_middleware (0.13.1)
|
23
28
|
faraday (>= 0.7.4, < 1.0)
|
24
|
-
ffi (1.15.
|
29
|
+
ffi (1.15.1)
|
25
30
|
ffi-compiler (1.0.1)
|
26
31
|
ffi (>= 1.0.0)
|
27
32
|
rake
|
@@ -47,6 +52,7 @@ PLATFORMS
|
|
47
52
|
ruby
|
48
53
|
|
49
54
|
DEPENDENCIES
|
55
|
+
bitcoin-ruby!
|
50
56
|
bundler (~> 2.0)
|
51
57
|
rake (~> 13.0.3)
|
52
58
|
rspec (~> 3.0)
|
data/exe/xgt-wallet
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'logger'
|
4
|
-
require 'bundler/setup'
|
5
3
|
require 'xgt/ruby'
|
4
|
+
require 'logger'
|
6
5
|
require 'bigdecimal'
|
7
6
|
|
8
7
|
# ------
|
@@ -120,12 +119,14 @@ def rpc
|
|
120
119
|
Xgt::Ruby::Rpc.new(@host)
|
121
120
|
end
|
122
121
|
|
122
|
+
=begin
|
123
123
|
def chain_properties
|
124
124
|
return @chain_properties if @chain_properties
|
125
125
|
witness_schedule = rpc.call('database_api.get_witness_schedule', {}) || {}
|
126
126
|
@chain_properties = witness_schedule['median_props']
|
127
127
|
@chain_properties
|
128
128
|
end
|
129
|
+
=end
|
129
130
|
|
130
131
|
def config
|
131
132
|
return @config if @config
|
@@ -134,25 +135,15 @@ def config
|
|
134
135
|
end
|
135
136
|
|
136
137
|
def address_prefix
|
137
|
-
return
|
138
|
-
@address_prefix = config['XGT_ADDRESS_PREFIX']
|
139
|
-
logger.info(%(Retrieved address prefix... #{@address_prefix}))
|
140
|
-
@address_prefix
|
138
|
+
return "XGT"
|
141
139
|
end
|
142
140
|
|
143
141
|
def chain_id
|
144
|
-
|
145
|
-
@chain_id = config['XGT_CHAIN_ID']
|
146
|
-
logger.info(%(Retrieved chain ID... #{@chain_id}))
|
147
|
-
@chain_id
|
142
|
+
"4e08b752aff5f66e1339cb8c0a8bca14c4ebb238655875db7dade86349091197"
|
148
143
|
end
|
149
144
|
|
150
145
|
def precision
|
151
|
-
8
|
152
|
-
end
|
153
|
-
|
154
|
-
def fee
|
155
|
-
(chain_properties['account_creation_fee'] || {})['amount']
|
146
|
+
8
|
156
147
|
end
|
157
148
|
|
158
149
|
def currency_symbol
|
@@ -196,7 +187,7 @@ def info
|
|
196
187
|
print(%(\n))
|
197
188
|
puts(%(You can get an Xgt::Ruby::Rpc instance via `rpc`.))
|
198
189
|
print(%(\n))
|
199
|
-
puts(%(Any method in `
|
190
|
+
puts(%(Any method in `xgt-wallet` is available from this CLI, so take a look!))
|
200
191
|
print(%(\n))
|
201
192
|
true
|
202
193
|
end
|
@@ -229,7 +220,7 @@ def create_wallet
|
|
229
220
|
'type' => 'wallet_create_operation',
|
230
221
|
'value' => {
|
231
222
|
'fee' => {
|
232
|
-
'amount' =>
|
223
|
+
'amount' => '0',
|
233
224
|
'precision' => precision,
|
234
225
|
'nai' => '@@000000021'
|
235
226
|
},
|
@@ -255,6 +246,10 @@ def create_wallet
|
|
255
246
|
}]
|
256
247
|
}
|
257
248
|
|
249
|
+
output_result
|
250
|
+
|
251
|
+
p current_wifs
|
252
|
+
|
258
253
|
id = rpc.broadcast_transaction(txn, current_wifs, chain_id)
|
259
254
|
(puts 'Waiting...' or sleep 1) until fetch_wallet_name(current_name)
|
260
255
|
|
@@ -265,6 +260,92 @@ def create_wallet
|
|
265
260
|
true
|
266
261
|
end
|
267
262
|
|
263
|
+
require 'net/http'
|
264
|
+
require 'json'
|
265
|
+
|
266
|
+
def create_mining_wallet
|
267
|
+
master = Xgt::Ruby::Auth.random_wif
|
268
|
+
recovery_private = Xgt::Ruby::Auth.generate_wif("33", master, 'recovery')
|
269
|
+
recovery_public = Xgt::Ruby::Auth.wif_to_public_key(recovery_private, address_prefix)
|
270
|
+
wallet_name = Xgt::Ruby::Auth.generate_wallet_name(recovery_public)
|
271
|
+
|
272
|
+
keys = generate_keys(wallet_name, recovery_private)
|
273
|
+
payload = {
|
274
|
+
'keys' => {
|
275
|
+
'wallet_name' => keys['wallet_name'],
|
276
|
+
'recovery_public' => keys['recovery_public'],
|
277
|
+
'money_public' => keys['money_public'],
|
278
|
+
'social_public' => keys['social_public'],
|
279
|
+
'memo_public' => keys['memo_public'],
|
280
|
+
}
|
281
|
+
}
|
282
|
+
host = ENV['XGT_FIRESTARTER_HOST'] || "http://firestarter.api.xgt.network"
|
283
|
+
uri = URI(host + "/wallet")
|
284
|
+
|
285
|
+
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
286
|
+
req.body = JSON.dump(payload)
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
291
|
+
http.request(req)
|
292
|
+
end
|
293
|
+
|
294
|
+
register_miner(keys["wallet_name"], keys["recovery_private"], keys["recovery_public"])
|
295
|
+
|
296
|
+
|
297
|
+
# output_result(response)
|
298
|
+
# @last_result = response
|
299
|
+
p "sudo docker run --publish 8751:8751 --publish 2001:2001 --env XGT_WALLET=#{keys["wallet_name"]} --env XGT_RECOVERY_PRIVATE_KEY=#{keys["recovery_private"]} --env XGT_HOST=98.33.76.100:2011 rjungemann/xgt:0.0.1"
|
300
|
+
output_result({ 'keys' => keys, 'body' => response.body })
|
301
|
+
|
302
|
+
true
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
def register_miner(registrant_wallet_name, recovery_private, recovery_public)
|
307
|
+
# name = wallet_name.call
|
308
|
+
# raise %(Matching wallet named "#{name}" doesn't already exist!) unless name
|
309
|
+
|
310
|
+
# components = fee.split(' ')
|
311
|
+
# decimal = BigDecimal(components.first) * 1
|
312
|
+
# final_fee = decimal.truncate.to_s + '.' + sprintf('%03d', (decimal.frac * 1000).truncate) + ' ' + components.last
|
313
|
+
|
314
|
+
# raise 'Witness already registered!' if does_witness_exist.call
|
315
|
+
|
316
|
+
txn = {
|
317
|
+
'extensions' => [],
|
318
|
+
'operations' => [{
|
319
|
+
'type' => 'witness_update_operation',
|
320
|
+
'value' => {
|
321
|
+
'owner' => registrant_wallet_name,
|
322
|
+
'url' => 'http://test.host',
|
323
|
+
# 'block_signing_key' => keys.call['recovery_public'],
|
324
|
+
'block_signing_key' => recovery_public,
|
325
|
+
'props' => {
|
326
|
+
# 'account_creation_fee' => fee,
|
327
|
+
# 'wallet_creation_fee' => '0 ',
|
328
|
+
'account_creation_fee' => {"amount":"0","precision":8,"nai":"@@000000021"}
|
329
|
+
},
|
330
|
+
# 'fee' => final_fee,
|
331
|
+
# 'fee' => 0,
|
332
|
+
'fee' => {"amount":"0","precision":8,"nai":"@@000000021"}
|
333
|
+
}
|
334
|
+
}]
|
335
|
+
}
|
336
|
+
p txn
|
337
|
+
response = rpc.broadcast_transaction(txn, [recovery_private], chain_id)
|
338
|
+
p response
|
339
|
+
# output_result(response)
|
340
|
+
@last_result = response
|
341
|
+
true
|
342
|
+
# signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [keys.call['recovery_private']], chain_id)
|
343
|
+
# $stderr.puts(%(Registering witness with recovery private WIF "#{keys.call['recovery_private']}"...))
|
344
|
+
# $stderr.puts(%(Signing keypair is #{keys.call['witness_private']} (private) and #{keys.call['witness_public']} (public)...))
|
345
|
+
# response = rpc.call('transaction_api.broadcast_transaction', [signed])
|
346
|
+
end
|
347
|
+
|
348
|
+
|
268
349
|
def list_wallets(name=nil)
|
269
350
|
enumerator = Enumerator.new do |yielder|
|
270
351
|
last_name = name
|
@@ -396,43 +477,43 @@ end
|
|
396
477
|
|
397
478
|
def start_console
|
398
479
|
require 'irb'
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
480
|
+
ARGV.clear
|
481
|
+
IRB.setup nil
|
482
|
+
|
483
|
+
IRB.conf[:PROMPT] = {}
|
484
|
+
IRB.conf[:IRB_NAME] = 'wallet'
|
485
|
+
IRB.conf[:PROMPT][:WALLET] = {
|
486
|
+
:PROMPT_I => '%N>> ',
|
487
|
+
:PROMPT_N => '%N>> ',
|
488
|
+
:PROMPT_S => '%N%l> ',
|
489
|
+
:PROMPT_C => '%N*> ',
|
490
|
+
:RETURN => "#=> %s\n"
|
491
|
+
}
|
492
|
+
IRB.conf[:PROMPT_MODE] = :WALLET
|
493
|
+
IRB.conf[:RC] = false
|
494
|
+
|
495
|
+
require 'irb/completion'
|
496
|
+
require 'irb/ext/save-history'
|
497
|
+
IRB.conf[:READLINE] = true
|
498
|
+
|
499
|
+
irb = IRB::Irb.new(IRB::WorkSpace.new(self))
|
500
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
501
|
+
|
502
|
+
trap('SIGINT') do
|
503
|
+
IRB.irb.signal_handle
|
504
|
+
end
|
505
|
+
|
506
|
+
begin
|
507
|
+
catch(:IRB_EXIT) do
|
508
|
+
irb.eval_input
|
509
|
+
end
|
510
|
+
ensure
|
511
|
+
IRB.irb_at_exit
|
512
|
+
end
|
432
513
|
end
|
433
514
|
|
434
515
|
# Allows for this file to be run as a script or loaded as a library.
|
435
|
-
|
436
|
-
puts logo
|
437
|
-
start_console
|
438
|
-
|
516
|
+
if File.basename(__FILE__) == File.basename($0)
|
517
|
+
puts logo
|
518
|
+
start_console
|
519
|
+
end
|
data/lib/xgt/ruby/version.rb
CHANGED
data/xgt-ruby.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
# Specify which files should be added to the gem when it is released.
|
16
16
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
17
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|test|spec|features)/}) }
|
19
19
|
end
|
20
20
|
spec.bindir = 'exe'
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xgt-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Jungemann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,13 +120,12 @@ files:
|
|
120
120
|
- ".rspec"
|
121
121
|
- ".travis.yml"
|
122
122
|
- CODE_OF_CONDUCT.md
|
123
|
+
- Dockerfile
|
123
124
|
- Gemfile
|
124
125
|
- Gemfile.lock
|
125
126
|
- LICENSE.txt
|
126
127
|
- README.md
|
127
128
|
- Rakefile
|
128
|
-
- bin/.wallet.swp
|
129
|
-
- bin/setup
|
130
129
|
- examples/api/account_by_key_api/get_key_references.rb
|
131
130
|
- examples/api/account_history_api/deprecated/enum_virtual_ops.rb
|
132
131
|
- examples/api/account_history_api/deprecated/get_transaction.rb
|
@@ -230,7 +229,6 @@ files:
|
|
230
229
|
- examples/operations/in_progress/escrow_approve.rb
|
231
230
|
- examples/operations/in_progress/witness_set_properties.rb
|
232
231
|
- exe/xgt-wallet
|
233
|
-
- lib/xgt/.ruby.rb.swp
|
234
232
|
- lib/xgt/ruby.rb
|
235
233
|
- lib/xgt/ruby/version.rb
|
236
234
|
- payloads.txt
|
@@ -256,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
254
|
- !ruby/object:Gem::Version
|
257
255
|
version: '0'
|
258
256
|
requirements: []
|
259
|
-
rubygems_version: 3.
|
257
|
+
rubygems_version: 3.1.4
|
260
258
|
signing_key:
|
261
259
|
specification_version: 4
|
262
260
|
summary: XGT client library
|
data/bin/.wallet.swp
DELETED
Binary file
|
data/bin/setup
DELETED
data/lib/xgt/.ruby.rb.swp
DELETED
Binary file
|