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
@@ -1,5 +1,5 @@
1
1
  module Stellar
2
- class PathPaymentResult
2
+ class PathPaymentStrictReceiveResult
3
3
  # send_amount returns the actual amount paid for the corresponding
4
4
  # PathPaymentOp to this result.
5
5
  #
@@ -8,10 +8,9 @@ module Stellar
8
8
  return s.last.amount if s.offers.blank?
9
9
 
10
10
  source_asset = s.offers.first.asset_bought
11
- source_offers = s.offers.take_while{|o| o.asset_bought == source_asset}
11
+ source_offers = s.offers.take_while { |o| o.asset_bought == source_asset }
12
12
 
13
13
  source_offers.map(&:amount_bought).sum
14
14
  end
15
-
16
15
  end
17
16
  end
@@ -1,8 +1,6 @@
1
1
  module Stellar
2
-
3
2
  # reopen class
4
3
  class Price
5
-
6
4
  MAX_PRECISION = (2**31) - 1
7
5
 
8
6
  def self.from_f(number)
@@ -14,7 +12,7 @@ module Stellar
14
12
  end
15
13
 
16
14
  def invert
17
- self.class.new(n:d,d:n)
15
+ self.class.new(n: d, d: n)
18
16
  end
19
17
 
20
18
  def to_f
@@ -29,4 +27,4 @@ module Stellar
29
27
  "#<Stellar::Price #{self}>"
30
28
  end
31
29
  end
32
- end
30
+ end
@@ -1,6 +1,5 @@
1
1
  module Stellar
2
2
  class SignerKey
3
-
4
3
  PREIMAGE_LENGTH = 32
5
4
 
6
5
  def self.ed25519(keypair)
@@ -8,16 +7,14 @@ module Stellar
8
7
  new(:signer_key_type_ed25519, keypair.raw_public_key)
9
8
  end
10
9
 
11
-
12
10
  def self.preauthorized_transaction(tx)
13
11
  new(:signer_key_type_pre_auth_tx, tx.hash)
14
12
  end
15
13
 
16
-
17
14
  def self.hash_x(preimage)
18
- raise ArgumentError, "Must be string" unless preimage.is_a?(String)
15
+ raise ArgumentError, "Must be string" unless preimage.is_a?(String)
19
16
  raise ArgumentError, "Must be 32 bytes" unless preimage.bytesize == PREIMAGE_LENGTH
20
-
17
+
21
18
  hash_x = Digest::SHA256.digest(preimage)
22
19
  new(:signer_key_type_hash_x, hash_x)
23
20
  end
@@ -37,14 +34,13 @@ module Stellar
37
34
  end
38
35
 
39
36
  def inspect
40
- label = switch.to_s
41
- "#<Stellar::SignerKey #{to_s}>"
37
+ # label = switch.to_s
38
+ "#<Stellar::SignerKey #{self}>"
42
39
  end
43
40
 
44
41
  def signature_hint
45
42
  # take last 4 bytes
46
43
  value.to_xdr.slice(-4, 4)
47
44
  end
48
-
49
45
  end
50
46
  end
@@ -3,10 +3,9 @@ module Stellar
3
3
  COMPONENTS = [:master_weight, :low, :medium, :high]
4
4
  VALID_RANGE = 0..255
5
5
 
6
- def make(thresholds={})
7
-
6
+ def make(thresholds = {})
8
7
  # error if any of the needed components are not provided
9
- if COMPONENTS.any?{|c| thresholds[c].blank? }
8
+ if COMPONENTS.any? { |c| thresholds[c].blank? }
10
9
  raise ArgumentError, "invalid thresholds hash, must have #{COMPONENTS.inspect} keys, had: #{thresholds.keys.inspect}"
11
10
  end
12
11
 
@@ -22,7 +21,6 @@ module Stellar
22
21
  end
23
22
  end
24
23
 
25
-
26
24
  thresholds.values_at(*COMPONENTS).pack("C*")
27
25
  end
28
26
 
@@ -30,9 +28,9 @@ module Stellar
30
28
  master_weight, low, medium, high = combined.unpack("C*")
