auction-ruby-base 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +15 -0
- data/.yardopts +8 -0
- data/CHANGELOG.md +58 -0
- data/CONTRIBUTING.md +48 -0
- data/Gemfile +15 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +202 -0
- data/README.md +83 -0
- data/Rakefile +4 -0
- data/auction-ruby-base.gemspec +35 -0
- data/examples/create_account.rb +26 -0
- data/examples/low_level_transaction_post.rb +46 -0
- data/examples/mid_level_transaction_post.rb +33 -0
- data/examples/non_native_payment.rb +60 -0
- data/examples/offer.rb +75 -0
- data/examples/transaction_merge.rb +23 -0
- data/generated/stellar-base-generated.rb +174 -0
- data/generated/stellar/account_entry.rb +55 -0
- data/generated/stellar/account_entry/ext.rb +24 -0
- data/generated/stellar/account_flags.rb +31 -0
- data/generated/stellar/account_merge_result.rb +26 -0
- data/generated/stellar/account_merge_result_code.rb +30 -0
- data/generated/stellar/affirm_fail_op.rb +22 -0
- data/generated/stellar/affirm_fail_result.rb +25 -0
- data/generated/stellar/affirm_fail_result_code.rb +22 -0
- data/generated/stellar/affirm_pass_op.rb +24 -0
- data/generated/stellar/affirm_pass_result.rb +25 -0
- data/generated/stellar/affirm_pass_result_code.rb +22 -0
- data/generated/stellar/allow_trust_op.rb +38 -0
- data/generated/stellar/allow_trust_op/asset.rb +33 -0
- data/generated/stellar/allow_trust_result.rb +25 -0
- data/generated/stellar/allow_trust_result_code.rb +31 -0
- data/generated/stellar/asset.rb +47 -0
- data/generated/stellar/asset/alpha_num12.rb +22 -0
- data/generated/stellar/asset/alpha_num4.rb +22 -0
- data/generated/stellar/asset_type.rb +24 -0
- data/generated/stellar/auth.rb +20 -0
- data/generated/stellar/auth_cert.rb +22 -0
- data/generated/stellar/authenticated_message.rb +32 -0
- data/generated/stellar/authenticated_message/v0.rb +24 -0
- data/generated/stellar/bucket_entry.rb +28 -0
- data/generated/stellar/bucket_entry_type.rb +22 -0
- data/generated/stellar/change_trust_op.rb +22 -0
- data/generated/stellar/change_trust_result.rb +25 -0
- data/generated/stellar/change_trust_result_code.rb +31 -0
- data/generated/stellar/claim_offer_atom.rb +33 -0
- data/generated/stellar/create_account_op.rb +20 -0
- data/generated/stellar/create_account_result.rb +25 -0
- data/generated/stellar/create_account_result_code.rb +32 -0
- data/generated/stellar/create_bid_op.rb +20 -0
- data/generated/stellar/create_bid_result.rb +25 -0
- data/generated/stellar/create_bid_result_code.rb +22 -0
- data/generated/stellar/create_lot_op.rb +46 -0
- data/generated/stellar/create_lot_result.rb +25 -0
- data/generated/stellar/create_lot_result_code.rb +22 -0
- data/generated/stellar/create_passive_offer_op.rb +24 -0
- data/generated/stellar/crypto_key_type.rb +20 -0
- data/generated/stellar/curve25519_public.rb +18 -0
- data/generated/stellar/curve25519_secret.rb +18 -0
- data/generated/stellar/decorated_signature.rb +20 -0
- data/generated/stellar/dont_have.rb +20 -0
- data/generated/stellar/envelope_type.rb +24 -0
- data/generated/stellar/error.rb +20 -0
- data/generated/stellar/error_code.rb +28 -0
- data/generated/stellar/hello.rb +34 -0
- data/generated/stellar/hmac_sha256_key.rb +18 -0
- data/generated/stellar/hmac_sha256_mac.rb +18 -0
- data/generated/stellar/inflation_payout.rb +20 -0
- data/generated/stellar/inflation_result.rb +26 -0
- data/generated/stellar/inflation_result_code.rb +24 -0
- data/generated/stellar/ip_addr_type.rb +22 -0
- data/generated/stellar/ledger_entry.rb +52 -0
- data/generated/stellar/ledger_entry/data.rb +49 -0
- data/generated/stellar/ledger_entry/ext.rb +24 -0
- data/generated/stellar/ledger_entry_change.rb +35 -0
- data/generated/stellar/ledger_entry_change_type.rb +26 -0
- data/generated/stellar/ledger_entry_type.rb +32 -0
- data/generated/stellar/ledger_header.rb +69 -0
- data/generated/stellar/ledger_header/ext.rb +24 -0
- data/generated/stellar/ledger_header_history_entry.rb +33 -0
- data/generated/stellar/ledger_header_history_entry/ext.rb +24 -0
- data/generated/stellar/ledger_key.rb +87 -0
- data/generated/stellar/ledger_key/account.rb +20 -0
- data/generated/stellar/ledger_key/lot.rb +22 -0
- data/generated/stellar/ledger_key/message.rb +22 -0
- data/generated/stellar/ledger_key/offer.rb +22 -0
- data/generated/stellar/ledger_key/participant.rb +22 -0
- data/generated/stellar/ledger_key/proof.rb +22 -0
- data/generated/stellar/ledger_key/trust_line.rb +22 -0
- data/generated/stellar/ledger_scp_messages.rb +20 -0
- data/generated/stellar/ledger_upgrade.rb +31 -0
- data/generated/stellar/ledger_upgrade_type.rb +24 -0
- data/generated/stellar/lot_branch.rb +21 -0
- data/generated/stellar/lot_entry.rb +64 -0
- data/generated/stellar/lot_entry/ext.rb +24 -0
- data/generated/stellar/lot_type.rb +21 -0
- data/generated/stellar/manage_offer_effect.rb +24 -0
- data/generated/stellar/manage_offer_op.rb +28 -0
- data/generated/stellar/manage_offer_result.rb +26 -0
- data/generated/stellar/manage_offer_result_code.rb +50 -0
- data/generated/stellar/manage_offer_success_result.rb +34 -0
- data/generated/stellar/manage_offer_success_result/offer.rb +30 -0
- data/generated/stellar/memo.rb +38 -0
- data/generated/stellar/memo_type.rb +28 -0
- data/generated/stellar/message_entry.rb +38 -0
- data/generated/stellar/message_entry/ext.rb +24 -0
- data/generated/stellar/message_type.rb +51 -0
- data/generated/stellar/offer_entry.rb +49 -0
- data/generated/stellar/offer_entry/ext.rb +24 -0
- data/generated/stellar/offer_entry_flags.rb +21 -0
- data/generated/stellar/operation.rb +65 -0
- data/generated/stellar/operation/body.rb +88 -0
- data/generated/stellar/operation_meta.rb +18 -0
- data/generated/stellar/operation_result.rb +67 -0
- data/generated/stellar/operation_result/tr.rb +89 -0
- data/generated/stellar/operation_result_code.rb +25 -0
- data/generated/stellar/operation_type.rb +52 -0
- data/generated/stellar/participant_entry.rb +39 -0
- data/generated/stellar/participant_entry/ext.rb +24 -0
- data/generated/stellar/participant_state.rb +25 -0
- data/generated/stellar/path_payment_op.rb +32 -0
- data/generated/stellar/path_payment_result.rb +38 -0
- data/generated/stellar/path_payment_result/success.rb +22 -0
- data/generated/stellar/path_payment_result_code.rb +47 -0
- data/generated/stellar/payment_op.rb +22 -0
- data/generated/stellar/payment_result.rb +25 -0
- data/generated/stellar/payment_result_code.rb +41 -0
- data/generated/stellar/peer_address.rb +33 -0
- data/generated/stellar/peer_address/ip.rb +29 -0
- data/generated/stellar/price.rb +20 -0
- data/generated/stellar/proof_entry.rb +42 -0
- data/generated/stellar/proof_entry/ext.rb +24 -0
- data/generated/stellar/provide_proof_op.rb +24 -0
- data/generated/stellar/provide_proof_result.rb +25 -0
- data/generated/stellar/provide_proof_result_code.rb +22 -0
- data/generated/stellar/public_key.rb +23 -0
- data/generated/stellar/register_participant_op.rb +22 -0
- data/generated/stellar/register_participant_result.rb +25 -0
- data/generated/stellar/register_participant_result_code.rb +22 -0
- data/generated/stellar/scp_ballot.rb +20 -0
- data/generated/stellar/scp_envelope.rb +20 -0
- data/generated/stellar/scp_history_entry.rb +23 -0
- data/generated/stellar/scp_history_entry_v0.rb +20 -0
- data/generated/stellar/scp_nomination.rb +22 -0
- data/generated/stellar/scp_quorum_set.rb +22 -0
- data/generated/stellar/scp_statement.rb +58 -0
- data/generated/stellar/scp_statement/pledges.rb +63 -0
- data/generated/stellar/scp_statement/pledges/confirm.rb +30 -0
- data/generated/stellar/scp_statement/pledges/externalize.rb +26 -0
- data/generated/stellar/scp_statement/pledges/prepare.rb +32 -0
- data/generated/stellar/scp_statement_type.rb +26 -0
- data/generated/stellar/send_message_op.rb +22 -0
- data/generated/stellar/send_message_result.rb +25 -0
- data/generated/stellar/send_message_result_code.rb +22 -0
- data/generated/stellar/set_options_op.rb +41 -0
- data/generated/stellar/set_options_result.rb +25 -0
- data/generated/stellar/set_options_result_code.rb +40 -0
- data/generated/stellar/signer.rb +20 -0
- data/generated/stellar/simple_payment_result.rb +22 -0
- data/generated/stellar/stellar_message.rb +74 -0
- data/generated/stellar/stellar_value.rb +41 -0
- data/generated/stellar/stellar_value/ext.rb +24 -0
- data/generated/stellar/threshold_indexes.rb +26 -0
- data/generated/stellar/time_bounds.rb +20 -0
- data/generated/stellar/transaction.rb +50 -0
- data/generated/stellar/transaction/ext.rb +24 -0
- data/generated/stellar/transaction_envelope.rb +20 -0
- data/generated/stellar/transaction_history_entry.rb +33 -0
- data/generated/stellar/transaction_history_entry/ext.rb +24 -0
- data/generated/stellar/transaction_history_result_entry.rb +33 -0
- data/generated/stellar/transaction_history_result_entry/ext.rb +24 -0
- data/generated/stellar/transaction_meta.rb +23 -0
- data/generated/stellar/transaction_result.rb +43 -0
- data/generated/stellar/transaction_result/ext.rb +24 -0
- data/generated/stellar/transaction_result/result.rb +30 -0
- data/generated/stellar/transaction_result_code.rb +45 -0
- data/generated/stellar/transaction_result_pair.rb +20 -0
- data/generated/stellar/transaction_result_set.rb +18 -0
- data/generated/stellar/transaction_set.rb +20 -0
- data/generated/stellar/trust_line_entry.rb +41 -0
- data/generated/stellar/trust_line_entry/ext.rb +24 -0
- data/generated/stellar/trust_line_flags.rb +21 -0
- data/lib/stellar-base.rb +33 -0
- data/lib/stellar/account_flags.rb +28 -0
- data/lib/stellar/asset.rb +69 -0
- data/lib/stellar/base.rb +1 -0
- data/lib/stellar/base/version.rb +5 -0
- data/lib/stellar/convert.rb +32 -0
- data/lib/stellar/key_pair.rb +112 -0
- data/lib/stellar/networks.rb +45 -0
- data/lib/stellar/operation.rb +384 -0
- data/lib/stellar/path_payment_result.rb +17 -0
- data/lib/stellar/price.rb +32 -0
- data/lib/stellar/thresholds.rb +39 -0
- data/lib/stellar/transaction.rb +205 -0
- data/lib/stellar/transaction_envelope.rb +32 -0
- data/lib/stellar/util/continued_fraction.rb +96 -0
- data/lib/stellar/util/strkey.rb +43 -0
- data/spec/lib/stellar/account_flags_spec.rb +19 -0
- data/spec/lib/stellar/asset_spec.rb +45 -0
- data/spec/lib/stellar/convert_spec.rb +61 -0
- data/spec/lib/stellar/key_pair_spec.rb +238 -0
- data/spec/lib/stellar/networks_spec.rb +77 -0
- data/spec/lib/stellar/operation_spec.rb +13 -0
- data/spec/lib/stellar/path_payment_result_spec.rb +95 -0
- data/spec/lib/stellar/price_spec.rb +34 -0
- data/spec/lib/stellar/thresholds_spec.rb +62 -0
- data/spec/lib/stellar/transaction_envelope_spec.rb +93 -0
- data/spec/lib/stellar/transaction_spec.rb +83 -0
- data/spec/lib/stellar/util/strkey_spec.rb +46 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/matchers/be_strkey.rb +9 -0
- data/spec/support/matchers/eq_bytes.rb +5 -0
- data/spec/support/matchers/have_length.rb +5 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/travis.rake +1 -0
- data/tasks/xdr.rake +50 -0
- data/xdr/Stellar-SCP.x +86 -0
- data/xdr/Stellar-ledger-entries.x +351 -0
- data/xdr/Stellar-ledger.x +288 -0
- data/xdr/Stellar-overlay.x +146 -0
- data/xdr/Stellar-transaction.x +936 -0
- data/xdr/Stellar-types.x +55 -0
- metadata +495 -0
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stellar/base/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "auction-ruby-base"
|
8
|
+
spec.version = Stellar::Base::VERSION
|
9
|
+
spec.authors = ["Hlib Naumenko"]
|
10
|
+
spec.summary = %q{eAuction client library: XDR}
|
11
|
+
spec.license = "Apache 2.0"
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["generated", "lib"]
|
17
|
+
|
18
|
+
spec.add_dependency "xdr", "~> 1.0.0"
|
19
|
+
spec.add_dependency "digest-crc"
|
20
|
+
spec.add_dependency "base32"
|
21
|
+
spec.add_dependency "rbnacl"
|
22
|
+
spec.add_dependency "rbnacl-libsodium", "~> 1.0.3"
|
23
|
+
spec.add_dependency "activesupport", "~> 4"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "xdrgen"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_development_dependency "simplecov"
|
31
|
+
spec.add_development_dependency "octokit"
|
32
|
+
spec.add_development_dependency "netrc"
|
33
|
+
spec.add_development_dependency "yard"
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
require 'stellar-base'
|
5
|
+
require 'faraday'
|
6
|
+
require 'faraday_middleware'
|
7
|
+
|
8
|
+
$server = Faraday.new(url: "http://localhost:39132") do |conn|
|
9
|
+
conn.response :json
|
10
|
+
conn.adapter Faraday.default_adapter
|
11
|
+
end
|
12
|
+
|
13
|
+
master = Stellar::KeyPair.master
|
14
|
+
destination = Stellar::KeyPair.random
|
15
|
+
|
16
|
+
tx = Stellar::Transaction.create_account({
|
17
|
+
account: master,
|
18
|
+
destination: destination,
|
19
|
+
sequence: 1,
|
20
|
+
starting_balance: 50
|
21
|
+
})
|
22
|
+
|
23
|
+
b64 = tx.to_envelope(master).to_xdr(:base64)
|
24
|
+
p b64
|
25
|
+
result = $server.get('tx', blob: b64)
|
26
|
+
p result.body
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is an example of using the raw xdr objects to post a transaction
|
4
|
+
# notice that we must manually hash/sign the structures and we must manually
|
5
|
+
# fill out all the fields.
|
6
|
+
#
|
7
|
+
# Look at mid_level_transaction_post.rb to see a friendlier form
|
8
|
+
|
9
|
+
require 'rbnacl'
|
10
|
+
require 'stellar-base'
|
11
|
+
require 'faraday'
|
12
|
+
require 'digest/sha2'
|
13
|
+
|
14
|
+
master = RbNaCl::SigningKey.new("allmylifemyhearthasbeensearching")
|
15
|
+
destination = RbNaCl::SigningKey.new("allmylifemyhearthasbeensearching")
|
16
|
+
|
17
|
+
tx = Stellar::Transaction.new
|
18
|
+
tx.account = master.verify_key.to_bytes
|
19
|
+
tx.fee = 1000
|
20
|
+
tx.seq_num = 1
|
21
|
+
|
22
|
+
payment = Stellar::PaymentOp.new
|
23
|
+
payment.destination = destination.verify_key.to_bytes
|
24
|
+
payment.asset = Stellar::Asset.new(:native)
|
25
|
+
payment.amount = 200 * Stellar::ONE
|
26
|
+
|
27
|
+
op = Stellar::Operation.new
|
28
|
+
op.body = Stellar::Operation::Body.new(:payment, payment)
|
29
|
+
|
30
|
+
tx.operations = [op]
|
31
|
+
|
32
|
+
raw = tx.to_xdr
|
33
|
+
tx_hash = Digest::SHA256.digest raw
|
34
|
+
signature = master.sign(tx_hash)
|
35
|
+
|
36
|
+
env = Stellar::TransactionEnvelope.new
|
37
|
+
env.tx = tx
|
38
|
+
env.signatures = [Stellar::DecoratedSignature.new({
|
39
|
+
hint:master.verify_key.to_bytes[0...4],
|
40
|
+
signature:signature
|
41
|
+
})]
|
42
|
+
|
43
|
+
env_hex = env.to_xdr.unpack("H*").first
|
44
|
+
|
45
|
+
result = Faraday.get('http://localhost:39132/tx', blob: env_hex)
|
46
|
+
puts result.body
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is an example of using the higher level "payment" wrapper. Notice
|
4
|
+
# that we are using KeyPair instead of the raw rbnacl keys and that we need
|
5
|
+
# not build the entire heirarchy of xdr object manually.
|
6
|
+
#
|
7
|
+
# You can see where these helpers are defined in the files underneath /lib,
|
8
|
+
# which is where we extend the xdrgen generated source files with our higher
|
9
|
+
# level api.
|
10
|
+
|
11
|
+
require 'stellar-base'
|
12
|
+
require 'faraday'
|
13
|
+
require 'faraday_middleware'
|
14
|
+
|
15
|
+
$server = Faraday.new(url: "http://localhost:39132") do |conn|
|
16
|
+
conn.response :json
|
17
|
+
conn.adapter Faraday.default_adapter
|
18
|
+
end
|
19
|
+
|
20
|
+
master = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
|
21
|
+
destination = Stellar::KeyPair.from_raw_seed("allmylifemyhearthasbeensearching")
|
22
|
+
|
23
|
+
tx = Stellar::Transaction.payment({
|
24
|
+
account: master,
|
25
|
+
destination: destination,
|
26
|
+
sequence: 1,
|
27
|
+
amount: [:native, 20]
|
28
|
+
})
|
29
|
+
|
30
|
+
b64 = tx.to_envelope(master).to_xdr(:base64)
|
31
|
+
|
32
|
+
result = $server.get('tx', blob: b64)
|
33
|
+
p result.body
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is an example of using the higher level "payment" wrapper. Notice
|
4
|
+
# that we are using KeyPair instead of the raw rbnacl keys and that we need
|
5
|
+
# not build the entire heirarchy of xdr object manually.
|
6
|
+
#
|
7
|
+
# You can see where these helpers are defined in the files underneath /lib,
|
8
|
+
# which is where we extend the xdrgen generated source files with our higher
|
9
|
+
# level api.
|
10
|
+
#
|
11
|
+
# NOTE: due to the way that sequence number for a new account are set, this
|
12
|
+
# example is pretty cumbersome to run. It is only used for illustrative purposes
|
13
|
+
# of the flow
|
14
|
+
|
15
|
+
require 'stellar-base'
|
16
|
+
require 'faraday'
|
17
|
+
require 'faraday_middleware'
|
18
|
+
|
19
|
+
$server = Faraday.new(url: "http://localhost:39132") do |conn|
|
20
|
+
conn.response :json
|
21
|
+
conn.adapter Faraday.default_adapter
|
22
|
+
end
|
23
|
+
|
24
|
+
def submit(key, tx)
|
25
|
+
b64 = tx.to_envelope(key).to_xdr(:base64)
|
26
|
+
response = $server.get('tx', blob: b64)
|
27
|
+
raw = [response.body["result"]].pack("H*")
|
28
|
+
p response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
master = Stellar::KeyPair.master
|
32
|
+
destination = Stellar::KeyPair.master
|
33
|
+
|
34
|
+
submit master, Stellar::Transaction.payment({
|
35
|
+
account: master,
|
36
|
+
destination: destination,
|
37
|
+
sequence: 1,
|
38
|
+
amount: [:native, 2000]
|
39
|
+
})
|
40
|
+
|
41
|
+
# NOTE: after this step, you need to get the sequence number for destination
|
42
|
+
# Which is based off of the ledger sequence number it was funded in.
|
43
|
+
gets # pause to get the account's sequence from the hayashi db
|
44
|
+
|
45
|
+
destination_sequence = FILL_ME_IN
|
46
|
+
# destination_sequence = 17179869185
|
47
|
+
|
48
|
+
submit destination, Stellar::Transaction.change_trust({
|
49
|
+
account: destination,
|
50
|
+
sequence: destination_sequence,
|
51
|
+
line: [:alphanum4, "USD\x00", master],
|
52
|
+
limit: 1000
|
53
|
+
})
|
54
|
+
|
55
|
+
submit master, Stellar::Transaction.payment({
|
56
|
+
account: master,
|
57
|
+
destination: destination,
|
58
|
+
sequence: 3,
|
59
|
+
amount: [:alphanum4, "USD\x00", master, 100]
|
60
|
+
})
|
data/examples/offer.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This is an example of using the higher level "payment" wrapper. Notice
|
4
|
+
# that we are using KeyPair instead of the raw rbnacl keys and that we need
|
5
|
+
# not build the entire heirarchy of xdr object manually.
|
6
|
+
#
|
7
|
+
# You can see where these helpers are defined in the files underneath /lib,
|
8
|
+
# which is where we extend the xdrgen generated source files with our higher
|
9
|
+
# level api.
|
10
|
+
#
|
11
|
+
# NOTE: due to the way that sequence number for a new account are set, this
|
12
|
+
# example is pretty cumbersome to run. It is only used for illustrative purposes
|
13
|
+
# of the flow
|
14
|
+
|
15
|
+
require 'stellar-base'
|
16
|
+
require 'faraday'
|
17
|
+
require 'faraday_middleware'
|
18
|
+
|
19
|
+
$server = Faraday.new(url: "http://localhost:39132") do |conn|
|
20
|
+
conn.response :json
|
21
|
+
conn.adapter Faraday.default_adapter
|
22
|
+
end
|
23
|
+
|
24
|
+
def submit(key, tx)
|
25
|
+
b64 = tx.to_envelope(key).to_xdr(:base64)
|
26
|
+
response = $server.get('tx', blob: b64)
|
27
|
+
p response.body
|
28
|
+
end
|
29
|
+
|
30
|
+
master = Stellar::KeyPair.master
|
31
|
+
destination = Stellar::KeyPair.master
|
32
|
+
|
33
|
+
submit master, Stellar::Transaction.payment({
|
34
|
+
account: master,
|
35
|
+
destination: destination,
|
36
|
+
sequence: 1,
|
37
|
+
amount: [:native, 2000]
|
38
|
+
})
|
39
|
+
|
40
|
+
# NOTE: after this step, you need to get the sequence number for destination
|
41
|
+
# Which is based off of the ledger sequence number it was funded in.
|
42
|
+
gets # pause to get the account's sequence from the hayashi db
|
43
|
+
|
44
|
+
destination_sequence = FILL_ME_IN
|
45
|
+
# destination_sequence = 17179869185
|
46
|
+
|
47
|
+
submit destination, Stellar::Transaction.change_trust({
|
48
|
+
account: destination,
|
49
|
+
sequence: destination_sequence,
|
50
|
+
line: [:alphanum4, "USD\x00", master],
|
51
|
+
limit: 1000
|
52
|
+
})
|
53
|
+
|
54
|
+
submit destination, Stellar::Transaction.change_trust({
|
55
|
+
account: destination,
|
56
|
+
sequence: destination_sequence + 1,
|
57
|
+
line: [:alphanum4, "EUR\x00", master],
|
58
|
+
limit: 1000
|
59
|
+
})
|
60
|
+
|
61
|
+
submit master, Stellar::Transaction.payment({
|
62
|
+
account: master,
|
63
|
+
destination: destination,
|
64
|
+
sequence: destination_sequence + 2,
|
65
|
+
amount: [:alphanum4, "USD\x00", master, 1000]
|
66
|
+
})
|
67
|
+
|
68
|
+
submit master, Stellar::Transaction.manage_offer({
|
69
|
+
account: destination,
|
70
|
+
sequence: destination_sequence + 3,
|
71
|
+
selling: [:alphanum4, "USD\x00", usd_gateway],
|
72
|
+
buying: [:alphanum4, "EUR\x00", eur_gateway],
|
73
|
+
amount: 100,
|
74
|
+
price: 2.0,
|
75
|
+
})
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'stellar-base'
|
4
|
+
|
5
|
+
master = Stellar::KeyPair.master
|
6
|
+
destination = Stellar::KeyPair.master
|
7
|
+
|
8
|
+
tx1 = Stellar::Transaction.payment({
|
9
|
+
account: master,
|
10
|
+
destination: destination,
|
11
|
+
sequence: 1,
|
12
|
+
amount: [:native, 20]
|
13
|
+
})
|
14
|
+
|
15
|
+
tx2 = Stellar::Transaction.payment({
|
16
|
+
account: master,
|
17
|
+
destination: destination,
|
18
|
+
sequence: 2,
|
19
|
+
amount: [:native, 20]
|
20
|
+
})
|
21
|
+
|
22
|
+
hex = tx1.merge(tx2).to_envelope(master).to_xdr(:base64)
|
23
|
+
puts hex
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# This code was automatically generated using xdrgen
|
2
|
+
# DO NOT EDIT or your changes may be overwritten
|
3
|
+
|
4
|
+
require 'xdr'
|
5
|
+
|
6
|
+
module Stellar
|
7
|
+
include XDR::Namespace
|
8
|
+
|
9
|
+
Hash = XDR::Opaque[32]
|
10
|
+
Uint256 = XDR::Opaque[32]
|
11
|
+
Uint32 = XDR::UnsignedInt
|
12
|
+
Int32 = XDR::Int
|
13
|
+
Uint64 = XDR::UnsignedHyper
|
14
|
+
Int64 = XDR::Hyper
|
15
|
+
autoload :CryptoKeyType
|
16
|
+
autoload :PublicKey
|
17
|
+
Signature = XDR::VarOpaque[64]
|
18
|
+
SignatureHint = XDR::Opaque[4]
|
19
|
+
NodeID = PublicKey
|
20
|
+
autoload :Curve25519Secret
|
21
|
+
autoload :Curve25519Public
|
22
|
+
autoload :HmacSha256Key
|
23
|
+
autoload :HmacSha256Mac
|
24
|
+
end
|
25
|
+
module Stellar
|
26
|
+
include XDR::Namespace
|
27
|
+
|
28
|
+
AccountID = PublicKey
|
29
|
+
Thresholds = XDR::Opaque[4]
|
30
|
+
String32 = XDR::String[32]
|
31
|
+
SequenceNumber = Uint64
|
32
|
+
autoload :AssetType
|
33
|
+
autoload :Asset
|
34
|
+
autoload :Price
|
35
|
+
autoload :ThresholdIndexes
|
36
|
+
autoload :LedgerEntryType
|
37
|
+
autoload :Signer
|
38
|
+
autoload :AccountFlags
|
39
|
+
autoload :AccountEntry
|
40
|
+
autoload :ProofEntry
|
41
|
+
autoload :TrustLineFlags
|
42
|
+
autoload :TrustLineEntry
|
43
|
+
autoload :OfferEntryFlags
|
44
|
+
autoload :OfferEntry
|
45
|
+
autoload :LotType
|
46
|
+
autoload :LotBranch
|
47
|
+
autoload :LotEntry
|
48
|
+
autoload :ParticipantState
|
49
|
+
autoload :ParticipantEntry
|
50
|
+
autoload :MessageEntry
|
51
|
+
autoload :LedgerEntry
|
52
|
+
autoload :EnvelopeType
|
53
|
+
end
|
54
|
+
module Stellar
|
55
|
+
include XDR::Namespace
|
56
|
+
|
57
|
+
autoload :DecoratedSignature
|
58
|
+
autoload :OperationType
|
59
|
+
autoload :CreateAccountOp
|
60
|
+
autoload :CreateLotOp
|
61
|
+
autoload :CreateBidOp
|
62
|
+
autoload :AffirmFailOp
|
63
|
+
autoload :AffirmPassOp
|
64
|
+
autoload :RegisterParticipantOp
|
65
|
+
autoload :ProvideProofOp
|
66
|
+
autoload :SendMessageOp
|
67
|
+
autoload :PaymentOp
|
68
|
+
autoload :PathPaymentOp
|
69
|
+
autoload :ManageOfferOp
|
70
|
+
autoload :CreatePassiveOfferOp
|
71
|
+
autoload :SetOptionsOp
|
72
|
+
autoload :ChangeTrustOp
|
73
|
+
autoload :AllowTrustOp
|
74
|
+
autoload :Operation
|
75
|
+
autoload :MemoType
|
76
|
+
autoload :Memo
|
77
|
+
autoload :TimeBounds
|
78
|
+
autoload :Transaction
|
79
|
+
autoload :TransactionEnvelope
|
80
|
+
autoload :ClaimOfferAtom
|
81
|
+
autoload :CreateAccountResultCode
|
82
|
+
autoload :CreateAccountResult
|
83
|
+
autoload :CreateLotResultCode
|
84
|
+
autoload :CreateLotResult
|
85
|
+
autoload :CreateBidResultCode
|
86
|
+
autoload :CreateBidResult
|
87
|
+
autoload :AffirmFailResultCode
|
88
|
+
autoload :AffirmFailResult
|
89
|
+
autoload :AffirmPassResultCode
|
90
|
+
autoload :AffirmPassResult
|
91
|
+
autoload :RegisterParticipantResultCode
|
92
|
+
autoload :RegisterParticipantResult
|
93
|
+
autoload :ProvideProofResultCode
|
94
|
+
autoload :ProvideProofResult
|
95
|
+
autoload :SendMessageResultCode
|
96
|
+
autoload :SendMessageResult
|
97
|
+
autoload :PaymentResultCode
|
98
|
+
autoload :PaymentResult
|
99
|
+
autoload :PathPaymentResultCode
|
100
|
+
autoload :SimplePaymentResult
|
101
|
+
autoload :PathPaymentResult
|
102
|
+
autoload :ManageOfferResultCode
|
103
|
+
autoload :ManageOfferEffect
|
104
|
+
autoload :ManageOfferSuccessResult
|
105
|
+
autoload :ManageOfferResult
|
106
|
+
autoload :SetOptionsResultCode
|
107
|
+
autoload :SetOptionsResult
|
108
|
+
autoload :ChangeTrustResultCode
|
109
|
+
autoload :ChangeTrustResult
|
110
|
+
autoload :AllowTrustResultCode
|
111
|
+
autoload :AllowTrustResult
|
112
|
+
autoload :AccountMergeResultCode
|
113
|
+
autoload :AccountMergeResult
|
114
|
+
autoload :InflationResultCode
|
115
|
+
autoload :InflationPayout
|
116
|
+
autoload :InflationResult
|
117
|
+
autoload :OperationResultCode
|
118
|
+
autoload :OperationResult
|
119
|
+
autoload :TransactionResultCode
|
120
|
+
autoload :TransactionResult
|
121
|
+
end
|
122
|
+
module Stellar
|
123
|
+
include XDR::Namespace
|
124
|
+
|
125
|
+
UpgradeType = XDR::VarOpaque[128]
|
126
|
+
autoload :StellarValue
|
127
|
+
autoload :LedgerHeader
|
128
|
+
autoload :LedgerUpgradeType
|
129
|
+
autoload :LedgerUpgrade
|
130
|
+
autoload :LedgerKey
|
131
|
+
autoload :BucketEntryType
|
132
|
+
autoload :BucketEntry
|
133
|
+
MAX_TX_PER_LEDGER = 5000
|
134
|
+
autoload :TransactionSet
|
135
|
+
autoload :TransactionResultPair
|
136
|
+
autoload :TransactionResultSet
|
137
|
+
autoload :TransactionHistoryEntry
|
138
|
+
autoload :TransactionHistoryResultEntry
|
139
|
+
autoload :LedgerHeaderHistoryEntry
|
140
|
+
autoload :LedgerSCPMessages
|
141
|
+
autoload :SCPHistoryEntryV0
|
142
|
+
autoload :SCPHistoryEntry
|
143
|
+
autoload :LedgerEntryChangeType
|
144
|
+
autoload :LedgerEntryChange
|
145
|
+
LedgerEntryChanges = XDR::VarArray[LedgerEntryChange]
|
146
|
+
autoload :OperationMeta
|
147
|
+
autoload :TransactionMeta
|
148
|
+
end
|
149
|
+
module Stellar
|
150
|
+
include XDR::Namespace
|
151
|
+
|
152
|
+
autoload :ErrorCode
|
153
|
+
autoload :Error
|
154
|
+
autoload :AuthCert
|
155
|
+
autoload :Hello
|
156
|
+
autoload :Auth
|
157
|
+
autoload :IPAddrType
|
158
|
+
autoload :PeerAddress
|
159
|
+
autoload :MessageType
|
160
|
+
autoload :DontHave
|
161
|
+
autoload :StellarMessage
|
162
|
+
autoload :AuthenticatedMessage
|
163
|
+
end
|
164
|
+
module Stellar
|
165
|
+
include XDR::Namespace
|
166
|
+
|
167
|
+
Value = XDR::VarOpaque[]
|
168
|
+
autoload :SCPBallot
|
169
|
+
autoload :SCPStatementType
|
170
|
+
autoload :SCPNomination
|
171
|
+
autoload :SCPStatement
|
172
|
+
autoload :SCPEnvelope
|
173
|
+
autoload :SCPQuorumSet
|
174
|
+
end
|