xgt-ruby 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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/.wallet.swp +0 -0
- data/bin/setup +8 -0
- data/bin/wallet +438 -0
- data/examples/api/account_by_key_api/get_key_references.rb +18 -0
- data/examples/api/account_history_api/deprecated/enum_virtual_ops.rb +15 -0
- data/examples/api/account_history_api/deprecated/get_transaction.rb +12 -0
- data/examples/api/account_history_api/get_account_history.rb +16 -0
- data/examples/api/account_history_api/get_ops_in_block.rb +17 -0
- data/examples/api/chain_api/deprecated/dummy_code.rb +65 -0
- data/examples/api/chain_api/deprecated/push_block.rb +20 -0
- data/examples/api/database_api/accounts/find_accounts.rb +16 -0
- data/examples/api/database_api/accounts/list_accounts.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/find_account_recovery_requests.rb +16 -0
- data/examples/api/database_api/accounts/not_supported/find_change_recovery_account_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_decline_voting_rights_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_escrows.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_sbd_conversion_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_vesting_delegation_expirations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_vesting_delegations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_withdraw_vesting_routes.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_account_recovery_requests.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_change_recovery_account_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_decline_voting_rights_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_escrows.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_recovery_histories.rb +17 -0
- data/examples/api/database_api/accounts/not_supported/list_sbd_conversion_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_vesting_delegation_expirations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_vesting_delegations.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_withdraw_vesting_routes.rb +18 -0
- data/examples/api/database_api/authority/not_supported/find_smt_contributions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_token_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_token_emissions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_tokens.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_nai_pool.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_potential_signatures.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_required_signatures.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_smt_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_transaction_hex.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_contributions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_token_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_token_emissions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_tokens.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_account_authority.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_authority.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_signatures.rb +0 -0
- data/examples/api/database_api/comments/not_supported/find_comments.rb +0 -0
- data/examples/api/database_api/comments/not_supported/find_votes.rb +0 -0
- data/examples/api/database_api/comments/not_supported/list_comments.rb +0 -0
- data/examples/api/database_api/comments/not_supported/list_votes.rb +0 -0
- data/examples/api/database_api/globals/get_config.rb +14 -0
- data/examples/api/database_api/globals/get_dynamic_global_properties.rb +14 -0
- data/examples/api/database_api/globals/get_hardfork_properties.rb +14 -0
- data/examples/api/database_api/globals/get_reward_funds.rb +14 -0
- data/examples/api/database_api/globals/get_version.rb +15 -0
- data/examples/api/database_api/globals/get_witness_schedule.rb +14 -0
- data/examples/api/database_api/market/not_supported/find_limit_orders.rb +0 -0
- data/examples/api/database_api/market/not_supported/get_order_book.rb +0 -0
- data/examples/api/database_api/market/not_supported/list_limit_orders.rb +0 -0
- data/examples/api/database_api/sps/not_supported/find_proposals.rb +0 -0
- data/examples/api/database_api/sps/not_supported/list_proposal_votes.rb +0 -0
- data/examples/api/database_api/sps/not_supported/list_proposals.rb +0 -0
- data/examples/api/database_api/witnesses/deprecated/get_round.rb +14 -0
- data/examples/api/database_api/witnesses/find_witnesses.rb +16 -0
- data/examples/api/database_api/witnesses/get_active_witnesses.rb +14 -0
- data/examples/api/database_api/witnesses/list_witnesses.rb +17 -0
- data/examples/api/database_api/witnesses/not_supported/list_witness_votes.rb +16 -0
- data/examples/api/extras/get_balance.rb +27 -0
- data/examples/api/network_broadcast_api/broadcast_transaction.rb +16 -0
- data/examples/api/network_broadcast_api/broadcast_transaction_synchronous.rb +15 -0
- data/examples/api/network_broadcast_api/create_wallet.rb +79 -0
- data/examples/api/network_broadcast_api/dummy_code.rb +68 -0
- data/examples/api/network_broadcast_api/get_transaction_hex.rb +17 -0
- data/examples/api/network_broadcast_api/not_supported/broadcast_block.rb +17 -0
- data/examples/api/network_broadcast_api/transfer.rb +45 -0
- data/examples/api/payloads.txt +3580 -0
- data/examples/api/transaction_status_api/find_transaction.rb +16 -0
- data/examples/operations/broadcast_transaction_synchronous.rb +16 -0
- data/examples/operations/completed/account_create.rb +79 -0
- data/examples/operations/completed/account_witness_proxy.rb +29 -0
- data/examples/operations/completed/account_witness_vote.rb +31 -0
- data/examples/operations/completed/claim_account.rb +33 -0
- data/examples/operations/completed/create_claimed_account.rb +62 -0
- data/examples/operations/completed/custom.rb +31 -0
- data/examples/operations/completed/custom_json.rb +32 -0
- data/examples/operations/completed/decline_voting_rights.rb +30 -0
- data/examples/operations/completed/delegate_some_vesting_shares.rb +32 -0
- data/examples/operations/completed/set_withdraw_vesting_route.rb +32 -0
- data/examples/operations/completed/transfer.rb +44 -0
- data/examples/operations/completed/transfer_to_vesting.rb +32 -0
- data/examples/operations/completed/update_proposal_votes.rb +31 -0
- data/examples/operations/completed/withdraw_vesting.rb +30 -0
- data/examples/operations/completed/witness_update.rb +64 -0
- data/examples/operations/deprecated/account_update.rb +44 -0
- data/examples/operations/deprecated/cancel_transfer_from_savings.rb +30 -0
- data/examples/operations/deprecated/challenge_authority.rb +28 -0
- data/examples/operations/deprecated/claim_reward_balance.rb +35 -0
- data/examples/operations/deprecated/convert.rb +38 -0
- data/examples/operations/deprecated/custom_binary.rb +31 -0
- data/examples/operations/deprecated/feed_publish.rb +33 -0
- data/examples/operations/do_later/change_recovery_account.rb +31 -0
- data/examples/operations/do_later/claim_reward_balance2.rb +37 -0
- data/examples/operations/do_later/remove_proposal_votes.rb +0 -0
- data/examples/operations/in_progress/create_proposal.rb +40 -0
- data/examples/operations/in_progress/escrow_approve.rb +36 -0
- data/examples/operations/in_progress/witness_set_properties.rb +62 -0
- data/lib/xgt/.ruby.rb.swp +0 -0
- data/lib/xgt/ruby.rb +200 -0
- data/lib/xgt/ruby/version.rb +5 -0
- data/payloads.txt +461 -0
- data/sample.rb +41 -0
- data/sample2.rb +104 -0
- data/xgt-ruby.gemspec +31 -0
- metadata +262 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def transfer_to_vesting
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config['XGT_CHAIN_ID']
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"transfer_to_vesting",
|
|
15
|
+
{
|
|
16
|
+
"from": "XGT0000000000000",
|
|
17
|
+
"to": "XGT0000000000000",
|
|
18
|
+
"amount": "1000.000 XGT",
|
|
19
|
+
"precision": 3,
|
|
20
|
+
"nai": "@@000000021"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
27
|
+
puts JSON.pretty_generate(signed)
|
|
28
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
29
|
+
puts JSON.pretty_generate(response)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
transfer_to_vesting
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def update_proposal_votes
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"update_proposal_votes",
|
|
15
|
+
{
|
|
16
|
+
"voter": "XGT0000000000000",
|
|
17
|
+
"proposal_ids": [0],
|
|
18
|
+
"approve": true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
25
|
+
puts JSON.pretty_generate(signed)
|
|
26
|
+
puts "\n\n"
|
|
27
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
28
|
+
puts JSON.pretty_generate(response)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
update_proposal_votes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def withdraw_vesting
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"withdraw_vesting",
|
|
15
|
+
{
|
|
16
|
+
"account": "XGT0000000000000",
|
|
17
|
+
"vesting_shares": "1.000000 VESTS",
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
24
|
+
puts JSON.pretty_generate(signed)
|
|
25
|
+
puts "\n\n"
|
|
26
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
27
|
+
puts JSON.pretty_generate(response)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
withdraw_vesting
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
require 'erb'
|
|
3
|
+
require 'pp'
|
|
4
|
+
require 'benchmark'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
require 'bigdecimal'
|
|
7
|
+
require 'uri'
|
|
8
|
+
require'xgt/ruby'
|
|
9
|
+
|
|
10
|
+
def msg(message)
|
|
11
|
+
puts "\e[36m#{message}\e[0m"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def witness_update
|
|
15
|
+
rpc = Xgt::Ruby::Rpc.new("http://localhost:8751")
|
|
16
|
+
recovery_wif = '5Kgsi9os8SG8kdg3ZVb4gjWnZhXYb4xLoYFEkQEWLkzodahY2dn'
|
|
17
|
+
config = rpc.call('database_api.get_config', {})
|
|
18
|
+
witness_schedule = rpc.call('database_api.get_witness_schedule', {}) || {}
|
|
19
|
+
chain_properties = witness_schedule['median_props']
|
|
20
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
21
|
+
chain_id = config['XGT_CHAIN_ID']
|
|
22
|
+
signing_private = '5Kgsi9os8SG8kdg3ZVb4gjWnZhXYb4xLoYFEkQEWLkzodahY2dn'
|
|
23
|
+
signing_public = Xgt::Ruby::Auth.wif_to_public_key(signing_private, address_prefix)
|
|
24
|
+
amount = (chain_properties['account_creation_fee'] || {})['amount'].to_f * 0.001
|
|
25
|
+
currency_symbol = config['XGT_SYMBOL_STR']
|
|
26
|
+
fee = "#{'%0.3f' % amount} #{currency_symbol}"
|
|
27
|
+
components = fee.split(' ')
|
|
28
|
+
decimal = BigDecimal(components.first) * 1
|
|
29
|
+
final_fee = decimal.truncate.to_s + '.' + sprintf('%03d', (decimal.frac * 1000).truncate) + ' ' + components.last
|
|
30
|
+
|
|
31
|
+
txn = {
|
|
32
|
+
'extensions': [],
|
|
33
|
+
'operations': [[
|
|
34
|
+
'witness_update',
|
|
35
|
+
{
|
|
36
|
+
'owner': 'XGT28Ab1ezDunt2g',
|
|
37
|
+
'url': 'http://test.host',
|
|
38
|
+
'block_signing_key': signing_public,
|
|
39
|
+
'props': {
|
|
40
|
+
'account_creation_fee': fee,
|
|
41
|
+
},
|
|
42
|
+
'fee': final_fee,
|
|
43
|
+
}
|
|
44
|
+
]]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [recovery_wif], chain_id)
|
|
48
|
+
puts JSON.pretty_generate(signed)
|
|
49
|
+
puts "\n\n"
|
|
50
|
+
|
|
51
|
+
msg %(Registering witness "XGT272up7iTGKArE" with recovery private WIF "#{recovery_wif}"...)
|
|
52
|
+
msg %(Signing keypair is #{signing_private} (private) and #{signing_public} (public)...)
|
|
53
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
54
|
+
puts "\n\n"
|
|
55
|
+
puts JSON.pretty_generate(response)
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
signing_private: signing_private,
|
|
59
|
+
signing_public: signing_public
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
witness_update
|
|
64
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def account_update
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config['XGT_CHAIN_ID']
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"account_update2",
|
|
15
|
+
{
|
|
16
|
+
"account": "XGT0000000000000",
|
|
17
|
+
"posting": {
|
|
18
|
+
"weight_threshold": 1,
|
|
19
|
+
"account_auths": [],
|
|
20
|
+
"key_auths": [
|
|
21
|
+
[
|
|
22
|
+
"XGT6FATHLohxTN8RWWkU9ZZwVywXo6MEDjHHui1jEBYkG2tTdvMYo",
|
|
23
|
+
1
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"XGT76EQNV2RTA6yF9TnBvGSV71mW7eW36MM7XQp24JxdoArTfKA76",
|
|
27
|
+
1
|
|
28
|
+
]
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"memo_key": "XGT6FATHLohxTN8RWWkU9ZZwVywXo6MEDjHHui1jEBYkG2tTdvMYo",
|
|
32
|
+
"json_metadata": ""
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
39
|
+
puts JSON.pretty_generate(signed)
|
|
40
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
41
|
+
puts JSON.pretty_generate(response)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
account_update
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def cancel_transfer_from_savings
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"cancel_transfer_from_savings",
|
|
15
|
+
{
|
|
16
|
+
"from": "alice",
|
|
17
|
+
"request_id": 1
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
24
|
+
puts JSON.pretty_generate(signed)
|
|
25
|
+
puts "\n\n"
|
|
26
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
27
|
+
puts JSON.pretty_generate(response)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
cancel_transfer_from_savings
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def challenge_authority
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"challenge_authority",
|
|
15
|
+
{
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
22
|
+
puts JSON.pretty_generate(signed)
|
|
23
|
+
puts "\n\n"
|
|
24
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
25
|
+
puts JSON.pretty_generate(response)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
challenge_authority
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def claim_reward_balance
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"claim_reward_balance",
|
|
15
|
+
{
|
|
16
|
+
"fee": {
|
|
17
|
+
"amount": 0,
|
|
18
|
+
"precision": 3,
|
|
19
|
+
"nai": "@@000000021"
|
|
20
|
+
},
|
|
21
|
+
"creator": "XGT0000000000000",
|
|
22
|
+
"extensions": []
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
29
|
+
puts JSON.pretty_generate(signed)
|
|
30
|
+
puts "\n\n"
|
|
31
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
32
|
+
puts JSON.pretty_generate(response)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
claim_reward_balance
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def convert
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JxT9NqfjymtBJi4dtrqGqnJvrZg5CiimEbC6YkYJGCV4YA7vQJ'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"convert",
|
|
15
|
+
{
|
|
16
|
+
"owner": "XGT25sPK8vj1o1Go",
|
|
17
|
+
"requestid": 1467592156,
|
|
18
|
+
"amount": "5000.000 XGT",
|
|
19
|
+
=begin
|
|
20
|
+
"amount": {
|
|
21
|
+
"amount": "5000",
|
|
22
|
+
"precision": 3,
|
|
23
|
+
"nai": "@@000000013"
|
|
24
|
+
}
|
|
25
|
+
=end
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
32
|
+
puts JSON.pretty_generate(signed)
|
|
33
|
+
puts "\n\n"
|
|
34
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
35
|
+
puts JSON.pretty_generate(response)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
convert
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def custom_binary
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"custom_binary",
|
|
15
|
+
{
|
|
16
|
+
"required_auths": ["bytemaster"],
|
|
17
|
+
"id": 777,
|
|
18
|
+
"data": "0a627974656d617374657207737465656d697402a3d13897d82114466ad87a74b73a53292d8331d1bd1d3082da6bfbcff19ed097029db013797711c88cccca3692407f9ff9b9ce7221aaa2d797f1692be2215d0a5f6d2a8cab6832050078bc5729201e3ea24ea9f7873e6dbdc65a6bd9899053b9acda876dc69f11a13df9ca8b26b6"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
25
|
+
puts JSON.pretty_generate(signed)
|
|
26
|
+
puts "\n\n"
|
|
27
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
28
|
+
puts JSON.pretty_generate(response)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
custom_binary
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def feed_publish
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"feed_publish",
|
|
15
|
+
{
|
|
16
|
+
"publisher": "XGT0000000000000",
|
|
17
|
+
"exchange_rate": {
|
|
18
|
+
"base": "500.000 XGT",
|
|
19
|
+
"quote": "500.000 SBD",
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
27
|
+
puts JSON.pretty_generate(signed)
|
|
28
|
+
puts "\n\n"
|
|
29
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
30
|
+
puts JSON.pretty_generate(response)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
feed_publish
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def change_recovery_account
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"change_recovery_account",
|
|
15
|
+
{
|
|
16
|
+
"account_to_recover": "XGT29L7X8ipcEpLz",
|
|
17
|
+
"new_recovery_account": "XGT0000000000000",
|
|
18
|
+
"extensions": []
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
25
|
+
puts JSON.pretty_generate(signed)
|
|
26
|
+
puts "\n\n"
|
|
27
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
28
|
+
puts JSON.pretty_generate(response)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
change_recovery_account
|