31
29
  {
32
30
  master_weight: master_weight,
33
- low: low,
34
- medium: medium,
35
- high: high,
31
+ low: low,
32
+ medium: medium,
33
+ high: high
36
34
  }
37
35
  end
38
36
  end
@@ -1,202 +1,187 @@
1
1
  module Stellar
2
2
  class Transaction
3
+ include Stellar::Concerns::Transaction
3
4
 
4
- #
5
- # @see Stellar::Operation.payment
6
- def self.payment(attributes={})
7
- make :payment, attributes
8
- end
5
+ class << self
6
+ #
7
+ # @see Stellar::Operation.payment
8
+ def payment(attributes = {})
9
+ make :payment, attributes
10
+ end
9
11
 
10
- #
11
- # @see Stellar::Operation.path_payment
12
- def self.path_payment(attributes={})
13
- make :path_payment, attributes
14
- end
12
+ #
13
+ # @see Stellar::Operation.path_payment
14
+ def path_payment(attributes = {})
15
+ make :path_payment, attributes
16
+ end
15
17
 
16
- #
17
- # @see Stellar::Operation.create_account
18
- def self.create_account(attributes={})
19
- make :create_account, attributes
20
- end
18
+ #
19
+ # @see Stellar::Operation.path_payment_strict_receive
20
+ def path_payment_strict_receive(attributes = {})
21
+ make :path_payment_strict_receive, attributes
22
+ end
21
23
 
22
- #
23
- # @see Stellar::Operation.change_trust
24
- def self.change_trust(attributes={})
25
- make :change_trust, attributes
26
- end
24
+ #
25
+ # @see Stellar::Operation.path_payment_strict_send
26
+ def path_payment_strict_send(attributes = {})
27
+ make :path_payment_strict_send, attributes
28
+ end
27
29
 
28
- #
29
- # @see Stellar::Operation.create_offer
30
- def self.manage_offer(attributes={})
31
- make :manage_offer, attributes
32
- end
30
+ #
31
+ # @see Stellar::Operation.create_account
32
+ def create_account(attributes = {})
33
+ make :create_account, attributes
34
+ end
33
35
 
34
- #
35
- # @see Stellar::Operation.create_passive_offer
36
- def self.create_passive_offer(attributes={})
37
- make :create_passive_offer, attributes
38
- end
36
+ #
37
+ # @see Stellar::Operation.change_trust
38
+ def change_trust(attributes = {})
39
+ make :change_trust, attributes
40
+ end
39
41
 
40
- #
41
- # @see Stellar::Operation.set_options
42
- def self.set_options(attributes={})
43
- make :set_options, attributes
44
- end
42
+ #
43
+ # @see Stellar::Operation.manage_sell_offer
44
+ def manage_sell_offer(attributes = {})
45
+ make :manage_sell_offer, attributes
46
+ end
45
47
 
46
- #
47
- # @see Stellar::Operation.allow_trust
48
- def self.allow_trust(attributes={})
49
- make :allow_trust, attributes
50
- end
48
+ #
49
+ # @see Stellar::Operation.manage_buy_offer
50
+ def manage_buy_offer(attributes = {})
51
+ make :manage_buy_offer, attributes
52
+ end
51
53
 
52
- #
53
- # @see Stellar::Operation.account_merge
54
- def self.account_merge(attributes={})
55
- make :account_merge, attributes
56
- end
54
+ #
55
+ # @see Stellar::Operation.create_passive_sell_offer
56
+ def create_passive_sell_offer(attributes = {})
57
+ make :create_passive_sell_offer, attributes
58
+ end
57
59
 
58
- #
59
- # @see Stellar::Operation.inflation
60
- def self.inflation(attributes={})
61
- make :inflation, attributes
62
- end
60
+ #
61
+ # @see Stellar::Operation.set_options
62
+ def set_options(attributes = {})
63
+ make :set_options, attributes
64
+ end
63
65
 
64
- #
65
- # @see Stellar::Operation.manage_data
66
- def self.manage_data(attributes={})
67
- make :manage_data, attributes
68
- end
66
+ #
67
+ # @see Stellar::Operation.allow_trust
68
+ def allow_trust(attributes = {})
69
+ make :allow_trust, attributes
70
+ end
69
71
 
