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.
- checksums.yaml +4 -4
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +2 -3
- data/generated/stellar-base-generated.rb +45 -8
- data/generated/stellar/allow_trust_op.rb +5 -4
- data/generated/stellar/allow_trust_op/asset.rb +4 -4
- data/generated/stellar/asset.rb +2 -2
- data/generated/stellar/asset/alpha_num12.rb +2 -2
- data/generated/stellar/asset/alpha_num4.rb +2 -2
- data/generated/stellar/authenticated_message.rb +4 -4
- data/generated/stellar/authenticated_message/v0.rb +4 -4
- data/generated/stellar/bucket_entry.rb +6 -0
- data/generated/stellar/bucket_entry_type.rb +8 -2
- data/generated/stellar/bucket_metadata.rb +32 -0
- data/generated/stellar/bucket_metadata/ext.rb +24 -0
- data/generated/stellar/claim_offer_atom.rb +2 -2
- data/generated/stellar/{create_passive_offer_op.rb → create_passive_sell_offer_op.rb} +2 -2
- data/generated/stellar/crypto_key_type.rb +8 -4
- data/generated/stellar/curve25519_public.rb +1 -1
- data/generated/stellar/curve25519_secret.rb +1 -1
- data/generated/stellar/envelope_type.rb +10 -4
- data/generated/stellar/fee_bump_transaction.rb +39 -0
- data/generated/stellar/fee_bump_transaction/ext.rb +24 -0
- data/generated/stellar/fee_bump_transaction/inner_tx.rb +25 -0
- data/generated/stellar/fee_bump_transaction_envelope.rb +22 -0
- data/generated/stellar/hmac_sha256_key.rb +1 -1
- data/generated/stellar/hmac_sha256_mac.rb +1 -1
- data/generated/stellar/inner_transaction_result.rb +56 -0
- data/generated/stellar/inner_transaction_result/ext.rb +24 -0
- data/generated/stellar/inner_transaction_result/result.rb +52 -0
- data/generated/stellar/inner_transaction_result_pair.rb +20 -0
- data/generated/stellar/ledger_close_meta.rb +23 -0
- data/generated/stellar/ledger_close_meta_v0.rb +35 -0
- data/generated/stellar/ledger_close_value_signature.rb +20 -0
- data/generated/stellar/ledger_key.rb +1 -1
- data/generated/stellar/ledger_key/offer.rb +2 -2
- data/generated/stellar/manage_buy_offer_op.rb +29 -0
- data/generated/stellar/{manage_offer_result.rb → manage_buy_offer_result.rb} +5 -5
- data/generated/stellar/manage_buy_offer_result_code.rb +51 -0
- data/generated/stellar/{manage_offer_op.rb → manage_sell_offer_op.rb} +4 -4
- data/generated/stellar/manage_sell_offer_result.rb +26 -0
- data/generated/stellar/manage_sell_offer_result_code.rb +54 -0
- data/generated/stellar/message_type.rb +6 -1
- data/generated/stellar/muxed_account.rb +35 -0
- data/generated/stellar/muxed_account/med25519.rb +22 -0
- data/generated/stellar/offer_entry.rb +2 -2
- data/generated/stellar/operation.rb +13 -9
- data/generated/stellar/operation/body.rb +37 -29
- data/generated/stellar/operation_result.rb +10 -6
- data/generated/stellar/operation_result/tr.rb +38 -30
- data/generated/stellar/operation_result_code.rb +11 -7
- data/generated/stellar/operation_type.rb +20 -16
- data/generated/stellar/{path_payment_op.rb → path_payment_strict_receive_op.rb} +6 -6
- data/generated/stellar/path_payment_strict_receive_result.rb +38 -0
- data/generated/stellar/path_payment_strict_receive_result/success.rb +22 -0
- data/generated/stellar/path_payment_strict_receive_result_code.rb +56 -0
- data/generated/stellar/path_payment_strict_send_op.rb +32 -0
- data/generated/stellar/{path_payment_result.rb → path_payment_strict_send_result.rb} +7 -7
- data/generated/stellar/{path_payment_result → path_payment_strict_send_result}/success.rb +1 -1
- data/generated/stellar/path_payment_strict_send_result_code.rb +55 -0
- data/generated/stellar/payment_op.rb +4 -4
- data/generated/stellar/peer_stats.rb +48 -0
- data/generated/stellar/signed_survey_request_message.rb +20 -0
- data/generated/stellar/signed_survey_response_message.rb +20 -0
- data/generated/stellar/signer.rb +1 -1
- data/generated/stellar/stellar_message.rb +22 -12
- data/generated/stellar/stellar_value.rb +7 -5
- data/generated/stellar/stellar_value/ext.rb +8 -4
- data/generated/stellar/stellar_value_type.rb +22 -0
- data/generated/stellar/survey_message_command_type.rb +20 -0
- data/generated/stellar/survey_request_message.rb +26 -0
- data/generated/stellar/survey_response_body.rb +23 -0
- data/generated/stellar/survey_response_message.rb +26 -0
- data/generated/stellar/time_bounds.rb +4 -4
- data/generated/stellar/topology_response_body.rb +25 -0
- data/generated/stellar/transaction.rb +4 -4
- data/generated/stellar/transaction_envelope.rb +17 -8
- data/generated/stellar/transaction_meta.rb +4 -0
- data/generated/stellar/transaction_meta_v1.rb +1 -1
- data/generated/stellar/transaction_meta_v2.rb +24 -0
- data/generated/stellar/transaction_result.rb +3 -0
- data/generated/stellar/transaction_result/result.rb +9 -3
- data/generated/stellar/transaction_result_code.rb +21 -14
- data/generated/stellar/transaction_result_meta.rb +22 -0
- data/generated/stellar/transaction_signature_payload.rb +3 -1
- data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +7 -3
- data/generated/stellar/transaction_v0.rb +39 -0
- data/generated/stellar/transaction_v0/ext.rb +24 -0
- data/generated/stellar/transaction_v0_envelope.rb +22 -0
- data/generated/stellar/transaction_v1_envelope.rb +22 -0
- data/generated/stellar/trust_line_flags.rb +6 -2
- data/generated/stellar/upgrade_entry_meta.rb +20 -0
- data/lib/stellar-base.rb +28 -23
- data/lib/stellar/account_flags.rb +2 -4
- data/lib/stellar/asset.rb +6 -6
- data/lib/stellar/base.rb +1 -1
- data/lib/stellar/compat.rb +21 -0
- data/lib/stellar/concerns/transaction.rb +49 -0
- data/lib/stellar/convert.rb +2 -2
- data/lib/stellar/factories.rb +1 -3
- data/lib/stellar/fee_bump_transaction.rb +21 -0
- data/lib/stellar/key_pair.rb +9 -6
- data/lib/stellar/networks.rb +5 -7
- data/lib/stellar/operation.rb +428 -317
- data/lib/stellar/{path_payment_result.rb → path_payment_strict_receive_result.rb} +2 -3
- data/lib/stellar/price.rb +2 -4
- data/lib/stellar/signer_key.rb +4 -8
- data/lib/stellar/thresholds.rb +5 -7
- data/lib/stellar/transaction.rb +154 -169
- data/lib/stellar/transaction_builder.rb +149 -0
- data/lib/stellar/transaction_envelope.rb +40 -8
- data/lib/stellar/transaction_v0.rb +39 -0
- data/lib/stellar/util/continued_fraction.rb +19 -19
- data/lib/stellar/util/strkey.rb +39 -14
- data/lib/stellar/{base/version.rb → version.rb} +1 -1
- metadata +68 -210
- data/.gitignore +0 -17
- data/.travis.yml +0 -13
- data/.yardopts +0 -8
- data/CHANGELOG.md +0 -120
- data/CONTRIBUTING.md +0 -48
- data/Gemfile +0 -15
- data/Guardfile +0 -5
- data/Rakefile +0 -4
- data/examples/create_account.rb +0 -26
- data/examples/low_level_transaction_post.rb +0 -46
- data/examples/mid_level_transaction_post.rb +0 -33
- data/examples/non_native_payment.rb +0 -60
- data/examples/offer.rb +0 -75
- data/examples/transaction_merge.rb +0 -23
- data/generated/stellar/manage_offer_result_code.rb +0 -50
- data/generated/stellar/path_payment_result_code.rb +0 -47
- data/ruby-stellar-base.gemspec +0 -34
- data/spec/lib/stellar/account_flags_spec.rb +0 -19
- data/spec/lib/stellar/asset_spec.rb +0 -45
- data/spec/lib/stellar/convert_spec.rb +0 -61
- data/spec/lib/stellar/key_pair_spec.rb +0 -251
- data/spec/lib/stellar/networks_spec.rb +0 -77
- data/spec/lib/stellar/operation_spec.rb +0 -71
- data/spec/lib/stellar/path_payment_result_spec.rb +0 -95
- data/spec/lib/stellar/price_spec.rb +0 -34
- data/spec/lib/stellar/signer_key_spec.rb +0 -26
- data/spec/lib/stellar/thresholds_spec.rb +0 -62
- data/spec/lib/stellar/transaction_envelope_spec.rb +0 -93
- data/spec/lib/stellar/transaction_spec.rb +0 -100
- data/spec/lib/stellar/util/strkey_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -16
- data/spec/support/matchers/be_strkey.rb +0 -9
- data/spec/support/matchers/eq_bytes.rb +0 -5
- data/spec/support/matchers/have_length.rb +0 -5
- data/tasks/rspec.rake +0 -6
- data/tasks/travis.rake +0 -1
- data/tasks/xdr.rake +0 -50
- data/xdr/Stellar-SCP.x +0 -86
- data/xdr/Stellar-ledger-entries.x +0 -288
- data/xdr/Stellar-ledger.x +0 -283
- data/xdr/Stellar-overlay.x +0 -146
- data/xdr/Stellar-transaction.x +0 -777
- data/xdr/Stellar-types.x +0 -81
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -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
data/CHANGELOG.md
DELETED
@@ -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`.
|
data/CONTRIBUTING.md
DELETED
@@ -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
data/Rakefile
DELETED
data/examples/create_account.rb
DELETED
@@ -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
|
-
})
|
data/examples/offer.rb
DELETED
@@ -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
|
-
})
|