stellar-base 0.19.0 → 0.23.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.txt → LICENSE} +0 -0
  3. data/README.md +2 -3
  4. data/generated/stellar-base-generated.rb +45 -8
  5. data/generated/stellar/allow_trust_op.rb +5 -4
  6. data/generated/stellar/allow_trust_op/asset.rb +4 -4
  7. data/generated/stellar/asset.rb +2 -2
  8. data/generated/stellar/asset/alpha_num12.rb +2 -2
  9. data/generated/stellar/asset/alpha_num4.rb +2 -2
  10. data/generated/stellar/authenticated_message.rb +4 -4
  11. data/generated/stellar/authenticated_message/v0.rb +4 -4
  12. data/generated/stellar/bucket_entry.rb +6 -0
  13. data/generated/stellar/bucket_entry_type.rb +8 -2
  14. data/generated/stellar/bucket_metadata.rb +32 -0
  15. data/generated/stellar/bucket_metadata/ext.rb +24 -0
  16. data/generated/stellar/claim_offer_atom.rb +2 -2
  17. data/generated/stellar/{create_passive_offer_op.rb → create_passive_sell_offer_op.rb} +2 -2
  18. data/generated/stellar/crypto_key_type.rb +8 -4
  19. data/generated/stellar/curve25519_public.rb +1 -1
  20. data/generated/stellar/curve25519_secret.rb +1 -1
  21. data/generated/stellar/envelope_type.rb +10 -4
  22. data/generated/stellar/fee_bump_transaction.rb +39 -0
  23. data/generated/stellar/fee_bump_transaction/ext.rb +24 -0
  24. data/generated/stellar/fee_bump_transaction/inner_tx.rb +25 -0
  25. data/generated/stellar/fee_bump_transaction_envelope.rb +22 -0
  26. data/generated/stellar/hmac_sha256_key.rb +1 -1
  27. data/generated/stellar/hmac_sha256_mac.rb +1 -1
  28. data/generated/stellar/inner_transaction_result.rb +56 -0
  29. data/generated/stellar/inner_transaction_result/ext.rb +24 -0
  30. data/generated/stellar/inner_transaction_result/result.rb +52 -0
  31. data/generated/stellar/inner_transaction_result_pair.rb +20 -0
  32. data/generated/stellar/ledger_close_meta.rb +23 -0
  33. data/generated/stellar/ledger_close_meta_v0.rb +35 -0
  34. data/generated/stellar/ledger_close_value_signature.rb +20 -0
  35. data/generated/stellar/ledger_key.rb +1 -1
  36. data/generated/stellar/ledger_key/offer.rb +2 -2
  37. data/generated/stellar/manage_buy_offer_op.rb +29 -0
  38. data/generated/stellar/{manage_offer_result.rb → manage_buy_offer_result.rb} +5 -5
  39. data/generated/stellar/manage_buy_offer_result_code.rb +51 -0
  40. data/generated/stellar/{manage_offer_op.rb → manage_sell_offer_op.rb} +4 -4
  41. data/generated/stellar/manage_sell_offer_result.rb +26 -0
  42. data/generated/stellar/manage_sell_offer_result_code.rb +54 -0
  43. data/generated/stellar/message_type.rb +6 -1
  44. data/generated/stellar/muxed_account.rb +35 -0
  45. data/generated/stellar/muxed_account/med25519.rb +22 -0
  46. data/generated/stellar/offer_entry.rb +2 -2
  47. data/generated/stellar/operation.rb +13 -9
  48. data/generated/stellar/operation/body.rb +37 -29
  49. data/generated/stellar/operation_result.rb +10 -6
  50. data/generated/stellar/operation_result/tr.rb +38 -30
  51. data/generated/stellar/operation_result_code.rb +11 -7
  52. data/generated/stellar/operation_type.rb +20 -16
  53. data/generated/stellar/{path_payment_op.rb → path_payment_strict_receive_op.rb} +6 -6
  54. data/generated/stellar/path_payment_strict_receive_result.rb +38 -0
  55. data/generated/stellar/path_payment_strict_receive_result/success.rb +22 -0
  56. data/generated/stellar/path_payment_strict_receive_result_code.rb +56 -0
  57. data/generated/stellar/path_payment_strict_send_op.rb +32 -0
  58. data/generated/stellar/{path_payment_result.rb → path_payment_strict_send_result.rb} +7 -7
  59. data/generated/stellar/{path_payment_result → path_payment_strict_send_result}/success.rb +1 -1
  60. data/generated/stellar/path_payment_strict_send_result_code.rb +55 -0
  61. data/generated/stellar/payment_op.rb +4 -4
  62. data/generated/stellar/peer_stats.rb +48 -0
  63. data/generated/stellar/signed_survey_request_message.rb +20 -0
  64. data/generated/stellar/signed_survey_response_message.rb +20 -0
  65. data/generated/stellar/signer.rb +1 -1
  66. data/generated/stellar/stellar_message.rb +22 -12
  67. data/generated/stellar/stellar_value.rb +7 -5
  68. data/generated/stellar/stellar_value/ext.rb +8 -4
  69. data/generated/stellar/stellar_value_type.rb +22 -0
  70. data/generated/stellar/survey_message_command_type.rb +20 -0
  71. data/generated/stellar/survey_request_message.rb +26 -0
  72. data/generated/stellar/survey_response_body.rb +23 -0
  73. data/generated/stellar/survey_response_message.rb +26 -0
  74. data/generated/stellar/time_bounds.rb +4 -4
  75. data/generated/stellar/topology_response_body.rb +25 -0
  76. data/generated/stellar/transaction.rb +4 -4
  77. data/generated/stellar/transaction_envelope.rb +17 -8
  78. data/generated/stellar/transaction_meta.rb +4 -0
  79. data/generated/stellar/transaction_meta_v1.rb +1 -1
  80. data/generated/stellar/transaction_meta_v2.rb +24 -0
  81. data/generated/stellar/transaction_result.rb +3 -0
  82. data/generated/stellar/transaction_result/result.rb +9 -3
  83. data/generated/stellar/transaction_result_code.rb +21 -14
  84. data/generated/stellar/transaction_result_meta.rb +22 -0
  85. data/generated/stellar/transaction_signature_payload.rb +3 -1
  86. data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +7 -3
  87. data/generated/stellar/transaction_v0.rb +39 -0
  88. data/generated/stellar/transaction_v0/ext.rb +24 -0
  89. data/generated/stellar/transaction_v0_envelope.rb +22 -0
  90. data/generated/stellar/transaction_v1_envelope.rb +22 -0
  91. data/generated/stellar/trust_line_flags.rb +6 -2
  92. data/generated/stellar/upgrade_entry_meta.rb +20 -0
  93. data/lib/stellar-base.rb +28 -23
  94. data/lib/stellar/account_flags.rb +2 -4
  95. data/lib/stellar/asset.rb +6 -6
  96. data/lib/stellar/base.rb +1 -1
  97. data/lib/stellar/compat.rb +21 -0
  98. data/lib/stellar/concerns/transaction.rb +49 -0
  99. data/lib/stellar/convert.rb +2 -2
  100. data/lib/stellar/factories.rb +1 -3
  101. data/lib/stellar/fee_bump_transaction.rb +21 -0
  102. data/lib/stellar/key_pair.rb +9 -6
  103. data/lib/stellar/networks.rb +5 -7
  104. data/lib/stellar/operation.rb +428 -317
  105. data/lib/stellar/{path_payment_result.rb → path_payment_strict_receive_result.rb} +2 -3
  106. data/lib/stellar/price.rb +2 -4
  107. data/lib/stellar/signer_key.rb +4 -8
  108. data/lib/stellar/thresholds.rb +5 -7
  109. data/lib/stellar/transaction.rb +154 -169
  110. data/lib/stellar/transaction_builder.rb +149 -0
  111. data/lib/stellar/transaction_envelope.rb +40 -8
  112. data/lib/stellar/transaction_v0.rb +39 -0
  113. data/lib/stellar/util/continued_fraction.rb +19 -19
  114. data/lib/stellar/util/strkey.rb +39 -14
  115. data/lib/stellar/{base/version.rb → version.rb} +1 -1
  116. metadata +68 -210
  117. data/.gitignore +0 -17
  118. data/.travis.yml +0 -13
  119. data/.yardopts +0 -8
  120. data/CHANGELOG.md +0 -120
  121. data/CONTRIBUTING.md +0 -48
  122. data/Gemfile +0 -15
  123. data/Guardfile +0 -5
  124. data/Rakefile +0 -4
  125. data/examples/create_account.rb +0 -26
  126. data/examples/low_level_transaction_post.rb +0 -46
  127. data/examples/mid_level_transaction_post.rb +0 -33
  128. data/examples/non_native_payment.rb +0 -60
  129. data/examples/offer.rb +0 -75
  130. data/examples/transaction_merge.rb +0 -23
  131. data/generated/stellar/manage_offer_result_code.rb +0 -50
  132. data/generated/stellar/path_payment_result_code.rb +0 -47
  133. data/ruby-stellar-base.gemspec +0 -34
  134. data/spec/lib/stellar/account_flags_spec.rb +0 -19
  135. data/spec/lib/stellar/asset_spec.rb +0 -45
  136. data/spec/lib/stellar/convert_spec.rb +0 -61
  137. data/spec/lib/stellar/key_pair_spec.rb +0 -251
  138. data/spec/lib/stellar/networks_spec.rb +0 -77
  139. data/spec/lib/stellar/operation_spec.rb +0 -71
  140. data/spec/lib/stellar/path_payment_result_spec.rb +0 -95
  141. data/spec/lib/stellar/price_spec.rb +0 -34
  142. data/spec/lib/stellar/signer_key_spec.rb +0 -26
  143. data/spec/lib/stellar/thresholds_spec.rb +0 -62
  144. data/spec/lib/stellar/transaction_envelope_spec.rb +0 -93
  145. data/spec/lib/stellar/transaction_spec.rb +0 -100
  146. data/spec/lib/stellar/util/strkey_spec.rb +0 -54
  147. data/spec/spec_helper.rb +0 -16
  148. data/spec/support/matchers/be_strkey.rb +0 -9
  149. data/spec/support/matchers/eq_bytes.rb +0 -5
  150. data/spec/support/matchers/have_length.rb +0 -5
  151. data/tasks/rspec.rake +0 -6
  152. data/tasks/travis.rake +0 -1
  153. data/tasks/xdr.rake +0 -50
  154. data/xdr/Stellar-SCP.x +0 -86
  155. data/xdr/Stellar-ledger-entries.x +0 -288
  156. data/xdr/Stellar-ledger.x +0 -283
  157. data/xdr/Stellar-overlay.x +0 -146
  158. data/xdr/Stellar-transaction.x +0 -777
  159. data/xdr/Stellar-types.x +0 -81
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- /.vscode
15
- mkmf.log
16
- .DS_Store
17
- .idea
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5.1
4
- - 2.6.2
5
- before_install:
6
- - sudo add-apt-repository -y ppa:chris-lea/libsodium
7
- - sudo apt-get -y update
8
- - sudo apt-get install -y libsodium-dev
9
- - gem update bundler
10
- script: bundle exec rake travis
11
- notifications:
12
- slack:
13
- secure: V/6a8KFe067uukrbCJA2R1HPO4xy0YSQ1pwmHVRi5StX+yl+lYsWWJdjdBdT0j3iJBYyPRqU4bQYck+OloxtELnrHCX+OkodxcxW8W/ACc914iIf0FyY9pnusK7ck2awmt4Iuf94YPgi0XTm1aCcm+f0yU7wiIVFpftoXSk1EDY=
data/.yardopts DELETED
@@ -1,8 +0,0 @@
1
- --output-dir doc/generated
2
- --protected
3
- --no-private
4
- --embed-mixin ClassMethods
5
- lib/**/*.rb
6
- generated/**/*.rb
7
- -
8
- doc/*.md
@@ -1,120 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this
4
- file. This project adheres to [Semantic Versioning](http://semver.org/).
5
-
6
- As this project is pre 1.0, breaking changes may happen for minor version
7
- bumps. A breaking change will get clearly notified in this log.
8
-
9
- ## [0.19.0](https://github.com/stellar/ruby-stellar-base/compare/v0.17.0...master)
10
- ### Added
11
- - Update XDR definitions for stellar-core v10.0.0 (introduces Liabilities and other changes to support asset-backed offers as per [CAP-0003 Specification](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0003.md#specification))
12
-
13
- ### Changed
14
- - Use rbnacl instead of rbnacl-libsodium (the latter has been [deprecated](https://github.com/crypto-rb/rbnacl-libsodium/issues/29))
15
- - Loosen ActiveSupport to >= 5.0.0
16
-
17
- ## [0.17.0](https://github.com/stellar/ruby-stellar-base/compare/v0.16.0...v0.17.0)
18
- ### Fixed
19
- - Rename `Stellar::SignerKey#onetime_signer` helper to `Stellar::SignerKey#hash_x`, add preimage validations
20
-
21
- ## [0.16.0](https://github.com/stellar/ruby-stellar-base/compare/v0.15.0...v0.16.0)
22
- ### Added
23
- - Create co-signers conveniently using helpers `ed25519(keypair)`, `preauthorized_transaction(tx)` and `onetime_signer(preimage)` from `Stellar::SignerKey` module
24
- - Merge two transactions with `Stellar::TransactionEnvelope#merge`
25
-
26
- ### Fixed
27
- - Source account overriding in Stellar::Transaction#to_operations
28
-
29
- ## [0.15.0](https://github.com/stellar/ruby-stellar-base/compare/v0.14.0...v0.15.0)
30
- ### Added
31
- - `Stellar::Operation.change_trust` can accept `Stellar::Asset` instance for `line`
32
-
33
- ### Fixed
34
- - Protect `Stellar::Operation.change_trust` against malicious arguments, in the event that developers pass this argument directly from user input
35
-
36
- ## [0.14.0](https://github.com/stellar/ruby-stellar-base/compare/v0.13.0...v0.14.0)
37
-
38
- ### Added
39
- - We now support the bump sequence operation with `Operation.bump_sequence`.
40
-
41
- ### Changed
42
- - Update XDR definitions for stellar-core 0.10.0 support
43
- - `Operation.change_trust` learned how to use a default for the `:limit` parameter
44
- - `StrKey` learned about new version bytes `pre_auth_tx` and `hash_x`
45
-
46
- ## [0.13.0](https://github.com/stellar/ruby-stellar-base/compare/v0.12.0...v0.13.0)
47
-
48
- ### Changed
49
- - Update XDR definitions for stellar-core 0.9.1 support
50
-
51
- ### Added
52
- - Added `#signer_key` helper to `KeyPair`
53
-
54
- ## [0.12.0](https://github.com/stellar/ruby-stellar-base/compare/v0.11.0...v0.12.0)
55
-
56
- ### Changed
57
- - Avoid modifying $LOAD_PATH to fix load order issues
58
- - Update XDR definitions for stellar-core 0.6 support
59
-
60
- ### Removed
61
-
62
- - BREAKING CHANGE: Removed support for JRuby.
63
-
64
- ## [0.11.0](https://github.com/stellar/ruby-stellar-base/compare/v0.10.0...v0.11.0)
65
-
66
- ### Added
67
- - Added support for `manage_data` operations
68
-
69
- ### Changed
70
- - `Stellar::Transaction#to_envelope` can now be used without arguments, returning a `Stellar::TransactionEnvelope` with zero signatures.
71
-
72
- ## [0.10.0](https://github.com/stellar/ruby-stellar-base/compare/v0.9.0...v0.10.0)
73
-
74
- - Added memo helpers to `Stellar::Transaction.for_account`, allowing any operation builder (such as `Stellar::Transaction.payment) to provide a custom memo using the `:memo` attribute.
75
-
76
- ## [0.9.0](https://github.com/stellar/ruby-stellar-base/compare/v0.8.0...v0.9.0)
77
-
78
- ### Changed
79
- - XDR Definitions have been updated to stellar-core commit eed89649c2060b8e9dacffe2cec4e8b258b32416
80
-
81
- ## [0.8.0](https://github.com/stellar/ruby-stellar-base/compare/v0.7.0...v0.8.0)
82
-
83
- ### Changed
84
- - BREAKING CHANGE: The default network for this library is now the stellar test network.
85
- To enable this library for the production network use `Stellar.default_network = Stellar::Networks::PUBLIC`
86
- at the head of your script or in your configuration function.
87
-
88
- ## [0.7.0](https://github.com/stellar/ruby-stellar-base/compare/v0.6.1...v0.7.0)
89
-
90
- ### Changed
91
-
92
- - Bump xdr dependency to 1.0.0
93
-
94
- ## [0.6.1](https://github.com/stellar/ruby-stellar-base/compare/v0.6.0...v0.6.1)
95
-
96
- ### Changed
97
-
98
- - Update default fee for transactions to new minimum of 100 stroops
99
-
100
-
101
- ## [0.6.0](https://github.com/stellar/ruby-stellar-base/compare/v0.5.0...v0.6.0)
102
-
103
- ### Changed
104
-
105
- - Update to latest xdr (stellar-core commit ad22bccafbbc14a358f05a989f7b95714dc9d4c6)
106
-
107
- ## [0.5.0](https://github.com/stellar/ruby-stellar-base/compare/v0.4.0...v0.5.0)
108
-
109
- ### Changed
110
-
111
- - Update to latest xdr
112
-
113
- ## [0.4.0](https://github.com/stellar/ruby-stellar-base/compare/v0.3.0...v0.4.0)
114
-
115
- ### Changed
116
- - BREAKING CHANGE: "Amounts", that is, input parameters that represent a
117
- certain amount of a given asset, such as the `:starting_balance` option for
118
- `Operation.create_account` are now interpreted using the convention of 7
119
- fixed-decimal places. For example, specifying a payment where the amount is
120
- `50` will result in a transaction with an amount set to `500000000`.
@@ -1,48 +0,0 @@
1
- # How to contribute
2
-
3
- Your contributions to the Stellar network will help improve the world’s financial
4
- infrastructure, faster.
5
-
6
- We want to make it as easy as possible to contribute changes that
7
- help the Stellar network grow and thrive. There are a few guidelines that we
8
- ask contributors to follow so that we can merge your changes quickly.
9
-
10
- ## Getting Started
11
-
12
- * Create a GitHub issue for your contribution, assuming one does not already exist.
13
- * Clearly describe the issue including steps to reproduce if it is a bug.
14
- * Fork the repository on GitHub
15
-
16
- ## Making Changes
17
-
18
- * Create a topic branch from where you want to base your work.
19
- * This is usually the master branch.
20
- * Please avoid working directly on the `master` branch.
21
- * Make sure you have added the necessary tests for your changes, and make sure all tests pass.
22
-
23
- ## Submitting Changes
24
-
25
- * <a href="https://docs.google.com/forms/d/1g7EF6PERciwn7zfmfke5Sir2n10yddGGSXyZsq98tVY/viewform?usp=send_form">Sign the Contributor License Agreement</a>
26
- * Push your changes to a topic branch in your fork of the repository.
27
- * Submit a pull request to the corresponding repository in the Stellar organization.
28
- * Include a descriptive [commit message](https://github.com/erlang/otp/wiki/Writing-good-commit-messages).
29
- * Changes contributed via pull request should focus on a single issue at a time.
30
- * Rebase your local changes against the master branch. Resolve any conflicts that arise.
31
-
32
- At this point you're waiting on us. We like to at least comment on pull requests within three
33
- business days. We may suggest some changes or improvements or alternatives.
34
-
35
- # Additional Resources
36
-
37
- * [Bug tracker (Github)](https://github.com/stellar/ruby-stellar-base/issues)
38
- * <a href="https://docs.google.com/forms/d/1g7EF6PERciwn7zfmfke5Sir2n10yddGGSXyZsq98tVY/viewform?usp=send_form">Contributor License Agreement</a>
39
- * #stellar-dev IRC channel on freenode.org and Slack chat on stellar-public.slack.com
40
-
41
-
42
- This document is inspired by:
43
-
44
- https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md
45
-
46
- https://github.com/thoughtbot/factory_girl_rails/blob/master/CONTRIBUTING.md
47
-
48
- https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- # gem "xdr", git: "https://github.com/stellar/ruby-xdr.git"
6
- # gem "xdr", path: "../ruby-xdr"
7
-
8
- group :development do
9
- gem "xdrgen", git: "https://github.com/stellar/xdrgen.git"
10
- # gem "xdrgen", path: "../xdrgen"
11
- gem "pry"
12
- gem "faraday"
13
- gem "faraday_middleware"
14
- end
15
-
data/Guardfile DELETED
@@ -1,5 +0,0 @@
1
- guard :rspec, cmd: 'bundle exec rspec' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
5
- end
data/Rakefile DELETED
@@ -1,4 +0,0 @@
1
- require "bundler/gem_tasks"
2
- Bundler.setup
3
-
4
- Dir["tasks/**/*.rake"].each{|f| load f}
@@ -1,26 +0,0 @@
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
@@ -1,46 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,60 +0,0 @@
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
- })
@@ -1,75 +0,0 @@
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
- })