70
- #
71
- # @see Stellar::Operation.manage_data
72
- def self.bump_sequence(attributes={})
73
- make :bump_sequence, attributes
74
- end
72
+ #
73
+ # @see Stellar::Operation.account_merge
74
+ def account_merge(attributes = {})
75
+ make :account_merge, attributes
76
+ end
75
77
 
76
- #
77
- # Helper method to create a transaction with a single
78
- # operation of the provided type. See class methods
79
- # on Stellar::Operation for available values for
80
- # operation_type.
81
- #
82
- # @see Stellar::Operation
83
- #
84
- # @param operation_type [Symbol] the operation to use
85
- # @param attributes={} [Hash] attributes to use for both the transaction and the operation
86
- #
87
- # @return [Stellar::Transaction] the resulting transaction
88
- def self.make(operation_type, attributes={})
89
- for_account(attributes).tap do |result|
90
- result.operations << Operation.send(operation_type, attributes)
78
+ #
79
+ # @see Stellar::Operation.inflation
80
+ def inflation(attributes = {})
81
+ make :inflation, attributes
91
82
  end
92
- end
93
83
 
84
+ #
85
+ # @see Stellar::Operation.manage_data
86
+ def manage_data(attributes = {})
87
+ make :manage_data, attributes
88
+ end
94
89
 
95
- #
96
- # Helper method to create the skeleton of a transaction.
97
- # The resulting transaction will have its source account,
98
- # sequence, fee, min ledger and max ledger set.
99
- #
100
- #
101
- # @param attributes={} [type] [description]
102
- #
103
- # @return [Stellar::Transaction] the resulting skeleton
104
- def self.for_account(attributes={})
105
- account = attributes[:account]
106
- sequence = attributes[:sequence]
107
- fee = attributes[:fee]
108
-
109
- raise ArgumentError, "Bad :account" unless account.is_a?(KeyPair)
110
- raise ArgumentError, "Bad :sequence #{sequence}" unless sequence.is_a?(Integer)
111
- raise ArgumentError, "Bad :fee #{sequence}" if fee.present? && !fee.is_a?(Integer)
112
-
113
- new.tap do |result|
114
- result.seq_num = sequence
115
- result.fee = fee
116
- result.memo = make_memo(attributes[:memo])
117
- result.source_account = account.account_id
118
- result.apply_defaults
90
+ #
91
+ # @see Stellar::Operation.manage_data
92
+ def bump_sequence(attributes = {})
93
+ make :bump_sequence, attributes
119
94
  end
120
- end
121
95
 
122
- def sign(key_pair)
123
- key_pair.sign(hash)
124
- end
96
+ #
97
+ # DEPRECATED
98
+ #
99
+ # All methods calling make() have been deprecated in favor of Stellar::TransactionBuilder.
100
+ # These functions only create single-operation transactions and essentially duplicate the
101
+ # methods provided by Stellar::Operation. Stellar::TransactionBuilder enables the construction
102
+ # of multi-operation transactions and mirrors the functionality provided by the Python and
103
+ # JavaScript SDKs.
104
+ #
105
+ # Helper method to create a transaction with a single
106
+ # operation of the provided type. See class methods
107
+ # on Stellar::Operation for available values for
108
+ # operation_type.
109
+ #
110
+ # @see Stellar::Operation
111
+ #
112
+ # @param operation_type [Symbol] the operation to use
113
+ # @param attributes={} [Hash] attributes to use for both the transaction and the operation
114
+ #
115
+ # @return [Stellar::Transaction] the resulting transaction
116
+ def make(operation_type, attributes = {})
117
+ Stellar::Deprecation.warn(
118
+ "Transaction.#{operation_type} is deprecated. Use Stellar::TransactionBuilder instead."
119
+ )
120
+ for_account(attributes).tap do |result|
121
+ result.operations << Operation.send(operation_type, attributes)
122
+ end
123
+ end
125
124
 
