stellar-base 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +11 -1
- data/generated/stellar-base-generated.rb +5 -1
- data/generated/stellar/account_merge_result_code.rb +6 -4
- data/generated/stellar/allow_trust_result_code.rb +1 -1
- data/generated/stellar/bump_sequence_op.rb +18 -0
- data/generated/stellar/bump_sequence_result.rb +25 -0
- data/generated/stellar/bump_sequence_result_code.rb +24 -0
- data/generated/stellar/change_trust_result_code.rb +2 -1
- data/generated/stellar/manage_data_op.rb +2 -2
- data/generated/stellar/manage_data_result_code.rb +6 -4
- data/generated/stellar/operation.rb +2 -0
- data/generated/stellar/operation/body.rb +4 -0
- data/generated/stellar/operation_result.rb +2 -0
- data/generated/stellar/operation_result/tr.rb +4 -0
- data/generated/stellar/operation_result_code.rb +7 -5
- data/generated/stellar/operation_type.rb +3 -1
- data/generated/stellar/stellar_message.rb +2 -2
- data/generated/stellar/transaction_envelope.rb +1 -2
- data/generated/stellar/transaction_meta.rb +4 -0
- data/generated/stellar/transaction_meta_v1.rb +20 -0
- data/generated/stellar/transaction_signature_payload.rb +6 -4
- data/generated/stellar/transaction_signature_payload/tagged_transaction.rb +2 -2
- data/lib/stellar/base/version.rb +1 -1
- data/lib/stellar/operation.rb +18 -2
- data/lib/stellar/transaction.rb +6 -0
- data/lib/stellar/util/strkey.rb +4 -2
- data/ruby-stellar-base.gemspec +1 -1
- data/spec/lib/stellar/operation_spec.rb +27 -0
- data/spec/lib/stellar/util/strkey_spec.rb +11 -3
- data/tasks/xdr.rake +1 -1
- data/xdr/Stellar-ledger-entries.x +1 -1
- data/xdr/Stellar-ledger.x +10 -0
- data/xdr/Stellar-overlay.x +1 -1
- data/xdr/Stellar-transaction.x +63 -23
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d155c06a6614979a0ea9eba7e5dcd903066c724
|
4
|
+
data.tar.gz: 0c64ccb007896ef7ce617b19aff2d542f9fe40cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00a096af9c978b25848d9a2efd572cc279e52e4860c5db26dee72a7ab954693b09b9e5178b6d63f1c0ff977de8ea0ee83cfd07c58332ce0045b67dbf86eb2706
|
7
|
+
data.tar.gz: f19a0bad6a1489411bb673ecf060a5232aa3c76ee029f6f24c901769501c709dc3058c693bb19fc4ba2defba259b24faa55b844e66b76c8ef5ce8d536b4d89d4
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,17 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
As this project is pre 1.0, breaking changes may happen for minor version
|
7
7
|
bumps. A breaking change will get clearly notified in this log.
|
8
8
|
|
9
|
-
## [unreleased](https://github.com/stellar/ruby-stellar-base/compare/v0.
|
9
|
+
## [unreleased](https://github.com/stellar/ruby-stellar-base/compare/v0.14.0...master)
|
10
|
+
|
11
|
+
## [0.14.0](https://github.com/stellar/ruby-stellar-base/compare/v0.13.0...v0.14.0)
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- We now support the bump sequence operation with `Operation.bump_sequence`.
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Update XDR definitions for stellar-core 0.10.0 support
|
18
|
+
- `Operation.change_trust` learned how to use a default for the `:limit` parameter
|
19
|
+
- `StrKey` learned about new version bytes `pre_auth_tx` and `hash_x`
|
10
20
|
|
11
21
|
## [0.13.0](https://github.com/stellar/ruby-stellar-base/compare/v0.12.0...v0.13.0)
|
12
22
|
|
@@ -32,7 +32,7 @@ module Stellar
|
|
32
32
|
Thresholds = XDR::Opaque[4]
|
33
33
|
String32 = XDR::String[32]
|
34
34
|
String64 = XDR::String[64]
|
35
|
-
SequenceNumber =
|
35
|
+
SequenceNumber = Int64
|
36
36
|
DataValue = XDR::VarOpaque[64]
|
37
37
|
autoload :AssetType
|
38
38
|
autoload :Asset
|
@@ -67,6 +67,7 @@ module Stellar
|
|
67
67
|
autoload :ChangeTrustOp
|
68
68
|
autoload :AllowTrustOp
|
69
69
|
autoload :ManageDataOp
|
70
|
+
autoload :BumpSequenceOp
|
70
71
|
autoload :Operation
|
71
72
|
autoload :MemoType
|
72
73
|
autoload :Memo
|
@@ -99,6 +100,8 @@ module Stellar
|
|
99
100
|
autoload :InflationResult
|
100
101
|
autoload :ManageDataResultCode
|
101
102
|
autoload :ManageDataResult
|
103
|
+
autoload :BumpSequenceResultCode
|
104
|
+
autoload :BumpSequenceResult
|
102
105
|
autoload :OperationResultCode
|
103
106
|
autoload :OperationResult
|
104
107
|
autoload :TransactionResultCode
|
@@ -128,6 +131,7 @@ module Stellar
|
|
128
131
|
autoload :LedgerEntryChange
|
129
132
|
LedgerEntryChanges = XDR::VarArray[LedgerEntryChange]
|
130
133
|
autoload :OperationMeta
|
134
|
+
autoload :TransactionMetaV1
|
131
135
|
autoload :TransactionMeta
|
132
136
|
end
|
133
137
|
module Stellar
|
@@ -10,10 +10,11 @@ require 'xdr'
|
|
10
10
|
# // codes considered as "success" for the operation
|
11
11
|
# ACCOUNT_MERGE_SUCCESS = 0,
|
12
12
|
# // codes considered as "failure" for the operation
|
13
|
-
# ACCOUNT_MERGE_MALFORMED = -1,
|
14
|
-
# ACCOUNT_MERGE_NO_ACCOUNT = -2,
|
15
|
-
# ACCOUNT_MERGE_IMMUTABLE_SET = -3,
|
16
|
-
# ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4 // account has trust lines/offers
|
13
|
+
# ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself
|
14
|
+
# ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist
|
15
|
+
# ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set
|
16
|
+
# ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers
|
17
|
+
# ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5 // sequence number is over max allowed
|
17
18
|
# };
|
18
19
|
#
|
19
20
|
# ===========================================================================
|
@@ -24,6 +25,7 @@ module Stellar
|
|
24
25
|
member :account_merge_no_account, -2
|
25
26
|
member :account_merge_immutable_set, -3
|
26
27
|
member :account_merge_has_sub_entries, -4
|
28
|
+
member :account_merge_seqnum_too_far, -5
|
27
29
|
|
28
30
|
seal
|
29
31
|
end
|
@@ -14,7 +14,7 @@ require 'xdr'
|
|
14
14
|
# ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
|
15
15
|
# // source account does not require trust
|
16
16
|
# ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
|
17
|
-
# ALLOW_TRUST_CANT_REVOKE = -4,
|
17
|
+
# ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust,
|
18
18
|
# ALLOW_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
|
19
19
|
# };
|
20
20
|
#
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This code was automatically generated using xdrgen
|
2
|
+
# DO NOT EDIT or your changes may be overwritten
|
3
|
+
|
4
|
+
require 'xdr'
|
5
|
+
|
6
|
+
# === xdr source ============================================================
|
7
|
+
#
|
8
|
+
# struct BumpSequenceOp
|
9
|
+
# {
|
10
|
+
# SequenceNumber bumpTo;
|
11
|
+
# };
|
12
|
+
#
|
13
|
+
# ===========================================================================
|
14
|
+
module Stellar
|
15
|
+
class BumpSequenceOp < XDR::Struct
|
16
|
+
attribute :bump_to, SequenceNumber
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This code was automatically generated using xdrgen
|
2
|
+
# DO NOT EDIT or your changes may be overwritten
|
3
|
+
|
4
|
+
require 'xdr'
|
5
|
+
|
6
|
+
# === xdr source ============================================================
|
7
|
+
#
|
8
|
+
# union BumpSequenceResult switch (BumpSequenceResultCode code)
|
9
|
+
# {
|
10
|
+
# case BUMP_SEQUENCE_SUCCESS:
|
11
|
+
# void;
|
12
|
+
# default:
|
13
|
+
# void;
|
14
|
+
# };
|
15
|
+
#
|
16
|
+
# ===========================================================================
|
17
|
+
module Stellar
|
18
|
+
class BumpSequenceResult < XDR::Union
|
19
|
+
switch_on BumpSequenceResultCode, :code
|
20
|
+
|
21
|
+
switch :bump_sequence_success
|
22
|
+
switch :default
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This code was automatically generated using xdrgen
|
2
|
+
# DO NOT EDIT or your changes may be overwritten
|
3
|
+
|
4
|
+
require 'xdr'
|
5
|
+
|
6
|
+
# === xdr source ============================================================
|
7
|
+
#
|
8
|
+
# enum BumpSequenceResultCode
|
9
|
+
# {
|
10
|
+
# // codes considered as "success" for the operation
|
11
|
+
# BUMP_SEQUENCE_SUCCESS = 0,
|
12
|
+
# // codes considered as "failure" for the operation
|
13
|
+
# BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds
|
14
|
+
# };
|
15
|
+
#
|
16
|
+
# ===========================================================================
|
17
|
+
module Stellar
|
18
|
+
class BumpSequenceResultCode < XDR::Enum
|
19
|
+
member :bump_sequence_success, 0
|
20
|
+
member :bump_sequence_bad_seq, -1
|
21
|
+
|
22
|
+
seal
|
23
|
+
end
|
24
|
+
end
|
@@ -14,7 +14,8 @@ require 'xdr'
|
|
14
14
|
# CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer
|
15
15
|
# CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance
|
16
16
|
# // cannot create with a limit of 0
|
17
|
-
# CHANGE_TRUST_LOW_RESERVE =
|
17
|
+
# CHANGE_TRUST_LOW_RESERVE =
|
18
|
+
# -4, // not enough funds to create a new trust line,
|
18
19
|
# CHANGE_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
|
19
20
|
# };
|
20
21
|
#
|
@@ -7,8 +7,8 @@ require 'xdr'
|
|
7
7
|
#
|
8
8
|
# struct ManageDataOp
|
9
9
|
# {
|
10
|
-
# string64 dataName;
|
11
|
-
# DataValue* dataValue;
|
10
|
+
# string64 dataName;
|
11
|
+
# DataValue* dataValue; // set to null to clear
|
12
12
|
# };
|
13
13
|
#
|
14
14
|
# ===========================================================================
|
@@ -10,10 +10,12 @@ require 'xdr'
|
|
10
10
|
# // codes considered as "success" for the operation
|
11
11
|
# MANAGE_DATA_SUCCESS = 0,
|
12
12
|
# // codes considered as "failure" for the operation
|
13
|
-
# MANAGE_DATA_NOT_SUPPORTED_YET =
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
13
|
+
# MANAGE_DATA_NOT_SUPPORTED_YET =
|
14
|
+
# -1, // The network hasn't moved to this protocol change yet
|
15
|
+
# MANAGE_DATA_NAME_NOT_FOUND =
|
16
|
+
# -2, // Trying to remove a Data Entry that isn't there
|
17
|
+
# MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry
|
18
|
+
# MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string
|
17
19
|
# };
|
18
20
|
#
|
19
21
|
# ===========================================================================
|
@@ -29,6 +29,8 @@ require 'xdr'
|
|
29
29
|
# void;
|
30
30
|
# case MANAGE_DATA:
|
31
31
|
# ManageDataOp manageDataOp;
|
32
|
+
# case BUMP_SEQUENCE:
|
33
|
+
# BumpSequenceOp bumpSequenceOp;
|
32
34
|
# }
|
33
35
|
#
|
34
36
|
# ===========================================================================
|
@@ -48,6 +50,7 @@ module Stellar
|
|
48
50
|
switch :account_merge, :destination
|
49
51
|
switch :inflation
|
50
52
|
switch :manage_data, :manage_data_op
|
53
|
+
switch :bump_sequence, :bump_sequence_op
|
51
54
|
|
52
55
|
attribute :create_account_op, CreateAccountOp
|
53
56
|
attribute :payment_op, PaymentOp
|
@@ -59,6 +62,7 @@ module Stellar
|
|
59
62
|
attribute :allow_trust_op, AllowTrustOp
|
60
63
|
attribute :destination, AccountID
|
61
64
|
attribute :manage_data_op, ManageDataOp
|
65
|
+
attribute :bump_sequence_op, BumpSequenceOp
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -29,6 +29,8 @@ require 'xdr'
|
|
29
29
|
# InflationResult inflationResult;
|
30
30
|
# case MANAGE_DATA:
|
31
31
|
# ManageDataResult manageDataResult;
|
32
|
+
# case BUMP_SEQUENCE:
|
33
|
+
# BumpSequenceResult bumpSeqResult;
|
32
34
|
# }
|
33
35
|
#
|
34
36
|
# ===========================================================================
|
@@ -48,6 +50,7 @@ module Stellar
|
|
48
50
|
switch :account_merge, :account_merge_result
|
49
51
|
switch :inflation, :inflation_result
|
50
52
|
switch :manage_data, :manage_data_result
|
53
|
+
switch :bump_sequence, :bump_seq_result
|
51
54
|
|
52
55
|
attribute :create_account_result, CreateAccountResult
|
53
56
|
attribute :payment_result, PaymentResult
|
@@ -60,6 +63,7 @@ module Stellar
|
|
60
63
|
attribute :account_merge_result, AccountMergeResult
|
61
64
|
attribute :inflation_result, InflationResult
|
62
65
|
attribute :manage_data_result, ManageDataResult
|
66
|
+
attribute :bump_seq_result, BumpSequenceResult
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
@@ -9,16 +9,18 @@ require 'xdr'
|
|
9
9
|
# {
|
10
10
|
# opINNER = 0, // inner object result is valid
|
11
11
|
#
|
12
|
-
# opBAD_AUTH = -1,
|
13
|
-
# opNO_ACCOUNT = -2
|
12
|
+
# opBAD_AUTH = -1, // too few valid signatures / wrong network
|
13
|
+
# opNO_ACCOUNT = -2, // source account was not found
|
14
|
+
# opNOT_SUPPORTED = -3 // operation not supported at this time
|
14
15
|
# };
|
15
16
|
#
|
16
17
|
# ===========================================================================
|
17
18
|
module Stellar
|
18
19
|
class OperationResultCode < XDR::Enum
|
19
|
-
member :op_inner,
|
20
|
-
member :op_bad_auth,
|
21
|
-
member :op_no_account,
|
20
|
+
member :op_inner, 0
|
21
|
+
member :op_bad_auth, -1
|
22
|
+
member :op_no_account, -2
|
23
|
+
member :op_not_supported, -3
|
22
24
|
|
23
25
|
seal
|
24
26
|
end
|
@@ -17,7 +17,8 @@ require 'xdr'
|
|
17
17
|
# ALLOW_TRUST = 7,
|
18
18
|
# ACCOUNT_MERGE = 8,
|
19
19
|
# INFLATION = 9,
|
20
|
-
# MANAGE_DATA = 10
|
20
|
+
# MANAGE_DATA = 10,
|
21
|
+
# BUMP_SEQUENCE = 11
|
21
22
|
# };
|
22
23
|
#
|
23
24
|
# ===========================================================================
|
@@ -34,6 +35,7 @@ module Stellar
|
|
34
35
|
member :account_merge, 8
|
35
36
|
member :inflation, 9
|
36
37
|
member :manage_data, 10
|
38
|
+
member :bump_sequence, 11
|
37
39
|
|
38
40
|
seal
|
39
41
|
end
|
@@ -18,7 +18,7 @@ require 'xdr'
|
|
18
18
|
# case GET_PEERS:
|
19
19
|
# void;
|
20
20
|
# case PEERS:
|
21
|
-
# PeerAddress peers
|
21
|
+
# PeerAddress peers<100>;
|
22
22
|
#
|
23
23
|
# case GET_TX_SET:
|
24
24
|
# uint256 txSetHash;
|
@@ -62,7 +62,7 @@ module Stellar
|
|
62
62
|
attribute :hello, Hello
|
63
63
|
attribute :auth, Auth
|
64
64
|
attribute :dont_have, DontHave
|
65
|
-
attribute :peers, XDR::VarArray[PeerAddress]
|
65
|
+
attribute :peers, XDR::VarArray[PeerAddress, 100]
|
66
66
|
attribute :tx_set_hash, Uint256
|
67
67
|
attribute :tx_set, TransactionSet
|
68
68
|
attribute :transaction, TransactionEnvelope
|
@@ -10,8 +10,7 @@ require 'xdr'
|
|
10
10
|
# Transaction tx;
|
11
11
|
# /* Each decorated signature is a signature over the SHA256 hash of
|
12
12
|
# * a TransactionSignaturePayload */
|
13
|
-
# DecoratedSignature
|
14
|
-
# signatures<20>;
|
13
|
+
# DecoratedSignature signatures<20>;
|
15
14
|
# };
|
16
15
|
#
|
17
16
|
# ===========================================================================
|
@@ -9,6 +9,8 @@ require 'xdr'
|
|
9
9
|
# {
|
10
10
|
# case 0:
|
11
11
|
# OperationMeta operations<>;
|
12
|
+
# case 1:
|
13
|
+
# TransactionMetaV1 v1;
|
12
14
|
# };
|
13
15
|
#
|
14
16
|
# ===========================================================================
|
@@ -17,7 +19,9 @@ module Stellar
|
|
17
19
|
switch_on XDR::Int, :v
|
18
20
|
|
19
21
|
switch 0, :operations
|
22
|
+
switch 1, :v1
|
20
23
|
|
21
24
|
attribute :operations, XDR::VarArray[OperationMeta]
|
25
|
+
attribute :v1, TransactionMetaV1
|
22
26
|
end
|
23
27
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This code was automatically generated using xdrgen
|
2
|
+
# DO NOT EDIT or your changes may be overwritten
|
3
|
+
|
4
|
+
require 'xdr'
|
5
|
+
|
6
|
+
# === xdr source ============================================================
|
7
|
+
#
|
8
|
+
# struct TransactionMetaV1
|
9
|
+
# {
|
10
|
+
# LedgerEntryChanges txChanges; // tx level changes if any
|
11
|
+
# OperationMeta operations<>; // meta for each operation
|
12
|
+
# };
|
13
|
+
#
|
14
|
+
# ===========================================================================
|
15
|
+
module Stellar
|
16
|
+
class TransactionMetaV1 < XDR::Struct
|
17
|
+
attribute :tx_changes, LedgerEntryChanges
|
18
|
+
attribute :operations, XDR::VarArray[OperationMeta]
|
19
|
+
end
|
20
|
+
end
|
@@ -5,14 +5,16 @@ require 'xdr'
|
|
5
5
|
|
6
6
|
# === xdr source ============================================================
|
7
7
|
#
|
8
|
-
# struct TransactionSignaturePayload
|
8
|
+
# struct TransactionSignaturePayload
|
9
|
+
# {
|
9
10
|
# Hash networkId;
|
10
11
|
# union switch (EnvelopeType type)
|
11
12
|
# {
|
12
13
|
# case ENVELOPE_TYPE_TX:
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# }
|
14
|
+
# Transaction tx;
|
15
|
+
# /* All other values of type are invalid */
|
16
|
+
# }
|
17
|
+
# taggedTransaction;
|
16
18
|
# };
|
17
19
|
#
|
18
20
|
# ===========================================================================
|
@@ -8,8 +8,8 @@ require 'xdr'
|
|
8
8
|
# union switch (EnvelopeType type)
|
9
9
|
# {
|
10
10
|
# case ENVELOPE_TYPE_TX:
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# Transaction tx;
|
12
|
+
# /* All other values of type are invalid */
|
13
13
|
# }
|
14
14
|
#
|
15
15
|
# ===========================================================================
|
data/lib/stellar/base/version.rb
CHANGED
data/lib/stellar/operation.rb
CHANGED
@@ -3,6 +3,7 @@ require 'bigdecimal'
|
|
3
3
|
module Stellar
|
4
4
|
class Operation
|
5
5
|
|
6
|
+
MAX_INT64 = 2**63 - 1
|
6
7
|
|
7
8
|
#
|
8
9
|
# Construct a new Stellar::Operation from the provided
|
@@ -115,13 +116,14 @@ module Stellar
|
|
115
116
|
#
|
116
117
|
# @param [Hash] attributes the attributes to create the operation with
|
117
118
|
# @option attributes [Stellar::Currrency] :line the asset to trust
|
118
|
-
# @option attributes [Fixnum] :limit the maximum amount to trust
|
119
|
+
# @option attributes [Fixnum] :limit the maximum amount to trust, defaults to max int64,
|
120
|
+
# if the limit is set to 0 it deletes the trustline.
|
119
121
|
#
|
120
122
|
# @return [Stellar::Operation] the built operation, containing a
|
121
123
|
# Stellar::ChangeTrustOp body
|
122
124
|
def self.change_trust(attributes={})
|
123
125
|
line = Asset.send(*attributes[:line])
|
124
|
-
limit =interpret_amount(attributes[:limit])
|
126
|
+
limit = attributes.key?(:limit) ? interpret_amount(attributes[:limit]) : MAX_INT64
|
125
127
|
|
126
128
|
raise ArgumentError, "Bad :limit #{limit}" unless limit.is_a?(Integer)
|
127
129
|
|
@@ -306,6 +308,20 @@ module Stellar
|
|
306
308
|
}))
|
307
309
|
end
|
308
310
|
|
311
|
+
def self.bump_sequence(attributes={})
|
312
|
+
op = BumpSequenceOp.new()
|
313
|
+
|
314
|
+
bump_to = attributes[:bump_to]
|
315
|
+
|
316
|
+
raise ArgumentError, ":bump_to too big" unless bump_to <= MAX_INT64
|
317
|
+
|
318
|
+
op.bump_to = bump_to
|
319
|
+
|
320
|
+
return make(attributes.merge({
|
321
|
+
body:[:bump_sequence, op]
|
322
|
+
}))
|
323
|
+
end
|
324
|
+
|
309
325
|
private
|
310
326
|
def self.extract_amount(a)
|
311
327
|
amount = interpret_amount(a.last)
|
data/lib/stellar/transaction.rb
CHANGED
@@ -67,6 +67,12 @@ module Stellar
|
|
67
67
|
make :manage_data, attributes
|
68
68
|
end
|
69
69
|
|
70
|
+
#
|
71
|
+
# @see Stellar::Operation.manage_data
|
72
|
+
def self.bump_sequence(attributes={})
|
73
|
+
make :bump_sequence, attributes
|
74
|
+
end
|
75
|
+
|
70
76
|
#
|
71
77
|
# Helper method to create a transaction with a single
|
72
78
|
# operation of the provided type. See class methods
|
data/lib/stellar/util/strkey.rb
CHANGED
@@ -7,8 +7,10 @@ module Stellar
|
|
7
7
|
class StrKey
|
8
8
|
|
9
9
|
VERSION_BYTES = {
|
10
|
-
account_id:
|
11
|
-
seed:
|
10
|
+
account_id: [ 6 << 3].pack("C"), # Base32-encodes to 'G...'
|
11
|
+
seed: [18 << 3].pack("C"), # Base32-encodes to 'S...'
|
12
|
+
pre_auth_tx: [19 << 3].pack("C"), # Base32-encodes to 'T...'
|
13
|
+
hash_x: [23 << 3].pack("C") # Base32-encodes to 'X...'
|
12
14
|
}
|
13
15
|
|
14
16
|
def self.check_encode(version, byte_str)
|
data/ruby-stellar-base.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "activesupport", ">= 4.2.7"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
27
27
|
spec.add_development_dependency "xdrgen"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.1"
|
29
29
|
spec.add_development_dependency "guard-rspec"
|
@@ -28,3 +28,30 @@ describe Stellar::Operation, ".manage_data" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
31
|
+
|
32
|
+
describe Stellar::Operation, ".change_trust" do
|
33
|
+
|
34
|
+
let(:issuer) { Stellar::KeyPair.from_address("GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7") }
|
35
|
+
let(:asset) { Stellar::Asset.alphanum4("USD", issuer) }
|
36
|
+
|
37
|
+
it "creates a ChangeTrustOp" do
|
38
|
+
op = Stellar::Operation.change_trust(line: [:alphanum4, "USD", issuer])
|
39
|
+
expect(op.body.value).to be_an_instance_of(Stellar::ChangeTrustOp)
|
40
|
+
expect(op.body.value.line).to eq(Stellar::Asset.alphanum4("USD", issuer))
|
41
|
+
expect(op.body.value.limit).to eq(9223372036854775807)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "creates a ChangeTrustOp with limit" do
|
45
|
+
op = Stellar::Operation.change_trust(line: [:alphanum4, "USD", issuer], limit: 1234.75)
|
46
|
+
expect(op.body.value).to be_an_instance_of(Stellar::ChangeTrustOp)
|
47
|
+
expect(op.body.value.line).to eq(Stellar::Asset.alphanum4("USD", issuer))
|
48
|
+
expect(op.body.value.limit).to eq(12347500000)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "throws ArgumentError for incorrect limit argument" do
|
52
|
+
expect {
|
53
|
+
Stellar::Operation.change_trust(line: [:alphanum4, "USD", issuer], limit: true)
|
54
|
+
}.to raise_error(ArgumentError)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -2,13 +2,19 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Stellar::Util::StrKey do
|
4
4
|
|
5
|
-
subject{ Stellar::Util::StrKey }
|
5
|
+
subject{ Stellar::Util::StrKey }
|
6
6
|
|
7
7
|
describe "#check_decode" do
|
8
8
|
it "properly decodes" do
|
9
9
|
expect(decode :seed, "SAAAAAAAAAADST3H").to eq_bytes("\x00\x00\x00\x00\x00\x00\x39")
|
10
10
|
expect(decode :account_id, "GD777777777764TU").to eq_bytes("\xFF\xFF\xFF\xFF\xFF\xFF\xFF")
|
11
11
|
expect(decode :account_id, "GBQWWBFLRP3BXZD5").to eq_bytes("\x61\x6b\x04\xab\x8b\xf6\x1b")
|
12
|
+
expect(decode :pre_auth_tx, "TBU2RRGLXH3E4VON").to eq_bytes("\x69\xa8\xc4\xcb\xb9\xf6\x4e")
|
13
|
+
expect(decode :hash_x, "XBU2RRGLXH3E4PNW").to eq_bytes("\x69\xa8\xc4\xcb\xb9\xf6\x4e")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "raises an ArgumentError when an invalid version is provided" do
|
17
|
+
expect{ decode :floob, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
|
12
18
|
end
|
13
19
|
|
14
20
|
it "raises an ArgumentError if the decoded version byte does not match the expected value" do
|
@@ -17,7 +23,7 @@ subject{ Stellar::Util::StrKey }
|
|
17
23
|
end
|
18
24
|
|
19
25
|
it "raises an ArgumentError if the decoded value cannot be validated by the checksum" do
|
20
|
-
expect{decode :seed, "SAAAAAAAAAADST3M"}.to raise_error(ArgumentError)
|
26
|
+
expect{ decode :seed, "SAAAAAAAAAADST3M" }.to raise_error(ArgumentError)
|
21
27
|
end
|
22
28
|
|
23
29
|
def decode(version, bytes)
|
@@ -25,11 +31,13 @@ subject{ Stellar::Util::StrKey }
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
describe"#check_encode" do
|
34
|
+
describe "#check_encode" do
|
29
35
|
it "properly encodes" do
|
30
36
|
expect(encode :seed, "\x00\x00\x00\x00\x00\x00\x39").to eq("SAAAAAAAAAADST3H")
|
31
37
|
expect(encode :account_id, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF").to eq("GD777777777764TU")
|
32
38
|
expect(encode :account_id, "\x61\x6b\x04\xab\x8b\xf6\x1b").to eq("GBQWWBFLRP3BXZD5")
|
39
|
+
expect(encode :pre_auth_tx, "\x69\xa8\xc4\xcb\xb9\xf6\x4e").to eq_bytes("TBU2RRGLXH3E4VON")
|
40
|
+
expect(encode :hash_x, "\x69\xa8\xc4\xcb\xb9\xf6\x4e").to eq_bytes("XBU2RRGLXH3E4PNW")
|
33
41
|
end
|
34
42
|
|
35
43
|
it "raises an ArgumentError when an invalid version is provided" do
|
data/tasks/xdr.rake
CHANGED
@@ -26,7 +26,7 @@ namespace :xdr do
|
|
26
26
|
|
27
27
|
HAYASHI_XDR.each do |src|
|
28
28
|
local_path = "xdr/" + File.basename(src)
|
29
|
-
encoded = client.contents("stellar/stellar-core", path: src
|
29
|
+
encoded = client.contents("stellar/stellar-core", path: src).content
|
30
30
|
decoded = Base64.decode64 encoded
|
31
31
|
|
32
32
|
IO.write(local_path, decoded)
|
data/xdr/Stellar-ledger.x
CHANGED
@@ -265,9 +265,19 @@ struct OperationMeta
|
|
265
265
|
LedgerEntryChanges changes;
|
266
266
|
};
|
267
267
|
|
268
|
+
struct TransactionMetaV1
|
269
|
+
{
|
270
|
+
LedgerEntryChanges txChanges; // tx level changes if any
|
271
|
+
OperationMeta operations<>; // meta for each operation
|
272
|
+
};
|
273
|
+
|
274
|
+
// this is the meta produced when applying transactions
|
275
|
+
// it does not include pre-apply updates such as fees
|
268
276
|
union TransactionMeta switch (int v)
|
269
277
|
{
|
270
278
|
case 0:
|
271
279
|
OperationMeta operations<>;
|
280
|
+
case 1:
|
281
|
+
TransactionMetaV1 v1;
|
272
282
|
};
|
273
283
|
}
|
data/xdr/Stellar-overlay.x
CHANGED
data/xdr/Stellar-transaction.x
CHANGED
@@ -25,7 +25,8 @@ enum OperationType
|
|
25
25
|
ALLOW_TRUST = 7,
|
26
26
|
ACCOUNT_MERGE = 8,
|
27
27
|
INFLATION = 9,
|
28
|
-
MANAGE_DATA = 10
|
28
|
+
MANAGE_DATA = 10,
|
29
|
+
BUMP_SEQUENCE = 11
|
29
30
|
};
|
30
31
|
|
31
32
|
/* CreateAccount
|
@@ -207,8 +208,8 @@ Result: InflationResult
|
|
207
208
|
*/
|
208
209
|
|
209
210
|
/* ManageData
|
210
|
-
Adds, Updates, or Deletes a key value pair associated with a particular
|
211
|
-
|
211
|
+
Adds, Updates, or Deletes a key value pair associated with a particular
|
212
|
+
account.
|
212
213
|
|
213
214
|
Threshold: med
|
214
215
|
|
@@ -217,8 +218,20 @@ Result: InflationResult
|
|
217
218
|
|
218
219
|
struct ManageDataOp
|
219
220
|
{
|
220
|
-
string64 dataName;
|
221
|
-
DataValue* dataValue;
|
221
|
+
string64 dataName;
|
222
|
+
DataValue* dataValue; // set to null to clear
|
223
|
+
};
|
224
|
+
|
225
|
+
/* Bump Sequence
|
226
|
+
|
227
|
+
increases the sequence to a given level
|
228
|
+
|
229
|
+
Result: BumpSequenceResult
|
230
|
+
*/
|
231
|
+
|
232
|
+
struct BumpSequenceOp
|
233
|
+
{
|
234
|
+
SequenceNumber bumpTo;
|
222
235
|
};
|
223
236
|
|
224
237
|
/* An operation is the lowest unit of work that a transaction does */
|
@@ -253,6 +266,8 @@ struct Operation
|
|
253
266
|
void;
|
254
267
|
case MANAGE_DATA:
|
255
268
|
ManageDataOp manageDataOp;
|
269
|
+
case BUMP_SEQUENCE:
|
270
|
+
BumpSequenceOp bumpSequenceOp;
|
256
271
|
}
|
257
272
|
body;
|
258
273
|
};
|
@@ -321,14 +336,16 @@ struct Transaction
|
|
321
336
|
ext;
|
322
337
|
};
|
323
338
|
|
324
|
-
struct TransactionSignaturePayload
|
339
|
+
struct TransactionSignaturePayload
|
340
|
+
{
|
325
341
|
Hash networkId;
|
326
342
|
union switch (EnvelopeType type)
|
327
343
|
{
|
328
344
|
case ENVELOPE_TYPE_TX:
|
329
|
-
|
330
|
-
|
331
|
-
}
|
345
|
+
Transaction tx;
|
346
|
+
/* All other values of type are invalid */
|
347
|
+
}
|
348
|
+
taggedTransaction;
|
332
349
|
};
|
333
350
|
|
334
351
|
/* A TransactionEnvelope wraps a transaction with signatures. */
|
@@ -337,8 +354,7 @@ struct TransactionEnvelope
|
|
337
354
|
Transaction tx;
|
338
355
|
/* Each decorated signature is a signature over the SHA256 hash of
|
339
356
|
* a TransactionSignaturePayload */
|
340
|
-
DecoratedSignature
|
341
|
-
signatures<20>;
|
357
|
+
DecoratedSignature signatures<20>;
|
342
358
|
};
|
343
359
|
|
344
360
|
/* Operation Results section */
|
@@ -545,7 +561,8 @@ enum ChangeTrustResultCode
|
|
545
561
|
CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer
|
546
562
|
CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance
|
547
563
|
// cannot create with a limit of 0
|
548
|
-
CHANGE_TRUST_LOW_RESERVE =
|
564
|
+
CHANGE_TRUST_LOW_RESERVE =
|
565
|
+
-4, // not enough funds to create a new trust line,
|
549
566
|
CHANGE_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
|
550
567
|
};
|
551
568
|
|
@@ -568,7 +585,7 @@ enum AllowTrustResultCode
|
|
568
585
|
ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
|
569
586
|
// source account does not require trust
|
570
587
|
ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
|
571
|
-
ALLOW_TRUST_CANT_REVOKE = -4,
|
588
|
+
ALLOW_TRUST_CANT_REVOKE = -4, // source account can't revoke trust,
|
572
589
|
ALLOW_TRUST_SELF_NOT_ALLOWED = -5 // trusting self is not allowed
|
573
590
|
};
|
574
591
|
|
@@ -587,10 +604,11 @@ enum AccountMergeResultCode
|
|
587
604
|
// codes considered as "success" for the operation
|
588
605
|
ACCOUNT_MERGE_SUCCESS = 0,
|
589
606
|
// codes considered as "failure" for the operation
|
590
|
-
ACCOUNT_MERGE_MALFORMED = -1,
|
591
|
-
ACCOUNT_MERGE_NO_ACCOUNT = -2,
|
592
|
-
ACCOUNT_MERGE_IMMUTABLE_SET = -3,
|
593
|
-
ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4 // account has trust lines/offers
|
607
|
+
ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself
|
608
|
+
ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist
|
609
|
+
ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set
|
610
|
+
ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4, // account has trust lines/offers
|
611
|
+
ACCOUNT_MERGE_SEQNUM_TOO_FAR = -5 // sequence number is over max allowed
|
594
612
|
};
|
595
613
|
|
596
614
|
union AccountMergeResult switch (AccountMergeResultCode code)
|
@@ -632,10 +650,12 @@ enum ManageDataResultCode
|
|
632
650
|
// codes considered as "success" for the operation
|
633
651
|
MANAGE_DATA_SUCCESS = 0,
|
634
652
|
// codes considered as "failure" for the operation
|
635
|
-
MANAGE_DATA_NOT_SUPPORTED_YET =
|
636
|
-
|
637
|
-
|
638
|
-
|
653
|
+
MANAGE_DATA_NOT_SUPPORTED_YET =
|
654
|
+
-1, // The network hasn't moved to this protocol change yet
|
655
|
+
MANAGE_DATA_NAME_NOT_FOUND =
|
656
|
+
-2, // Trying to remove a Data Entry that isn't there
|
657
|
+
MANAGE_DATA_LOW_RESERVE = -3, // not enough funds to create a new Data Entry
|
658
|
+
MANAGE_DATA_INVALID_NAME = -4 // Name not a valid string
|
639
659
|
};
|
640
660
|
|
641
661
|
union ManageDataResult switch (ManageDataResultCode code)
|
@@ -646,14 +666,32 @@ default:
|
|
646
666
|
void;
|
647
667
|
};
|
648
668
|
|
669
|
+
/******* BumpSequence Result ********/
|
670
|
+
|
671
|
+
enum BumpSequenceResultCode
|
672
|
+
{
|
673
|
+
// codes considered as "success" for the operation
|
674
|
+
BUMP_SEQUENCE_SUCCESS = 0,
|
675
|
+
// codes considered as "failure" for the operation
|
676
|
+
BUMP_SEQUENCE_BAD_SEQ = -1 // `bumpTo` is not within bounds
|
677
|
+
};
|
678
|
+
|
679
|
+
union BumpSequenceResult switch (BumpSequenceResultCode code)
|
680
|
+
{
|
681
|
+
case BUMP_SEQUENCE_SUCCESS:
|
682
|
+
void;
|
683
|
+
default:
|
684
|
+
void;
|
685
|
+
};
|
649
686
|
/* High level Operation Result */
|
650
687
|
|
651
688
|
enum OperationResultCode
|
652
689
|
{
|
653
690
|
opINNER = 0, // inner object result is valid
|
654
691
|
|
655
|
-
opBAD_AUTH = -1,
|
656
|
-
opNO_ACCOUNT = -2
|
692
|
+
opBAD_AUTH = -1, // too few valid signatures / wrong network
|
693
|
+
opNO_ACCOUNT = -2, // source account was not found
|
694
|
+
opNOT_SUPPORTED = -3 // operation not supported at this time
|
657
695
|
};
|
658
696
|
|
659
697
|
union OperationResult switch (OperationResultCode code)
|
@@ -683,6 +721,8 @@ case opINNER:
|
|
683
721
|
InflationResult inflationResult;
|
684
722
|
case MANAGE_DATA:
|
685
723
|
ManageDataResult manageDataResult;
|
724
|
+
case BUMP_SEQUENCE:
|
725
|
+
BumpSequenceResult bumpSeqResult;
|
686
726
|
}
|
687
727
|
tr;
|
688
728
|
default:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellar-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Fleckenstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xdr
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '12.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '12.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: xdrgen
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -263,6 +263,9 @@ files:
|
|
263
263
|
- generated/stellar/authenticated_message/v0.rb
|
264
264
|
- generated/stellar/bucket_entry.rb
|
265
265
|
- generated/stellar/bucket_entry_type.rb
|
266
|
+
- generated/stellar/bump_sequence_op.rb
|
267
|
+
- generated/stellar/bump_sequence_result.rb
|
268
|
+
- generated/stellar/bump_sequence_result_code.rb
|
266
269
|
- generated/stellar/change_trust_op.rb
|
267
270
|
- generated/stellar/change_trust_result.rb
|
268
271
|
- generated/stellar/change_trust_result_code.rb
|
@@ -372,6 +375,7 @@ files:
|
|
372
375
|
- generated/stellar/transaction_history_result_entry.rb
|
373
376
|
- generated/stellar/transaction_history_result_entry/ext.rb
|
374
377
|
- generated/stellar/transaction_meta.rb
|
378
|
+
- generated/stellar/transaction_meta_v1.rb
|
375
379
|
- generated/stellar/transaction_result.rb
|
376
380
|
- generated/stellar/transaction_result/ext.rb
|
377
381
|
- generated/stellar/transaction_result/result.rb
|