126
- def sign_decorated(key_pair)
127
- key_pair.sign_decorated(hash)
128
- end
125
+ #
126
+ # Helper method to create the skeleton of a transaction.
127
+ # The resulting transaction will have its source account,
128
+ # sequence, fee, min ledger and max ledger set.
129
+ #
130
+ #
131
+ # @param attributes={} [type] [description]
132
+ #
133
+ # @return [Stellar::Transaction] the resulting skeleton
134
+ def for_account(attributes = {})
135
+ account = attributes[:account]
136
+ sequence = attributes[:sequence]
137
+ fee = attributes[:fee]
138
+
139
+ raise ArgumentError, "Bad :account" unless account.is_a?(KeyPair)
140
+ raise ArgumentError, "Bad :sequence #{sequence}" unless sequence.is_a?(Integer)
141
+ raise ArgumentError, "Bad :fee #{sequence}" if fee.present? && !fee.is_a?(Integer)
142
+
143
+ new.tap do |result|
144
+ result.seq_num = sequence
145
+ result.fee = fee
146
+ result.memo = make_memo(attributes[:memo])
147
+ result.source_account = account.muxed_account
148
+ result.apply_defaults
149
+ end
150
+ end
129
151
 
130
- def hash
131
- Digest::SHA256.digest(signature_base)
152
+ private
153
+
154
+ def make_memo(memo)
155
+ case memo
156
+ when Stellar::Memo
157
+ memo
158
+ when nil
159
+ nil
160
+ when Integer
161
+ Memo.new(:memo_id, memo)
162
+ when String
163
+ Memo.new(:memo_text, memo)
164
+ when Array
165
+ t, val = *memo
166
+ Memo.new(:"memo_#{t}", val)
167
+ else
168
+ raise ArgumentError, "Bad :memo"
169
+ end
170
+ end
132
171
  end
133
172
 
134
- # Returns the string of bytes that, when hashed, provide the value which
135
- # should be signed to create a valid stellar transaciton signature
136
173
  def signature_base
137
- signature_base_prefix + to_xdr
138
- end
139
-
140
- def signature_base_prefix
141
- val = Stellar::EnvelopeType.envelope_type_tx
142
-
143
- Stellar.current_network_id + Stellar::EnvelopeType.to_xdr(val)
174
+ tagged_tx = Stellar::TransactionSignaturePayload::TaggedTransaction.new(:envelope_type_tx, self)
175
+ Stellar::TransactionSignaturePayload.new(
176
+ network_id: Stellar.current_network_id,
177
+ tagged_transaction: tagged_tx
178
+ ).to_xdr
144
179
  end
145
180
 
146
181
  def to_envelope(*key_pairs)
147
182
  signatures = (key_pairs || []).map(&method(:sign_decorated))
148
183
 
149
- TransactionEnvelope.new({
150
- :signatures => signatures,
151
- :tx => self
152
- })
153
- end
154
-
155
- def merge(other)
156
- cloned = Marshal.load Marshal.dump(self)
157
- cloned.operations += other.to_operations
158
- cloned
159
- end
160
-
161
-
162
- #
163
- # Extracts the operations from this single transaction,
164
- # setting the source account on the extracted operations.
165
- #
166
- # Useful for merging transactions.
167
- #
168
- # @return [Array<Operation>] the operations
169
- def to_operations
170
- cloned = Marshal.load Marshal.dump(operations)
171
- operations.each do |op|
172
- op.source_account ||= self.source_account
173
- end
174
- end
175
-
176
- def apply_defaults
177
- self.operations ||= []
178
- self.fee ||= 100
179
- self.memo ||= Memo.new(:memo_none)
180
- self.ext ||= Stellar::Transaction::Ext.new 0
181
- end
182
-
183
- private
184
- def self.make_memo(memo)
185
- case memo
186
- when Stellar::Memo ;
187
- memo
188
- when nil ;
189
- nil
190
- when Integer ;
191
- Memo.new(:memo_id, memo)
192
- when String ;
193
- Memo.new(:memo_text, memo)
194
- when Array ;
195
- t, val = *memo
196
- Memo.new(:"memo_#{t}", val)
197
- else
198
- raise ArgumentError, "Bad :memo"
199
- end
184
+ TransactionEnvelope.v1(signatures: signatures, tx: self)
200
185
  end
201
186
  end
202
187
  end