diff --git a/build.gradle b/build.gradle
index 26222eaa1..a65bb9cd5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,6 +32,7 @@ repositories {
}
dependencies {
+ compile 'commons-codec:commons-codec:1.5'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'org.apache.httpcomponents:fluent-hc:4.5.1'
compile 'com.moandjiezana.toml:toml4j:0.5.1'
diff --git a/libs/net.i2p.crypto-4.0.0.jar b/libs/net.i2p.crypto-4.0.0.jar
new file mode 100644
index 000000000..dc923edae
Binary files /dev/null and b/libs/net.i2p.crypto-4.0.0.jar differ
diff --git a/libs/stellar-base.jar b/libs/stellar-base.jar
deleted file mode 100644
index b5d8cb981..000000000
Binary files a/libs/stellar-base.jar and /dev/null differ
diff --git a/src/main/java/org/stellar/sdk/Account.java b/src/main/java/org/stellar/sdk/Account.java
index 022960d96..f96463103 100644
--- a/src/main/java/org/stellar/sdk/Account.java
+++ b/src/main/java/org/stellar/sdk/Account.java
@@ -1,262 +1,44 @@
package org.stellar.sdk;
-import com.google.gson.annotations.SerializedName;
-
-import org.stellar.base.KeyPair;
-
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Represents account response.
- * @see Account documentation
- * @see org.stellar.sdk.requests.AccountsRequestBuilder
- * @see org.stellar.sdk.Server#accounts()
+ * Represents an account in Stellar network with it's sequence number.
+ * Account object is required to build a {@link Transaction}.
+ * @see org.stellar.sdk.Transaction.Builder
*/
-public class Account implements org.stellar.base.TransactionBuilderAccount {
- @SerializedName("account_id") /* KeyPairTypeAdapter used */
- private KeyPair keypair;
- @SerializedName("sequence")
- private Long sequenceNumber;
- @SerializedName("paging_token")
- private String pagingToken;
- @SerializedName("subentry_count")
- private Integer subentryCount;
- @SerializedName("inflation_destination")
- private String inflationDestination;
- @SerializedName("home_domain")
- private String homeDomain;
- @SerializedName("thresholds")
- private Thresholds thresholds;
- @SerializedName("flags")
- private Flags flags;
- @SerializedName("balances")
- private Balance[] balances;
- @SerializedName("signers")
- private Signer[] signers;
- @SerializedName("_links")
- private Links links;
-
- Account(KeyPair keypair) {
- this.keypair = keypair;
- }
-
- public Account(KeyPair keypair, Long sequenceNumber) {
- this.keypair = keypair;
- this.sequenceNumber = sequenceNumber;
- }
-
- @Override
- public KeyPair getKeypair() {
- return keypair;
- }
-
- @Override
- public Long getSequenceNumber() {
- return sequenceNumber;
- }
-
- @Override
- public void incrementSequenceNumber() {
- sequenceNumber++;
- }
-
- public String getPagingToken() {
- return pagingToken;
- }
-
- public Integer getSubentryCount() {
- return subentryCount;
- }
-
- public String getInflationDestination() {
- return inflationDestination;
- }
-
- public String getHomeDomain() {
- return homeDomain;
- }
-
- public Thresholds getThresholds() {
- return thresholds;
- }
-
- public Flags getFlags() {
- return flags;
- }
-
- public Balance[] getBalances() {
- return balances;
- }
-
- public Signer[] getSigners() {
- return signers;
- }
+public class Account implements TransactionBuilderAccount {
+ private final KeyPair mKeyPair;
+ private Long mSequenceNumber;
/**
- * Represents account thresholds.
+ * Class constructor.
+ * @param keypair KeyPair associated with this Account
+ * @param sequenceNumber Current sequence number of the account (can be obtained using java-stellar-sdk or horizon server)
*/
- public static class Thresholds {
- @SerializedName("low_threshold")
- private final int lowThreshold;
- @SerializedName("med_threshold")
- private final int medThreshold;
- @SerializedName("high_threshold")
- private final int highThreshold;
-
- Thresholds(int lowThreshold, int medThreshold, int highThreshold) {
- this.lowThreshold = lowThreshold;
- this.medThreshold = medThreshold;
- this.highThreshold = highThreshold;
- }
-
- public int getLowThreshold() {
- return lowThreshold;
- }
-
- public int getMedThreshold() {
- return medThreshold;
- }
-
- public int getHighThreshold() {
- return highThreshold;
- }
- }
-
- /**
- * Represents account flags.
- */
- public static class Flags {
- @SerializedName("auth_required")
- private final boolean authRequired;
- @SerializedName("auth_revocable")
- private final boolean authRevocable;
-
- Flags(boolean authRequired, boolean authRevocable) {
- this.authRequired = authRequired;
- this.authRevocable = authRevocable;
- }
-
- public boolean getAuthRequired() {
- return authRequired;
- }
-
- public boolean getAuthRevocable() {
- return authRevocable;
- }
+ public Account(KeyPair keypair, Long sequenceNumber) {
+ mKeyPair = checkNotNull(keypair, "keypair cannot be null");
+ mSequenceNumber = checkNotNull(sequenceNumber, "sequenceNumber cannot be null");
}
/**
- * Represents account balance.
+ * Returns keypair associated with this Account
*/
- public static class Balance {
- @SerializedName("asset_type")
- private final String assetType;
- @SerializedName("asset_code")
- private final String assetCode;
- @SerializedName("asset_issuer")
- private final String assetIssuer;
- @SerializedName("limit")
- private final String limit;
- @SerializedName("balance")
- private final String balance;
-
- Balance(String assetType, String assetCode, String assetIssuer, String balance, String limit) {
- this.assetType = checkNotNull(assetType, "assertType cannot be null");
- this.balance = checkNotNull(balance, "balance cannot be null");
- this.limit = limit;
- this.assetCode = assetCode;
- this.assetIssuer = assetIssuer;
- }
-
- public String getAssetType() {
- return assetType;
- }
-
- public String getAssetCode() {
- return assetCode;
- }
-
- public String getAssetIssuer() {
- return assetIssuer;
- }
-
- public String getBalance() {
- return balance;
- }
-
- public String getLimit() {
- return limit;
- }
+ public KeyPair getKeypair() {
+ return mKeyPair;
}
/**
- * Represents account signers.
+ * Returns current sequence number ot this Account.
*/
- public static class Signer {
- @SerializedName("public_key")
- private final String accountId;
- @SerializedName("weight")
- private final int weight;
-
- Signer(String accountId, int weight) {
- this.accountId = checkNotNull(accountId, "accountId cannot be null");
- this.weight = checkNotNull(weight, "weight cannot be null");
- }
-
- public String getAccountId() {
- return accountId;
- }
-
- public int getWeight() {
- return weight;
- }
- }
-
- public Links getLinks() {
- return links;
+ public Long getSequenceNumber() {
+ return mSequenceNumber;
}
/**
- * Links connected to account.
+ * Increments sequence number in this object by one.
*/
- public static class Links {
- @SerializedName("effects")
- private final Link effects;
- @SerializedName("offers")
- private final Link offers;
- @SerializedName("operations")
- private final Link operations;
- @SerializedName("self")
- private final Link self;
- @SerializedName("transactions")
- private final Link transactions;
-
- Links(Link effects, Link offers, Link operations, Link self, Link transactions) {
- this.effects = effects;
- this.offers = offers;
- this.operations = operations;
- this.self = self;
- this.transactions = transactions;
- }
-
- public Link getEffects() {
- return effects;
- }
-
- public Link getOffers() {
- return offers;
- }
-
- public Link getOperations() {
- return operations;
- }
-
- public Link getSelf() {
- return self;
- }
-
- public Link getTransactions() {
- return transactions;
- }
+ public void incrementSequenceNumber() {
+ mSequenceNumber++;
}
}
diff --git a/src/main/java/org/stellar/sdk/AccountMergeOperation.java b/src/main/java/org/stellar/sdk/AccountMergeOperation.java
new file mode 100644
index 000000000..9468ad71d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AccountMergeOperation.java
@@ -0,0 +1,80 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.Operation.OperationBody;
+import org.stellar.sdk.xdr.OperationType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents AccountMerge operation.
+ * @see List of Operations
+ */
+public class AccountMergeOperation extends Operation {
+
+ private final KeyPair destination;
+
+ private AccountMergeOperation(KeyPair destination) {
+ this.destination = checkNotNull(destination, "destination cannot be null");
+ }
+
+ /**
+ * The account that receives the remaining XLM balance of the source account.
+ */
+ public KeyPair getDestination() {
+ return destination;
+ }
+
+ @Override
+ OperationBody toOperationBody() {
+ OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ AccountID destination = new AccountID();
+ destination.setAccountID(this.destination.getXdrPublicKey());
+ body.setDestination(destination);
+ body.setDiscriminant(OperationType.ACCOUNT_MERGE);
+ return body;
+ }
+
+ /**
+ * Builds AccountMerge operation.
+ * @see AccountMergeOperation
+ */
+ public static class Builder {
+ private final KeyPair destination;
+
+ private KeyPair mSourceAccount;
+
+ Builder(OperationBody op) {
+ destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID());
+ }
+
+ /**
+ * Creates a new AccountMerge builder.
+ * @param destination The account that receives the remaining XLM balance of the source account.
+ */
+ public Builder(KeyPair destination) {
+ this.destination = destination;
+ }
+
+ /**
+ * Set source account of this operation
+ * @param sourceAccount Source account
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = sourceAccount;
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public AccountMergeOperation build() {
+ AccountMergeOperation operation = new AccountMergeOperation(destination);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/AllowTrustOperation.java b/src/main/java/org/stellar/sdk/AllowTrustOperation.java
new file mode 100644
index 000000000..36559b720
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AllowTrustOperation.java
@@ -0,0 +1,133 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.AllowTrustOp;
+import org.stellar.sdk.xdr.AssetType;
+import org.stellar.sdk.xdr.OperationType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents AllowTrust operation.
+ * @see List of Operations
+ */
+public class AllowTrustOperation extends Operation {
+
+ private final KeyPair trustor;
+ private final String assetCode;
+ private final boolean authorize;
+
+ private AllowTrustOperation(KeyPair trustor, String assetCode, boolean authorize) {
+ this.trustor = checkNotNull(trustor, "trustor cannot be null");
+ this.assetCode = checkNotNull(assetCode, "assetCode cannot be null");
+ this.authorize = authorize;
+ }
+
+ /**
+ * The account of the recipient of the trustline.
+ */
+ public KeyPair getTrustor() {
+ return trustor;
+ }
+
+ /**
+ * The asset of the trustline the source account is authorizing. For example, if a gateway wants to allow another account to hold its USD credit, the type is USD.
+ */
+ public String getAssetCode() {
+ return assetCode;
+ }
+
+ /**
+ * Flag indicating whether the trustline is authorized.
+ */
+ public boolean getAuthorize() {
+ return authorize;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ AllowTrustOp op = new AllowTrustOp();
+
+ // trustor
+ AccountID trustor = new AccountID();
+ trustor.setAccountID(this.trustor.getXdrPublicKey());
+ op.setTrustor(trustor);
+ // asset
+ AllowTrustOp.AllowTrustOpAsset asset = new AllowTrustOp.AllowTrustOpAsset();
+ if (assetCode.length() <= 4) {
+ asset.setDiscriminant(AssetType.ASSET_TYPE_CREDIT_ALPHANUM4);
+ asset.setAssetCode4(Util.paddedByteArray(assetCode, 4));
+ } else {
+ asset.setDiscriminant(AssetType.ASSET_TYPE_CREDIT_ALPHANUM12);
+ asset.setAssetCode12(Util.paddedByteArray(assetCode, 12));
+ }
+ op.setAsset(asset);
+ // authorize
+ op.setAuthorize(authorize);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.ALLOW_TRUST);
+ body.setAllowTrustOp(op);
+ return body;
+ }
+
+ /**
+ * Builds AllowTrust operation.
+ * @see AllowTrustOperation
+ */
+ public static class Builder {
+ private final KeyPair trustor;
+ private final String assetCode;
+ private final boolean authorize;
+
+ private KeyPair mSourceAccount;
+
+ Builder(AllowTrustOp op) {
+ trustor = KeyPair.fromXdrPublicKey(op.getTrustor().getAccountID());
+ switch (op.getAsset().getDiscriminant()) {
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ assetCode = new String(op.getAsset().getAssetCode4());
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ assetCode = new String(op.getAsset().getAssetCode12().toString());
+ break;
+ default:
+ throw new RuntimeException("Unknown asset code");
+ }
+ authorize = op.getAuthorize();
+ }
+
+ /**
+ * Creates a new AllowTrust builder.
+ * @param trustor The account of the recipient of the trustline.
+ * @param assetCode The asset of the trustline the source account is authorizing. For example, if a gateway wants to allow another account to hold its USD credit, the type is USD.
+ * @param authorize Flag indicating whether the trustline is authorized.
+ */
+ public Builder(KeyPair trustor, String assetCode, boolean authorize) {
+ this.trustor = trustor;
+ this.assetCode = assetCode;
+ this.authorize = authorize;
+ }
+
+ /**
+ * Set source account of this operation
+ * @param sourceAccount Source account
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = sourceAccount;
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public AllowTrustOperation build() {
+ AllowTrustOperation operation = new AllowTrustOperation(trustor, assetCode, authorize);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Asset.java b/src/main/java/org/stellar/sdk/Asset.java
new file mode 100644
index 000000000..9d9280503
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Asset.java
@@ -0,0 +1,64 @@
+package org.stellar.sdk;
+
+/**
+ * Base Asset class.
+ * @see Assets
+ */
+public abstract class Asset {
+ Asset() {}
+
+ /**
+ * Creates one of AssetTypeCreditAlphaNum4 or AssetTypeCreditAlphaNum12 object based on a code
length
+ * @param code Asset code
+ * @param issuer Asset issuer
+ */
+ public static Asset createNonNativeAsset(String code, KeyPair issuer) {
+ if (code.length() >= 1 && code.length() <= 4) {
+ return new AssetTypeCreditAlphaNum4(code, issuer);
+ } else if (code.length() >= 5 && code.length() <= 12) {
+ return new AssetTypeCreditAlphaNum12(code, issuer);
+ } else {
+ throw new AssetCodeLengthInvalidException();
+ }
+ }
+
+ /**
+ * Generates Asset object from a given XDR object
+ * @param xdr XDR object
+ */
+ public static Asset fromXdr(org.stellar.sdk.xdr.Asset xdr) {
+ switch (xdr.getDiscriminant()) {
+ case ASSET_TYPE_NATIVE:
+ return new AssetTypeNative();
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ String assetCode4 = Util.paddedByteArrayToString(xdr.getAlphaNum4().getAssetCode());
+ KeyPair issuer4 = KeyPair.fromXdrPublicKey(
+ xdr.getAlphaNum4().getIssuer().getAccountID());
+ return new AssetTypeCreditAlphaNum4(assetCode4, issuer4);
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ String assetCode12 = Util.paddedByteArrayToString(xdr.getAlphaNum12().getAssetCode());
+ KeyPair issuer12 = KeyPair.fromXdrPublicKey(xdr.getAlphaNum12().getIssuer().getAccountID());
+ return new AssetTypeCreditAlphaNum12(assetCode12, issuer12);
+ default:
+ throw new IllegalArgumentException("Unknown asset type " + xdr.getDiscriminant());
+ }
+ }
+
+ /**
+ * Returns asset type. Possible types:
+ *
+ * native
+ * credit_alphanum4
+ * credit_alphanum12
+ *
+ */
+ public abstract String getType();
+
+ @Override
+ public abstract boolean equals(Object object);
+
+ /**
+ * Generates XDR object from a given Asset object
+ */
+ public abstract org.stellar.sdk.xdr.Asset toXdr();
+}
diff --git a/src/main/java/org/stellar/sdk/AssetCodeLengthInvalidException.java b/src/main/java/org/stellar/sdk/AssetCodeLengthInvalidException.java
new file mode 100644
index 000000000..cee47af46
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AssetCodeLengthInvalidException.java
@@ -0,0 +1,16 @@
+package org.stellar.sdk;
+
+/**
+ * Indicates that asset code is not valid for a specified asset class
+ * @see AssetTypeCreditAlphaNum4
+ * @see AssetTypeCreditAlphaNum12
+ */
+public class AssetCodeLengthInvalidException extends RuntimeException {
+ public AssetCodeLengthInvalidException() {
+ super();
+ }
+
+ public AssetCodeLengthInvalidException(String message) {
+ super(message);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java
new file mode 100644
index 000000000..752665556
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum.java
@@ -0,0 +1,43 @@
+package org.stellar.sdk;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Base class for AssetTypeCreditAlphaNum4 and AssetTypeCreditAlphaNum12 subclasses.
+ * @see Assets
+ */
+public abstract class AssetTypeCreditAlphaNum extends Asset {
+ protected final String mCode;
+ protected final KeyPair mIssuer;
+
+ public AssetTypeCreditAlphaNum(String code, KeyPair issuer) {
+ mCode = checkNotNull(code, "code cannot be null");
+ mIssuer = checkNotNull(issuer, "issuer cannot be null");
+ }
+
+ /**
+ * Returns asset code
+ */
+ public String getCode() {
+ return mCode;
+ }
+
+ /**
+ * Returns asset issuer
+ */
+ public KeyPair getIssuer() {
+ return mIssuer;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!this.getClass().equals(object.getClass())) {
+ return false;
+ }
+
+ AssetTypeCreditAlphaNum o = (AssetTypeCreditAlphaNum) object;
+
+ return this.getCode().equals(o.getCode()) &&
+ this.getIssuer().getAccountId().equals(o.getIssuer().getAccountId());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java
new file mode 100644
index 000000000..7e3f00ad2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum12.java
@@ -0,0 +1,41 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.AssetType;
+
+/**
+ * Represents all assets with codes 5-12 characters long.
+ * @see Assets
+ */
+public class AssetTypeCreditAlphaNum12 extends AssetTypeCreditAlphaNum {
+
+ /**
+ * Class constructor
+ * @param code Asset code
+ * @param issuer Asset issuer
+ */
+ public AssetTypeCreditAlphaNum12(String code, KeyPair issuer) {
+ super(code, issuer);
+ if (code.length() < 5 || code.length() > 12) {
+ throw new AssetCodeLengthInvalidException();
+ }
+ }
+
+ @Override
+ public String getType() {
+ return "credit_alphanum12";
+ }
+
+ @Override
+ public org.stellar.sdk.xdr.Asset toXdr() {
+ org.stellar.sdk.xdr.Asset xdr = new org.stellar.sdk.xdr.Asset();
+ xdr.setDiscriminant(AssetType.ASSET_TYPE_CREDIT_ALPHANUM12);
+ org.stellar.sdk.xdr.Asset.AssetAlphaNum12 credit = new org.stellar.sdk.xdr.Asset.AssetAlphaNum12();
+ credit.setAssetCode(Util.paddedByteArray(mCode, 12));
+ AccountID accountID = new AccountID();
+ accountID.setAccountID(mIssuer.getXdrPublicKey());
+ credit.setIssuer(accountID);
+ xdr.setAlphaNum12(credit);
+ return xdr;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java
new file mode 100644
index 000000000..2f06d9af6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java
@@ -0,0 +1,41 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.AssetType;
+
+/**
+ * Represents all assets with codes 1-4 characters long.
+ * @see Assets
+ */
+public class AssetTypeCreditAlphaNum4 extends AssetTypeCreditAlphaNum {
+
+ /**
+ * Class constructor
+ * @param code Asset code
+ * @param issuer Asset issuer
+ */
+ public AssetTypeCreditAlphaNum4(String code, KeyPair issuer) {
+ super(code, issuer);
+ if (code.length() < 1 || code.length() > 4) {
+ throw new AssetCodeLengthInvalidException();
+ }
+ }
+
+ @Override
+ public String getType() {
+ return "credit_alphanum4";
+ }
+
+ @Override
+ public org.stellar.sdk.xdr.Asset toXdr() {
+ org.stellar.sdk.xdr.Asset xdr = new org.stellar.sdk.xdr.Asset();
+ xdr.setDiscriminant(AssetType.ASSET_TYPE_CREDIT_ALPHANUM4);
+ org.stellar.sdk.xdr.Asset.AssetAlphaNum4 credit = new org.stellar.sdk.xdr.Asset.AssetAlphaNum4();
+ credit.setAssetCode(Util.paddedByteArray(mCode, 4));
+ AccountID accountID = new AccountID();
+ accountID.setAccountID(mIssuer.getXdrPublicKey());
+ credit.setIssuer(accountID);
+ xdr.setAlphaNum4(credit);
+ return xdr;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/AssetTypeNative.java b/src/main/java/org/stellar/sdk/AssetTypeNative.java
new file mode 100644
index 000000000..8079e4535
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/AssetTypeNative.java
@@ -0,0 +1,29 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AssetType;
+
+/**
+ * Represents Stellar native asset - lumens (XLM)
+ * @see Assets
+ */
+public class AssetTypeNative extends Asset {
+
+ public AssetTypeNative() {}
+
+ @Override
+ public String getType() {
+ return "native";
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return this.getClass().equals(object.getClass());
+ }
+
+ @Override
+ public org.stellar.sdk.xdr.Asset toXdr() {
+ org.stellar.sdk.xdr.Asset xdr = new org.stellar.sdk.xdr.Asset();
+ xdr.setDiscriminant(AssetType.ASSET_TYPE_NATIVE);
+ return xdr;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/ChangeTrustOperation.java b/src/main/java/org/stellar/sdk/ChangeTrustOperation.java
new file mode 100644
index 000000000..01eb78d3d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/ChangeTrustOperation.java
@@ -0,0 +1,98 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.ChangeTrustOp;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.OperationType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents ChangeTrust operation.
+ * @see List of Operations
+ */
+public class ChangeTrustOperation extends Operation {
+
+ private final Asset asset;
+ private final String limit;
+
+ private ChangeTrustOperation(Asset asset, String limit) {
+ this.asset = checkNotNull(asset, "asset cannot be null");
+ this.limit = checkNotNull(limit, "limit cannot be null");
+ }
+
+ /**
+ * The asset of the trustline. For example, if a gateway extends a trustline of up to 200 USD to a user, the line is USD.
+ */
+ public Asset getAsset() {
+ return asset;
+ }
+
+ /**
+ * The limit of the trustline. For example, if a gateway extends a trustline of up to 200 USD to a user, the limit is 200.
+ */
+ public String getLimit() {
+ return limit;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ ChangeTrustOp op = new ChangeTrustOp();
+ op.setLine(asset.toXdr());
+ Int64 limit = new Int64();
+ limit.setInt64(Operation.toXdrAmount(this.limit));
+ op.setLimit(limit);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.CHANGE_TRUST);
+ body.setChangeTrustOp(op);
+ return body;
+ }
+
+ /**
+ * Builds ChangeTrust operation.
+ * @see ChangeTrustOperation
+ */
+ public static class Builder {
+ private final Asset asset;
+ private final String limit;
+
+ private KeyPair mSourceAccount;
+
+ Builder(ChangeTrustOp op) {
+ asset = Asset.fromXdr(op.getLine());
+ limit = Operation.fromXdrAmount(op.getLimit().getInt64().longValue());
+ }
+
+ /**
+ * Creates a new ChangeTrust builder.
+ * @param asset The asset of the trustline. For example, if a gateway extends a trustline of up to 200 USD to a user, the line is USD.
+ * @param limit The limit of the trustline. For example, if a gateway extends a trustline of up to 200 USD to a user, the limit is 200.
+ * @throws ArithmeticException when limit has more than 7 decimal places.
+ */
+ public Builder(Asset asset, String limit) {
+ this.asset = checkNotNull(asset, "asset cannot be null");
+ this.limit = checkNotNull(limit, "limit cannot be null");
+ }
+
+ /**
+ * Set source account of this operation
+ * @param sourceAccount Source account
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public ChangeTrustOperation build() {
+ ChangeTrustOperation operation = new ChangeTrustOperation(asset, limit);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/CreateAccountOperation.java b/src/main/java/org/stellar/sdk/CreateAccountOperation.java
new file mode 100644
index 000000000..46c2e8528
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/CreateAccountOperation.java
@@ -0,0 +1,105 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.CreateAccountOp;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.OperationType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents CreateAccount operation.
+ * @see List of Operations
+ */
+public class CreateAccountOperation extends Operation {
+
+ private final KeyPair destination;
+ private final String startingBalance;
+
+ private CreateAccountOperation(KeyPair destination, String startingBalance) {
+ this.destination = checkNotNull(destination, "destination cannot be null");
+ this.startingBalance = checkNotNull(startingBalance, "startingBalance cannot be null");
+ }
+
+ /**
+ * Amount of XLM to send to the newly created account.
+ */
+ public String getStartingBalance() {
+ return startingBalance;
+ }
+
+ /**
+ * Account that is created and funded
+ */
+ public KeyPair getDestination() {
+ return destination;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ CreateAccountOp op = new CreateAccountOp();
+ AccountID destination = new AccountID();
+ destination.setAccountID(this.destination.getXdrPublicKey());
+ op.setDestination(destination);
+ Int64 startingBalance = new Int64();
+ startingBalance.setInt64(Operation.toXdrAmount(this.startingBalance));
+ op.setStartingBalance(startingBalance);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.CREATE_ACCOUNT);
+ body.setCreateAccountOp(op);
+ return body;
+ }
+
+ /**
+ * Builds CreateAccount operation.
+ * @see CreateAccountOperation
+ */
+ public static class Builder {
+ private final KeyPair destination;
+ private final String startingBalance;
+
+ private KeyPair mSourceAccount;
+
+ /**
+ * Construct a new CreateAccount builder from a CreateAccountOp XDR.
+ * @param op {@link CreateAccountOp}
+ */
+ Builder(CreateAccountOp op) {
+ destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID());
+ startingBalance = Operation.fromXdrAmount(op.getStartingBalance().getInt64().longValue());
+ }
+
+ /**
+ * Creates a new CreateAccount builder.
+ * @param destination The destination keypair (uses only the public key).
+ * @param startingBalance The initial balance to start with in lumens.
+ * @throws ArithmeticException when startingBalance has more than 7 decimal places.
+ */
+ public Builder(KeyPair destination, String startingBalance) {
+ this.destination = destination;
+ this.startingBalance = startingBalance;
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param account The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair account) {
+ mSourceAccount = account;
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public CreateAccountOperation build() {
+ CreateAccountOperation operation = new CreateAccountOperation(destination, startingBalance);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/CreatePassiveOfferOperation.java b/src/main/java/org/stellar/sdk/CreatePassiveOfferOperation.java
new file mode 100644
index 000000000..0d871e8cc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/CreatePassiveOfferOperation.java
@@ -0,0 +1,136 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.CreatePassiveOfferOp;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.OperationType;
+
+import java.math.BigDecimal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents CreatePassiveOffer operation.
+ * @see List of Operations
+ */
+public class CreatePassiveOfferOperation extends Operation {
+ private final Asset selling;
+ private final Asset buying;
+ private final String amount;
+ private final String price;
+
+ private CreatePassiveOfferOperation(Asset selling, Asset buying, String amount, String price) {
+ this.selling = checkNotNull(selling, "selling cannot be null");
+ this.buying = checkNotNull(buying, "buying cannot be null");
+ this.amount = checkNotNull(amount, "amount cannot be null");
+ this.price = checkNotNull(price, "price cannot be null");
+ }
+
+ /**
+ * The asset being sold in this operation
+ */
+ public Asset getSelling() {
+ return selling;
+ }
+
+ /**
+ * The asset being bought in this operation
+ */
+ public Asset getBuying() {
+ return buying;
+ }
+
+ /**
+ * Amount of selling being sold.
+ */
+ public String getAmount() {
+ return amount;
+ }
+
+ /**
+ * Price of 1 unit of selling in terms of buying.
+ */
+ public String getPrice() {
+ return price;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ CreatePassiveOfferOp op = new CreatePassiveOfferOp();
+ op.setSelling(selling.toXdr());
+ op.setBuying(buying.toXdr());
+ Int64 amount = new Int64();
+ amount.setInt64(Operation.toXdrAmount(this.amount));
+ op.setAmount(amount);
+ Price price = Price.fromString(this.price);
+ op.setPrice(price.toXdr());
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.CREATE_PASSIVE_OFFER);
+ body.setCreatePassiveOfferOp(op);
+
+ return body;
+ }
+
+ /**
+ * Builds CreatePassiveOffer operation.
+ * @see CreatePassiveOfferOperation
+ */
+ public static class Builder {
+
+ private final Asset selling;
+ private final Asset buying;
+ private final String amount;
+ private final String price;
+
+ private KeyPair mSourceAccount;
+
+ /**
+ * Construct a new CreatePassiveOffer builder from a CreatePassiveOfferOp XDR.
+ * @param op
+ */
+ Builder(CreatePassiveOfferOp op) {
+ selling = Asset.fromXdr(op.getSelling());
+ buying = Asset.fromXdr(op.getBuying());
+ amount = Operation.fromXdrAmount(op.getAmount().getInt64().longValue());
+ int n = op.getPrice().getN().getInt32().intValue();
+ int d = op.getPrice().getD().getInt32().intValue();
+ price = new BigDecimal(n).divide(new BigDecimal(d)).toString();
+ }
+
+ /**
+ * Creates a new CreatePassiveOffer builder.
+ * @param selling The asset being sold in this operation
+ * @param buying The asset being bought in this operation
+ * @param amount Amount of selling being sold.
+ * @param price Price of 1 unit of selling in terms of buying.
+ * @throws ArithmeticException when amount has more than 7 decimal places.
+ */
+ public Builder(Asset selling, Asset buying, String amount, String price) {
+ this.selling = checkNotNull(selling, "selling cannot be null");
+ this.buying = checkNotNull(buying, "buying cannot be null");
+ this.amount = checkNotNull(amount, "amount cannot be null");
+ this.price = checkNotNull(price, "price cannot be null");
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param sourceAccount The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public CreatePassiveOfferOperation build() {
+ CreatePassiveOfferOperation operation = new CreatePassiveOfferOperation(selling, buying, amount, price);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/EffectDeserializer.java b/src/main/java/org/stellar/sdk/EffectDeserializer.java
deleted file mode 100644
index 38ffbba84..000000000
--- a/src/main/java/org/stellar/sdk/EffectDeserializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.stellar.sdk;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.effects.*;
-
-import java.lang.reflect.Type;
-
-class EffectDeserializer implements JsonDeserializer {
- @Override
- public Effect deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- // Create new Gson object with adapters needed in Operation
- Gson gson = new GsonBuilder()
- .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
- .create();
-
- int type = json.getAsJsonObject().get("type_i").getAsInt();
- switch (type) {
- // Account effects
- case 0:
- return gson.fromJson(json, AccountCreatedEffect.class);
- case 1:
- return gson.fromJson(json, AccountRemovedEffect.class);
- case 2:
- return gson.fromJson(json, AccountCreditedEffect.class);
- case 3:
- return gson.fromJson(json, AccountDebitedEffect.class);
- case 4:
- return gson.fromJson(json, AccountThresholdsUpdatedEffect.class);
- case 5:
- return gson.fromJson(json, AccountHomeDomainUpdatedEffect.class);
- case 6:
- return gson.fromJson(json, AccountFlagsUpdatedEffect.class);
- // Signer effects
- case 10:
- return gson.fromJson(json, SignerCreatedEffect.class);
- case 11:
- return gson.fromJson(json, SignerRemovedEffect.class);
- case 12:
- return gson.fromJson(json, SignerUpdatedEffect.class);
- // Trustline effects
- case 20:
- return gson.fromJson(json, TrustlineCreatedEffect.class);
- case 21:
- return gson.fromJson(json, TrustlineRemovedEffect.class);
- case 22:
- return gson.fromJson(json, TrustlineUpdatedEffect.class);
- case 23:
- return gson.fromJson(json, TrustlineAuthorizedEffect.class);
- case 24:
- return gson.fromJson(json, TrustlineDeauthorizedEffect.class);
- // Trading effects
- case 30:
- return gson.fromJson(json, OfferCreatedEffect.class);
- case 31:
- return gson.fromJson(json, OfferRemovedEffect.class);
- case 32:
- return gson.fromJson(json, OfferUpdatedEffect.class);
- case 33:
- return gson.fromJson(json, TradeEffect.class);
- default:
- throw new RuntimeException("Invalid operation type");
- }
- }
-}
diff --git a/src/main/java/org/stellar/sdk/FormatException.java b/src/main/java/org/stellar/sdk/FormatException.java
new file mode 100644
index 000000000..e3671e805
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/FormatException.java
@@ -0,0 +1,15 @@
+package org.stellar.sdk;
+
+/**
+ * Indicates that there was a problem decoding strkey encoded string.
+ * @see KeyPair
+ */
+public class FormatException extends RuntimeException {
+ public FormatException() {
+ super();
+ }
+
+ public FormatException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/GsonSingleton.java b/src/main/java/org/stellar/sdk/GsonSingleton.java
deleted file mode 100644
index 74430ac8a..000000000
--- a/src/main/java/org/stellar/sdk/GsonSingleton.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.stellar.sdk;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
-
-import org.stellar.base.Asset;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.effects.Effect;
-import org.stellar.sdk.operations.Operation;
-
-public class GsonSingleton {
- private static Gson instance = null;
-
- protected GsonSingleton() {}
-
- public static Gson getInstance() {
- if (instance == null) {
- TypeToken accountPageType = new TypeToken>() {};
- TypeToken effectPageType = new TypeToken>() {};
- TypeToken ledgerPageType = new TypeToken>() {};
- TypeToken operationPageType = new TypeToken>() {};
- TypeToken pathPageType = new TypeToken>() {};
- TypeToken transactionPageType = new TypeToken>() {};
-
- instance = new GsonBuilder()
- .registerTypeAdapter(Asset.class, new AssetDeserializer())
- .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
- .registerTypeAdapter(Operation.class, new OperationDeserializer())
- .registerTypeAdapter(Effect.class, new EffectDeserializer())
- .registerTypeAdapter(Transaction.class, new TransactionDeserializer())
- .registerTypeAdapter(accountPageType.getType(), new PageDeserializer(accountPageType))
- .registerTypeAdapter(effectPageType.getType(), new PageDeserializer(effectPageType))
- .registerTypeAdapter(ledgerPageType.getType(), new PageDeserializer(ledgerPageType))
- .registerTypeAdapter(operationPageType.getType(), new PageDeserializer(operationPageType))
- .registerTypeAdapter(pathPageType.getType(), new PageDeserializer(pathPageType))
- .registerTypeAdapter(transactionPageType.getType(), new PageDeserializer(transactionPageType))
- .create();
- }
- return instance;
- }
-
-}
diff --git a/src/main/java/org/stellar/sdk/InflationOperation.java b/src/main/java/org/stellar/sdk/InflationOperation.java
new file mode 100644
index 000000000..b2ee39a0b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/InflationOperation.java
@@ -0,0 +1,16 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.OperationType;
+
+/**
+ * Represents Inflation operation.
+ * @see List of Operations
+ */
+public class InflationOperation extends Operation {
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.INFLATION);
+ return body;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/KeyPair.java b/src/main/java/org/stellar/sdk/KeyPair.java
new file mode 100644
index 000000000..62587473f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/KeyPair.java
@@ -0,0 +1,239 @@
+package org.stellar.sdk;
+
+import net.i2p.crypto.eddsa.EdDSAEngine;
+import net.i2p.crypto.eddsa.EdDSAPrivateKey;
+import net.i2p.crypto.eddsa.EdDSAPublicKey;
+import net.i2p.crypto.eddsa.KeyPairGenerator;
+import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec;
+import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable;
+import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec;
+import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;
+
+import org.stellar.sdk.xdr.CryptoKeyType;
+import org.stellar.sdk.xdr.DecoratedSignature;
+import org.stellar.sdk.xdr.PublicKey;
+import org.stellar.sdk.xdr.SignatureHint;
+import org.stellar.sdk.xdr.Uint256;
+import org.stellar.sdk.xdr.XdrDataOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.util.Arrays;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Holds a Stellar keypair.
+ */
+public class KeyPair {
+
+ private static final EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("ed25519-sha-512");
+
+ private final EdDSAPublicKey mPublicKey;
+ private final EdDSAPrivateKey mPrivateKey;
+
+ /**
+ * Creates a new KeyPair without a private key. Useful to simply verify a signature from a
+ * given public address.
+ * @param publicKey
+ */
+ public KeyPair(EdDSAPublicKey publicKey) {
+ this(publicKey, null);
+ }
+
+ /**
+ * Creates a new KeyPair from the given public and private keys.
+ * @param publicKey
+ * @param privateKey
+ */
+ public KeyPair(EdDSAPublicKey publicKey, EdDSAPrivateKey privateKey) {
+ mPublicKey = checkNotNull(publicKey, "publicKey cannot be null");
+ mPrivateKey = privateKey;
+ }
+
+ /**
+ * Returns true if this Keypair is capable of signing
+ */
+ public boolean canSign() {
+ return mPrivateKey != null;
+ }
+
+ /**
+ * Creates a new Stellar KeyPair from a strkey encoded Stellar secret seed.
+ * @param seed Char array containing strkey encoded Stellar secret seed.
+ * @return {@link KeyPair}
+ */
+ public static KeyPair fromSecretSeed(char[] seed) {
+ byte[] decoded = StrKey.decodeStellarSecretSeed(seed);
+ KeyPair keypair = fromSecretSeed(decoded);
+ Arrays.fill(decoded, (byte) 0);
+ return keypair;
+ }
+
+ /**
+ * Insecure Creates a new Stellar KeyPair from a strkey encoded Stellar secret seed.
+ * This method is insecure. Use only if you are aware of security implications.
+ * @see Using Password-Based Encryption
+ * @param seed The strkey encoded Stellar secret seed.
+ * @return {@link KeyPair}
+ */
+ public static KeyPair fromSecretSeed(String seed) {
+ char[] charSeed = seed.toCharArray();
+ byte[] decoded = StrKey.decodeStellarSecretSeed(charSeed);
+ KeyPair keypair = fromSecretSeed(decoded);
+ Arrays.fill(charSeed, ' ');
+ Arrays.fill(decoded, (byte) 0);
+ return keypair;
+ }
+
+ /**
+ * Creates a new Stellar keypair from a raw 32 byte secret seed.
+ * @param seed The 32 byte secret seed.
+ * @return {@link KeyPair}
+ */
+ public static KeyPair fromSecretSeed(byte[] seed) {
+ EdDSAPrivateKeySpec privKeySpec = new EdDSAPrivateKeySpec(seed, ed25519);
+ EdDSAPublicKeySpec publicKeySpec = new EdDSAPublicKeySpec(privKeySpec.getA().toByteArray(), ed25519);
+ return new KeyPair(new EdDSAPublicKey(publicKeySpec), new EdDSAPrivateKey(privKeySpec));
+ }
+
+ /**
+ * Creates a new Stellar KeyPair from a strkey encoded Stellar account ID.
+ * @param accountId The strkey encoded Stellar account ID.
+ * @return {@link KeyPair}
+ */
+ public static KeyPair fromAccountId(String accountId) {
+ byte[] decoded = StrKey.decodeStellarAccountId(accountId);
+ return fromPublicKey(decoded);
+ }
+
+ /**
+ * Creates a new Stellar keypair from a 32 byte address.
+ * @param publicKey The 32 byte public key.
+ * @return {@link KeyPair}
+ */
+ public static KeyPair fromPublicKey(byte[] publicKey) {
+ EdDSAPublicKeySpec publicKeySpec = new EdDSAPublicKeySpec(publicKey, ed25519);
+ return new KeyPair(new EdDSAPublicKey(publicKeySpec));
+ }
+
+ /**
+ * Generates a random Stellar keypair.
+ * @return a random Stellar keypair.
+ */
+ public static KeyPair random() {
+ java.security.KeyPair keypair = new KeyPairGenerator().generateKeyPair();
+ return new KeyPair((EdDSAPublicKey) keypair.getPublic(), (EdDSAPrivateKey) keypair.getPrivate());
+ }
+
+ /**
+ * Returns the human readable account ID encoded in strkey.
+ */
+ public String getAccountId() {
+ return StrKey.encodeStellarAccountId(mPublicKey.getAbyte());
+ }
+
+ /**
+ * Returns the human readable secret seed encoded in strkey.
+ */
+ public char[] getSecretSeed() {
+ return StrKey.encodeStellarSecretSeed(mPrivateKey.getSeed());
+ }
+
+ public byte[] getPublicKey() {
+ return mPublicKey.getAbyte();
+ }
+
+ public SignatureHint getSignatureHint() {
+ try {
+ ByteArrayOutputStream publicKeyBytesStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrOutputStream = new XdrDataOutputStream(publicKeyBytesStream);
+ PublicKey.encode(xdrOutputStream, this.getXdrPublicKey());
+ byte[] publicKeyBytes = publicKeyBytesStream.toByteArray();
+ byte[] signatureHintBytes = Arrays.copyOfRange(publicKeyBytes, publicKeyBytes.length - 4, publicKeyBytes.length);
+
+ SignatureHint signatureHint = new SignatureHint();
+ signatureHint.setSignatureHint(signatureHintBytes);
+ return signatureHint;
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ public PublicKey getXdrPublicKey() {
+ PublicKey publicKey = new PublicKey();
+ publicKey.setDiscriminant(CryptoKeyType.KEY_TYPE_ED25519);
+ Uint256 uint256 = new Uint256();
+ uint256.setUint256(getPublicKey());
+ publicKey.setEd25519(uint256);
+ return publicKey;
+ }
+
+ public static KeyPair fromXdrPublicKey(PublicKey key) {
+ return KeyPair.fromPublicKey(key.getEd25519().getUint256());
+ }
+
+ /**
+ * Sign the provided data with the keypair's private key.
+ * @param data The data to sign.
+ * @return signed bytes, null if the private key for this keypair is null.
+ */
+ public byte[] sign(byte[] data) {
+ if (mPrivateKey == null) {
+ return null;
+ }
+ try {
+ Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
+ sgr.initSign(mPrivateKey);
+ sgr.update(data);
+ return sgr.sign();
+ } catch (GeneralSecurityException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Sign the provided data with the keypair's private key and returns {@link DecoratedSignature}.
+ * @param data
+ */
+ public DecoratedSignature signDecorated(byte[] data) {
+ byte[] signatureBytes = this.sign(data);
+
+ org.stellar.sdk.xdr.Signature signature = new org.stellar.sdk.xdr.Signature();
+ signature.setSignature(signatureBytes);
+
+ DecoratedSignature decoratedSignature = new DecoratedSignature();
+ decoratedSignature.setHint(this.getSignatureHint());
+ decoratedSignature.setSignature(signature);
+ return decoratedSignature;
+ }
+
+ /**
+ * Verify the provided data and signature match this keypair's public key.
+ * @param data The data that was signed.
+ * @param signature The signature.
+ * @return True if they match, false otherwise.
+ * @throws SignatureException If the signature length is wrong.
+ */
+ public boolean verify(byte[] data, byte[] signature) {
+ try {
+ Signature sgr = new EdDSAEngine(MessageDigest.getInstance("SHA-512"));
+ sgr.initVerify(mPublicKey);
+ sgr.update(data);
+ return sgr.verify(signature);
+ } catch (SignatureException e) {
+ return false;
+ } catch (GeneralSecurityException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/ManageOfferOperation.java b/src/main/java/org/stellar/sdk/ManageOfferOperation.java
new file mode 100644
index 000000000..0612e5d7a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/ManageOfferOperation.java
@@ -0,0 +1,163 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.CreateAccountOp;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.ManageOfferOp;
+import org.stellar.sdk.xdr.OperationType;
+import org.stellar.sdk.xdr.Uint64;
+
+import java.math.BigDecimal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents ManageOffer operation.
+ * @see List of Operations
+ */
+public class ManageOfferOperation extends Operation {
+
+ private final Asset selling;
+ private final Asset buying;
+ private final String amount;
+ private final String price;
+ private final long offerId;
+
+ private ManageOfferOperation(Asset selling, Asset buying, String amount, String price, long offerId) {
+ this.selling = checkNotNull(selling, "selling cannot be null");
+ this.buying = checkNotNull(buying, "buying cannot be null");
+ this.amount = checkNotNull(amount, "amount cannot be null");
+ this.price = checkNotNull(price, "price cannot be null");
+ // offerId can be null
+ this.offerId = offerId;
+ }
+
+ /**
+ * The asset being sold in this operation
+ */
+ public Asset getSelling() {
+ return selling;
+ }
+
+ /**
+ * The asset being bought in this operation
+ */
+ public Asset getBuying() {
+ return buying;
+ }
+
+ /**
+ * Amount of selling being sold.
+ */
+ public String getAmount() {
+ return amount;
+ }
+
+ /**
+ * Price of 1 unit of selling in terms of buying.
+ */
+ public String getPrice() {
+ return price;
+ }
+
+ /**
+ * The ID of the offer.
+ */
+ public long getOfferId() {
+ return offerId;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ ManageOfferOp op = new ManageOfferOp();
+ op.setSelling(selling.toXdr());
+ op.setBuying(buying.toXdr());
+ Int64 amount = new Int64();
+ amount.setInt64(Operation.toXdrAmount(this.amount));
+ op.setAmount(amount);
+ Price price = Price.fromString(this.price);
+ op.setPrice(price.toXdr());
+ Uint64 offerId = new Uint64();
+ offerId.setUint64(Long.valueOf(this.offerId));
+ op.setOfferID(offerId);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.MANAGE_OFFER);
+ body.setManageOfferOp(op);
+
+ return body;
+ }
+
+ /**
+ * Builds ManageOffer operation.
+ * @see ManageOfferOperation
+ */
+ public static class Builder {
+
+ private final Asset selling;
+ private final Asset buying;
+ private final String amount;
+ private final String price;
+ private long offerId = 0;
+
+ private KeyPair mSourceAccount;
+
+ /**
+ * Construct a new CreateAccount builder from a CreateAccountOp XDR.
+ * @param op {@link CreateAccountOp}
+ */
+ Builder(ManageOfferOp op) {
+ selling = Asset.fromXdr(op.getSelling());
+ buying = Asset.fromXdr(op.getBuying());
+ amount = Operation.fromXdrAmount(op.getAmount().getInt64().longValue());
+ int n = op.getPrice().getN().getInt32().intValue();
+ int d = op.getPrice().getD().getInt32().intValue();
+ price = new BigDecimal(n).divide(new BigDecimal(d)).toString();
+ offerId = op.getOfferID().getUint64().longValue();
+ }
+
+ /**
+ * Creates a new ManageOffer builder.
+ * @param selling The asset being sold in this operation
+ * @param buying The asset being bought in this operation
+ * @param amount Amount of selling being sold.
+ * @param price Price of 1 unit of selling in terms of buying.
+ * @throws ArithmeticException when amount has more than 7 decimal places.
+ */
+ public Builder(Asset selling, Asset buying, String amount, String price) {
+ this.selling = checkNotNull(selling, "selling cannot be null");
+ this.buying = checkNotNull(buying, "buying cannot be null");
+ this.amount = checkNotNull(amount, "amount cannot be null");
+ this.price = checkNotNull(price, "price cannot be null");
+ }
+
+ /**
+ * Sets offer ID. 0
creates a new offer. Set to existing offer ID to change it.
+ * @param offerId
+ */
+ public Builder setOfferId(long offerId) {
+ this.offerId = offerId;
+ return this;
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param sourceAccount The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public ManageOfferOperation build() {
+ ManageOfferOperation operation = new ManageOfferOperation(selling, buying, amount, price, offerId);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Memo.java b/src/main/java/org/stellar/sdk/Memo.java
new file mode 100644
index 000000000..9a757de60
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Memo.java
@@ -0,0 +1,76 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.DecoderException;
+
+/**
+ * The memo contains optional extra information. It is the responsibility of the client to interpret this value. Memos can be one of the following types:
+ *
+ * MEMO_NONE
: Empty memo.
+ * MEMO_TEXT
: A string up to 28-bytes long.
+ * MEMO_ID
: A 64 bit unsigned integer.
+ * MEMO_HASH
: A 32 byte hash.
+ * MEMO_RETURN
: A 32 byte hash intended to be interpreted as the hash of the transaction the sender is refunding.
+ *
+ * Use static methods to generate any of above types.
+ * @see Transaction
+ */
+public abstract class Memo {
+ /**
+ * Creates new MemoNone instance.
+ */
+ public static MemoNone none() {
+ return new MemoNone();
+ }
+
+ /**
+ * Creates new {@link MemoText} instance.
+ * @param text
+ */
+ public static MemoText text(String text) {
+ return new MemoText(text);
+ }
+
+ /**
+ * Creates new {@link MemoId} instance.
+ * @param id
+ */
+ public static MemoId id(long id) {
+ return new MemoId(id);
+ }
+
+ /**
+ * Creates new {@link MemoHash} instance from byte array.
+ * @param bytes
+ */
+ public static MemoHash hash(byte[] bytes) {
+ return new MemoHash(bytes);
+ }
+
+ /**
+ * Creates new {@link MemoHash} instance from hex-encoded string
+ * @param hexString
+ * @throws DecoderException
+ */
+ public static MemoHash hash(String hexString) throws DecoderException {
+ return new MemoHash(hexString);
+ }
+
+ /**
+ * Creates new {@link MemoReturnHash} instance from byte array.
+ * @param bytes
+ */
+ public static MemoReturnHash returnHash(byte[] bytes) {
+ return new MemoReturnHash(bytes);
+ }
+
+ /**
+ * Creates new {@link MemoReturnHash} instance from hex-encoded string.
+ * @param hexString
+ * @throws DecoderException
+ */
+ public static MemoReturnHash returnHash(String hexString) throws DecoderException {
+ return new MemoReturnHash(hexString);
+ }
+
+ abstract org.stellar.sdk.xdr.Memo toXdr();
+}
diff --git a/src/main/java/org/stellar/sdk/MemoHash.java b/src/main/java/org/stellar/sdk/MemoHash.java
new file mode 100644
index 000000000..432e41bca
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoHash.java
@@ -0,0 +1,29 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.DecoderException;
+import org.stellar.sdk.xdr.MemoType;
+
+/**
+ * Represents MEMO_HASH.
+ */
+public class MemoHash extends MemoHashAbstract {
+ public MemoHash(byte[] bytes) {
+ super(bytes);
+ }
+
+ public MemoHash(String hexString) throws DecoderException {
+ super(hexString);
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Memo toXdr() {
+ org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
+ memo.setDiscriminant(MemoType.MEMO_HASH);
+
+ org.stellar.sdk.xdr.Hash hash = new org.stellar.sdk.xdr.Hash();
+ hash.setHash(bytes);
+
+ memo.setHash(hash);
+ return memo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/MemoHashAbstract.java b/src/main/java/org/stellar/sdk/MemoHashAbstract.java
new file mode 100644
index 000000000..30369e1d4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoHashAbstract.java
@@ -0,0 +1,60 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+
+abstract class MemoHashAbstract extends Memo {
+ protected byte[] bytes;
+
+ public MemoHashAbstract(byte[] bytes) {
+ if (bytes.length < 32) {
+ bytes = Util.paddedByteArray(bytes, 32);
+ } else if (bytes.length > 32) {
+ throw new MemoTooLongException("MEMO_HASH can contain 32 bytes at max.");
+ }
+
+ this.bytes = bytes;
+ }
+
+ public MemoHashAbstract(String hexString) throws DecoderException {
+ this(Hex.decodeHex(hexString.toCharArray()));
+ }
+
+ /**
+ * Returns 32 bytes long array contained in this memo.
+ */
+ public byte[] getBytes() {
+ return bytes;
+ }
+
+ /**
+ * Returns hex representation of bytes contained in this memo.
+ *
+ * Example:
+ *
+ * MemoHash memo = new MemoHash("4142434445");
+ * memo.getHexValue(); // 4142434445000000000000000000000000000000000000000000000000000000
+ * memo.getTrimmedHexValue(); // 4142434445
+ *
+ */
+ public String getHexValue() {
+ return new String(Hex.encodeHex(this.bytes));
+ }
+
+ /**
+ * Returns hex representation of bytes contained in this memo until null byte (0x00) is found.
+ *
+ * Example:
+ *
+ * MemoHash memo = new MemoHash("4142434445");
+ * memo.getHexValue(); // 4142434445000000000000000000000000000000000000000000000000000000
+ * memo.getTrimmedHexValue(); // 4142434445
+ *
+ */
+ public String getTrimmedHexValue() {
+ return this.getHexValue().split("00")[0];
+ }
+
+ @Override
+ abstract org.stellar.sdk.xdr.Memo toXdr();
+}
diff --git a/src/main/java/org/stellar/sdk/MemoId.java b/src/main/java/org/stellar/sdk/MemoId.java
new file mode 100644
index 000000000..4cfb1db6e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoId.java
@@ -0,0 +1,32 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.MemoType;
+import org.stellar.sdk.xdr.Uint64;
+
+/**
+ * Represents MEMO_ID.
+ */
+public class MemoId extends Memo {
+ private long id;
+
+ public MemoId(long id) {
+ if (id < 0) {
+ throw new IllegalArgumentException("id must be a positive number");
+ }
+ this.id = id;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Memo toXdr() {
+ org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
+ memo.setDiscriminant(MemoType.MEMO_ID);
+ Uint64 idXdr = new Uint64();
+ idXdr.setUint64(id);
+ memo.setId(idXdr);
+ return memo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/MemoNone.java b/src/main/java/org/stellar/sdk/MemoNone.java
new file mode 100644
index 000000000..d6b520f3d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoNone.java
@@ -0,0 +1,15 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.MemoType;
+
+/**
+ * Represents MEMO_NONE.
+ */
+public class MemoNone extends Memo {
+ @Override
+ org.stellar.sdk.xdr.Memo toXdr() {
+ org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
+ memo.setDiscriminant(MemoType.MEMO_NONE);
+ return memo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/MemoReturnHash.java b/src/main/java/org/stellar/sdk/MemoReturnHash.java
new file mode 100644
index 000000000..3805d8021
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoReturnHash.java
@@ -0,0 +1,30 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.DecoderException;
+import org.stellar.sdk.xdr.Memo;
+import org.stellar.sdk.xdr.MemoType;
+
+/**
+ * Represents MEMO_RETURN.
+ */
+public class MemoReturnHash extends MemoHashAbstract {
+ public MemoReturnHash(byte[] bytes) {
+ super(bytes);
+ }
+
+ public MemoReturnHash(String hexString) throws DecoderException {
+ super(hexString);
+ }
+
+ @Override
+ Memo toXdr() {
+ org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
+ memo.setDiscriminant(MemoType.MEMO_RETURN);
+
+ org.stellar.sdk.xdr.Hash hash = new org.stellar.sdk.xdr.Hash();
+ hash.setHash(bytes);
+
+ memo.setHash(hash);
+ return memo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/MemoText.java b/src/main/java/org/stellar/sdk/MemoText.java
new file mode 100644
index 000000000..9b0e95709
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoText.java
@@ -0,0 +1,35 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.MemoType;
+
+import java.nio.charset.StandardCharsets;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents MEMO_TEXT.
+ */
+public class MemoText extends Memo {
+ private String text;
+
+ public MemoText(String text) {
+ this.text = checkNotNull(text, "text cannot be null");
+
+ int length = text.getBytes((StandardCharsets.UTF_8)).length;
+ if (length > 28) {
+ throw new MemoTooLongException("text must be <= 28 bytes. length=" + String.valueOf(length));
+ }
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Memo toXdr() {
+ org.stellar.sdk.xdr.Memo memo = new org.stellar.sdk.xdr.Memo();
+ memo.setDiscriminant(MemoType.MEMO_TEXT);
+ memo.setText(text);
+ return memo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/MemoTooLongException.java b/src/main/java/org/stellar/sdk/MemoTooLongException.java
new file mode 100644
index 000000000..dd4d21707
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/MemoTooLongException.java
@@ -0,0 +1,15 @@
+package org.stellar.sdk;
+
+/**
+ * Indicates that value passed to Memo
+ * @see Memo
+ */
+public class MemoTooLongException extends RuntimeException {
+ public MemoTooLongException() {
+ super();
+ }
+
+ public MemoTooLongException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Network.java b/src/main/java/org/stellar/sdk/Network.java
new file mode 100644
index 000000000..8fd1fc229
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Network.java
@@ -0,0 +1,71 @@
+package org.stellar.sdk;
+
+import java.nio.charset.StandardCharsets;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Network class is used to specify which Stellar network you want to use.
+ * Each network has a networkPassphrase
which is hashed to
+ * every transaction id.
+ * Default network is Test Network.
+ */
+public class Network {
+ private final static String PUBLIC = "Public Global Stellar Network ; September 2015";
+ private final static String TESTNET = "Test SDF Network ; September 2015";
+ private static Network current = new Network(TESTNET);
+
+ private final String networkPassphrase;
+
+ /**
+ * Creates a new Network object to represent a network with a given passphrase
+ * @param networkPassphrase
+ */
+ Network(String networkPassphrase) {
+ this.networkPassphrase = checkNotNull(networkPassphrase, "networkPassphrase cannot be null");
+ }
+
+ /**
+ * Returns network passphrase
+ */
+ public String getNetworkPassphrase() {
+ return networkPassphrase;
+ }
+
+ /**
+ * Returns network id (SHA-256 hashed networkPassphrase
).
+ */
+ public byte[] getNetworkId() {
+ return Util.hash(current.getNetworkPassphrase().getBytes(StandardCharsets.UTF_8));
+ }
+
+ /**
+ * Returns currently used Network object.
+ */
+ public static Network current() {
+ return current;
+ }
+
+ /**
+ * Use network
as a current network.
+ * @param network Network object to set as current network
+ */
+ public static void use(Network network) {
+ checkNotNull(network, "network cannot be null");
+ current = network;
+ }
+
+ /**
+ * Use Stellar Public Network
+ */
+ public static void usePublicNetwork() {
+ Network.use(new Network(PUBLIC));
+ }
+
+ /**
+ * Use Stellar Test Network.
+ */
+ public static void useTestNetwork() {
+ Network.use(new Network(TESTNET));
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/NotEnoughSignaturesException.java b/src/main/java/org/stellar/sdk/NotEnoughSignaturesException.java
new file mode 100644
index 000000000..7fa3b33ab
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/NotEnoughSignaturesException.java
@@ -0,0 +1,14 @@
+package org.stellar.sdk;
+
+/**
+ * Indicates that the object that has to be signed has not enough signatures.
+ */
+public class NotEnoughSignaturesException extends RuntimeException {
+ public NotEnoughSignaturesException() {
+ super();
+ }
+
+ public NotEnoughSignaturesException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Operation.java b/src/main/java/org/stellar/sdk/Operation.java
new file mode 100644
index 000000000..132d92eb5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Operation.java
@@ -0,0 +1,128 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.binary.Base64;
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.XdrDataOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Abstract class for operations.
+ */
+public abstract class Operation {
+ Operation() {}
+
+ private KeyPair mSourceAccount;
+
+ private static final BigDecimal ONE = new BigDecimal(10).pow(7);
+
+ protected static long toXdrAmount(String value) {
+ value = checkNotNull(value, "value cannot be null");
+ BigDecimal amount = new BigDecimal(value).multiply(Operation.ONE);
+ return amount.longValueExact();
+ }
+
+ protected static String fromXdrAmount(long value) {
+ BigDecimal amount = new BigDecimal(value).divide(Operation.ONE);
+ return amount.toPlainString();
+ }
+
+ /**
+ * Generates Operation XDR object.
+ */
+ public org.stellar.sdk.xdr.Operation toXdr() {
+ org.stellar.sdk.xdr.Operation xdr = new org.stellar.sdk.xdr.Operation();
+ if (getSourceAccount() != null) {
+ AccountID sourceAccount = new AccountID();
+ sourceAccount.setAccountID(getSourceAccount().getXdrPublicKey());
+ xdr.setSourceAccount(sourceAccount);
+ }
+ xdr.setBody(toOperationBody());
+ return xdr;
+ }
+
+ /**
+ * Returns base64-encoded Operation XDR object.
+ */
+ public String toXdrBase64() {
+ try {
+ org.stellar.sdk.xdr.Operation operation = this.toXdr();
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrOutputStream = new XdrDataOutputStream(outputStream);
+ org.stellar.sdk.xdr.Operation.encode(xdrOutputStream, operation);
+ Base64 base64Codec = new Base64();
+ return base64Codec.encodeAsString(outputStream.toByteArray());
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ /**
+ * Returns new Operation object from Operation XDR object.
+ * @param xdr XDR object
+ */
+ public static Operation fromXdr(org.stellar.sdk.xdr.Operation xdr) {
+ org.stellar.sdk.xdr.Operation.OperationBody body = xdr.getBody();
+ Operation operation;
+ switch (body.getDiscriminant()) {
+ case CREATE_ACCOUNT:
+ operation = new CreateAccountOperation.Builder(body.getCreateAccountOp()).build();
+ break;
+ case PAYMENT:
+ operation = new PaymentOperation.Builder(body.getPaymentOp()).build();
+ break;
+ case PATH_PAYMENT:
+ operation = new PathPaymentOperation.Builder(body.getPathPaymentOp()).build();
+ break;
+ case MANAGE_OFFER:
+ operation = new ManageOfferOperation.Builder(body.getManageOfferOp()).build();
+ break;
+ case CREATE_PASSIVE_OFFER:
+ operation = new CreatePassiveOfferOperation.Builder(body.getCreatePassiveOfferOp()).build();
+ break;
+ case SET_OPTIONS:
+ operation = new SetOptionsOperation.Builder(body.getSetOptionsOp()).build();
+ break;
+ case CHANGE_TRUST:
+ operation = new ChangeTrustOperation.Builder(body.getChangeTrustOp()).build();
+ break;
+ case ALLOW_TRUST:
+ operation = new AllowTrustOperation.Builder(body.getAllowTrustOp()).build();
+ break;
+ case ACCOUNT_MERGE:
+ operation = new AccountMergeOperation.Builder(body).build();
+ break;
+ default:
+ throw new RuntimeException("Unknown operation body " + body.getDiscriminant());
+ }
+ if (xdr.getSourceAccount() != null) {
+ operation.setSourceAccount(KeyPair.fromXdrPublicKey(xdr.getSourceAccount().getAccountID()));
+ }
+ return operation;
+ }
+
+ /**
+ * Returns operation source account.
+ */
+ public KeyPair getSourceAccount() {
+ return mSourceAccount;
+ }
+
+ /**
+ * Sets operation source account.
+ * @param keypair
+ */
+ void setSourceAccount(KeyPair keypair) {
+ mSourceAccount = checkNotNull(keypair, "keypair cannot be null");
+ }
+
+ /**
+ * Generates OperationBody XDR object
+ * @return OperationBody XDR object
+ */
+ abstract org.stellar.sdk.xdr.Operation.OperationBody toOperationBody();
+}
diff --git a/src/main/java/org/stellar/sdk/OperationDeserializer.java b/src/main/java/org/stellar/sdk/OperationDeserializer.java
deleted file mode 100644
index 7e7fa2e6a..000000000
--- a/src/main/java/org/stellar/sdk/OperationDeserializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.stellar.sdk;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.operations.*;
-
-import java.lang.reflect.Type;
-
-class OperationDeserializer implements JsonDeserializer {
- @Override
- public Operation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- // Create new Gson object with adapters needed in Operation
- Gson gson = new GsonBuilder()
- .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
- .create();
-
- int type = json.getAsJsonObject().get("type_i").getAsInt();
- switch (type) {
- case 0:
- return gson.fromJson(json, CreateAccountOperation.class);
- case 1:
- return gson.fromJson(json, PaymentOperation.class);
- case 2:
- return gson.fromJson(json, PathPaymentOperation.class);
- case 3:
- return gson.fromJson(json, ManageOfferOperation.class);
- case 4:
- return gson.fromJson(json, CreatePassiveOfferOperation.class);
- case 5:
- return gson.fromJson(json, SetOptionsOperation.class);
- case 6:
- return gson.fromJson(json, ChangeTrustOperation.class);
- case 7:
- return gson.fromJson(json, AllowTrustOperation.class);
- case 8:
- return gson.fromJson(json, AccountMergeOperation.class);
- case 9:
- return gson.fromJson(json, InflationOperation.class);
- default:
- throw new RuntimeException("Invalid operation type");
- }
- }
-}
diff --git a/src/main/java/org/stellar/sdk/PathPaymentOperation.java b/src/main/java/org/stellar/sdk/PathPaymentOperation.java
new file mode 100644
index 000000000..701069d54
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/PathPaymentOperation.java
@@ -0,0 +1,192 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.OperationType;
+import org.stellar.sdk.xdr.PathPaymentOp;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents PathPayment operation.
+ * @see List of Operations
+ */
+public class PathPaymentOperation extends Operation {
+
+ private final Asset sendAsset;
+ private final String sendMax;
+ private final KeyPair destination;
+ private final Asset destAsset;
+ private final String destAmount;
+ private final Asset[] path;
+
+ private PathPaymentOperation(Asset sendAsset, String sendMax, KeyPair destination,
+ Asset destAsset, String destAmount, Asset[] path) {
+ this.sendAsset = checkNotNull(sendAsset, "sendAsset cannot be null");
+ this.sendMax = checkNotNull(sendMax, "sendMax cannot be null");
+ this.destination = checkNotNull(destination, "destination cannot be null");
+ this.destAsset = checkNotNull(destAsset, "destAsset cannot be null");
+ this.destAmount = checkNotNull(destAmount, "destAmount cannot be null");
+ if (path == null) {
+ this.path = new Asset[0];
+ } else {
+ checkArgument(path.length <= 5, "The maximum number of assets in the path is 5");
+ this.path = path;
+ }
+ }
+
+ /**
+ * The asset deducted from the sender's account.
+ */
+ public Asset getSendAsset() {
+ return sendAsset;
+ }
+
+ /**
+ * The maximum amount of send asset to deduct (excluding fees)
+ */
+ public String getSendMax() {
+ return sendMax;
+ }
+
+ /**
+ * Account that receives the payment.
+ */
+ public KeyPair getDestination() {
+ return destination;
+ }
+
+ /**
+ * The asset the destination account receives.
+ */
+ public Asset getDestAsset() {
+ return destAsset;
+ }
+
+ /**
+ * The amount of destination asset the destination account receives.
+ */
+ public String getDestAmount() {
+ return destAmount;
+ }
+
+ /**
+ * The assets (other than send asset and destination asset) involved in the offers the path takes. For example, if you can only find a path from USD to EUR through XLM and BTC, the path would be USD -> XLM -> BTC -> EUR and the path would contain XLM and BTC.
+ */
+ public Asset[] getPath() {
+ return path;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ PathPaymentOp op = new PathPaymentOp();
+
+ // sendAsset
+ op.setSendAsset(sendAsset.toXdr());
+ // sendMax
+ Int64 sendMax = new Int64();
+ sendMax.setInt64(Operation.toXdrAmount(this.sendMax));
+ op.setSendMax(sendMax);
+ // destination
+ AccountID destination = new AccountID();
+ destination.setAccountID(this.destination.getXdrPublicKey());
+ op.setDestination(destination);
+ // destAsset
+ op.setDestAsset(destAsset.toXdr());
+ // destAmount
+ Int64 destAmount = new Int64();
+ destAmount.setInt64(Operation.toXdrAmount(this.destAmount));
+ op.setDestAmount(destAmount);
+ // path
+ org.stellar.sdk.xdr.Asset[] path = new org.stellar.sdk.xdr.Asset[this.path.length];
+ for (int i = 0; i < this.path.length; i++) {
+ path[i] = this.path[i].toXdr();
+ }
+ op.setPath(path);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.PATH_PAYMENT);
+ body.setPathPaymentOp(op);
+ return body;
+ }
+
+ /**
+ * Builds PathPayment operation.
+ * @see PathPaymentOperation
+ */
+ public static class Builder {
+ private final Asset sendAsset;
+ private final String sendMax;
+ private final KeyPair destination;
+ private final Asset destAsset;
+ private final String destAmount;
+ private Asset[] path;
+
+ private KeyPair mSourceAccount;
+
+ Builder(PathPaymentOp op) {
+ sendAsset = Asset.fromXdr(op.getSendAsset());
+ sendMax = Operation.fromXdrAmount(op.getSendMax().getInt64().longValue());
+ destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID());
+ destAsset = Asset.fromXdr(op.getDestAsset());
+ destAmount = Operation.fromXdrAmount(op.getDestAmount().getInt64().longValue());
+ path = new Asset[op.getPath().length];
+ for (int i = 0; i < op.getPath().length; i++) {
+ path[i] = Asset.fromXdr(op.getPath()[i]);
+ }
+ }
+
+ /**
+ * Creates a new PathPaymentOperation builder.
+ * @param sendAsset The asset deducted from the sender's account.
+ * @param sendMax The asset deducted from the sender's account.
+ * @param destination Payment destination
+ * @param destAsset The asset the destination account receives.
+ * @param destAmount The amount of destination asset the destination account receives.
+ * @throws ArithmeticException when sendMax or destAmount has more than 7 decimal places.
+ */
+ public Builder(Asset sendAsset, String sendMax, KeyPair destination,
+ Asset destAsset, String destAmount) {
+ this.sendAsset = checkNotNull(sendAsset, "sendAsset cannot be null");
+ this.sendMax = checkNotNull(sendMax, "sendMax cannot be null");
+ this.destination = checkNotNull(destination, "destination cannot be null");
+ this.destAsset = checkNotNull(destAsset, "destAsset cannot be null");
+ this.destAmount = checkNotNull(destAmount, "destAmount cannot be null");
+ }
+
+ /**
+ * Sets path for this operation
+ * @param path The assets (other than send asset and destination asset) involved in the offers the path takes. For example, if you can only find a path from USD to EUR through XLM and BTC, the path would be USD -> XLM -> BTC -> EUR and the path field would contain XLM and BTC.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setPath(Asset[] path) {
+ checkNotNull(path, "path cannot be null");
+ checkArgument(path.length <= 5, "The maximum number of assets in the path is 5");
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param sourceAccount The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public PathPaymentOperation build() {
+ PathPaymentOperation operation = new PathPaymentOperation(sendAsset, sendMax, destination,
+ destAsset, destAmount, path);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/PaymentOperation.java b/src/main/java/org/stellar/sdk/PaymentOperation.java
new file mode 100644
index 000000000..1191fab6f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/PaymentOperation.java
@@ -0,0 +1,123 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.Int64;
+import org.stellar.sdk.xdr.OperationType;
+import org.stellar.sdk.xdr.PaymentOp;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents Payment operation.
+ * @see List of Operations
+ */
+public class PaymentOperation extends Operation {
+
+ private final KeyPair destination;
+ private final Asset asset;
+ private final String amount;
+
+ private PaymentOperation(KeyPair destination, Asset asset, String amount) {
+ this.destination = checkNotNull(destination, "destination cannot be null");
+ this.asset = checkNotNull(asset, "asset cannot be null");
+ this.amount = checkNotNull(amount, "amount cannot be null");
+ }
+
+ /**
+ * Account that receives the payment.
+ */
+ public KeyPair getDestination() {
+ return destination;
+ }
+
+ /**
+ * Asset to send to the destination account.
+ */
+ public Asset getAsset() {
+ return asset;
+ }
+
+ /**
+ * Amount of the asset to send.
+ */
+ public String getAmount() {
+ return amount;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ PaymentOp op = new PaymentOp();
+
+ // destination
+ AccountID destination = new AccountID();
+ destination.setAccountID(this.destination.getXdrPublicKey());
+ op.setDestination(destination);
+ // asset
+ op.setAsset(asset.toXdr());
+ // amount
+ Int64 amount = new Int64();
+ amount.setInt64(Operation.toXdrAmount(this.amount));
+ op.setAmount(amount);
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.PAYMENT);
+ body.setPaymentOp(op);
+ return body;
+ }
+
+ /**
+ * Builds Payment operation.
+ * @see PathPaymentOperation
+ */
+ public static class Builder {
+ private final KeyPair destination;
+ private final Asset asset;
+ private final String amount;
+
+ private KeyPair mSourceAccount;
+
+ /**
+ * Construct a new PaymentOperation builder from a PaymentOp XDR.
+ * @param op {@link PaymentOp}
+ */
+ Builder(PaymentOp op) {
+ destination = KeyPair.fromXdrPublicKey(op.getDestination().getAccountID());
+ asset = Asset.fromXdr(op.getAsset());
+ amount = Operation.fromXdrAmount(op.getAmount().getInt64().longValue());
+ }
+
+ /**
+ * Creates a new PaymentOperation builder.
+ * @param destination The destination keypair (uses only the public key).
+ * @param asset The asset to send.
+ * @param amount The amount to send in lumens.
+ * @throws ArithmeticException when amount has more than 7 decimal places.
+ */
+ public Builder(KeyPair destination, Asset asset, String amount) {
+ this.destination = destination;
+ this.asset = asset;
+ this.amount = amount;
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param account The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair account) {
+ mSourceAccount = account;
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public PaymentOperation build() {
+ PaymentOperation operation = new PaymentOperation(destination, asset, amount);
+ if (mSourceAccount != null) {
+ operation.setSourceAccount(mSourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Price.java b/src/main/java/org/stellar/sdk/Price.java
new file mode 100644
index 000000000..a8599afcd
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Price.java
@@ -0,0 +1,105 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.Int32;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents Price. Price in Stellar is represented as a fraction.
+ */
+public class Price {
+ private final int n;
+ private final int d;
+
+ /**
+ * Create a new price. Price in Stellar is represented as a fraction.
+ * @param n numerator
+ * @param d denominator
+ */
+ Price(int n, int d) {
+ this.n = n;
+ this.d = d;
+ }
+
+ /**
+ * Returns numerator.
+ */
+ public int getNumerator() {
+ return n;
+ }
+
+ /**
+ * Returns denominator
+ */
+ public int getDenominator() {
+ return d;
+ }
+
+ /**
+ * Approximates price
to a fraction.
+ * @param price Ex. "1.25"
+ */
+ public static Price fromString(String price) {
+ checkNotNull(price, "price cannot be null");
+ BigDecimal maxInt = new BigDecimal(Integer.MAX_VALUE);
+ BigDecimal number = new BigDecimal(price);
+ BigDecimal a;
+ BigDecimal f;
+ List fractions = new ArrayList();
+ fractions.add(new BigDecimal[]{new BigDecimal(0), new BigDecimal(1)});
+ fractions.add(new BigDecimal[]{new BigDecimal(1), new BigDecimal(0)});
+ int i = 2;
+ while (true) {
+ if (number.compareTo(maxInt) > 0) {
+ break;
+ }
+ a = number.setScale(0, BigDecimal.ROUND_FLOOR);
+ f = number.subtract(a);
+ BigDecimal h = a.multiply(fractions.get(i - 1)[0]).add(fractions.get(i - 2)[0]);
+ BigDecimal k = a.multiply(fractions.get(i - 1)[1]).add(fractions.get(i - 2)[1]);
+ if (h.compareTo(maxInt) > 0 || k.compareTo(maxInt) > 0) {
+ break;
+ }
+ fractions.add(new BigDecimal[]{h, k});
+ if (f.compareTo(BigDecimal.ZERO) == 0) {
+ break;
+ }
+ number = new BigDecimal(1).divide(f, 20, BigDecimal.ROUND_HALF_UP);
+ i = i + 1;
+ }
+ BigDecimal n = fractions.get(fractions.size()-1)[0];
+ BigDecimal d = fractions.get(fractions.size()-1)[1];
+ return new Price(n.intValue(), d.intValue());
+ }
+
+ /**
+ * Generates Price XDR object.
+ */
+ public org.stellar.sdk.xdr.Price toXdr() {
+ org.stellar.sdk.xdr.Price xdr = new org.stellar.sdk.xdr.Price();
+ Int32 n = new Int32();
+ Int32 d = new Int32();
+ n.setInt32(this.n);
+ d.setInt32(this.d);
+ xdr.setN(n);
+ xdr.setD(d);
+ return xdr;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Price)) {
+ return false;
+ }
+
+ Price price = (Price) object;
+
+ return this.getNumerator() == price.getNumerator() &&
+ this.getDenominator() == price.getDenominator();
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Server.java b/src/main/java/org/stellar/sdk/Server.java
index e11ca7b54..9b0f9cb07 100644
--- a/src/main/java/org/stellar/sdk/Server.java
+++ b/src/main/java/org/stellar/sdk/Server.java
@@ -10,8 +10,9 @@
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
-import org.stellar.base.Transaction;
import org.stellar.sdk.requests.*;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.SubmitTransactionResponse;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/org/stellar/sdk/SetOptionsOperation.java b/src/main/java/org/stellar/sdk/SetOptionsOperation.java
new file mode 100644
index 000000000..a58c8c273
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/SetOptionsOperation.java
@@ -0,0 +1,344 @@
+package org.stellar.sdk;
+
+import org.stellar.sdk.xdr.AccountID;
+import org.stellar.sdk.xdr.OperationType;
+import org.stellar.sdk.xdr.SetOptionsOp;
+import org.stellar.sdk.xdr.Signer;
+import org.stellar.sdk.xdr.String32;
+import org.stellar.sdk.xdr.Uint32;
+
+/**
+ * Represents SetOptions operation.
+ * @see List of Operations
+ */
+public class SetOptionsOperation extends Operation {
+
+ private final KeyPair inflationDestination;
+ private final Integer clearFlags;
+ private final Integer setFlags;
+ private final Integer masterKeyWeight;
+ private final Integer lowThreshold;
+ private final Integer mediumThreshold;
+ private final Integer highThreshold;
+ private final String homeDomain;
+ private final KeyPair signer;
+ private final Integer signerWeight;
+
+ private SetOptionsOperation(KeyPair inflationDestination, Integer clearFlags, Integer setFlags,
+ Integer masterKeyWeight, Integer lowThreshold, Integer mediumThreshold,
+ Integer highThreshold, String homeDomain, KeyPair signer, Integer signerWeight) {
+ this.inflationDestination = inflationDestination;
+ this.clearFlags = clearFlags;
+ this.setFlags = setFlags;
+ this.masterKeyWeight = masterKeyWeight;
+ this.lowThreshold = lowThreshold;
+ this.mediumThreshold = mediumThreshold;
+ this.highThreshold = highThreshold;
+ this.homeDomain = homeDomain;
+ this.signer = signer;
+ this.signerWeight = signerWeight;
+ }
+
+ /**
+ * Account of the inflation destination.
+ */
+ public KeyPair getInflationDestination() {
+ return inflationDestination;
+ }
+
+ /**
+ * Indicates which flags to clear. For details about the flags, please refer to the accounts doc.
+ */
+ public Integer getClearFlags() {
+ return clearFlags;
+ }
+
+ /**
+ * Indicates which flags to set. For details about the flags, please refer to the accounts doc.
+ */
+ public Integer getSetFlags() {
+ return setFlags;
+ }
+
+ /**
+ * Weight of the master key.
+ */
+ public Integer getMasterKeyWeight() {
+ return masterKeyWeight;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a low threshold.
+ */
+ public Integer getLowThreshold() {
+ return lowThreshold;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a medium threshold.
+ */
+ public Integer getMediumThreshold() {
+ return mediumThreshold;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a high threshold.
+ */
+ public Integer getHighThreshold() {
+ return highThreshold;
+ }
+
+ /**
+ * The home domain of an account.
+ */
+ public String getHomeDomain() {
+ return homeDomain;
+ }
+
+ /**
+ * Additional signer added/removed in this operation.
+ */
+ public KeyPair getSigner() {
+ return signer;
+ }
+
+ /**
+ * Additional signer weight. The signer is deleted if the weight is 0.
+ */
+ public Integer getSignerWeight() {
+ return signerWeight;
+ }
+
+ @Override
+ org.stellar.sdk.xdr.Operation.OperationBody toOperationBody() {
+ SetOptionsOp op = new SetOptionsOp();
+ if (inflationDestination != null) {
+ AccountID inflationDestination = new AccountID();
+ inflationDestination.setAccountID(this.inflationDestination.getXdrPublicKey());
+ op.setInflationDest(inflationDestination);
+ }
+ if (clearFlags != null) {
+ Uint32 clearFlags = new Uint32();
+ clearFlags.setUint32(this.clearFlags);
+ op.setClearFlags(clearFlags);
+ }
+ if (setFlags != null) {
+ Uint32 setFlags = new Uint32();
+ setFlags.setUint32(this.setFlags);
+ op.setSetFlags(setFlags);
+ }
+ if (masterKeyWeight != null) {
+ Uint32 uint32 = new Uint32();
+ uint32.setUint32(masterKeyWeight);
+ op.setMasterWeight(uint32);
+ }
+ if (lowThreshold != null) {
+ Uint32 uint32 = new Uint32();
+ uint32.setUint32(lowThreshold);
+ op.setLowThreshold(uint32);
+ }
+ if (mediumThreshold != null) {
+ Uint32 uint32 = new Uint32();
+ uint32.setUint32(mediumThreshold);
+ op.setMedThreshold(uint32);
+ }
+ if (highThreshold != null) {
+ Uint32 uint32 = new Uint32();
+ uint32.setUint32(highThreshold);
+ op.setHighThreshold(uint32);
+ }
+ if (homeDomain != null) {
+ String32 homeDomain = new String32();
+ homeDomain.setString32(this.homeDomain);
+ op.setHomeDomain(homeDomain);
+ }
+ if (signer != null) {
+ Signer signer = new Signer();
+ Uint32 weight = new Uint32();
+ weight.setUint32((int) signerWeight & 0xFF);
+ AccountID accountID = new AccountID();
+ accountID.setAccountID(this.signer.getXdrPublicKey());
+ signer.setPubKey(accountID);
+ signer.setWeight(weight);
+ op.setSigner(signer);
+ }
+
+ org.stellar.sdk.xdr.Operation.OperationBody body = new org.stellar.sdk.xdr.Operation.OperationBody();
+ body.setDiscriminant(OperationType.SET_OPTIONS);
+ body.setSetOptionsOp(op);
+ return body;
+ }
+
+ /**
+ * Builds SetOptions operation.
+ * @see SetOptionsOperation
+ */
+ public static class Builder {
+ private KeyPair inflationDestination;
+ private Integer clearFlags;
+ private Integer setFlags;
+ private Integer masterKeyWeight;
+ private Integer lowThreshold;
+ private Integer mediumThreshold;
+ private Integer highThreshold;
+ private String homeDomain;
+ private KeyPair signer;
+ private Integer signerWeight;
+ private KeyPair sourceAccount;
+
+ Builder(SetOptionsOp op) {
+ if (op.getInflationDest() != null) {
+ inflationDestination = KeyPair.fromXdrPublicKey(
+ op.getInflationDest().getAccountID());
+ }
+ if (op.getClearFlags() != null) {
+ clearFlags = op.getClearFlags().getUint32();
+ }
+ if (op.getSetFlags() != null) {
+ setFlags = op.getSetFlags().getUint32();
+ }
+ if (op.getMasterWeight() != null) {
+ masterKeyWeight = op.getMasterWeight().getUint32().intValue();
+ }
+ if (op.getLowThreshold() != null) {
+ lowThreshold = op.getLowThreshold().getUint32().intValue();
+ }
+ if (op.getMedThreshold() != null) {
+ mediumThreshold = op.getMedThreshold().getUint32().intValue();
+ }
+ if (op.getHighThreshold() != null) {
+ highThreshold = op.getHighThreshold().getUint32().intValue();
+ }
+ if (op.getHomeDomain() != null) {
+ homeDomain = op.getHomeDomain().getString32();
+ }
+ if (op.getSigner() != null) {
+ signer = KeyPair.fromXdrPublicKey(op.getSigner().getPubKey().getAccountID());
+ signerWeight = op.getSigner().getWeight().getUint32().intValue() & 0xFF;
+ }
+ }
+
+ /**
+ * Creates a new SetOptionsOperation builder.
+ */
+ public Builder() {}
+
+ /**
+ * Sets the inflation destination for the account.
+ * @param inflationDestination The inflation destination account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setInflationDestination(KeyPair inflationDestination) {
+ this.inflationDestination = inflationDestination;
+ return this;
+ }
+
+ /**
+ * Clears the given flags from the account.
+ * @param clearFlags For details about the flags, please refer to the accounts doc.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setClearFlags(int clearFlags) {
+ this.clearFlags = clearFlags;
+ return this;
+ }
+
+ /**
+ * Sets the given flags on the account.
+ * @param setFlags For details about the flags, please refer to the accounts doc.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSetFlags(int setFlags) {
+ this.setFlags = setFlags;
+ return this;
+ }
+
+ /**
+ * Weight of the master key.
+ * @param masterKeyWeight Number between 0 and 255
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setMasterKeyWeight(int masterKeyWeight) {
+ this.masterKeyWeight = masterKeyWeight;
+ return this;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a low threshold.
+ * @param lowThreshold Number between 0 and 255
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setLowThreshold(int lowThreshold) {
+ this.lowThreshold = lowThreshold;
+ return this;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a medium threshold.
+ * @param mediumThreshold Number between 0 and 255
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setMediumThreshold(int mediumThreshold) {
+ this.mediumThreshold = mediumThreshold;
+ return this;
+ }
+
+ /**
+ * A number from 0-255 representing the threshold this account sets on all operations it performs that have a high threshold.
+ * @param highThreshold Number between 0 and 255
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setHighThreshold(int highThreshold) {
+ this.highThreshold = highThreshold;
+ return this;
+ }
+
+ /**
+ * Sets the account's home domain address used in Federation.
+ * @param homeDomain A string of the address which can be up to 32 characters.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setHomeDomain(String homeDomain) {
+ if (homeDomain.length() > 32) {
+ throw new IllegalArgumentException("Home domain must be <= 32 characters");
+ }
+ this.homeDomain = homeDomain;
+ return this;
+ }
+
+ /**
+ * Add, update, or remove a signer from the account. Signer is deleted if the weight = 0;
+ * @param signer The keypair to set as a signer.
+ * @param weight The weight to attach to the signer (0-255)
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSigner(KeyPair signer, Integer weight) {
+ this.signer = signer;
+ signerWeight = weight & 0xFF;
+ return this;
+ }
+
+ /**
+ * Sets the source account for this operation.
+ * @param sourceAccount The operation's source account.
+ * @return Builder object so you can chain methods.
+ */
+ public Builder setSourceAccount(KeyPair sourceAccount) {
+ this.sourceAccount = sourceAccount;
+ return this;
+ }
+
+ /**
+ * Builds an operation
+ */
+ public SetOptionsOperation build() {
+ SetOptionsOperation operation = new SetOptionsOperation(inflationDestination, clearFlags,
+ setFlags, masterKeyWeight, lowThreshold, mediumThreshold, highThreshold,
+ homeDomain, signer, signerWeight);
+ if (sourceAccount != null) {
+ operation.setSourceAccount(sourceAccount);
+ }
+ return operation;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/StrKey.java b/src/main/java/org/stellar/sdk/StrKey.java
new file mode 100644
index 000000000..a98bb4410
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/StrKey.java
@@ -0,0 +1,129 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.binary.Base32;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+class StrKey {
+ public enum VersionByte {
+ ACCOUNT_ID((byte)0x30),
+ SEED((byte)0x90);
+ private final byte value;
+ VersionByte(byte value) {
+ this.value = value;
+ }
+ public int getValue() {
+ return value;
+ }
+ }
+
+ public static String encodeStellarAccountId(byte[] data) {
+ char[] encoded = encodeCheck(VersionByte.ACCOUNT_ID, data);
+ return String.valueOf(encoded);
+ }
+
+ public static char[] encodeStellarSecretSeed(byte[] data) {
+ return encodeCheck(VersionByte.SEED, data);
+ }
+
+ public static byte[] decodeStellarAccountId(String data) {
+ return decodeCheck(VersionByte.ACCOUNT_ID, data.toCharArray());
+ }
+
+ public static byte[] decodeStellarSecretSeed(char[] data) {
+ return decodeCheck(VersionByte.SEED, data);
+ }
+
+ protected static char[] encodeCheck(VersionByte versionByte, byte[] data) {
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ outputStream.write(versionByte.getValue());
+ outputStream.write(data);
+ byte payload[] = outputStream.toByteArray();
+ byte checksum[] = StrKey.calculateChecksum(payload);
+ outputStream.write(checksum);
+ byte unencoded[] = outputStream.toByteArray();
+ Base32 base32Codec = new Base32();
+ byte[] bytesEncoded = base32Codec.encode(unencoded);
+
+ char[] charsEncoded = new char[bytesEncoded.length];
+ for (int i = 0; i < bytesEncoded.length; i++) {
+ charsEncoded[i] = (char) bytesEncoded[i];
+ }
+
+ if (VersionByte.SEED == versionByte) {
+ Arrays.fill(unencoded, (byte) 0);
+ Arrays.fill(payload, (byte) 0);
+ Arrays.fill(bytesEncoded, (byte) 0);
+ }
+
+ return charsEncoded;
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ protected static byte[] decodeCheck(VersionByte versionByte, char[] encoded) {
+ byte[] bytes = new byte[encoded.length];
+ for (int i = 0; i < encoded.length; i++) {
+ if (encoded[i] > 127) {
+ throw new IllegalArgumentException("Illegal characters in encoded char array.");
+ }
+ bytes[i] = (byte) encoded[i];
+ }
+
+ Base32 base32Codec = new Base32();
+ byte[] decoded = base32Codec.decode(bytes);
+ byte decodedVersionByte = decoded[0];
+ byte[] payload = Arrays.copyOfRange(decoded, 0, decoded.length-2);
+ byte[] data = Arrays.copyOfRange(payload, 1, payload.length);
+ byte[] checksum = Arrays.copyOfRange(decoded, decoded.length-2, decoded.length);
+
+ if (decodedVersionByte != versionByte.getValue()) {
+ throw new FormatException("Version byte is invalid");
+ }
+
+ byte[] expectedChecksum = StrKey.calculateChecksum(payload);
+
+ if (!Arrays.equals(expectedChecksum, checksum)) {
+ throw new FormatException("Checksum invalid");
+ }
+
+ if (VersionByte.SEED.getValue() == decodedVersionByte) {
+ Arrays.fill(bytes, (byte) 0);
+ Arrays.fill(decoded, (byte) 0);
+ Arrays.fill(payload, (byte) 0);
+ }
+
+ return data;
+ }
+
+ protected static byte[] calculateChecksum(byte[] bytes) {
+ // This code calculates CRC16-XModem checksum
+ // Ported from https://github.com/alexgorbatchev/node-crc
+ int crc = 0x0000;
+ int count = bytes.length;
+ int i = 0;
+ int code;
+
+ while (count > 0) {
+ code = crc >>> 8 & 0xFF;
+ code ^= bytes[i++] & 0xFF;
+ code ^= code >>> 4;
+ crc = crc << 8 & 0xFFFF;
+ crc ^= code;
+ code = code << 5 & 0xFFFF;
+ crc ^= code;
+ code = code << 7 & 0xFFFF;
+ crc ^= code;
+ count--;
+ }
+
+ // little-endian
+ return new byte[] {
+ (byte)crc,
+ (byte)(crc >>> 8)};
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Transaction.java b/src/main/java/org/stellar/sdk/Transaction.java
index dc38f4fd3..4b57b7ebc 100644
--- a/src/main/java/org/stellar/sdk/Transaction.java
+++ b/src/main/java/org/stellar/sdk/Transaction.java
@@ -1,179 +1,223 @@
package org.stellar.sdk;
-import com.google.gson.annotations.SerializedName;
-
-import org.stellar.base.KeyPair;
-import org.stellar.base.Memo;
-
+import org.apache.commons.codec.binary.Base64;
+import org.stellar.sdk.xdr.DecoratedSignature;
+import org.stellar.sdk.xdr.EnvelopeType;
+import org.stellar.sdk.xdr.XdrDataOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Represents transaction response.
- * @see Transaction documentation
- * @see org.stellar.sdk.requests.TransactionsRequestBuilder
- * @see org.stellar.sdk.Server#transactions()
+ * Represents Transaction in Stellar network.
*/
public class Transaction {
- @SerializedName("hash")
- private final String hash;
- @SerializedName("ledger")
- private final Long ledger;
- @SerializedName("created_at")
- private final String createdAt;
- @SerializedName("source_account")
- private final KeyPair sourceAccount;
- @SerializedName("paging_token")
- private final String pagingToken;
- @SerializedName("source_account_sequence")
- private final Long sourceAccountSequence;
- @SerializedName("fee_paid")
- private final Long feePaid;
- @SerializedName("operation_count")
- private final Integer operationCount;
- @SerializedName("envelope_xdr")
- private final String envelopeXdr;
- @SerializedName("result_xdr")
- private final String resultXdr;
- @SerializedName("result_meta_xdr")
- private final String resultMetaXdr;
- @SerializedName("_links")
- private final Links links;
-
- // GSON won't serialize `transient` variables automatically. We need this behaviour
- // because Memo is an abstract class and GSON tries to instantiate it.
- private transient Memo memo;
-
- Transaction(String hash, Long ledger, String createdAt, KeyPair sourceAccount, String pagingToken, Long sourceAccountSequence, Long feePaid, Integer operationCount, String envelopeXdr, String resultXdr, String resultMetaXdr, Memo memo, Links links) {
- this.hash = hash;
- this.ledger = ledger;
- this.createdAt = createdAt;
- this.sourceAccount = sourceAccount;
- this.pagingToken = pagingToken;
- this.sourceAccountSequence = sourceAccountSequence;
- this.feePaid = feePaid;
- this.operationCount = operationCount;
- this.envelopeXdr = envelopeXdr;
- this.resultXdr = resultXdr;
- this.resultMetaXdr = resultMetaXdr;
- this.memo = memo;
- this.links = links;
- }
+ private final int BASE_FEE = 100;
- public String getHash() {
- return hash;
- }
+ private final int mFee;
+ private final KeyPair mSourceAccount;
+ private final long mSequenceNumber;
+ private final Operation[] mOperations;
+ private final Memo mMemo;
+ private List mSignatures;
- public Long getLedger() {
- return ledger;
- }
+ Transaction(KeyPair sourceAccount, long sequenceNumber, Operation[] operations, Memo memo) {
+ mSourceAccount = checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ mSequenceNumber = checkNotNull(sequenceNumber, "sequenceNumber cannot be null");
+ mOperations = checkNotNull(operations, "operations cannot be null");
+ checkArgument(operations.length > 0, "At least one operation required");
- public String getCreatedAt() {
- return createdAt;
+ mFee = operations.length * BASE_FEE;
+ mSignatures = new ArrayList();
+ mMemo = memo != null ? memo : Memo.none();
}
- public KeyPair getSourceAccount() {
- return sourceAccount;
- }
-
- public String getPagingToken() {
- return pagingToken;
- }
-
- public Long getSourceAccountSequence() {
- return sourceAccountSequence;
+ /**
+ * Adds a new signature to this transaction.
+ * @param signer {@link KeyPair} object representing a signer
+ */
+ public void sign(KeyPair signer) {
+ byte[] txHash = this.hash();
+ mSignatures.add(signer.signDecorated(txHash));
}
- public Long getFeePaid() {
- return feePaid;
+ /**
+ * Returns transaction hash.
+ */
+ public byte[] hash() {
+ return Util.hash(this.signatureBase());
}
- public Integer getOperationCount() {
- return operationCount;
+ /**
+ * Returns signature base.
+ */
+ public byte[] signatureBase() {
+ try {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ // Hashed NetworkID
+ outputStream.write(Network.current().getNetworkId());
+ // Envelope Type - 4 bytes
+ outputStream.write(ByteBuffer.allocate(4).putInt(EnvelopeType.ENVELOPE_TYPE_TX.getValue()).array());
+ // Transaction XDR bytes
+ ByteArrayOutputStream txOutputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrOutputStream = new XdrDataOutputStream(txOutputStream);
+ org.stellar.sdk.xdr.Transaction.encode(xdrOutputStream, this.toXdr());
+ outputStream.write(txOutputStream.toByteArray());
+
+ return outputStream.toByteArray();
+ } catch (IOException exception) {
+ return null;
+ }
}
- public String getEnvelopeXdr() {
- return envelopeXdr;
+ public KeyPair getSourceAccount() {
+ return mSourceAccount;
}
- public String getResultXdr() {
- return resultXdr;
+ public long getSequenceNumber() {
+ return mSequenceNumber;
}
- public String getResultMetaXdr() {
- return resultMetaXdr;
+ public Memo getMemo() {
+ return mMemo;
}
- public Memo getMemo() {
- return memo;
+ /**
+ * Returns fee paid for transaction in stroops (1 stroop = 0.0000001 XLM).
+ */
+ public int getFee() {
+ return mFee;
}
- void setMemo(Memo memo) {
- memo = checkNotNull(memo, "memo cannot be null");
- if (this.memo != null) {
- throw new RuntimeException("Memo has been already set.");
+ /**
+ * Generates Transaction XDR object.
+ */
+ public org.stellar.sdk.xdr.Transaction toXdr() {
+ // fee
+ org.stellar.sdk.xdr.Uint32 fee = new org.stellar.sdk.xdr.Uint32();
+ fee.setUint32(mFee);
+ // sequenceNumber
+ org.stellar.sdk.xdr.Uint64 sequenceNumberUint = new org.stellar.sdk.xdr.Uint64();
+ sequenceNumberUint.setUint64(mSequenceNumber);
+ org.stellar.sdk.xdr.SequenceNumber sequenceNumber = new org.stellar.sdk.xdr.SequenceNumber();
+ sequenceNumber.setSequenceNumber(sequenceNumberUint);
+ // sourceAccount
+ org.stellar.sdk.xdr.AccountID sourceAccount = new org.stellar.sdk.xdr.AccountID();
+ sourceAccount.setAccountID(mSourceAccount.getXdrPublicKey());
+ // operations
+ org.stellar.sdk.xdr.Operation[] operations = new org.stellar.sdk.xdr.Operation[mOperations.length];
+ for (int i = 0; i < mOperations.length; i++) {
+ operations[i] = mOperations[i].toXdr();
}
- this.memo = memo;
- }
+ // ext
+ org.stellar.sdk.xdr.Transaction.TransactionExt ext = new org.stellar.sdk.xdr.Transaction.TransactionExt();
+ ext.setDiscriminant(0);
- public Links getLinks() {
- return links;
+ org.stellar.sdk.xdr.Transaction transaction = new org.stellar.sdk.xdr.Transaction();
+ transaction.setFee(fee);
+ transaction.setSeqNum(sequenceNumber);
+ transaction.setSourceAccount(sourceAccount);
+ transaction.setOperations(operations);
+ transaction.setMemo(mMemo.toXdr());
+ transaction.setExt(ext);
+ return transaction;
}
/**
- * Links connected to transaction.
+ * Generates TransactionEnvelope XDR object. Transaction need to have at least one signature.
*/
- public static class Links {
- @SerializedName("account")
- private final Link account;
- @SerializedName("effects")
- private final Link effects;
- @SerializedName("ledger")
- private final Link ledger;
- @SerializedName("operations")
- private final Link operations;
- @SerializedName("precedes")
- private final Link precedes;
- @SerializedName("self")
- private final Link self;
- @SerializedName("succeeds")
- private final Link succeeds;
-
- Links(Link account, Link effects, Link ledger, Link operations, Link self, Link precedes, Link succeeds) {
- this.account = account;
- this.effects = effects;
- this.ledger = ledger;
- this.operations = operations;
- this.self = self;
- this.precedes = precedes;
- this.succeeds = succeeds;
+ public org.stellar.sdk.xdr.TransactionEnvelope toEnvelopeXdr() {
+ if (mSignatures.size() == 0) {
+ throw new NotEnoughSignaturesException("Transaction must be signed by at least one signer. Use transaction.sign().");
}
- public Link getAccount() {
- return account;
- }
+ org.stellar.sdk.xdr.TransactionEnvelope xdr = new org.stellar.sdk.xdr.TransactionEnvelope();
+ org.stellar.sdk.xdr.Transaction transaction = this.toXdr();
+ xdr.setTx(transaction);
- public Link getEffects() {
- return effects;
- }
+ DecoratedSignature[] signatures = new DecoratedSignature[mSignatures.size()];
+ signatures = mSignatures.toArray(signatures);
+ xdr.setSignatures(signatures);
+ return xdr;
+ }
- public Link getLedger() {
- return ledger;
+ /**
+ * Returns base64-encoded TransactionEnvelope XDR object. Transaction need to have at least one signature.
+ */
+ public String toEnvelopeXdrBase64() {
+ try {
+ org.stellar.sdk.xdr.TransactionEnvelope envelope = this.toEnvelopeXdr();
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ XdrDataOutputStream xdrOutputStream = new XdrDataOutputStream(outputStream);
+ org.stellar.sdk.xdr.TransactionEnvelope.encode(xdrOutputStream, envelope);
+ Base64 base64Codec = new Base64();
+ return base64Codec.encodeAsString(outputStream.toByteArray());
+ } catch (IOException e) {
+ throw new AssertionError(e);
}
+ }
- public Link getOperations() {
- return operations;
+ /**
+ * Builds a new Transaction object.
+ */
+ public static class Builder {
+ private final TransactionBuilderAccount mSourceAccount;
+ private Memo mMemo;
+ List mOperations;
+
+ /**
+ * Construct a new transaction builder.
+ * @param sourceAccount The source account for this transaction. This account is the account
+ * who will use a sequence number. When build() is called, the account object's sequence number
+ * will be incremented.
+ */
+ public Builder(TransactionBuilderAccount sourceAccount) {
+ checkNotNull(sourceAccount, "sourceAccount cannot be null");
+ mSourceAccount = sourceAccount;
+ mOperations = new ArrayList();
}
- public Link getPrecedes() {
- return precedes;
+ /**
+ * Adds a new operation to this transaction.
+ * @param operation
+ * @return Builder object so you can chain methods.
+ * @see Operation
+ */
+ public Builder addOperation(Operation operation) {
+ checkNotNull(operation, "operation cannot be null");
+ mOperations.add(operation);
+ return this;
}
- public Link getSelf() {
- return self;
+ /**
+ * Adds a memo to this transaction.
+ * @param memo
+ * @return Builder object so you can chain methods.
+ * @see Memo
+ */
+ public Builder addMemo(Memo memo) {
+ if (mMemo != null) {
+ throw new RuntimeException("Memo has been already added.");
+ }
+ checkNotNull(memo, "memo cannot be null");
+ mMemo = memo;
+ return this;
}
- public Link getSucceeds() {
- return succeeds;
+ /**
+ * Builds a transaction.
+ */
+ public Transaction build() {
+ Operation[] operations = new Operation[mOperations.size()];
+ operations = mOperations.toArray(operations);
+ mSourceAccount.incrementSequenceNumber();
+ return new Transaction(mSourceAccount.getKeypair(), mSourceAccount.getSequenceNumber(), operations, mMemo);
}
}
}
diff --git a/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java b/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java
new file mode 100644
index 000000000..af7aa4c33
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/TransactionBuilderAccount.java
@@ -0,0 +1,21 @@
+package org.stellar.sdk;
+
+/**
+ * Specifies interface for Account object used in {@link org.stellar.sdk.Transaction.Builder}
+ */
+public interface TransactionBuilderAccount {
+ /**
+ * Returns keypair associated with this Account
+ */
+ KeyPair getKeypair();
+
+ /**
+ * Returns current sequence number ot this Account.
+ */
+ Long getSequenceNumber();
+
+ /**
+ * Increments sequence number in this object by one.
+ */
+ void incrementSequenceNumber();
+}
diff --git a/src/main/java/org/stellar/sdk/Util.java b/src/main/java/org/stellar/sdk/Util.java
new file mode 100644
index 000000000..44875a27a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/Util.java
@@ -0,0 +1,73 @@
+package org.stellar.sdk;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+
+class Util {
+
+ public static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+
+ public static String bytesToHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for ( int j = 0; j < bytes.length; j++ ) {
+ int v = bytes[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return new String(hexChars);
+ }
+
+ public static byte[] hexToBytes(String s) {
+ int len = s.length();
+ byte[] data = new byte[len / 2];
+ for (int i = 0; i < len; i += 2) {
+ data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ + Character.digit(s.charAt(i+1), 16));
+ }
+ return data;
+ }
+
+ /**
+ * Returns SHA-256 hash of data
.
+ * @param data
+ */
+ public static byte[] hash(byte[] data) {
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+ md.update(data);
+ return md.digest();
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("SHA-256 not implemented");
+ }
+ }
+
+ /**
+ * Pads bytes
array to length
with zeros.
+ * @param bytes
+ * @param length
+ */
+ static byte[] paddedByteArray(byte[] bytes, int length) {
+ byte[] finalBytes = new byte[length];
+ Arrays.fill(finalBytes, (byte) 0);
+ System.arraycopy(bytes, 0, finalBytes, 0, bytes.length);
+ return finalBytes;
+ }
+
+ /**
+ * Pads string
to length
with zeros.
+ * @param string
+ * @param length
+ */
+ static byte[] paddedByteArray(String string, int length) {
+ return Util.paddedByteArray(string.getBytes(), length);
+ }
+
+ /**
+ * Remove zeros from the end of bytes
array.
+ * @param bytes
+ */
+ static String paddedByteArrayToString(byte[] bytes) {
+ return new String(bytes).split("\0")[0];
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/effects/SignerRemovedEffect.java b/src/main/java/org/stellar/sdk/effects/SignerRemovedEffect.java
deleted file mode 100644
index 6a757aef0..000000000
--- a/src/main/java/org/stellar/sdk/effects/SignerRemovedEffect.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.stellar.sdk.effects;
-
-/**
- * Represents signer_removed effect response.
- */
-public class SignerRemovedEffect extends SignerEffect {
- SignerRemovedEffect(Integer weight, String publicKey) {
- super(weight, publicKey);
- }
-}
diff --git a/src/main/java/org/stellar/sdk/federation/FederationResponse.java b/src/main/java/org/stellar/sdk/federation/FederationResponse.java
index e682dbdb6..448671904 100644
--- a/src/main/java/org/stellar/sdk/federation/FederationResponse.java
+++ b/src/main/java/org/stellar/sdk/federation/FederationResponse.java
@@ -16,7 +16,7 @@ public class FederationResponse {
@SerializedName("memo")
private final String memo;
- public FederationResponse(String stellarAddress, String accountId, String memoType, String memo) {
+ FederationResponse(String stellarAddress, String accountId, String memoType, String memo) {
this.stellarAddress = stellarAddress;
this.accountId = accountId;
this.memoType = memoType;
diff --git a/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java
index 1fcd0ff34..d7b44bc3d 100644
--- a/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/AccountsRequestBuilder.java
@@ -6,10 +6,10 @@
import org.glassfish.jersey.media.sse.EventSource;
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.Account;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Page;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.AccountResponse;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.Page;
import java.io.IOException;
import java.net.URI;
@@ -27,14 +27,14 @@ public AccountsRequestBuilder(URI serverURI) {
}
/**
- * Requests specific uri
and returns {@link Account}.
+ * Requests specific uri
and returns {@link AccountResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
- public Account account(URI uri) throws IOException {
- TypeToken type = new TypeToken() {};
- ResponseHandler responseHandler = new ResponseHandler(type);
- return (Account) Request.Get(uri).execute().handleResponse(responseHandler);
+ public AccountResponse account(URI uri) throws IOException {
+ TypeToken type = new TypeToken() {};
+ ResponseHandler responseHandler = new ResponseHandler(type);
+ return (AccountResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -43,21 +43,21 @@ public Account account(URI uri) throws IOException {
* @param account Account to fetch
* @throws IOException
*/
- public Account account(KeyPair account) throws IOException {
- this.setSegments("accounts", account.getAddress());
+ public AccountResponse account(KeyPair account) throws IOException {
+ this.setSegments("accounts", account.getAccountId());
return this.account(this.buildUri());
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Account}.
+ * Requests specific uri
and returns {@link Page} of {@link AccountResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Account}
+ * @return {@link Page} of {@link AccountResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -67,10 +67,10 @@ public static Page execute(URI uri) throws IOException {
* responses as ledgers close.
* @see Server-Sent Events
* @see Response Format documentation
- * @param listener {@link EventListener} implementation with {@link Account} type
+ * @param listener {@link EventListener} implementation with {@link AccountResponse} type
* @return EventSource object, so you can close()
connection when not needed anymore
*/
- public EventSource stream(final EventListener listener) {
+ public EventSource stream(final EventListener listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
@@ -80,7 +80,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
- Account account = GsonSingleton.getInstance().fromJson(data, Account.class);
+ AccountResponse account = GsonSingleton.getInstance().fromJson(data, AccountResponse.class);
listener.onEvent(account);
}
};
@@ -88,11 +88,11 @@ public void onEvent(InboundEvent inboundEvent) {
}
/**
- * Build and execute request. Warning! {@link Account}s in {@link Page} will contain only keypair
field.
- * @return {@link Page} of {@link Account}
+ * Build and execute request. Warning! {@link AccountResponse}s in {@link Page} will contain only keypair
field.
+ * @return {@link Page} of {@link AccountResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java
index 3a0620377..0f23e8fa4 100644
--- a/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/EffectsRequestBuilder.java
@@ -6,10 +6,10 @@
import org.glassfish.jersey.media.sse.EventSource;
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Page;
-import org.stellar.sdk.effects.Effect;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.Page;
+import org.stellar.sdk.responses.effects.EffectResponse;
import java.io.IOException;
import java.net.URI;
@@ -35,7 +35,7 @@ public EffectsRequestBuilder(URI serverURI) {
*/
public EffectsRequestBuilder forAccount(KeyPair account) {
account = checkNotNull(account, "account cannot be null");
- this.setSegments("accounts", account.getAddress(), "effects");
+ this.setSegments("accounts", account.getAccountId(), "effects");
return this;
}
@@ -71,15 +71,15 @@ public EffectsRequestBuilder forOperation(long operationId) {
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Effect}.
+ * Requests specific uri
and returns {@link Page} of {@link EffectResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Effect}
+ * @return {@link Page} of {@link EffectResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -89,10 +89,10 @@ public static Page execute(URI uri) throws IOException {
* responses as ledgers close.
* @see Server-Sent Events
* @see Response Format documentation
- * @param listener {@link EventListener} implementation with {@link Effect} type
+ * @param listener {@link EventListener} implementation with {@link EffectResponse} type
* @return EventSource object, so you can close()
connection when not needed anymore
*/
- public EventSource stream(final EventListener listener) {
+ public EventSource stream(final EventListener listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
@@ -102,7 +102,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
- Effect effect = GsonSingleton.getInstance().fromJson(data, Effect.class);
+ EffectResponse effect = GsonSingleton.getInstance().fromJson(data, EffectResponse.class);
listener.onEvent(effect);
}
};
@@ -111,10 +111,10 @@ public void onEvent(InboundEvent inboundEvent) {
/**
* Build and execute request.
- * @return {@link Page} of {@link Effect}
+ * @return {@link Page} of {@link EffectResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/requests/LedgersRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/LedgersRequestBuilder.java
index 8b27632df..7c2e09e10 100644
--- a/src/main/java/org/stellar/sdk/requests/LedgersRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/LedgersRequestBuilder.java
@@ -6,9 +6,9 @@
import org.glassfish.jersey.media.sse.EventSource;
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Ledger;
-import org.stellar.sdk.Page;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.LedgerResponse;
+import org.stellar.sdk.responses.Page;
import java.io.IOException;
import java.net.URI;
@@ -26,14 +26,14 @@ public LedgersRequestBuilder(URI serverURI) {
}
/**
- * Requests specific uri
and returns {@link Ledger}.
+ * Requests specific uri
and returns {@link LedgerResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
- public Ledger ledger(URI uri) throws IOException {
- TypeToken type = new TypeToken() {};
- ResponseHandler responseHandler = new ResponseHandler(type);
- return (Ledger) Request.Get(uri).execute().handleResponse(responseHandler);
+ public LedgerResponse ledger(URI uri) throws IOException {
+ TypeToken type = new TypeToken() {};
+ ResponseHandler responseHandler = new ResponseHandler(type);
+ return (LedgerResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -42,21 +42,21 @@ public Ledger ledger(URI uri) throws IOException {
* @param ledgerSeq Ledger to fetch
* @throws IOException
*/
- public Ledger ledger(long ledgerSeq) throws IOException {
+ public LedgerResponse ledger(long ledgerSeq) throws IOException {
this.setSegments("ledgers", String.valueOf(ledgerSeq));
return this.ledger(this.buildUri());
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Ledger}.
+ * Requests specific uri
and returns {@link Page} of {@link LedgerResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Ledger}
+ * @return {@link Page} of {@link LedgerResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -66,10 +66,10 @@ public static Page execute(URI uri) throws IOException {
* responses as ledgers close.
* @see Server-Sent Events
* @see Response Format documentation
- * @param listener {@link EventListener} implementation with {@link Ledger} type
+ * @param listener {@link EventListener} implementation with {@link LedgerResponse} type
* @return EventSource object, so you can close()
connection when not needed anymore
*/
- public EventSource stream(final EventListener listener) {
+ public EventSource stream(final EventListener listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
@@ -79,7 +79,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
- Ledger ledger = GsonSingleton.getInstance().fromJson(data, Ledger.class);
+ LedgerResponse ledger = GsonSingleton.getInstance().fromJson(data, LedgerResponse.class);
listener.onEvent(ledger);
}
};
@@ -88,10 +88,10 @@ public void onEvent(InboundEvent inboundEvent) {
/**
* Build and execute request.
- * @return {@link Page} of {@link Ledger}
+ * @return {@link Page} of {@link LedgerResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java
index d8ddd1e56..4493dd332 100644
--- a/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/OperationsRequestBuilder.java
@@ -3,9 +3,9 @@
import com.google.gson.reflect.TypeToken;
import org.apache.http.client.fluent.Request;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.Page;
-import org.stellar.sdk.operations.Operation;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.Page;
+import org.stellar.sdk.responses.operations.OperationResponse;
import java.io.IOException;
import java.net.URI;
@@ -21,14 +21,14 @@ public OperationsRequestBuilder(URI serverURI) {
}
/**
- * Requests specific uri
and returns {@link Operation}.
+ * Requests specific uri
and returns {@link OperationResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
- public Operation operation(URI uri) throws IOException {
- TypeToken type = new TypeToken() {};
- ResponseHandler responseHandler = new ResponseHandler(type);
- return (Operation) Request.Get(uri).execute().handleResponse(responseHandler);
+ public OperationResponse operation(URI uri) throws IOException {
+ TypeToken type = new TypeToken() {};
+ ResponseHandler responseHandler = new ResponseHandler(type);
+ return (OperationResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -37,7 +37,7 @@ public Operation operation(URI uri) throws IOException {
* @param operationId Operation to fetch
* @throws IOException
*/
- public Operation operation(long operationId) throws IOException {
+ public OperationResponse operation(long operationId) throws IOException {
this.setSegments("operation", String.valueOf(operationId));
return this.operation(this.buildUri());
}
@@ -49,7 +49,7 @@ public Operation operation(long operationId) throws IOException {
*/
public OperationsRequestBuilder forAccount(KeyPair account) {
account = checkNotNull(account, "account cannot be null");
- this.setSegments("accounts", account.getAddress(), "operations");
+ this.setSegments("accounts", account.getAccountId(), "operations");
return this;
}
@@ -75,23 +75,23 @@ public OperationsRequestBuilder forTransaction(String transactionId) {
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Operation}.
+ * Requests specific uri
and returns {@link Page} of {@link OperationResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Operation}
+ * @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
* Build and execute request.
- * @return {@link Page} of {@link Operation}
+ * @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java
index d64756f0c..49f0c944f 100644
--- a/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/OrderBookRequestBuilder.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.requests;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeCreditAlphaNum;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeCreditAlphaNum;
import java.net.URI;
@@ -18,7 +18,7 @@ public OrderBookRequestBuilder buyingAsset(Asset asset) {
if (asset instanceof AssetTypeCreditAlphaNum) {
AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset;
uriBuilder.addParameter("buying_asset_code", creditAlphaNumAsset.getCode());
- uriBuilder.addParameter("buying_asset_issuer", creditAlphaNumAsset.getIssuer().getAddress());
+ uriBuilder.addParameter("buying_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId());
}
return this;
}
@@ -28,7 +28,7 @@ public OrderBookRequestBuilder sellingAsset(Asset asset) {
if (asset instanceof AssetTypeCreditAlphaNum) {
AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset;
uriBuilder.addParameter("selling_asset_code", creditAlphaNumAsset.getCode());
- uriBuilder.addParameter("selling_asset_issuer", creditAlphaNumAsset.getIssuer().getAddress());
+ uriBuilder.addParameter("selling_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId());
}
return this;
}
diff --git a/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java
index 1eb52e670..6421115a3 100644
--- a/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/PathsRequestBuilder.java
@@ -3,11 +3,11 @@
import com.google.gson.reflect.TypeToken;
import org.apache.http.client.fluent.Request;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeCreditAlphaNum;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.Page;
-import org.stellar.sdk.Path;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeCreditAlphaNum;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.Page;
+import org.stellar.sdk.responses.PathResponse;
import java.io.IOException;
import java.net.URI;
@@ -21,12 +21,12 @@ public PathsRequestBuilder(URI serverURI) {
}
public PathsRequestBuilder destinationAccount(KeyPair account) {
- uriBuilder.addParameter("destination_account", account.getAddress());
+ uriBuilder.addParameter("destination_account", account.getAccountId());
return this;
}
public PathsRequestBuilder sourceAccount(KeyPair account) {
- uriBuilder.addParameter("source_account", account.getAddress());
+ uriBuilder.addParameter("source_account", account.getAccountId());
return this;
}
@@ -40,18 +40,18 @@ public PathsRequestBuilder destinationAsset(Asset asset) {
if (asset instanceof AssetTypeCreditAlphaNum) {
AssetTypeCreditAlphaNum creditAlphaNumAsset = (AssetTypeCreditAlphaNum) asset;
uriBuilder.addParameter("destination_asset_code", creditAlphaNumAsset.getCode());
- uriBuilder.addParameter("destination_asset_issuer", creditAlphaNumAsset.getIssuer().getAddress());
+ uriBuilder.addParameter("destination_asset_issuer", creditAlphaNumAsset.getIssuer().getAccountId());
}
return this;
}
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
}
diff --git a/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java
index 9137d922d..a2a053811 100644
--- a/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/PaymentsRequestBuilder.java
@@ -6,10 +6,10 @@
import org.glassfish.jersey.media.sse.EventSource;
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Page;
-import org.stellar.sdk.operations.Operation;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.Page;
+import org.stellar.sdk.responses.operations.OperationResponse;
import java.io.IOException;
import java.net.URI;
@@ -35,7 +35,7 @@ public PaymentsRequestBuilder(URI serverURI) {
*/
public PaymentsRequestBuilder forAccount(KeyPair account) {
account = checkNotNull(account, "account cannot be null");
- this.setSegments("accounts", account.getAddress(), "payments");
+ this.setSegments("accounts", account.getAccountId(), "payments");
return this;
}
@@ -61,15 +61,15 @@ public PaymentsRequestBuilder forTransaction(String transactionId) {
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Operation}.
+ * Requests specific uri
and returns {@link Page} of {@link OperationResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Operation}
+ * @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -79,10 +79,10 @@ public static Page execute(URI uri) throws IOException {
* responses as ledgers close.
* @see Server-Sent Events
* @see Response Format documentation
- * @param listener {@link EventListener} implementation with {@link Operation} type
+ * @param listener {@link EventListener} implementation with {@link OperationResponse} type
* @return EventSource object, so you can close()
connection when not needed anymore
*/
- public EventSource stream(final EventListener listener) {
+ public EventSource stream(final EventListener listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
@@ -92,7 +92,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
- Operation payment = GsonSingleton.getInstance().fromJson(data, Operation.class);
+ OperationResponse payment = GsonSingleton.getInstance().fromJson(data, OperationResponse.class);
listener.onEvent(payment);
}
};
@@ -101,10 +101,10 @@ public void onEvent(InboundEvent inboundEvent) {
/**
* Build and execute request.
- * @return {@link Page} of {@link Operation}
+ * @return {@link Page} of {@link OperationResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/requests/RequestBuilder.java b/src/main/java/org/stellar/sdk/requests/RequestBuilder.java
index df9351426..f270e99b5 100644
--- a/src/main/java/org/stellar/sdk/requests/RequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/RequestBuilder.java
@@ -1,20 +1,11 @@
package org.stellar.sdk.requests;
import org.apache.http.client.utils.URIBuilder;
-import org.glassfish.jersey.media.sse.EventSource;
-import org.glassfish.jersey.media.sse.InboundEvent;
-import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Ledger;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-
/**
* Abstract class for request builders.
*/
diff --git a/src/main/java/org/stellar/sdk/requests/ResponseHandler.java b/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
index 673e5d468..a5c40db28 100644
--- a/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
+++ b/src/main/java/org/stellar/sdk/requests/ResponseHandler.java
@@ -8,7 +8,7 @@
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
-import org.stellar.sdk.GsonSingleton;
+import org.stellar.sdk.responses.GsonSingleton;
import java.io.IOException;
import java.io.StringWriter;
diff --git a/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java b/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java
index 18d3a226a..4f43d37eb 100644
--- a/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java
+++ b/src/main/java/org/stellar/sdk/requests/TransactionsRequestBuilder.java
@@ -6,10 +6,10 @@
import org.glassfish.jersey.media.sse.EventSource;
import org.glassfish.jersey.media.sse.InboundEvent;
import org.glassfish.jersey.media.sse.SseFeature;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.GsonSingleton;
-import org.stellar.sdk.Page;
-import org.stellar.sdk.Transaction;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.GsonSingleton;
+import org.stellar.sdk.responses.Page;
+import org.stellar.sdk.responses.TransactionResponse;
import java.io.IOException;
import java.net.URI;
@@ -29,14 +29,14 @@ public TransactionsRequestBuilder(URI serverURI) {
}
/**
- * Requests specific uri
and returns {@link Transaction}.
+ * Requests specific uri
and returns {@link TransactionResponse}.
* This method is helpful for getting the links.
* @throws IOException
*/
- public Transaction transaction(URI uri) throws IOException {
- TypeToken type = new TypeToken() {};
- ResponseHandler responseHandler = new ResponseHandler(type);
- return (Transaction) Request.Get(uri).execute().handleResponse(responseHandler);
+ public TransactionResponse transaction(URI uri) throws IOException {
+ TypeToken type = new TypeToken() {};
+ ResponseHandler responseHandler = new ResponseHandler(type);
+ return (TransactionResponse) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -45,7 +45,7 @@ public Transaction transaction(URI uri) throws IOException {
* @param transactionId Transaction to fetch
* @throws IOException
*/
- public Transaction transaction(String transactionId) throws IOException {
+ public TransactionResponse transaction(String transactionId) throws IOException {
this.setSegments("transaction", transactionId);
return this.transaction(this.buildUri());
}
@@ -57,7 +57,7 @@ public Transaction transaction(String transactionId) throws IOException {
*/
public TransactionsRequestBuilder forAccount(KeyPair account) {
account = checkNotNull(account, "account cannot be null");
- this.setSegments("accounts", account.getAddress(), "transactions");
+ this.setSegments("accounts", account.getAccountId(), "transactions");
return this;
}
@@ -72,15 +72,15 @@ public TransactionsRequestBuilder forLedger(long ledgerSeq) {
}
/**
- * Requests specific uri
and returns {@link Page} of {@link Transaction}.
+ * Requests specific uri
and returns {@link Page} of {@link TransactionResponse}.
* This method is helpful for getting the next set of results.
- * @return {@link Page} of {@link Transaction}
+ * @return {@link Page} of {@link TransactionResponse}
* @throws IOException
*/
- public static Page execute(URI uri) throws IOException {
- TypeToken type = new TypeToken>() {};
- ResponseHandler> responseHandler = new ResponseHandler>(type);
- return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
+ public static Page execute(URI uri) throws IOException {
+ TypeToken type = new TypeToken>() {};
+ ResponseHandler> responseHandler = new ResponseHandler>(type);
+ return (Page) Request.Get(uri).execute().handleResponse(responseHandler);
}
/**
@@ -90,10 +90,10 @@ public static Page execute(URI uri) throws IOException {
* responses as ledgers close.
* @see Server-Sent Events
* @see Response Format documentation
- * @param listener {@link EventListener} implementation with {@link Transaction} type
+ * @param listener {@link EventListener} implementation with {@link TransactionResponse} type
* @return EventSource object, so you can close()
connection when not needed anymore
*/
- public EventSource stream(final EventListener listener) {
+ public EventSource stream(final EventListener listener) {
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target(this.buildUri());
EventSource eventSource = new EventSource(target) {
@@ -103,7 +103,7 @@ public void onEvent(InboundEvent inboundEvent) {
if (data.equals("\"hello\"")) {
return;
}
- Transaction transaction = GsonSingleton.getInstance().fromJson(data, Transaction.class);
+ TransactionResponse transaction = GsonSingleton.getInstance().fromJson(data, TransactionResponse.class);
listener.onEvent(transaction);
}
};
@@ -112,10 +112,10 @@ public void onEvent(InboundEvent inboundEvent) {
/**
* Build and execute request.
- * @return {@link Page} of {@link Transaction}
+ * @return {@link Page} of {@link TransactionResponse}
* @throws IOException
*/
- public Page execute() throws IOException {
+ public Page execute() throws IOException {
return this.execute(this.buildUri());
}
diff --git a/src/main/java/org/stellar/sdk/responses/AccountResponse.java b/src/main/java/org/stellar/sdk/responses/AccountResponse.java
new file mode 100644
index 000000000..403b4852b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/AccountResponse.java
@@ -0,0 +1,262 @@
+package org.stellar.sdk.responses;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.stellar.sdk.KeyPair;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents account response.
+ * @see Account documentation
+ * @see org.stellar.sdk.requests.AccountsRequestBuilder
+ * @see org.stellar.sdk.Server#accounts()
+ */
+public class AccountResponse implements org.stellar.sdk.TransactionBuilderAccount {
+ @SerializedName("account_id") /* KeyPairTypeAdapter used */
+ private KeyPair keypair;
+ @SerializedName("sequence")
+ private Long sequenceNumber;
+ @SerializedName("paging_token")
+ private String pagingToken;
+ @SerializedName("subentry_count")
+ private Integer subentryCount;
+ @SerializedName("inflation_destination")
+ private String inflationDestination;
+ @SerializedName("home_domain")
+ private String homeDomain;
+ @SerializedName("thresholds")
+ private Thresholds thresholds;
+ @SerializedName("flags")
+ private Flags flags;
+ @SerializedName("balances")
+ private Balance[] balances;
+ @SerializedName("signers")
+ private Signer[] signers;
+ @SerializedName("_links")
+ private Links links;
+
+ AccountResponse(KeyPair keypair) {
+ this.keypair = keypair;
+ }
+
+ public AccountResponse(KeyPair keypair, Long sequenceNumber) {
+ this.keypair = keypair;
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ @Override
+ public KeyPair getKeypair() {
+ return keypair;
+ }
+
+ @Override
+ public Long getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ @Override
+ public void incrementSequenceNumber() {
+ sequenceNumber++;
+ }
+
+ public String getPagingToken() {
+ return pagingToken;
+ }
+
+ public Integer getSubentryCount() {
+ return subentryCount;
+ }
+
+ public String getInflationDestination() {
+ return inflationDestination;
+ }
+
+ public String getHomeDomain() {
+ return homeDomain;
+ }
+
+ public Thresholds getThresholds() {
+ return thresholds;
+ }
+
+ public Flags getFlags() {
+ return flags;
+ }
+
+ public Balance[] getBalances() {
+ return balances;
+ }
+
+ public Signer[] getSigners() {
+ return signers;
+ }
+
+ /**
+ * Represents account thresholds.
+ */
+ public static class Thresholds {
+ @SerializedName("low_threshold")
+ private final int lowThreshold;
+ @SerializedName("med_threshold")
+ private final int medThreshold;
+ @SerializedName("high_threshold")
+ private final int highThreshold;
+
+ Thresholds(int lowThreshold, int medThreshold, int highThreshold) {
+ this.lowThreshold = lowThreshold;
+ this.medThreshold = medThreshold;
+ this.highThreshold = highThreshold;
+ }
+
+ public int getLowThreshold() {
+ return lowThreshold;
+ }
+
+ public int getMedThreshold() {
+ return medThreshold;
+ }
+
+ public int getHighThreshold() {
+ return highThreshold;
+ }
+ }
+
+ /**
+ * Represents account flags.
+ */
+ public static class Flags {
+ @SerializedName("auth_required")
+ private final boolean authRequired;
+ @SerializedName("auth_revocable")
+ private final boolean authRevocable;
+
+ Flags(boolean authRequired, boolean authRevocable) {
+ this.authRequired = authRequired;
+ this.authRevocable = authRevocable;
+ }
+
+ public boolean getAuthRequired() {
+ return authRequired;
+ }
+
+ public boolean getAuthRevocable() {
+ return authRevocable;
+ }
+ }
+
+ /**
+ * Represents account balance.
+ */
+ public static class Balance {
+ @SerializedName("asset_type")
+ private final String assetType;
+ @SerializedName("asset_code")
+ private final String assetCode;
+ @SerializedName("asset_issuer")
+ private final String assetIssuer;
+ @SerializedName("limit")
+ private final String limit;
+ @SerializedName("balance")
+ private final String balance;
+
+ Balance(String assetType, String assetCode, String assetIssuer, String balance, String limit) {
+ this.assetType = checkNotNull(assetType, "assertType cannot be null");
+ this.balance = checkNotNull(balance, "balance cannot be null");
+ this.limit = limit;
+ this.assetCode = assetCode;
+ this.assetIssuer = assetIssuer;
+ }
+
+ public String getAssetType() {
+ return assetType;
+ }
+
+ public String getAssetCode() {
+ return assetCode;
+ }
+
+ public String getAssetIssuer() {
+ return assetIssuer;
+ }
+
+ public String getBalance() {
+ return balance;
+ }
+
+ public String getLimit() {
+ return limit;
+ }
+ }
+
+ /**
+ * Represents account signers.
+ */
+ public static class Signer {
+ @SerializedName("public_key")
+ private final String accountId;
+ @SerializedName("weight")
+ private final int weight;
+
+ Signer(String accountId, int weight) {
+ this.accountId = checkNotNull(accountId, "accountId cannot be null");
+ this.weight = checkNotNull(weight, "weight cannot be null");
+ }
+
+ public String getAccountId() {
+ return accountId;
+ }
+
+ public int getWeight() {
+ return weight;
+ }
+ }
+
+ public Links getLinks() {
+ return links;
+ }
+
+ /**
+ * Links connected to account.
+ */
+ public static class Links {
+ @SerializedName("effects")
+ private final Link effects;
+ @SerializedName("offers")
+ private final Link offers;
+ @SerializedName("operations")
+ private final Link operations;
+ @SerializedName("self")
+ private final Link self;
+ @SerializedName("transactions")
+ private final Link transactions;
+
+ Links(Link effects, Link offers, Link operations, Link self, Link transactions) {
+ this.effects = effects;
+ this.offers = offers;
+ this.operations = operations;
+ this.self = self;
+ this.transactions = transactions;
+ }
+
+ public Link getEffects() {
+ return effects;
+ }
+
+ public Link getOffers() {
+ return offers;
+ }
+
+ public Link getOperations() {
+ return operations;
+ }
+
+ public Link getSelf() {
+ return self;
+ }
+
+ public Link getTransactions() {
+ return transactions;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/AssetDeserializer.java b/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/AssetDeserializer.java
rename to src/main/java/org/stellar/sdk/responses/AssetDeserializer.java
index 712ce4180..c8c0d1883 100644
--- a/src/main/java/org/stellar/sdk/AssetDeserializer.java
+++ b/src/main/java/org/stellar/sdk/responses/AssetDeserializer.java
@@ -1,13 +1,13 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
import java.lang.reflect.Type;
@@ -20,7 +20,7 @@ public Asset deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
} else {
String code = json.getAsJsonObject().get("asset_code").getAsString();
String issuer = json.getAsJsonObject().get("asset_issuer").getAsString();
- return Asset.createNonNativeAsset(code, KeyPair.fromAddress(issuer));
+ return Asset.createNonNativeAsset(code, KeyPair.fromAccountId(issuer));
}
}
}
diff --git a/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java
new file mode 100644
index 000000000..aa8c72933
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/EffectDeserializer.java
@@ -0,0 +1,71 @@
+package org.stellar.sdk.responses;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.effects.*;
+
+import java.lang.reflect.Type;
+
+class EffectDeserializer implements JsonDeserializer {
+ @Override
+ public EffectResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ // Create new Gson object with adapters needed in Operation
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
+ .create();
+
+ int type = json.getAsJsonObject().get("type_i").getAsInt();
+ switch (type) {
+ // Account effects
+ case 0:
+ return gson.fromJson(json, AccountCreatedEffectResponse.class);
+ case 1:
+ return gson.fromJson(json, AccountRemovedEffectResponse.class);
+ case 2:
+ return gson.fromJson(json, AccountCreditedEffectResponse.class);
+ case 3:
+ return gson.fromJson(json, AccountDebitedEffectResponse.class);
+ case 4:
+ return gson.fromJson(json, AccountThresholdsUpdatedEffectResponse.class);
+ case 5:
+ return gson.fromJson(json, AccountHomeDomainUpdatedEffectResponse.class);
+ case 6:
+ return gson.fromJson(json, AccountFlagsUpdatedEffectResponse.class);
+ // Signer effects
+ case 10:
+ return gson.fromJson(json, SignerCreatedEffectResponse.class);
+ case 11:
+ return gson.fromJson(json, SignerRemovedEffectResponse.class);
+ case 12:
+ return gson.fromJson(json, SignerUpdatedEffectResponse.class);
+ // Trustline effects
+ case 20:
+ return gson.fromJson(json, TrustlineCreatedEffectResponse.class);
+ case 21:
+ return gson.fromJson(json, TrustlineRemovedEffectResponse.class);
+ case 22:
+ return gson.fromJson(json, TrustlineUpdatedEffectResponse.class);
+ case 23:
+ return gson.fromJson(json, TrustlineAuthorizedEffectResponse.class);
+ case 24:
+ return gson.fromJson(json, TrustlineDeauthorizedEffectResponse.class);
+ // Trading effects
+ case 30:
+ return gson.fromJson(json, OfferCreatedEffectResponse.class);
+ case 31:
+ return gson.fromJson(json, OfferRemovedEffectResponse.class);
+ case 32:
+ return gson.fromJson(json, OfferUpdatedEffectResponse.class);
+ case 33:
+ return gson.fromJson(json, TradeEffectResponse.class);
+ default:
+ throw new RuntimeException("Invalid operation type");
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/responses/GsonSingleton.java b/src/main/java/org/stellar/sdk/responses/GsonSingleton.java
new file mode 100644
index 000000000..6f3c0a3e8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/GsonSingleton.java
@@ -0,0 +1,43 @@
+package org.stellar.sdk.responses;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.effects.EffectResponse;
+import org.stellar.sdk.responses.operations.OperationResponse;
+
+public class GsonSingleton {
+ private static Gson instance = null;
+
+ protected GsonSingleton() {}
+
+ public static Gson getInstance() {
+ if (instance == null) {
+ TypeToken accountPageType = new TypeToken>() {};
+ TypeToken effectPageType = new TypeToken>() {};
+ TypeToken ledgerPageType = new TypeToken>() {};
+ TypeToken operationPageType = new TypeToken>() {};
+ TypeToken pathPageType = new TypeToken>() {};
+ TypeToken transactionPageType = new TypeToken>() {};
+
+ instance = new GsonBuilder()
+ .registerTypeAdapter(Asset.class, new AssetDeserializer())
+ .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
+ .registerTypeAdapter(OperationResponse.class, new OperationDeserializer())
+ .registerTypeAdapter(EffectResponse.class, new EffectDeserializer())
+ .registerTypeAdapter(TransactionResponse.class, new TransactionDeserializer())
+ .registerTypeAdapter(accountPageType.getType(), new PageDeserializer(accountPageType))
+ .registerTypeAdapter(effectPageType.getType(), new PageDeserializer(effectPageType))
+ .registerTypeAdapter(ledgerPageType.getType(), new PageDeserializer(ledgerPageType))
+ .registerTypeAdapter(operationPageType.getType(), new PageDeserializer(operationPageType))
+ .registerTypeAdapter(pathPageType.getType(), new PageDeserializer(pathPageType))
+ .registerTypeAdapter(transactionPageType.getType(), new PageDeserializer(transactionPageType))
+ .create();
+ }
+ return instance;
+ }
+
+}
diff --git a/src/main/java/org/stellar/sdk/KeypairTypeAdapter.java b/src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/KeypairTypeAdapter.java
rename to src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java
index e2fdcd657..4d25162a9 100644
--- a/src/main/java/org/stellar/sdk/KeypairTypeAdapter.java
+++ b/src/main/java/org/stellar/sdk/responses/KeyPairTypeAdapter.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
import java.io.IOException;
@@ -16,6 +16,6 @@ public void write(JsonWriter out, KeyPair value) throws IOException {
@Override
public KeyPair read(JsonReader in) throws IOException {
- return KeyPair.fromAddress(in.nextString());
+ return KeyPair.fromAccountId(in.nextString());
}
}
diff --git a/src/main/java/org/stellar/sdk/Ledger.java b/src/main/java/org/stellar/sdk/responses/LedgerResponse.java
similarity index 90%
rename from src/main/java/org/stellar/sdk/Ledger.java
rename to src/main/java/org/stellar/sdk/responses/LedgerResponse.java
index 092eb8dcb..f0f4b4d63 100644
--- a/src/main/java/org/stellar/sdk/Ledger.java
+++ b/src/main/java/org/stellar/sdk/responses/LedgerResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.annotations.SerializedName;
@@ -8,7 +8,7 @@
* @see org.stellar.sdk.requests.LedgersRequestBuilder
* @see org.stellar.sdk.Server#ledgers()
*/
-public class Ledger {
+public class LedgerResponse {
@SerializedName("sequence")
private final Long sequence;
@SerializedName("hash")
@@ -36,7 +36,7 @@ public class Ledger {
@SerializedName("_links")
private final Links links;
- Ledger(Long sequence, String hash, String pagingToken, String prevHash, Integer transactionCount, Integer operationCount, String closedAt, String totalCoins, String feePool, Long baseFee, String baseReserve, Integer maxTxSetSize, Links links) {
+ LedgerResponse(Long sequence, String hash, String pagingToken, String prevHash, Integer transactionCount, Integer operationCount, String closedAt, String totalCoins, String feePool, Long baseFee, String baseReserve, Integer maxTxSetSize, Links links) {
this.sequence = sequence;
this.hash = hash;
this.pagingToken = pagingToken;
diff --git a/src/main/java/org/stellar/sdk/Link.java b/src/main/java/org/stellar/sdk/responses/Link.java
similarity index 95%
rename from src/main/java/org/stellar/sdk/Link.java
rename to src/main/java/org/stellar/sdk/responses/Link.java
index 1f3759f82..b69a22ba7 100644
--- a/src/main/java/org/stellar/sdk/Link.java
+++ b/src/main/java/org/stellar/sdk/responses/Link.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java
new file mode 100644
index 000000000..142eaef3e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/OperationDeserializer.java
@@ -0,0 +1,59 @@
+package org.stellar.sdk.responses;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.operations.OperationResponse;
+import org.stellar.sdk.responses.operations.CreateAccountOperationResponse;
+import org.stellar.sdk.responses.operations.PaymentOperationResponse;
+import org.stellar.sdk.responses.operations.PathPaymentOperationResponse;
+import org.stellar.sdk.responses.operations.ManageOfferOperationResponse;
+import org.stellar.sdk.responses.operations.CreatePassiveOfferOperationResponse;
+import org.stellar.sdk.responses.operations.SetOptionsOperationResponse;
+import org.stellar.sdk.responses.operations.ChangeTrustOperationResponse;
+import org.stellar.sdk.responses.operations.AllowTrustOperationResponse;
+import org.stellar.sdk.responses.operations.AccountMergeOperationResponse;
+import org.stellar.sdk.responses.operations.InflationOperationResponse;
+
+import java.lang.reflect.Type;
+
+class OperationDeserializer implements JsonDeserializer {
+ @Override
+ public OperationResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ // Create new Gson object with adapters needed in Operation
+ Gson gson = new GsonBuilder()
+ .registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
+ .create();
+
+ int type = json.getAsJsonObject().get("type_i").getAsInt();
+ switch (type) {
+ case 0:
+ return gson.fromJson(json, CreateAccountOperationResponse.class);
+ case 1:
+ return gson.fromJson(json, PaymentOperationResponse.class);
+ case 2:
+ return gson.fromJson(json, PathPaymentOperationResponse.class);
+ case 3:
+ return gson.fromJson(json, ManageOfferOperationResponse.class);
+ case 4:
+ return gson.fromJson(json, CreatePassiveOfferOperationResponse.class);
+ case 5:
+ return gson.fromJson(json, SetOptionsOperationResponse.class);
+ case 6:
+ return gson.fromJson(json, ChangeTrustOperationResponse.class);
+ case 7:
+ return gson.fromJson(json, AllowTrustOperationResponse.class);
+ case 8:
+ return gson.fromJson(json, AccountMergeOperationResponse.class);
+ case 9:
+ return gson.fromJson(json, InflationOperationResponse.class);
+ default:
+ throw new RuntimeException("Invalid operation type");
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/Page.java b/src/main/java/org/stellar/sdk/responses/Page.java
similarity index 97%
rename from src/main/java/org/stellar/sdk/Page.java
rename to src/main/java/org/stellar/sdk/responses/Page.java
index e15fdc7f5..cf40bc342 100644
--- a/src/main/java/org/stellar/sdk/Page.java
+++ b/src/main/java/org/stellar/sdk/responses/Page.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
diff --git a/src/main/java/org/stellar/sdk/PageDeserializer.java b/src/main/java/org/stellar/sdk/responses/PageDeserializer.java
similarity index 81%
rename from src/main/java/org/stellar/sdk/PageDeserializer.java
rename to src/main/java/org/stellar/sdk/responses/PageDeserializer.java
index dc444ae5d..0637983f8 100644
--- a/src/main/java/org/stellar/sdk/PageDeserializer.java
+++ b/src/main/java/org/stellar/sdk/responses/PageDeserializer.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -9,10 +9,10 @@
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
-import org.stellar.base.Asset;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.effects.Effect;
-import org.stellar.sdk.operations.Operation;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.effects.EffectResponse;
+import org.stellar.sdk.responses.operations.OperationResponse;
import java.lang.reflect.Type;
@@ -41,8 +41,8 @@ public Page deserialize(JsonElement json, Type typeOfT, JsonDeserializationCo
Gson gson = new GsonBuilder()
.registerTypeAdapter(Asset.class, new AssetDeserializer())
.registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
- .registerTypeAdapter(Operation.class, new OperationDeserializer())
- .registerTypeAdapter(Effect.class, new EffectDeserializer())
+ .registerTypeAdapter(OperationResponse.class, new OperationDeserializer())
+ .registerTypeAdapter(EffectResponse.class, new EffectDeserializer())
.create();
return gson.fromJson(newJson, pageType.getType());
diff --git a/src/main/java/org/stellar/sdk/Path.java b/src/main/java/org/stellar/sdk/responses/PathResponse.java
similarity index 81%
rename from src/main/java/org/stellar/sdk/Path.java
rename to src/main/java/org/stellar/sdk/responses/PathResponse.java
index 12594022f..1032796a1 100644
--- a/src/main/java/org/stellar/sdk/Path.java
+++ b/src/main/java/org/stellar/sdk/responses/PathResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
import java.util.ArrayList;
@@ -14,7 +14,7 @@
* @see org.stellar.sdk.requests.PathsRequestBuilder
* @see org.stellar.sdk.Server#paths()
*/
-public class Path {
+public class PathResponse {
@SerializedName("destination_amount")
private final String destinationAmount;
@SerializedName("destination_asset_type")
@@ -39,7 +39,7 @@ public class Path {
@SerializedName("_links")
private final Links links;
- Path(String destinationAmount, String destinationAssetType, String destinationAssetCode, String destinationAssetIssuer, String sourceAmount, String sourceAssetType, String sourceAssetCode, String sourceAssetIssuer, ArrayList path, Links links) {
+ PathResponse(String destinationAmount, String destinationAssetType, String destinationAssetCode, String destinationAssetIssuer, String sourceAmount, String sourceAssetType, String sourceAssetCode, String sourceAssetIssuer, ArrayList path, Links links) {
this.destinationAmount = destinationAmount;
this.destinationAssetType = destinationAssetType;
this.destinationAssetCode = destinationAssetCode;
@@ -68,7 +68,7 @@ public Asset getDestinationAsset() {
if (destinationAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(destinationAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(destinationAssetIssuer);
return Asset.createNonNativeAsset(destinationAssetCode, issuer);
}
}
@@ -77,7 +77,7 @@ public Asset getSourceAsset() {
if (sourceAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(sourceAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(sourceAssetIssuer);
return Asset.createNonNativeAsset(sourceAssetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/SubmitTransactionResponse.java b/src/main/java/org/stellar/sdk/responses/SubmitTransactionResponse.java
similarity index 92%
rename from src/main/java/org/stellar/sdk/SubmitTransactionResponse.java
rename to src/main/java/org/stellar/sdk/responses/SubmitTransactionResponse.java
index 891520fec..c5b632b17 100644
--- a/src/main/java/org/stellar/sdk/SubmitTransactionResponse.java
+++ b/src/main/java/org/stellar/sdk/responses/SubmitTransactionResponse.java
@@ -1,10 +1,12 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.annotations.SerializedName;
+import org.stellar.sdk.Server;
+
/**
* Represents server response after submitting transaction.
- * @see Server#submitTransaction(org.stellar.base.Transaction)
+ * @see Server#submitTransaction(org.stellar.sdk.Transaction)
*/
public class SubmitTransactionResponse {
@SerializedName("hash")
diff --git a/src/main/java/org/stellar/sdk/TransactionDeserializer.java b/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java
similarity index 80%
rename from src/main/java/org/stellar/sdk/TransactionDeserializer.java
rename to src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java
index 512ae1058..6d1ba8fe6 100644
--- a/src/main/java/org/stellar/sdk/TransactionDeserializer.java
+++ b/src/main/java/org/stellar/sdk/responses/TransactionDeserializer.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -8,20 +8,20 @@
import com.google.gson.JsonParseException;
import org.apache.commons.codec.binary.Base64;
-import org.stellar.base.KeyPair;
-import org.stellar.base.Memo;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.Memo;
import java.lang.reflect.Type;
-public class TransactionDeserializer implements JsonDeserializer {
+public class TransactionDeserializer implements JsonDeserializer {
@Override
- public Transaction deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ public TransactionResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// Create new Gson object with adapters needed in Transaction
Gson gson = new GsonBuilder()
.registerTypeAdapter(KeyPair.class, new KeyPairTypeAdapter().nullSafe())
.create();
- Transaction transaction = gson.fromJson(json, Transaction.class);
+ TransactionResponse transaction = gson.fromJson(json, TransactionResponse.class);
String memoType = json.getAsJsonObject().get("memo_type").getAsString();
Memo memo;
diff --git a/src/main/java/org/stellar/sdk/responses/TransactionResponse.java b/src/main/java/org/stellar/sdk/responses/TransactionResponse.java
new file mode 100644
index 000000000..453839463
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/TransactionResponse.java
@@ -0,0 +1,179 @@
+package org.stellar.sdk.responses;
+
+import com.google.gson.annotations.SerializedName;
+
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.Memo;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents transaction response.
+ * @see Transaction documentation
+ * @see org.stellar.sdk.requests.TransactionsRequestBuilder
+ * @see org.stellar.sdk.Server#transactions()
+ */
+public class TransactionResponse {
+ @SerializedName("hash")
+ private final String hash;
+ @SerializedName("ledger")
+ private final Long ledger;
+ @SerializedName("created_at")
+ private final String createdAt;
+ @SerializedName("source_account")
+ private final KeyPair sourceAccount;
+ @SerializedName("paging_token")
+ private final String pagingToken;
+ @SerializedName("source_account_sequence")
+ private final Long sourceAccountSequence;
+ @SerializedName("fee_paid")
+ private final Long feePaid;
+ @SerializedName("operation_count")
+ private final Integer operationCount;
+ @SerializedName("envelope_xdr")
+ private final String envelopeXdr;
+ @SerializedName("result_xdr")
+ private final String resultXdr;
+ @SerializedName("result_meta_xdr")
+ private final String resultMetaXdr;
+ @SerializedName("_links")
+ private final Links links;
+
+ // GSON won't serialize `transient` variables automatically. We need this behaviour
+ // because Memo is an abstract class and GSON tries to instantiate it.
+ private transient Memo memo;
+
+ TransactionResponse(String hash, Long ledger, String createdAt, KeyPair sourceAccount, String pagingToken, Long sourceAccountSequence, Long feePaid, Integer operationCount, String envelopeXdr, String resultXdr, String resultMetaXdr, Memo memo, Links links) {
+ this.hash = hash;
+ this.ledger = ledger;
+ this.createdAt = createdAt;
+ this.sourceAccount = sourceAccount;
+ this.pagingToken = pagingToken;
+ this.sourceAccountSequence = sourceAccountSequence;
+ this.feePaid = feePaid;
+ this.operationCount = operationCount;
+ this.envelopeXdr = envelopeXdr;
+ this.resultXdr = resultXdr;
+ this.resultMetaXdr = resultMetaXdr;
+ this.memo = memo;
+ this.links = links;
+ }
+
+ public String getHash() {
+ return hash;
+ }
+
+ public Long getLedger() {
+ return ledger;
+ }
+
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ public KeyPair getSourceAccount() {
+ return sourceAccount;
+ }
+
+ public String getPagingToken() {
+ return pagingToken;
+ }
+
+ public Long getSourceAccountSequence() {
+ return sourceAccountSequence;
+ }
+
+ public Long getFeePaid() {
+ return feePaid;
+ }
+
+ public Integer getOperationCount() {
+ return operationCount;
+ }
+
+ public String getEnvelopeXdr() {
+ return envelopeXdr;
+ }
+
+ public String getResultXdr() {
+ return resultXdr;
+ }
+
+ public String getResultMetaXdr() {
+ return resultMetaXdr;
+ }
+
+ public Memo getMemo() {
+ return memo;
+ }
+
+ public void setMemo(Memo memo) {
+ memo = checkNotNull(memo, "memo cannot be null");
+ if (this.memo != null) {
+ throw new RuntimeException("Memo has been already set.");
+ }
+ this.memo = memo;
+ }
+
+ public Links getLinks() {
+ return links;
+ }
+
+ /**
+ * Links connected to transaction.
+ */
+ public static class Links {
+ @SerializedName("account")
+ private final Link account;
+ @SerializedName("effects")
+ private final Link effects;
+ @SerializedName("ledger")
+ private final Link ledger;
+ @SerializedName("operations")
+ private final Link operations;
+ @SerializedName("precedes")
+ private final Link precedes;
+ @SerializedName("self")
+ private final Link self;
+ @SerializedName("succeeds")
+ private final Link succeeds;
+
+ Links(Link account, Link effects, Link ledger, Link operations, Link self, Link precedes, Link succeeds) {
+ this.account = account;
+ this.effects = effects;
+ this.ledger = ledger;
+ this.operations = operations;
+ this.self = self;
+ this.precedes = precedes;
+ this.succeeds = succeeds;
+ }
+
+ public Link getAccount() {
+ return account;
+ }
+
+ public Link getEffects() {
+ return effects;
+ }
+
+ public Link getLedger() {
+ return ledger;
+ }
+
+ public Link getOperations() {
+ return operations;
+ }
+
+ public Link getPrecedes() {
+ return precedes;
+ }
+
+ public Link getSelf() {
+ return self;
+ }
+
+ public Link getSucceeds() {
+ return succeeds;
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountCreatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountCreatedEffectResponse.java
similarity index 76%
rename from src/main/java/org/stellar/sdk/effects/AccountCreatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountCreatedEffectResponse.java
index 668579f0e..7e5f08960 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountCreatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountCreatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
@@ -8,11 +8,11 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountCreatedEffect extends Effect {
+public class AccountCreatedEffectResponse extends EffectResponse {
@SerializedName("starting_balance")
protected final String startingBalance;
- AccountCreatedEffect(String startingBalance) {
+ AccountCreatedEffectResponse(String startingBalance) {
this.startingBalance = startingBalance;
}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountCreditedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountCreditedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/AccountCreditedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountCreditedEffectResponse.java
index fe1af27e1..952da6512 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountCreditedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountCreditedEffectResponse.java
@@ -1,10 +1,11 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
+
/**
* Represents account_credited effect response.
@@ -12,7 +13,7 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountCreditedEffect extends Effect {
+public class AccountCreditedEffectResponse extends EffectResponse {
@SerializedName("amount")
protected final String amount;
@SerializedName("asset_type")
@@ -22,7 +23,7 @@ public class AccountCreditedEffect extends Effect {
@SerializedName("asset_issuer")
protected final String assetIssuer;
- AccountCreditedEffect(String amount, String assetType, String assetCode, String assetIssuer) {
+ AccountCreditedEffectResponse(String amount, String assetType, String assetCode, String assetIssuer) {
this.amount = amount;
this.assetType = assetType;
this.assetCode = assetCode;
@@ -37,7 +38,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountDebitedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountDebitedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/AccountDebitedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountDebitedEffectResponse.java
index 7ae5d44f2..d51f9b3e1 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountDebitedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountDebitedEffectResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents account_debited effect response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountDebitedEffect extends Effect {
+public class AccountDebitedEffectResponse extends EffectResponse {
@SerializedName("amount")
protected final String amount;
@SerializedName("asset_type")
@@ -22,7 +22,7 @@ public class AccountDebitedEffect extends Effect {
@SerializedName("asset_issuer")
protected final String assetIssuer;
- AccountDebitedEffect(String amount, String assetType, String assetCode, String assetIssuer) {
+ AccountDebitedEffectResponse(String amount, String assetType, String assetCode, String assetIssuer) {
this.amount = amount;
this.assetType = assetType;
this.assetCode = assetCode;
@@ -37,7 +37,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountFlagsUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountFlagsUpdatedEffectResponse.java
similarity index 78%
rename from src/main/java/org/stellar/sdk/effects/AccountFlagsUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountFlagsUpdatedEffectResponse.java
index efabaa76b..5585d71c4 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountFlagsUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountFlagsUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
@@ -8,13 +8,13 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountFlagsUpdatedEffect extends Effect {
+public class AccountFlagsUpdatedEffectResponse extends EffectResponse {
@SerializedName("auth_required_flag")
protected final Boolean authRequiredFlag;
@SerializedName("auth_revokable_flag")
protected final Boolean authRevokableFlag;
- AccountFlagsUpdatedEffect(Boolean authRequiredFlag, Boolean authRevokableFlag) {
+ AccountFlagsUpdatedEffectResponse(Boolean authRequiredFlag, Boolean authRevokableFlag) {
this.authRequiredFlag = authRequiredFlag;
this.authRevokableFlag = authRevokableFlag;
}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountHomeDomainUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountHomeDomainUpdatedEffectResponse.java
similarity index 74%
rename from src/main/java/org/stellar/sdk/effects/AccountHomeDomainUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountHomeDomainUpdatedEffectResponse.java
index 387fb789d..7e4e687e0 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountHomeDomainUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountHomeDomainUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
@@ -8,11 +8,11 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountHomeDomainUpdatedEffect extends Effect {
+public class AccountHomeDomainUpdatedEffectResponse extends EffectResponse {
@SerializedName("home_domain")
protected final String homeDomain;
- AccountHomeDomainUpdatedEffect(String homeDomain) {
+ AccountHomeDomainUpdatedEffectResponse(String homeDomain) {
this.homeDomain = homeDomain;
}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountRemovedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountRemovedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/AccountRemovedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountRemovedEffectResponse.java
index 8862d4c7f..44ce78765 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountRemovedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountRemovedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents account_removed effect response.
@@ -6,4 +6,4 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountRemovedEffect extends Effect {}
+public class AccountRemovedEffectResponse extends EffectResponse {}
diff --git a/src/main/java/org/stellar/sdk/effects/AccountThresholdsUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/AccountThresholdsUpdatedEffectResponse.java
similarity index 79%
rename from src/main/java/org/stellar/sdk/effects/AccountThresholdsUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/AccountThresholdsUpdatedEffectResponse.java
index 53219021b..b675efb9e 100644
--- a/src/main/java/org/stellar/sdk/effects/AccountThresholdsUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/AccountThresholdsUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
@@ -8,7 +8,7 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class AccountThresholdsUpdatedEffect extends Effect {
+public class AccountThresholdsUpdatedEffectResponse extends EffectResponse {
@SerializedName("low_threshold")
protected final Integer lowThreshold;
@SerializedName("med_threshold")
@@ -16,7 +16,7 @@ public class AccountThresholdsUpdatedEffect extends Effect {
@SerializedName("high_threshold")
protected final Integer highThreshold;
- AccountThresholdsUpdatedEffect(Integer lowThreshold, Integer medThreshold, Integer highThreshold) {
+ AccountThresholdsUpdatedEffectResponse(Integer lowThreshold, Integer medThreshold, Integer highThreshold) {
this.lowThreshold = lowThreshold;
this.medThreshold = medThreshold;
this.highThreshold = highThreshold;
diff --git a/src/main/java/org/stellar/sdk/effects/Effect.java b/src/main/java/org/stellar/sdk/responses/effects/EffectResponse.java
similarity index 93%
rename from src/main/java/org/stellar/sdk/effects/Effect.java
rename to src/main/java/org/stellar/sdk/responses/effects/EffectResponse.java
index 06535ff10..69b02b4c1 100644
--- a/src/main/java/org/stellar/sdk/effects/Effect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/EffectResponse.java
@@ -1,9 +1,9 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.Link;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.Link;
/**
* Abstract class for effect responses.
@@ -11,7 +11,7 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public abstract class Effect {
+public abstract class EffectResponse {
@SerializedName("id")
protected String id;
@SerializedName("account")
diff --git a/src/main/java/org/stellar/sdk/effects/OfferCreatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/OfferCreatedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/OfferCreatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/OfferCreatedEffectResponse.java
index 137540ace..aaf2c96ed 100644
--- a/src/main/java/org/stellar/sdk/effects/OfferCreatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/OfferCreatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents offer_created effect response.
@@ -6,6 +6,6 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class OfferCreatedEffect extends Effect {
+public class OfferCreatedEffectResponse extends EffectResponse {
//
}
diff --git a/src/main/java/org/stellar/sdk/effects/OfferRemovedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/OfferRemovedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/OfferRemovedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/OfferRemovedEffectResponse.java
index fce8d2e77..2bf136758 100644
--- a/src/main/java/org/stellar/sdk/effects/OfferRemovedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/OfferRemovedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents offer_removed effect response.
@@ -6,6 +6,6 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class OfferRemovedEffect extends Effect {
+public class OfferRemovedEffectResponse extends EffectResponse {
//
}
diff --git a/src/main/java/org/stellar/sdk/effects/OfferUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/OfferUpdatedEffectResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/effects/OfferUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/OfferUpdatedEffectResponse.java
index 2f8d76eb5..fe9e6128c 100644
--- a/src/main/java/org/stellar/sdk/effects/OfferUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/OfferUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents offer_updated effect response.
@@ -6,6 +6,6 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class OfferUpdatedEffect extends Effect {
+public class OfferUpdatedEffectResponse extends EffectResponse {
//
}
diff --git a/src/main/java/org/stellar/sdk/effects/SignerCreatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/SignerCreatedEffectResponse.java
similarity index 63%
rename from src/main/java/org/stellar/sdk/effects/SignerCreatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/SignerCreatedEffectResponse.java
index 77479745f..9b9bb02f4 100644
--- a/src/main/java/org/stellar/sdk/effects/SignerCreatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/SignerCreatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents signer_created effect response.
@@ -6,8 +6,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class SignerCreatedEffect extends SignerEffect {
- SignerCreatedEffect(Integer weight, String publicKey) {
+public class SignerCreatedEffectResponse extends SignerEffectResponse {
+ SignerCreatedEffectResponse(Integer weight, String publicKey) {
super(weight, publicKey);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/SignerEffect.java b/src/main/java/org/stellar/sdk/responses/effects/SignerEffectResponse.java
similarity index 68%
rename from src/main/java/org/stellar/sdk/effects/SignerEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/SignerEffectResponse.java
index 20fd7d8e2..d02dc4725 100644
--- a/src/main/java/org/stellar/sdk/effects/SignerEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/SignerEffectResponse.java
@@ -1,14 +1,14 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-abstract class SignerEffect extends Effect {
+abstract class SignerEffectResponse extends EffectResponse {
@SerializedName("weight")
protected final Integer weight;
@SerializedName("public_key")
protected final String publicKey;
- public SignerEffect(Integer weight, String publicKey) {
+ public SignerEffectResponse(Integer weight, String publicKey) {
this.weight = weight;
this.publicKey = publicKey;
}
diff --git a/src/main/java/org/stellar/sdk/responses/effects/SignerRemovedEffectResponse.java b/src/main/java/org/stellar/sdk/responses/effects/SignerRemovedEffectResponse.java
new file mode 100644
index 000000000..69ec1886a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/responses/effects/SignerRemovedEffectResponse.java
@@ -0,0 +1,10 @@
+package org.stellar.sdk.responses.effects;
+
+/**
+ * Represents signer_removed effect response.
+ */
+public class SignerRemovedEffectResponse extends SignerEffectResponse {
+ SignerRemovedEffectResponse(Integer weight, String publicKey) {
+ super(weight, publicKey);
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/effects/SignerUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/SignerUpdatedEffectResponse.java
similarity index 63%
rename from src/main/java/org/stellar/sdk/effects/SignerUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/SignerUpdatedEffectResponse.java
index b5274a243..12865740c 100644
--- a/src/main/java/org/stellar/sdk/effects/SignerUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/SignerUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents signed_updated effect response.
@@ -6,8 +6,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class SignerUpdatedEffect extends SignerEffect {
- SignerUpdatedEffect(Integer weight, String publicKey) {
+public class SignerUpdatedEffectResponse extends SignerEffectResponse {
+ SignerUpdatedEffectResponse(Integer weight, String publicKey) {
super(weight, publicKey);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TradeEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TradeEffectResponse.java
similarity index 78%
rename from src/main/java/org/stellar/sdk/effects/TradeEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TradeEffectResponse.java
index b3ce06725..cf7acf007 100644
--- a/src/main/java/org/stellar/sdk/effects/TradeEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TradeEffectResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents trade effect response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TradeEffect extends Effect {
+public class TradeEffectResponse extends EffectResponse {
@SerializedName("seller")
protected final KeyPair seller;
@SerializedName("offer_id")
@@ -36,7 +36,7 @@ public class TradeEffect extends Effect {
@SerializedName("bought_asset_issuer")
protected final String boughtAssetIssuer;
- TradeEffect(KeyPair seller, Long offerId, String soldAmount, String soldAssetType, String soldAssetCode, String soldAssetIssuer, String boughtAmount, String boughtAssetType, String boughtAssetCode, String boughtAssetIssuer) {
+ TradeEffectResponse(KeyPair seller, Long offerId, String soldAmount, String soldAssetType, String soldAssetCode, String soldAssetIssuer, String boughtAmount, String boughtAssetType, String boughtAssetCode, String boughtAssetIssuer) {
this.seller = seller;
this.offerId = offerId;
this.soldAmount = soldAmount;
@@ -69,7 +69,7 @@ public Asset getSoldAsset() {
if (soldAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(soldAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(soldAssetIssuer);
return Asset.createNonNativeAsset(soldAssetCode, issuer);
}
}
@@ -78,7 +78,7 @@ public Asset getBoughtAsset() {
if (boughtAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(boughtAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(boughtAssetIssuer);
return Asset.createNonNativeAsset(boughtAssetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineAuthorization.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizationResponse.java
similarity index 69%
rename from src/main/java/org/stellar/sdk/effects/TrustlineAuthorization.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizationResponse.java
index 6bd521857..92d3e1d0a 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineAuthorization.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
-abstract class TrustlineAuthorization extends Effect {
+abstract class TrustlineAuthorizationResponse extends EffectResponse {
@SerializedName("trustor")
protected final KeyPair trustor;
@SerializedName("asset_type")
@@ -12,7 +12,7 @@ abstract class TrustlineAuthorization extends Effect {
@SerializedName("asset_code")
protected final String assetCode;
- TrustlineAuthorization(KeyPair trustor, String assetType, String assetCode) {
+ TrustlineAuthorizationResponse(KeyPair trustor, String assetType, String assetCode) {
this.trustor = trustor;
this.assetType = assetType;
this.assetCode = assetCode;
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineAuthorizedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
similarity index 57%
rename from src/main/java/org/stellar/sdk/effects/TrustlineAuthorizedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
index 34e2ef8c8..6d258d848 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineAuthorizedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineAuthorizedEffectResponse.java
@@ -1,6 +1,6 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
/**
* Represents trustline_authorized effect response.
@@ -8,8 +8,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TrustlineAuthorizedEffect extends TrustlineAuthorization {
- TrustlineAuthorizedEffect(KeyPair trustor, String assetType, String assetCode) {
+public class TrustlineAuthorizedEffectResponse extends TrustlineAuthorizationResponse {
+ TrustlineAuthorizedEffectResponse(KeyPair trustor, String assetType, String assetCode) {
super(trustor, assetType, assetCode);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineCUD.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java
similarity index 65%
rename from src/main/java/org/stellar/sdk/effects/TrustlineCUD.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java
index de6d0fb1a..65d2ff618 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineCUD.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCUDResponse.java
@@ -1,12 +1,12 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
-abstract class TrustlineCUD extends Effect {
+abstract class TrustlineCUDResponse extends EffectResponse {
@SerializedName("limit")
protected final String limit;
@SerializedName("asset_type")
@@ -16,7 +16,7 @@ abstract class TrustlineCUD extends Effect {
@SerializedName("asset_issuer")
protected final String assetIssuer;
- public TrustlineCUD(String limit, String assetType, String assetCode, String assetIssuer) {
+ public TrustlineCUDResponse(String limit, String assetType, String assetCode, String assetIssuer) {
this.limit = limit;
this.assetType = assetType;
this.assetCode = assetCode;
@@ -31,7 +31,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineCreatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCreatedEffectResponse.java
similarity index 60%
rename from src/main/java/org/stellar/sdk/effects/TrustlineCreatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineCreatedEffectResponse.java
index cfb6fa656..e600b5464 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineCreatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineCreatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents trustline_created effect response.
@@ -6,8 +6,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TrustlineCreatedEffect extends TrustlineCUD {
- TrustlineCreatedEffect(String limit, String assetType, String assetCode, String assetIssuer) {
+public class TrustlineCreatedEffectResponse extends TrustlineCUDResponse {
+ TrustlineCreatedEffectResponse(String limit, String assetType, String assetCode, String assetIssuer) {
super(limit, assetType, assetCode, assetIssuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineDeauthorizedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
similarity index 57%
rename from src/main/java/org/stellar/sdk/effects/TrustlineDeauthorizedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
index ed2b0487e..84cf1712c 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineDeauthorizedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineDeauthorizedEffectResponse.java
@@ -1,6 +1,6 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
/**
* Represents trustline_deauthorized effect response.
@@ -8,8 +8,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TrustlineDeauthorizedEffect extends TrustlineAuthorization {
- TrustlineDeauthorizedEffect(KeyPair trustor, String assetType, String assetCode) {
+public class TrustlineDeauthorizedEffectResponse extends TrustlineAuthorizationResponse {
+ TrustlineDeauthorizedEffectResponse(KeyPair trustor, String assetType, String assetCode) {
super(trustor, assetType, assetCode);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineRemovedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineRemovedEffectResponse.java
similarity index 60%
rename from src/main/java/org/stellar/sdk/effects/TrustlineRemovedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineRemovedEffectResponse.java
index 636a30b5c..0936d620d 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineRemovedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineRemovedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents trustline_removed effect response.
@@ -6,8 +6,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TrustlineRemovedEffect extends TrustlineCUD {
- TrustlineRemovedEffect(String limit, String assetType, String assetCode, String assetIssuer) {
+public class TrustlineRemovedEffectResponse extends TrustlineCUDResponse {
+ TrustlineRemovedEffectResponse(String limit, String assetType, String assetCode, String assetIssuer) {
super(limit, assetType, assetCode, assetIssuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/effects/TrustlineUpdatedEffect.java b/src/main/java/org/stellar/sdk/responses/effects/TrustlineUpdatedEffectResponse.java
similarity index 60%
rename from src/main/java/org/stellar/sdk/effects/TrustlineUpdatedEffect.java
rename to src/main/java/org/stellar/sdk/responses/effects/TrustlineUpdatedEffectResponse.java
index 3f83c31b2..a1c085f0d 100644
--- a/src/main/java/org/stellar/sdk/effects/TrustlineUpdatedEffect.java
+++ b/src/main/java/org/stellar/sdk/responses/effects/TrustlineUpdatedEffectResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.effects;
+package org.stellar.sdk.responses.effects;
/**
* Represents trustline_updated effect response.
@@ -6,8 +6,8 @@
* @see org.stellar.sdk.requests.EffectsRequestBuilder
* @see org.stellar.sdk.Server#effects()
*/
-public class TrustlineUpdatedEffect extends TrustlineCUD {
- TrustlineUpdatedEffect(String limit, String assetType, String assetCode, String assetIssuer) {
+public class TrustlineUpdatedEffectResponse extends TrustlineCUDResponse {
+ TrustlineUpdatedEffectResponse(String limit, String assetType, String assetCode, String assetIssuer) {
super(limit, assetType, assetCode, assetIssuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/AccountMergeOperation.java b/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java
similarity index 74%
rename from src/main/java/org/stellar/sdk/operations/AccountMergeOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java
index 3d29d73f8..6856a7a98 100644
--- a/src/main/java/org/stellar/sdk/operations/AccountMergeOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/AccountMergeOperationResponse.java
@@ -1,8 +1,8 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
/**
* Represents AccountMerge operation response.
@@ -10,13 +10,13 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class AccountMergeOperation extends Operation {
+public class AccountMergeOperationResponse extends OperationResponse {
@SerializedName("account")
protected final KeyPair account;
@SerializedName("into")
protected final KeyPair into;
- AccountMergeOperation(KeyPair account, KeyPair into) {
+ AccountMergeOperationResponse(KeyPair account, KeyPair into) {
this.account = account;
this.into = into;
}
diff --git a/src/main/java/org/stellar/sdk/operations/AllowTrustOperation.java b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
similarity index 75%
rename from src/main/java/org/stellar/sdk/operations/AllowTrustOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
index 238002d22..b394a6b3b 100644
--- a/src/main/java/org/stellar/sdk/operations/AllowTrustOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/AllowTrustOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents AllowTrust operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class AllowTrustOperation extends Operation {
+public class AllowTrustOperationResponse extends OperationResponse {
@SerializedName("trustor")
protected final KeyPair trustor;
@SerializedName("trustee")
@@ -26,7 +26,7 @@ public class AllowTrustOperation extends Operation {
@SerializedName("authorize")
protected final boolean authorize;
- AllowTrustOperation(boolean authorize, String assetIssuer, String assetCode, String assetType, KeyPair trustee, KeyPair trustor) {
+ AllowTrustOperationResponse(boolean authorize, String assetIssuer, String assetCode, String assetType, KeyPair trustee, KeyPair trustor) {
this.authorize = authorize;
this.assetIssuer = assetIssuer;
this.assetCode = assetCode;
@@ -51,7 +51,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/ChangeTrustOperation.java b/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java
similarity index 75%
rename from src/main/java/org/stellar/sdk/operations/ChangeTrustOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java
index da4962870..33e167eb3 100644
--- a/src/main/java/org/stellar/sdk/operations/ChangeTrustOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/ChangeTrustOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents ChangeTrust operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class ChangeTrustOperation extends Operation {
+public class ChangeTrustOperationResponse extends OperationResponse {
@SerializedName("trustor")
protected final KeyPair trustor;
@SerializedName("trustee")
@@ -26,7 +26,7 @@ public class ChangeTrustOperation extends Operation {
@SerializedName("limit")
protected final String limit;
- ChangeTrustOperation(KeyPair trustor, KeyPair trustee, String assetType, String assetCode, String assetIssuer, String limit) {
+ ChangeTrustOperationResponse(KeyPair trustor, KeyPair trustee, String assetType, String assetCode, String assetIssuer, String limit) {
this.trustor = trustor;
this.trustee = trustee;
this.assetType = assetType;
@@ -51,7 +51,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/CreateAccountOperation.java b/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/operations/CreateAccountOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java
index 9e5d379c2..c7764b04a 100644
--- a/src/main/java/org/stellar/sdk/operations/CreateAccountOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/CreateAccountOperationResponse.java
@@ -1,8 +1,8 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
/**
* Represents CreateAccount operation response.
@@ -10,7 +10,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class CreateAccountOperation extends Operation {
+public class CreateAccountOperationResponse extends OperationResponse {
@SerializedName("account")
protected final KeyPair account;
@SerializedName("funder")
@@ -18,7 +18,7 @@ public class CreateAccountOperation extends Operation {
@SerializedName("starting_balance")
protected final String startingBalance;
- CreateAccountOperation(KeyPair funder, String startingBalance, KeyPair account) {
+ CreateAccountOperationResponse(KeyPair funder, String startingBalance, KeyPair account) {
this.funder = funder;
this.startingBalance = startingBalance;
this.account = account;
diff --git a/src/main/java/org/stellar/sdk/operations/CreatePassiveOfferOperation.java b/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveOfferOperationResponse.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/operations/CreatePassiveOfferOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/CreatePassiveOfferOperationResponse.java
index ec3ff15df..74b2b6ce9 100644
--- a/src/main/java/org/stellar/sdk/operations/CreatePassiveOfferOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/CreatePassiveOfferOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents CreatePassiveOffer operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class CreatePassiveOfferOperation extends Operation {
+public class CreatePassiveOfferOperationResponse extends OperationResponse {
@SerializedName("offer_id")
protected final Integer offerId;
@SerializedName("amount")
@@ -36,7 +36,7 @@ public class CreatePassiveOfferOperation extends Operation {
@SerializedName("selling_asset_issuer")
protected final String sellingAssetIssuer;
- CreatePassiveOfferOperation(Integer offerId, String amount, String price, String buyingAssetType, String buyingAssetCode, String buyingAssetIssuer, String sellingAssetType, String sellingAssetCode, String sellingAssetIssuer) {
+ CreatePassiveOfferOperationResponse(Integer offerId, String amount, String price, String buyingAssetType, String buyingAssetCode, String buyingAssetIssuer, String sellingAssetType, String sellingAssetCode, String sellingAssetIssuer) {
this.offerId = offerId;
this.amount = amount;
this.price = price;
@@ -64,7 +64,7 @@ public Asset getBuyingAsset() {
if (buyingAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(buyingAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(buyingAssetIssuer);
return Asset.createNonNativeAsset(buyingAssetCode, issuer);
}
}
@@ -73,7 +73,7 @@ public Asset getSellingAsset() {
if (sellingAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(sellingAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(sellingAssetIssuer);
return Asset.createNonNativeAsset(sellingAssetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/InflationOperation.java b/src/main/java/org/stellar/sdk/responses/operations/InflationOperationResponse.java
similarity index 72%
rename from src/main/java/org/stellar/sdk/operations/InflationOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/InflationOperationResponse.java
index 71732e1b4..c0054d224 100644
--- a/src/main/java/org/stellar/sdk/operations/InflationOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/InflationOperationResponse.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
/**
* Represents Inflation operation response.
@@ -6,5 +6,5 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class InflationOperation extends Operation {
+public class InflationOperationResponse extends OperationResponse {
}
diff --git a/src/main/java/org/stellar/sdk/operations/ManageOfferOperation.java b/src/main/java/org/stellar/sdk/responses/operations/ManageOfferOperationResponse.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/operations/ManageOfferOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/ManageOfferOperationResponse.java
index 7c93cf896..e0da51b15 100644
--- a/src/main/java/org/stellar/sdk/operations/ManageOfferOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/ManageOfferOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents ManageOffer operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class ManageOfferOperation extends Operation {
+public class ManageOfferOperationResponse extends OperationResponse {
@SerializedName("offer_id")
protected final Integer offerId;
@SerializedName("amount")
@@ -36,7 +36,7 @@ public class ManageOfferOperation extends Operation {
@SerializedName("selling_asset_issuer")
protected final String sellingAssetIssuer;
- ManageOfferOperation(Integer offerId, String amount, String price, String buyingAssetType, String buyingAssetCode, String buyingAssetIssuer, String sellingAssetType, String sellingAssetCode, String sellingAssetIssuer) {
+ ManageOfferOperationResponse(Integer offerId, String amount, String price, String buyingAssetType, String buyingAssetCode, String buyingAssetIssuer, String sellingAssetType, String sellingAssetCode, String sellingAssetIssuer) {
this.offerId = offerId;
this.amount = amount;
this.price = price;
@@ -64,7 +64,7 @@ public Asset getBuyingAsset() {
if (buyingAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(buyingAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(buyingAssetIssuer);
return Asset.createNonNativeAsset(buyingAssetCode, issuer);
}
}
@@ -73,7 +73,7 @@ public Asset getSellingAsset() {
if (sellingAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(sellingAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(sellingAssetIssuer);
return Asset.createNonNativeAsset(sellingAssetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/Operation.java b/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java
similarity index 93%
rename from src/main/java/org/stellar/sdk/operations/Operation.java
rename to src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java
index 72a2095eb..b701e983f 100644
--- a/src/main/java/org/stellar/sdk/operations/Operation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/OperationResponse.java
@@ -1,9 +1,9 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.Link;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.Link;
/**
* Abstract class for operation responses.
@@ -11,7 +11,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public abstract class Operation {
+public abstract class OperationResponse {
@SerializedName("id")
protected Long id;
@SerializedName("source_account")
diff --git a/src/main/java/org/stellar/sdk/operations/PathPaymentOperation.java b/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java
similarity index 77%
rename from src/main/java/org/stellar/sdk/operations/PathPaymentOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java
index f6c227334..8750f2ff8 100644
--- a/src/main/java/org/stellar/sdk/operations/PathPaymentOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/PathPaymentOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents PathPayment operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class PathPaymentOperation extends Operation {
+public class PathPaymentOperationResponse extends OperationResponse {
@SerializedName("amount")
protected final String amount;
@SerializedName("source_amount")
@@ -36,7 +36,7 @@ public class PathPaymentOperation extends Operation {
@SerializedName("send_asset_issuer")
protected final String sendAssetIssuer;
- PathPaymentOperation(String amount, String sourceAmount, KeyPair from, KeyPair to, String assetType, String assetCode, String assetIssuer, String sendAssetType, String sendAssetCode, String sendAssetIssuer) {
+ PathPaymentOperationResponse(String amount, String sourceAmount, KeyPair from, KeyPair to, String assetType, String assetCode, String assetIssuer, String sendAssetType, String sendAssetCode, String sendAssetIssuer) {
this.amount = amount;
this.sourceAmount = sourceAmount;
this.from = from;
@@ -69,7 +69,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
@@ -78,7 +78,7 @@ public Asset getSendAsset() {
if (sendAssetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(sendAssetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(sendAssetIssuer);
return Asset.createNonNativeAsset(sendAssetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/PaymentOperation.java b/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java
similarity index 75%
rename from src/main/java/org/stellar/sdk/operations/PaymentOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java
index 8b5aec4e6..623d5257e 100644
--- a/src/main/java/org/stellar/sdk/operations/PaymentOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/PaymentOperationResponse.java
@@ -1,10 +1,10 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
/**
* Represents Payment operation response.
@@ -12,7 +12,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class PaymentOperation extends Operation {
+public class PaymentOperationResponse extends OperationResponse {
@SerializedName("amount")
protected final String amount;
@SerializedName("asset_type")
@@ -26,7 +26,7 @@ public class PaymentOperation extends Operation {
@SerializedName("to")
protected final KeyPair to;
- PaymentOperation(String amount, String assetType, String assetCode, String assetIssuer, KeyPair from, KeyPair to) {
+ PaymentOperationResponse(String amount, String assetType, String assetCode, String assetIssuer, KeyPair from, KeyPair to) {
this.amount = amount;
this.assetType = assetType;
this.assetCode = assetCode;
@@ -43,7 +43,7 @@ public Asset getAsset() {
if (assetType.equals("native")) {
return new AssetTypeNative();
} else {
- KeyPair issuer = KeyPair.fromAddress(assetIssuer);
+ KeyPair issuer = KeyPair.fromAccountId(assetIssuer);
return Asset.createNonNativeAsset(assetCode, issuer);
}
}
diff --git a/src/main/java/org/stellar/sdk/operations/SetOptionsOperation.java b/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java
similarity index 84%
rename from src/main/java/org/stellar/sdk/operations/SetOptionsOperation.java
rename to src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java
index 1f2f271f4..02cf45044 100644
--- a/src/main/java/org/stellar/sdk/operations/SetOptionsOperation.java
+++ b/src/main/java/org/stellar/sdk/responses/operations/SetOptionsOperationResponse.java
@@ -1,8 +1,8 @@
-package org.stellar.sdk.operations;
+package org.stellar.sdk.responses.operations;
import com.google.gson.annotations.SerializedName;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
/**
* Represents SetOptions operation response.
@@ -10,7 +10,7 @@
* @see org.stellar.sdk.requests.OperationsRequestBuilder
* @see org.stellar.sdk.Server#operations()
*/
-public class SetOptionsOperation extends Operation {
+public class SetOptionsOperationResponse extends OperationResponse {
@SerializedName("low_threshold")
protected final Integer lowThreshold;
@SerializedName("med_threshold")
@@ -32,7 +32,7 @@ public class SetOptionsOperation extends Operation {
@SerializedName("set_flags_s")
protected final String[] setFlags;
- SetOptionsOperation(Integer lowThreshold, Integer medThreshold, Integer highThreshold, KeyPair inflationDestination, String homeDomain, KeyPair signerKey, Integer signerWeight, Integer masterKeyWeight, String[] clearFlags, String[] setFlags) {
+ SetOptionsOperationResponse(Integer lowThreshold, Integer medThreshold, Integer highThreshold, KeyPair inflationDestination, String homeDomain, KeyPair signerKey, Integer signerWeight, Integer masterKeyWeight, String[] clearFlags, String[] setFlags) {
this.lowThreshold = lowThreshold;
this.medThreshold = medThreshold;
this.highThreshold = highThreshold;
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountEntry.java b/src/main/java/org/stellar/sdk/xdr/AccountEntry.java
new file mode 100644
index 000000000..405f4738a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AccountEntry.java
@@ -0,0 +1,180 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct AccountEntry
+// {
+// AccountID accountID; // master public key for this account
+// int64 balance; // in stroops
+// SequenceNumber seqNum; // last sequence number used for this account
+// uint32 numSubEntries; // number of sub-entries this account has
+// // drives the reserve
+// AccountID* inflationDest; // Account to vote for during inflation
+// uint32 flags; // see AccountFlags
+//
+// string32 homeDomain; // can be used for reverse federation and memo lookup
+//
+// // fields used for signatures
+// // thresholds stores unsigned bytes: [weight of master|low|medium|high]
+// Thresholds thresholds;
+//
+// Signer signers<20>; // possible signers for this account
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class AccountEntry {
+ public AccountEntry () {}
+ private AccountID accountID;
+ public AccountID getAccountID() {
+ return this.accountID;
+ }
+ public void setAccountID(AccountID value) {
+ this.accountID = value;
+ }
+ private Int64 balance;
+ public Int64 getBalance() {
+ return this.balance;
+ }
+ public void setBalance(Int64 value) {
+ this.balance = value;
+ }
+ private SequenceNumber seqNum;
+ public SequenceNumber getSeqNum() {
+ return this.seqNum;
+ }
+ public void setSeqNum(SequenceNumber value) {
+ this.seqNum = value;
+ }
+ private Uint32 numSubEntries;
+ public Uint32 getNumSubEntries() {
+ return this.numSubEntries;
+ }
+ public void setNumSubEntries(Uint32 value) {
+ this.numSubEntries = value;
+ }
+ private AccountID inflationDest;
+ public AccountID getInflationDest() {
+ return this.inflationDest;
+ }
+ public void setInflationDest(AccountID value) {
+ this.inflationDest = value;
+ }
+ private Uint32 flags;
+ public Uint32 getFlags() {
+ return this.flags;
+ }
+ public void setFlags(Uint32 value) {
+ this.flags = value;
+ }
+ private String32 homeDomain;
+ public String32 getHomeDomain() {
+ return this.homeDomain;
+ }
+ public void setHomeDomain(String32 value) {
+ this.homeDomain = value;
+ }
+ private Thresholds thresholds;
+ public Thresholds getThresholds() {
+ return this.thresholds;
+ }
+ public void setThresholds(Thresholds value) {
+ this.thresholds = value;
+ }
+ private Signer[] signers;
+ public Signer[] getSigners() {
+ return this.signers;
+ }
+ public void setSigners(Signer[] value) {
+ this.signers = value;
+ }
+ private AccountEntryExt ext;
+ public AccountEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(AccountEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AccountEntry encodedAccountEntry) throws IOException{
+ AccountID.encode(stream, encodedAccountEntry.accountID);
+ Int64.encode(stream, encodedAccountEntry.balance);
+ SequenceNumber.encode(stream, encodedAccountEntry.seqNum);
+ Uint32.encode(stream, encodedAccountEntry.numSubEntries);
+ if (encodedAccountEntry.inflationDest != null) {
+ stream.writeInt(1);
+ AccountID.encode(stream, encodedAccountEntry.inflationDest);
+ } else {
+ stream.writeInt(0);
+ }
+ Uint32.encode(stream, encodedAccountEntry.flags);
+ String32.encode(stream, encodedAccountEntry.homeDomain);
+ Thresholds.encode(stream, encodedAccountEntry.thresholds);
+ int signerssize = encodedAccountEntry.getSigners().length;
+ stream.writeInt(signerssize);
+ for (int i = 0; i < signerssize; i++) {
+ Signer.encode(stream, encodedAccountEntry.signers[i]);
+ }
+ AccountEntryExt.encode(stream, encodedAccountEntry.ext);
+ }
+ public static AccountEntry decode(XdrDataInputStream stream) throws IOException {
+ AccountEntry decodedAccountEntry = new AccountEntry();
+ decodedAccountEntry.accountID = AccountID.decode(stream);
+ decodedAccountEntry.balance = Int64.decode(stream);
+ decodedAccountEntry.seqNum = SequenceNumber.decode(stream);
+ decodedAccountEntry.numSubEntries = Uint32.decode(stream);
+ int inflationDestPresent = stream.readInt();
+ if (inflationDestPresent != 0) {
+ decodedAccountEntry.inflationDest = AccountID.decode(stream);
+ }
+ decodedAccountEntry.flags = Uint32.decode(stream);
+ decodedAccountEntry.homeDomain = String32.decode(stream);
+ decodedAccountEntry.thresholds = Thresholds.decode(stream);
+ int signerssize = stream.readInt();
+ decodedAccountEntry.signers = new Signer[signerssize];
+ for (int i = 0; i < signerssize; i++) {
+ decodedAccountEntry.signers[i] = Signer.decode(stream);
+ }
+ decodedAccountEntry.ext = AccountEntryExt.decode(stream);
+ return decodedAccountEntry;
+ }
+
+ public static class AccountEntryExt {
+ public AccountEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AccountEntryExt encodedAccountEntryExt) throws IOException {
+ stream.writeInt(encodedAccountEntryExt.getDiscriminant().intValue());
+ switch (encodedAccountEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static AccountEntryExt decode(XdrDataInputStream stream) throws IOException {
+ AccountEntryExt decodedAccountEntryExt = new AccountEntryExt();
+ switch (decodedAccountEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedAccountEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountFlags.java b/src/main/java/org/stellar/sdk/xdr/AccountFlags.java
new file mode 100644
index 000000000..24002321c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AccountFlags.java
@@ -0,0 +1,55 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum AccountFlags
+// { // masks for each flag
+//
+// // Flags set on issuer accounts
+// // TrustLines are created with authorized set to "false" requiring
+// // the issuer to set it for each TrustLine
+// AUTH_REQUIRED_FLAG = 0x1,
+// // If set, the authorized flag in TrustLines can be cleared
+// // otherwise, authorization cannot be revoked
+// AUTH_REVOCABLE_FLAG = 0x2,
+// // Once set, causes all AUTH_* flags to be read-only
+// AUTH_IMMUTABLE_FLAG = 0x4
+// };
+
+// ===========================================================================
+public enum AccountFlags {
+ AUTH_REQUIRED_FLAG(1),
+ AUTH_REVOCABLE_FLAG(2),
+ AUTH_IMMUTABLE_FLAG(4),
+ ;
+ private int mValue;
+
+ AccountFlags(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static AccountFlags decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 1: return AUTH_REQUIRED_FLAG;
+ case 2: return AUTH_REVOCABLE_FLAG;
+ case 4: return AUTH_IMMUTABLE_FLAG;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, AccountFlags value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountID.java b/src/main/java/org/stellar/sdk/xdr/AccountID.java
new file mode 100644
index 000000000..92d6e0a6b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AccountID.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef PublicKey AccountID;
+
+// ===========================================================================
+public class AccountID {
+ private PublicKey AccountID;
+ public PublicKey getAccountID() {
+ return this.AccountID;
+ }
+ public void setAccountID(PublicKey value) {
+ this.AccountID = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AccountID encodedAccountID) throws IOException {
+ PublicKey.encode(stream, encodedAccountID.AccountID);
+ }
+ public static AccountID decode(XdrDataInputStream stream) throws IOException {
+ AccountID decodedAccountID = new AccountID();
+ decodedAccountID.AccountID = PublicKey.decode(stream);
+ return decodedAccountID;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java b/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
new file mode 100644
index 000000000..a5c91479a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AccountMergeResult.java
@@ -0,0 +1,57 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union AccountMergeResult switch (AccountMergeResultCode code)
+// {
+// case ACCOUNT_MERGE_SUCCESS:
+// int64 sourceAccountBalance; // how much got transfered from source account
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class AccountMergeResult {
+ public AccountMergeResult () {}
+ AccountMergeResultCode code;
+ public AccountMergeResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(AccountMergeResultCode value) {
+ this.code = value;
+ }
+ private Int64 sourceAccountBalance;
+ public Int64 getSourceAccountBalance() {
+ return this.sourceAccountBalance;
+ }
+ public void setSourceAccountBalance(Int64 value) {
+ this.sourceAccountBalance = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AccountMergeResult encodedAccountMergeResult) throws IOException {
+ stream.writeInt(encodedAccountMergeResult.getDiscriminant().getValue());
+ switch (encodedAccountMergeResult.getDiscriminant()) {
+ case ACCOUNT_MERGE_SUCCESS:
+ Int64.encode(stream, encodedAccountMergeResult.sourceAccountBalance);
+ break;
+ default:
+ break;
+ }
+ }
+ public static AccountMergeResult decode(XdrDataInputStream stream) throws IOException {
+ AccountMergeResult decodedAccountMergeResult = new AccountMergeResult();
+ switch (decodedAccountMergeResult.getDiscriminant()) {
+ case ACCOUNT_MERGE_SUCCESS:
+ decodedAccountMergeResult.sourceAccountBalance = Int64.decode(stream);
+ break;
+ default:
+ break;
+ }
+ return decodedAccountMergeResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java b/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java
new file mode 100644
index 000000000..410f58d81
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AccountMergeResultCode.java
@@ -0,0 +1,56 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum AccountMergeResultCode
+// {
+// // codes considered as "success" for the operation
+// ACCOUNT_MERGE_SUCCESS = 0,
+// // codes considered as "failure" for the operation
+// ACCOUNT_MERGE_MALFORMED = -1, // can't merge onto itself
+// ACCOUNT_MERGE_NO_ACCOUNT = -2, // destination does not exist
+// ACCOUNT_MERGE_IMMUTABLE_SET = -3, // source account has AUTH_IMMUTABLE set
+// ACCOUNT_MERGE_HAS_SUB_ENTRIES = -4 // account has trust lines/offers
+// };
+
+// ===========================================================================
+public enum AccountMergeResultCode {
+ ACCOUNT_MERGE_SUCCESS(0),
+ ACCOUNT_MERGE_MALFORMED(-1),
+ ACCOUNT_MERGE_NO_ACCOUNT(-2),
+ ACCOUNT_MERGE_IMMUTABLE_SET(-3),
+ ACCOUNT_MERGE_HAS_SUB_ENTRIES(-4),
+ ;
+ private int mValue;
+
+ AccountMergeResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static AccountMergeResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ACCOUNT_MERGE_SUCCESS;
+ case -1: return ACCOUNT_MERGE_MALFORMED;
+ case -2: return ACCOUNT_MERGE_NO_ACCOUNT;
+ case -3: return ACCOUNT_MERGE_IMMUTABLE_SET;
+ case -4: return ACCOUNT_MERGE_HAS_SUB_ENTRIES;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, AccountMergeResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
new file mode 100644
index 000000000..d112697de
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustOp.java
@@ -0,0 +1,121 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct AllowTrustOp
+// {
+// AccountID trustor;
+// union switch (AssetType type)
+// {
+// // ASSET_TYPE_NATIVE is not allowed
+// case ASSET_TYPE_CREDIT_ALPHANUM4:
+// opaque assetCode4[4];
+//
+// case ASSET_TYPE_CREDIT_ALPHANUM12:
+// opaque assetCode12[12];
+//
+// // add other asset types here in the future
+// }
+// asset;
+//
+// bool authorize;
+// };
+
+// ===========================================================================
+public class AllowTrustOp {
+ public AllowTrustOp () {}
+ private AccountID trustor;
+ public AccountID getTrustor() {
+ return this.trustor;
+ }
+ public void setTrustor(AccountID value) {
+ this.trustor = value;
+ }
+ private AllowTrustOpAsset asset;
+ public AllowTrustOpAsset getAsset() {
+ return this.asset;
+ }
+ public void setAsset(AllowTrustOpAsset value) {
+ this.asset = value;
+ }
+ private Boolean authorize;
+ public Boolean getAuthorize() {
+ return this.authorize;
+ }
+ public void setAuthorize(Boolean value) {
+ this.authorize = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AllowTrustOp encodedAllowTrustOp) throws IOException{
+ AccountID.encode(stream, encodedAllowTrustOp.trustor);
+ AllowTrustOpAsset.encode(stream, encodedAllowTrustOp.asset);
+ stream.writeInt(encodedAllowTrustOp.authorize ? 1 : 0);
+ }
+ public static AllowTrustOp decode(XdrDataInputStream stream) throws IOException {
+ AllowTrustOp decodedAllowTrustOp = new AllowTrustOp();
+ decodedAllowTrustOp.trustor = AccountID.decode(stream);
+ decodedAllowTrustOp.asset = AllowTrustOpAsset.decode(stream);
+ decodedAllowTrustOp.authorize = stream.readInt() == 1 ? true : false;
+ return decodedAllowTrustOp;
+ }
+
+ public static class AllowTrustOpAsset {
+ public AllowTrustOpAsset () {}
+ AssetType type;
+ public AssetType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(AssetType value) {
+ this.type = value;
+ }
+ private byte[] assetCode4;
+ public byte[] getAssetCode4() {
+ return this.assetCode4;
+ }
+ public void setAssetCode4(byte[] value) {
+ this.assetCode4 = value;
+ }
+ private byte[] assetCode12;
+ public byte[] getAssetCode12() {
+ return this.assetCode12;
+ }
+ public void setAssetCode12(byte[] value) {
+ this.assetCode12 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AllowTrustOpAsset encodedAllowTrustOpAsset) throws IOException {
+ stream.writeInt(encodedAllowTrustOpAsset.getDiscriminant().getValue());
+ switch (encodedAllowTrustOpAsset.getDiscriminant()) {
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ int assetCode4size = encodedAllowTrustOpAsset.assetCode4.length;
+ stream.write(encodedAllowTrustOpAsset.getAssetCode4(), 0, assetCode4size);
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ int assetCode12size = encodedAllowTrustOpAsset.assetCode12.length;
+ stream.write(encodedAllowTrustOpAsset.getAssetCode12(), 0, assetCode12size);
+ break;
+ }
+ }
+ public static AllowTrustOpAsset decode(XdrDataInputStream stream) throws IOException {
+ AllowTrustOpAsset decodedAllowTrustOpAsset = new AllowTrustOpAsset();
+ switch (decodedAllowTrustOpAsset.getDiscriminant()) {
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ int assetCode4size = 4;
+ decodedAllowTrustOpAsset.assetCode4 = new byte[assetCode4size];
+ stream.read(decodedAllowTrustOpAsset.assetCode4, 0, assetCode4size);
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ int assetCode12size = 12;
+ decodedAllowTrustOpAsset.assetCode12 = new byte[assetCode12size];
+ stream.read(decodedAllowTrustOpAsset.assetCode12, 0, assetCode12size);
+ break;
+ }
+ return decodedAllowTrustOpAsset;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
new file mode 100644
index 000000000..e2d84927f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustResult.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union AllowTrustResult switch (AllowTrustResultCode code)
+// {
+// case ALLOW_TRUST_SUCCESS:
+// void;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class AllowTrustResult {
+ public AllowTrustResult () {}
+ AllowTrustResultCode code;
+ public AllowTrustResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(AllowTrustResultCode value) {
+ this.code = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AllowTrustResult encodedAllowTrustResult) throws IOException {
+ stream.writeInt(encodedAllowTrustResult.getDiscriminant().getValue());
+ switch (encodedAllowTrustResult.getDiscriminant()) {
+ case ALLOW_TRUST_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ }
+ public static AllowTrustResult decode(XdrDataInputStream stream) throws IOException {
+ AllowTrustResult decodedAllowTrustResult = new AllowTrustResult();
+ switch (decodedAllowTrustResult.getDiscriminant()) {
+ case ALLOW_TRUST_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ return decodedAllowTrustResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java b/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java
new file mode 100644
index 000000000..e766c79b1
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AllowTrustResultCode.java
@@ -0,0 +1,57 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum AllowTrustResultCode
+// {
+// // codes considered as "success" for the operation
+// ALLOW_TRUST_SUCCESS = 0,
+// // codes considered as "failure" for the operation
+// ALLOW_TRUST_MALFORMED = -1, // asset is not ASSET_TYPE_ALPHANUM
+// ALLOW_TRUST_NO_TRUST_LINE = -2, // trustor does not have a trustline
+// // source account does not require trust
+// ALLOW_TRUST_TRUST_NOT_REQUIRED = -3,
+// ALLOW_TRUST_CANT_REVOKE = -4 // source account can't revoke trust
+// };
+
+// ===========================================================================
+public enum AllowTrustResultCode {
+ ALLOW_TRUST_SUCCESS(0),
+ ALLOW_TRUST_MALFORMED(-1),
+ ALLOW_TRUST_NO_TRUST_LINE(-2),
+ ALLOW_TRUST_TRUST_NOT_REQUIRED(-3),
+ ALLOW_TRUST_CANT_REVOKE(-4),
+ ;
+ private int mValue;
+
+ AllowTrustResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static AllowTrustResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ALLOW_TRUST_SUCCESS;
+ case -1: return ALLOW_TRUST_MALFORMED;
+ case -2: return ALLOW_TRUST_NO_TRUST_LINE;
+ case -3: return ALLOW_TRUST_TRUST_NOT_REQUIRED;
+ case -4: return ALLOW_TRUST_CANT_REVOKE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, AllowTrustResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Asset.java b/src/main/java/org/stellar/sdk/xdr/Asset.java
new file mode 100644
index 000000000..dd597712b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Asset.java
@@ -0,0 +1,147 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union Asset switch (AssetType type)
+// {
+// case ASSET_TYPE_NATIVE: // Not credit
+// void;
+//
+// case ASSET_TYPE_CREDIT_ALPHANUM4:
+// struct
+// {
+// opaque assetCode[4]; // 1 to 4 characters
+// AccountID issuer;
+// } alphaNum4;
+//
+// case ASSET_TYPE_CREDIT_ALPHANUM12:
+// struct
+// {
+// opaque assetCode[12]; // 5 to 12 characters
+// AccountID issuer;
+// } alphaNum12;
+//
+// // add other asset types here in the future
+// };
+
+// ===========================================================================
+public class Asset {
+ public Asset () {}
+ AssetType type;
+ public AssetType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(AssetType value) {
+ this.type = value;
+ }
+ private AssetAlphaNum4 alphaNum4;
+ public AssetAlphaNum4 getAlphaNum4() {
+ return this.alphaNum4;
+ }
+ public void setAlphaNum4(AssetAlphaNum4 value) {
+ this.alphaNum4 = value;
+ }
+ private AssetAlphaNum12 alphaNum12;
+ public AssetAlphaNum12 getAlphaNum12() {
+ return this.alphaNum12;
+ }
+ public void setAlphaNum12(AssetAlphaNum12 value) {
+ this.alphaNum12 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Asset encodedAsset) throws IOException {
+ stream.writeInt(encodedAsset.getDiscriminant().getValue());
+ switch (encodedAsset.getDiscriminant()) {
+ case ASSET_TYPE_NATIVE:
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ AssetAlphaNum4.encode(stream, encodedAsset.alphaNum4);
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ AssetAlphaNum12.encode(stream, encodedAsset.alphaNum12);
+ break;
+ }
+ }
+ public static Asset decode(XdrDataInputStream stream) throws IOException {
+ Asset decodedAsset = new Asset();
+ switch (decodedAsset.getDiscriminant()) {
+ case ASSET_TYPE_NATIVE:
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM4:
+ decodedAsset.alphaNum4 = AssetAlphaNum4.decode(stream);
+ break;
+ case ASSET_TYPE_CREDIT_ALPHANUM12:
+ decodedAsset.alphaNum12 = AssetAlphaNum12.decode(stream);
+ break;
+ }
+ return decodedAsset;
+ }
+
+ public static class AssetAlphaNum4 {
+ public AssetAlphaNum4 () {}
+ private byte[] assetCode;
+ public byte[] getAssetCode() {
+ return this.assetCode;
+ }
+ public void setAssetCode(byte[] value) {
+ this.assetCode = value;
+ }
+ private AccountID issuer;
+ public AccountID getIssuer() {
+ return this.issuer;
+ }
+ public void setIssuer(AccountID value) {
+ this.issuer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AssetAlphaNum4 encodedAssetAlphaNum4) throws IOException{
+ int assetCodesize = encodedAssetAlphaNum4.assetCode.length;
+ stream.write(encodedAssetAlphaNum4.getAssetCode(), 0, assetCodesize);
+ AccountID.encode(stream, encodedAssetAlphaNum4.issuer);
+ }
+ public static AssetAlphaNum4 decode(XdrDataInputStream stream) throws IOException {
+ AssetAlphaNum4 decodedAssetAlphaNum4 = new AssetAlphaNum4();
+ int assetCodesize = 4;
+ decodedAssetAlphaNum4.assetCode = new byte[assetCodesize];
+ stream.read(decodedAssetAlphaNum4.assetCode, 0, assetCodesize);
+ decodedAssetAlphaNum4.issuer = AccountID.decode(stream);
+ return decodedAssetAlphaNum4;
+ }
+
+ }
+ public static class AssetAlphaNum12 {
+ public AssetAlphaNum12 () {}
+ private byte[] assetCode;
+ public byte[] getAssetCode() {
+ return this.assetCode;
+ }
+ public void setAssetCode(byte[] value) {
+ this.assetCode = value;
+ }
+ private AccountID issuer;
+ public AccountID getIssuer() {
+ return this.issuer;
+ }
+ public void setIssuer(AccountID value) {
+ this.issuer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AssetAlphaNum12 encodedAssetAlphaNum12) throws IOException{
+ int assetCodesize = encodedAssetAlphaNum12.assetCode.length;
+ stream.write(encodedAssetAlphaNum12.getAssetCode(), 0, assetCodesize);
+ AccountID.encode(stream, encodedAssetAlphaNum12.issuer);
+ }
+ public static AssetAlphaNum12 decode(XdrDataInputStream stream) throws IOException {
+ AssetAlphaNum12 decodedAssetAlphaNum12 = new AssetAlphaNum12();
+ int assetCodesize = 12;
+ decodedAssetAlphaNum12.assetCode = new byte[assetCodesize];
+ stream.read(decodedAssetAlphaNum12.assetCode, 0, assetCodesize);
+ decodedAssetAlphaNum12.issuer = AccountID.decode(stream);
+ return decodedAssetAlphaNum12;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AssetType.java b/src/main/java/org/stellar/sdk/xdr/AssetType.java
new file mode 100644
index 000000000..aee598523
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AssetType.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum AssetType
+// {
+// ASSET_TYPE_NATIVE = 0,
+// ASSET_TYPE_CREDIT_ALPHANUM4 = 1,
+// ASSET_TYPE_CREDIT_ALPHANUM12 = 2
+// };
+
+// ===========================================================================
+public enum AssetType {
+ ASSET_TYPE_NATIVE(0),
+ ASSET_TYPE_CREDIT_ALPHANUM4(1),
+ ASSET_TYPE_CREDIT_ALPHANUM12(2),
+ ;
+ private int mValue;
+
+ AssetType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static AssetType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ASSET_TYPE_NATIVE;
+ case 1: return ASSET_TYPE_CREDIT_ALPHANUM4;
+ case 2: return ASSET_TYPE_CREDIT_ALPHANUM12;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, AssetType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Auth.java b/src/main/java/org/stellar/sdk/xdr/Auth.java
new file mode 100644
index 000000000..cedb715ca
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Auth.java
@@ -0,0 +1,36 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Auth
+// {
+// // Empty message, just to confirm
+// // establishment of MAC keys.
+// int unused;
+// };
+
+// ===========================================================================
+public class Auth {
+ public Auth () {}
+ private Integer unused;
+ public Integer getUnused() {
+ return this.unused;
+ }
+ public void setUnused(Integer value) {
+ this.unused = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Auth encodedAuth) throws IOException{
+ stream.writeInt(encodedAuth.unused);
+ }
+ public static Auth decode(XdrDataInputStream stream) throws IOException {
+ Auth decodedAuth = new Auth();
+ decodedAuth.unused = stream.readInt();
+ return decodedAuth;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AuthCert.java b/src/main/java/org/stellar/sdk/xdr/AuthCert.java
new file mode 100644
index 000000000..d2aa04f04
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AuthCert.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct AuthCert
+// {
+// Curve25519Public pubkey;
+// uint64 expiration;
+// Signature sig;
+// };
+
+// ===========================================================================
+public class AuthCert {
+ public AuthCert () {}
+ private Curve25519Public pubkey;
+ public Curve25519Public getPubkey() {
+ return this.pubkey;
+ }
+ public void setPubkey(Curve25519Public value) {
+ this.pubkey = value;
+ }
+ private Uint64 expiration;
+ public Uint64 getExpiration() {
+ return this.expiration;
+ }
+ public void setExpiration(Uint64 value) {
+ this.expiration = value;
+ }
+ private Signature sig;
+ public Signature getSig() {
+ return this.sig;
+ }
+ public void setSig(Signature value) {
+ this.sig = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AuthCert encodedAuthCert) throws IOException{
+ Curve25519Public.encode(stream, encodedAuthCert.pubkey);
+ Uint64.encode(stream, encodedAuthCert.expiration);
+ Signature.encode(stream, encodedAuthCert.sig);
+ }
+ public static AuthCert decode(XdrDataInputStream stream) throws IOException {
+ AuthCert decodedAuthCert = new AuthCert();
+ decodedAuthCert.pubkey = Curve25519Public.decode(stream);
+ decodedAuthCert.expiration = Uint64.decode(stream);
+ decodedAuthCert.sig = Signature.decode(stream);
+ return decodedAuthCert;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java b/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
new file mode 100644
index 000000000..439f274fb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/AuthenticatedMessage.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct AuthenticatedMessage
+// {
+// uint64 sequence;
+// StellarMessage message;
+// HmacSha256Mac mac;
+// };
+
+// ===========================================================================
+public class AuthenticatedMessage {
+ public AuthenticatedMessage () {}
+ private Uint64 sequence;
+ public Uint64 getSequence() {
+ return this.sequence;
+ }
+ public void setSequence(Uint64 value) {
+ this.sequence = value;
+ }
+ private StellarMessage message;
+ public StellarMessage getMessage() {
+ return this.message;
+ }
+ public void setMessage(StellarMessage value) {
+ this.message = value;
+ }
+ private HmacSha256Mac mac;
+ public HmacSha256Mac getMac() {
+ return this.mac;
+ }
+ public void setMac(HmacSha256Mac value) {
+ this.mac = value;
+ }
+ public static void encode(XdrDataOutputStream stream, AuthenticatedMessage encodedAuthenticatedMessage) throws IOException{
+ Uint64.encode(stream, encodedAuthenticatedMessage.sequence);
+ StellarMessage.encode(stream, encodedAuthenticatedMessage.message);
+ HmacSha256Mac.encode(stream, encodedAuthenticatedMessage.mac);
+ }
+ public static AuthenticatedMessage decode(XdrDataInputStream stream) throws IOException {
+ AuthenticatedMessage decodedAuthenticatedMessage = new AuthenticatedMessage();
+ decodedAuthenticatedMessage.sequence = Uint64.decode(stream);
+ decodedAuthenticatedMessage.message = StellarMessage.decode(stream);
+ decodedAuthenticatedMessage.mac = HmacSha256Mac.decode(stream);
+ return decodedAuthenticatedMessage;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/BucketEntry.java b/src/main/java/org/stellar/sdk/xdr/BucketEntry.java
new file mode 100644
index 000000000..f4e7a11d5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/BucketEntry.java
@@ -0,0 +1,67 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union BucketEntry switch (BucketEntryType type)
+// {
+// case LIVEENTRY:
+// LedgerEntry liveEntry;
+//
+// case DEADENTRY:
+// LedgerKey deadEntry;
+// };
+
+// ===========================================================================
+public class BucketEntry {
+ public BucketEntry () {}
+ BucketEntryType type;
+ public BucketEntryType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(BucketEntryType value) {
+ this.type = value;
+ }
+ private LedgerEntry liveEntry;
+ public LedgerEntry getLiveEntry() {
+ return this.liveEntry;
+ }
+ public void setLiveEntry(LedgerEntry value) {
+ this.liveEntry = value;
+ }
+ private LedgerKey deadEntry;
+ public LedgerKey getDeadEntry() {
+ return this.deadEntry;
+ }
+ public void setDeadEntry(LedgerKey value) {
+ this.deadEntry = value;
+ }
+ public static void encode(XdrDataOutputStream stream, BucketEntry encodedBucketEntry) throws IOException {
+ stream.writeInt(encodedBucketEntry.getDiscriminant().getValue());
+ switch (encodedBucketEntry.getDiscriminant()) {
+ case LIVEENTRY:
+ LedgerEntry.encode(stream, encodedBucketEntry.liveEntry);
+ break;
+ case DEADENTRY:
+ LedgerKey.encode(stream, encodedBucketEntry.deadEntry);
+ break;
+ }
+ }
+ public static BucketEntry decode(XdrDataInputStream stream) throws IOException {
+ BucketEntry decodedBucketEntry = new BucketEntry();
+ switch (decodedBucketEntry.getDiscriminant()) {
+ case LIVEENTRY:
+ decodedBucketEntry.liveEntry = LedgerEntry.decode(stream);
+ break;
+ case DEADENTRY:
+ decodedBucketEntry.deadEntry = LedgerKey.decode(stream);
+ break;
+ }
+ return decodedBucketEntry;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java b/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java
new file mode 100644
index 000000000..daffd7fb3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/BucketEntryType.java
@@ -0,0 +1,45 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum BucketEntryType
+// {
+// LIVEENTRY = 0,
+// DEADENTRY = 1
+// };
+
+// ===========================================================================
+public enum BucketEntryType {
+ LIVEENTRY(0),
+ DEADENTRY(1),
+ ;
+ private int mValue;
+
+ BucketEntryType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static BucketEntryType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return LIVEENTRY;
+ case 1: return DEADENTRY;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, BucketEntryType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java
new file mode 100644
index 000000000..09520a1cf
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustOp.java
@@ -0,0 +1,46 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct ChangeTrustOp
+// {
+// Asset line;
+//
+// // if limit is set to 0, deletes the trust line
+// int64 limit;
+// };
+
+// ===========================================================================
+public class ChangeTrustOp {
+ public ChangeTrustOp () {}
+ private Asset line;
+ public Asset getLine() {
+ return this.line;
+ }
+ public void setLine(Asset value) {
+ this.line = value;
+ }
+ private Int64 limit;
+ public Int64 getLimit() {
+ return this.limit;
+ }
+ public void setLimit(Int64 value) {
+ this.limit = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ChangeTrustOp encodedChangeTrustOp) throws IOException{
+ Asset.encode(stream, encodedChangeTrustOp.line);
+ Int64.encode(stream, encodedChangeTrustOp.limit);
+ }
+ public static ChangeTrustOp decode(XdrDataInputStream stream) throws IOException {
+ ChangeTrustOp decodedChangeTrustOp = new ChangeTrustOp();
+ decodedChangeTrustOp.line = Asset.decode(stream);
+ decodedChangeTrustOp.limit = Int64.decode(stream);
+ return decodedChangeTrustOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
new file mode 100644
index 000000000..a2dad4f4d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResult.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union ChangeTrustResult switch (ChangeTrustResultCode code)
+// {
+// case CHANGE_TRUST_SUCCESS:
+// void;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class ChangeTrustResult {
+ public ChangeTrustResult () {}
+ ChangeTrustResultCode code;
+ public ChangeTrustResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(ChangeTrustResultCode value) {
+ this.code = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ChangeTrustResult encodedChangeTrustResult) throws IOException {
+ stream.writeInt(encodedChangeTrustResult.getDiscriminant().getValue());
+ switch (encodedChangeTrustResult.getDiscriminant()) {
+ case CHANGE_TRUST_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ }
+ public static ChangeTrustResult decode(XdrDataInputStream stream) throws IOException {
+ ChangeTrustResult decodedChangeTrustResult = new ChangeTrustResult();
+ switch (decodedChangeTrustResult.getDiscriminant()) {
+ case CHANGE_TRUST_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ return decodedChangeTrustResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java
new file mode 100644
index 000000000..b24550ffa
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ChangeTrustResultCode.java
@@ -0,0 +1,57 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ChangeTrustResultCode
+// {
+// // codes considered as "success" for the operation
+// CHANGE_TRUST_SUCCESS = 0,
+// // codes considered as "failure" for the operation
+// CHANGE_TRUST_MALFORMED = -1, // bad input
+// CHANGE_TRUST_NO_ISSUER = -2, // could not find issuer
+// CHANGE_TRUST_INVALID_LIMIT = -3, // cannot drop limit below balance
+// // cannot create with a limit of 0
+// CHANGE_TRUST_LOW_RESERVE = -4 // not enough funds to create a new trust line
+// };
+
+// ===========================================================================
+public enum ChangeTrustResultCode {
+ CHANGE_TRUST_SUCCESS(0),
+ CHANGE_TRUST_MALFORMED(-1),
+ CHANGE_TRUST_NO_ISSUER(-2),
+ CHANGE_TRUST_INVALID_LIMIT(-3),
+ CHANGE_TRUST_LOW_RESERVE(-4),
+ ;
+ private int mValue;
+
+ ChangeTrustResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ChangeTrustResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return CHANGE_TRUST_SUCCESS;
+ case -1: return CHANGE_TRUST_MALFORMED;
+ case -2: return CHANGE_TRUST_NO_ISSUER;
+ case -3: return CHANGE_TRUST_INVALID_LIMIT;
+ case -4: return CHANGE_TRUST_LOW_RESERVE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ChangeTrustResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
new file mode 100644
index 000000000..5490d37ad
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ClaimOfferAtom.java
@@ -0,0 +1,89 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct ClaimOfferAtom
+// {
+// // emited to identify the offer
+// AccountID sellerID; // Account that owns the offer
+// uint64 offerID;
+//
+// // amount and asset taken from the owner
+// Asset assetSold;
+// int64 amountSold;
+//
+// // amount and asset sent to the owner
+// Asset assetBought;
+// int64 amountBought;
+// };
+
+// ===========================================================================
+public class ClaimOfferAtom {
+ public ClaimOfferAtom () {}
+ private AccountID sellerID;
+ public AccountID getSellerID() {
+ return this.sellerID;
+ }
+ public void setSellerID(AccountID value) {
+ this.sellerID = value;
+ }
+ private Uint64 offerID;
+ public Uint64 getOfferID() {
+ return this.offerID;
+ }
+ public void setOfferID(Uint64 value) {
+ this.offerID = value;
+ }
+ private Asset assetSold;
+ public Asset getAssetSold() {
+ return this.assetSold;
+ }
+ public void setAssetSold(Asset value) {
+ this.assetSold = value;
+ }
+ private Int64 amountSold;
+ public Int64 getAmountSold() {
+ return this.amountSold;
+ }
+ public void setAmountSold(Int64 value) {
+ this.amountSold = value;
+ }
+ private Asset assetBought;
+ public Asset getAssetBought() {
+ return this.assetBought;
+ }
+ public void setAssetBought(Asset value) {
+ this.assetBought = value;
+ }
+ private Int64 amountBought;
+ public Int64 getAmountBought() {
+ return this.amountBought;
+ }
+ public void setAmountBought(Int64 value) {
+ this.amountBought = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ClaimOfferAtom encodedClaimOfferAtom) throws IOException{
+ AccountID.encode(stream, encodedClaimOfferAtom.sellerID);
+ Uint64.encode(stream, encodedClaimOfferAtom.offerID);
+ Asset.encode(stream, encodedClaimOfferAtom.assetSold);
+ Int64.encode(stream, encodedClaimOfferAtom.amountSold);
+ Asset.encode(stream, encodedClaimOfferAtom.assetBought);
+ Int64.encode(stream, encodedClaimOfferAtom.amountBought);
+ }
+ public static ClaimOfferAtom decode(XdrDataInputStream stream) throws IOException {
+ ClaimOfferAtom decodedClaimOfferAtom = new ClaimOfferAtom();
+ decodedClaimOfferAtom.sellerID = AccountID.decode(stream);
+ decodedClaimOfferAtom.offerID = Uint64.decode(stream);
+ decodedClaimOfferAtom.assetSold = Asset.decode(stream);
+ decodedClaimOfferAtom.amountSold = Int64.decode(stream);
+ decodedClaimOfferAtom.assetBought = Asset.decode(stream);
+ decodedClaimOfferAtom.amountBought = Int64.decode(stream);
+ return decodedClaimOfferAtom;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java
new file mode 100644
index 000000000..def2fd238
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountOp.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct CreateAccountOp
+// {
+// AccountID destination; // account to create
+// int64 startingBalance; // amount they end up with
+// };
+
+// ===========================================================================
+public class CreateAccountOp {
+ public CreateAccountOp () {}
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ private Int64 startingBalance;
+ public Int64 getStartingBalance() {
+ return this.startingBalance;
+ }
+ public void setStartingBalance(Int64 value) {
+ this.startingBalance = value;
+ }
+ public static void encode(XdrDataOutputStream stream, CreateAccountOp encodedCreateAccountOp) throws IOException{
+ AccountID.encode(stream, encodedCreateAccountOp.destination);
+ Int64.encode(stream, encodedCreateAccountOp.startingBalance);
+ }
+ public static CreateAccountOp decode(XdrDataInputStream stream) throws IOException {
+ CreateAccountOp decodedCreateAccountOp = new CreateAccountOp();
+ decodedCreateAccountOp.destination = AccountID.decode(stream);
+ decodedCreateAccountOp.startingBalance = Int64.decode(stream);
+ return decodedCreateAccountOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
new file mode 100644
index 000000000..2f26e2b9f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountResult.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union CreateAccountResult switch (CreateAccountResultCode code)
+// {
+// case CREATE_ACCOUNT_SUCCESS:
+// void;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class CreateAccountResult {
+ public CreateAccountResult () {}
+ CreateAccountResultCode code;
+ public CreateAccountResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(CreateAccountResultCode value) {
+ this.code = value;
+ }
+ public static void encode(XdrDataOutputStream stream, CreateAccountResult encodedCreateAccountResult) throws IOException {
+ stream.writeInt(encodedCreateAccountResult.getDiscriminant().getValue());
+ switch (encodedCreateAccountResult.getDiscriminant()) {
+ case CREATE_ACCOUNT_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ }
+ public static CreateAccountResult decode(XdrDataInputStream stream) throws IOException {
+ CreateAccountResult decodedCreateAccountResult = new CreateAccountResult();
+ switch (decodedCreateAccountResult.getDiscriminant()) {
+ case CREATE_ACCOUNT_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ return decodedCreateAccountResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java b/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java
new file mode 100644
index 000000000..8218c20bb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CreateAccountResultCode.java
@@ -0,0 +1,58 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum CreateAccountResultCode
+// {
+// // codes considered as "success" for the operation
+// CREATE_ACCOUNT_SUCCESS = 0, // account was created
+//
+// // codes considered as "failure" for the operation
+// CREATE_ACCOUNT_MALFORMED = -1, // invalid destination
+// CREATE_ACCOUNT_UNDERFUNDED = -2, // not enough funds in source account
+// CREATE_ACCOUNT_LOW_RESERVE =
+// -3, // would create an account below the min reserve
+// CREATE_ACCOUNT_ALREADY_EXIST = -4 // account already exists
+// };
+
+// ===========================================================================
+public enum CreateAccountResultCode {
+ CREATE_ACCOUNT_SUCCESS(0),
+ CREATE_ACCOUNT_MALFORMED(-1),
+ CREATE_ACCOUNT_UNDERFUNDED(-2),
+ CREATE_ACCOUNT_LOW_RESERVE(-3),
+ CREATE_ACCOUNT_ALREADY_EXIST(-4),
+ ;
+ private int mValue;
+
+ CreateAccountResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static CreateAccountResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return CREATE_ACCOUNT_SUCCESS;
+ case -1: return CREATE_ACCOUNT_MALFORMED;
+ case -2: return CREATE_ACCOUNT_UNDERFUNDED;
+ case -3: return CREATE_ACCOUNT_LOW_RESERVE;
+ case -4: return CREATE_ACCOUNT_ALREADY_EXIST;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, CreateAccountResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java b/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java
new file mode 100644
index 000000000..2deddc435
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CreatePassiveOfferOp.java
@@ -0,0 +1,64 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct CreatePassiveOfferOp
+// {
+// Asset selling; // A
+// Asset buying; // B
+// int64 amount; // amount taker gets. if set to 0, delete the offer
+// Price price; // cost of A in terms of B
+// };
+
+// ===========================================================================
+public class CreatePassiveOfferOp {
+ public CreatePassiveOfferOp () {}
+ private Asset selling;
+ public Asset getSelling() {
+ return this.selling;
+ }
+ public void setSelling(Asset value) {
+ this.selling = value;
+ }
+ private Asset buying;
+ public Asset getBuying() {
+ return this.buying;
+ }
+ public void setBuying(Asset value) {
+ this.buying = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ private Price price;
+ public Price getPrice() {
+ return this.price;
+ }
+ public void setPrice(Price value) {
+ this.price = value;
+ }
+ public static void encode(XdrDataOutputStream stream, CreatePassiveOfferOp encodedCreatePassiveOfferOp) throws IOException{
+ Asset.encode(stream, encodedCreatePassiveOfferOp.selling);
+ Asset.encode(stream, encodedCreatePassiveOfferOp.buying);
+ Int64.encode(stream, encodedCreatePassiveOfferOp.amount);
+ Price.encode(stream, encodedCreatePassiveOfferOp.price);
+ }
+ public static CreatePassiveOfferOp decode(XdrDataInputStream stream) throws IOException {
+ CreatePassiveOfferOp decodedCreatePassiveOfferOp = new CreatePassiveOfferOp();
+ decodedCreatePassiveOfferOp.selling = Asset.decode(stream);
+ decodedCreatePassiveOfferOp.buying = Asset.decode(stream);
+ decodedCreatePassiveOfferOp.amount = Int64.decode(stream);
+ decodedCreatePassiveOfferOp.price = Price.decode(stream);
+ return decodedCreatePassiveOfferOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java b/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java
new file mode 100644
index 000000000..6bc5bb36a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/CryptoKeyType.java
@@ -0,0 +1,42 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum CryptoKeyType
+// {
+// KEY_TYPE_ED25519 = 0
+// };
+
+// ===========================================================================
+public enum CryptoKeyType {
+ KEY_TYPE_ED25519(0),
+ ;
+ private int mValue;
+
+ CryptoKeyType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static CryptoKeyType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return KEY_TYPE_ED25519;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, CryptoKeyType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java b/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java
new file mode 100644
index 000000000..e2a65a062
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Curve25519Public.java
@@ -0,0 +1,37 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Curve25519Public
+// {
+// opaque key[32];
+// };
+
+// ===========================================================================
+public class Curve25519Public {
+ public Curve25519Public () {}
+ private byte[] key;
+ public byte[] getKey() {
+ return this.key;
+ }
+ public void setKey(byte[] value) {
+ this.key = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Curve25519Public encodedCurve25519Public) throws IOException{
+ int keysize = encodedCurve25519Public.key.length;
+ stream.write(encodedCurve25519Public.getKey(), 0, keysize);
+ }
+ public static Curve25519Public decode(XdrDataInputStream stream) throws IOException {
+ Curve25519Public decodedCurve25519Public = new Curve25519Public();
+ int keysize = 32;
+ decodedCurve25519Public.key = new byte[keysize];
+ stream.read(decodedCurve25519Public.key, 0, keysize);
+ return decodedCurve25519Public;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java b/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java
new file mode 100644
index 000000000..2ba03a9c5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Curve25519Secret.java
@@ -0,0 +1,37 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Curve25519Secret
+// {
+// opaque key[32];
+// };
+
+// ===========================================================================
+public class Curve25519Secret {
+ public Curve25519Secret () {}
+ private byte[] key;
+ public byte[] getKey() {
+ return this.key;
+ }
+ public void setKey(byte[] value) {
+ this.key = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Curve25519Secret encodedCurve25519Secret) throws IOException{
+ int keysize = encodedCurve25519Secret.key.length;
+ stream.write(encodedCurve25519Secret.getKey(), 0, keysize);
+ }
+ public static Curve25519Secret decode(XdrDataInputStream stream) throws IOException {
+ Curve25519Secret decodedCurve25519Secret = new Curve25519Secret();
+ int keysize = 32;
+ decodedCurve25519Secret.key = new byte[keysize];
+ stream.read(decodedCurve25519Secret.key, 0, keysize);
+ return decodedCurve25519Secret;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java b/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java
new file mode 100644
index 000000000..27b622b71
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/DecoratedSignature.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct DecoratedSignature
+// {
+// SignatureHint hint; // last 4 bytes of the public key, used as a hint
+// Signature signature; // actual signature
+// };
+
+// ===========================================================================
+public class DecoratedSignature {
+ public DecoratedSignature () {}
+ private SignatureHint hint;
+ public SignatureHint getHint() {
+ return this.hint;
+ }
+ public void setHint(SignatureHint value) {
+ this.hint = value;
+ }
+ private Signature signature;
+ public Signature getSignature() {
+ return this.signature;
+ }
+ public void setSignature(Signature value) {
+ this.signature = value;
+ }
+ public static void encode(XdrDataOutputStream stream, DecoratedSignature encodedDecoratedSignature) throws IOException{
+ SignatureHint.encode(stream, encodedDecoratedSignature.hint);
+ Signature.encode(stream, encodedDecoratedSignature.signature);
+ }
+ public static DecoratedSignature decode(XdrDataInputStream stream) throws IOException {
+ DecoratedSignature decodedDecoratedSignature = new DecoratedSignature();
+ decodedDecoratedSignature.hint = SignatureHint.decode(stream);
+ decodedDecoratedSignature.signature = Signature.decode(stream);
+ return decodedDecoratedSignature;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/DontHave.java b/src/main/java/org/stellar/sdk/xdr/DontHave.java
new file mode 100644
index 000000000..9b3b711af
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/DontHave.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct DontHave
+// {
+// MessageType type;
+// uint256 reqHash;
+// };
+
+// ===========================================================================
+public class DontHave {
+ public DontHave () {}
+ private MessageType type;
+ public MessageType getType() {
+ return this.type;
+ }
+ public void setType(MessageType value) {
+ this.type = value;
+ }
+ private Uint256 reqHash;
+ public Uint256 getReqHash() {
+ return this.reqHash;
+ }
+ public void setReqHash(Uint256 value) {
+ this.reqHash = value;
+ }
+ public static void encode(XdrDataOutputStream stream, DontHave encodedDontHave) throws IOException{
+ MessageType.encode(stream, encodedDontHave.type);
+ Uint256.encode(stream, encodedDontHave.reqHash);
+ }
+ public static DontHave decode(XdrDataInputStream stream) throws IOException {
+ DontHave decodedDontHave = new DontHave();
+ decodedDontHave.type = MessageType.decode(stream);
+ decodedDontHave.reqHash = Uint256.decode(stream);
+ return decodedDontHave;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java b/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java
new file mode 100644
index 000000000..2b6a9c73b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/EnvelopeType.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum EnvelopeType
+// {
+// ENVELOPE_TYPE_SCP = 1,
+// ENVELOPE_TYPE_TX = 2,
+// ENVELOPE_TYPE_AUTH = 3
+// };
+
+// ===========================================================================
+public enum EnvelopeType {
+ ENVELOPE_TYPE_SCP(1),
+ ENVELOPE_TYPE_TX(2),
+ ENVELOPE_TYPE_AUTH(3),
+ ;
+ private int mValue;
+
+ EnvelopeType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static EnvelopeType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 1: return ENVELOPE_TYPE_SCP;
+ case 2: return ENVELOPE_TYPE_TX;
+ case 3: return ENVELOPE_TYPE_AUTH;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, EnvelopeType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Error.java b/src/main/java/org/stellar/sdk/xdr/Error.java
new file mode 100644
index 000000000..7e8df3bb9
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Error.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Error
+// {
+// ErrorCode code;
+// string msg<100>;
+// };
+
+// ===========================================================================
+public class Error {
+ public Error () {}
+ private ErrorCode code;
+ public ErrorCode getCode() {
+ return this.code;
+ }
+ public void setCode(ErrorCode value) {
+ this.code = value;
+ }
+ private String msg;
+ public String getMsg() {
+ return this.msg;
+ }
+ public void setMsg(String value) {
+ this.msg = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Error encodedError) throws IOException{
+ ErrorCode.encode(stream, encodedError.code);
+ stream.writeString(encodedError.msg);
+ }
+ public static Error decode(XdrDataInputStream stream) throws IOException {
+ Error decodedError = new Error();
+ decodedError.code = ErrorCode.decode(stream);
+ decodedError.msg = stream.readString();
+ return decodedError;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ErrorCode.java b/src/main/java/org/stellar/sdk/xdr/ErrorCode.java
new file mode 100644
index 000000000..ec3ad623c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ErrorCode.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ErrorCode
+// {
+// ERR_MISC = 0, // Unspecific error
+// ERR_DATA = 1, // Malformed data
+// ERR_CONF = 2, // Misconfiguration error
+// ERR_AUTH = 3, // Authentication failure
+// ERR_LOAD = 4 // System overloaded
+// };
+
+// ===========================================================================
+public enum ErrorCode {
+ ERR_MISC(0),
+ ERR_DATA(1),
+ ERR_CONF(2),
+ ERR_AUTH(3),
+ ERR_LOAD(4),
+ ;
+ private int mValue;
+
+ ErrorCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ErrorCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ERR_MISC;
+ case 1: return ERR_DATA;
+ case 2: return ERR_CONF;
+ case 3: return ERR_AUTH;
+ case 4: return ERR_LOAD;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ErrorCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Hash.java b/src/main/java/org/stellar/sdk/xdr/Hash.java
new file mode 100644
index 000000000..f8adea987
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Hash.java
@@ -0,0 +1,33 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque Hash[32];
+
+// ===========================================================================
+public class Hash {
+ private byte[] Hash;
+ public byte[] getHash() {
+ return this.Hash;
+ }
+ public void setHash(byte[] value) {
+ this.Hash = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Hash encodedHash) throws IOException {
+ int Hashsize = encodedHash.Hash.length;
+ stream.write(encodedHash.getHash(), 0, Hashsize);
+ }
+ public static Hash decode(XdrDataInputStream stream) throws IOException {
+ Hash decodedHash = new Hash();
+ int Hashsize = 32;
+ decodedHash.Hash = new byte[Hashsize];
+ stream.read(decodedHash.Hash, 0, Hashsize);
+ return decodedHash;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Hello.java b/src/main/java/org/stellar/sdk/xdr/Hello.java
new file mode 100644
index 000000000..f9236974b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Hello.java
@@ -0,0 +1,104 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Hello
+// {
+// uint32 ledgerVersion;
+// uint32 overlayVersion;
+// Hash networkID;
+// string versionStr<100>;
+// int listeningPort;
+// NodeID peerID;
+// AuthCert cert;
+// uint256 nonce;
+// };
+
+// ===========================================================================
+public class Hello {
+ public Hello () {}
+ private Uint32 ledgerVersion;
+ public Uint32 getLedgerVersion() {
+ return this.ledgerVersion;
+ }
+ public void setLedgerVersion(Uint32 value) {
+ this.ledgerVersion = value;
+ }
+ private Uint32 overlayVersion;
+ public Uint32 getOverlayVersion() {
+ return this.overlayVersion;
+ }
+ public void setOverlayVersion(Uint32 value) {
+ this.overlayVersion = value;
+ }
+ private Hash networkID;
+ public Hash getNetworkID() {
+ return this.networkID;
+ }
+ public void setNetworkID(Hash value) {
+ this.networkID = value;
+ }
+ private String versionStr;
+ public String getVersionStr() {
+ return this.versionStr;
+ }
+ public void setVersionStr(String value) {
+ this.versionStr = value;
+ }
+ private Integer listeningPort;
+ public Integer getListeningPort() {
+ return this.listeningPort;
+ }
+ public void setListeningPort(Integer value) {
+ this.listeningPort = value;
+ }
+ private NodeID peerID;
+ public NodeID getPeerID() {
+ return this.peerID;
+ }
+ public void setPeerID(NodeID value) {
+ this.peerID = value;
+ }
+ private AuthCert cert;
+ public AuthCert getCert() {
+ return this.cert;
+ }
+ public void setCert(AuthCert value) {
+ this.cert = value;
+ }
+ private Uint256 nonce;
+ public Uint256 getNonce() {
+ return this.nonce;
+ }
+ public void setNonce(Uint256 value) {
+ this.nonce = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Hello encodedHello) throws IOException{
+ Uint32.encode(stream, encodedHello.ledgerVersion);
+ Uint32.encode(stream, encodedHello.overlayVersion);
+ Hash.encode(stream, encodedHello.networkID);
+ stream.writeString(encodedHello.versionStr);
+ stream.writeInt(encodedHello.listeningPort);
+ NodeID.encode(stream, encodedHello.peerID);
+ AuthCert.encode(stream, encodedHello.cert);
+ Uint256.encode(stream, encodedHello.nonce);
+ }
+ public static Hello decode(XdrDataInputStream stream) throws IOException {
+ Hello decodedHello = new Hello();
+ decodedHello.ledgerVersion = Uint32.decode(stream);
+ decodedHello.overlayVersion = Uint32.decode(stream);
+ decodedHello.networkID = Hash.decode(stream);
+ decodedHello.versionStr = stream.readString();
+ decodedHello.listeningPort = stream.readInt();
+ decodedHello.peerID = NodeID.decode(stream);
+ decodedHello.cert = AuthCert.decode(stream);
+ decodedHello.nonce = Uint256.decode(stream);
+ return decodedHello;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java b/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java
new file mode 100644
index 000000000..e17c74a35
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/HmacSha256Key.java
@@ -0,0 +1,37 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct HmacSha256Key
+// {
+// opaque key[32];
+// };
+
+// ===========================================================================
+public class HmacSha256Key {
+ public HmacSha256Key () {}
+ private byte[] key;
+ public byte[] getKey() {
+ return this.key;
+ }
+ public void setKey(byte[] value) {
+ this.key = value;
+ }
+ public static void encode(XdrDataOutputStream stream, HmacSha256Key encodedHmacSha256Key) throws IOException{
+ int keysize = encodedHmacSha256Key.key.length;
+ stream.write(encodedHmacSha256Key.getKey(), 0, keysize);
+ }
+ public static HmacSha256Key decode(XdrDataInputStream stream) throws IOException {
+ HmacSha256Key decodedHmacSha256Key = new HmacSha256Key();
+ int keysize = 32;
+ decodedHmacSha256Key.key = new byte[keysize];
+ stream.read(decodedHmacSha256Key.key, 0, keysize);
+ return decodedHmacSha256Key;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java b/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java
new file mode 100644
index 000000000..cbfb8b2c2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/HmacSha256Mac.java
@@ -0,0 +1,37 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct HmacSha256Mac
+// {
+// opaque mac[32];
+// };
+
+// ===========================================================================
+public class HmacSha256Mac {
+ public HmacSha256Mac () {}
+ private byte[] mac;
+ public byte[] getMac() {
+ return this.mac;
+ }
+ public void setMac(byte[] value) {
+ this.mac = value;
+ }
+ public static void encode(XdrDataOutputStream stream, HmacSha256Mac encodedHmacSha256Mac) throws IOException{
+ int macsize = encodedHmacSha256Mac.mac.length;
+ stream.write(encodedHmacSha256Mac.getMac(), 0, macsize);
+ }
+ public static HmacSha256Mac decode(XdrDataInputStream stream) throws IOException {
+ HmacSha256Mac decodedHmacSha256Mac = new HmacSha256Mac();
+ int macsize = 32;
+ decodedHmacSha256Mac.mac = new byte[macsize];
+ stream.read(decodedHmacSha256Mac.mac, 0, macsize);
+ return decodedHmacSha256Mac;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/IPAddrType.java b/src/main/java/org/stellar/sdk/xdr/IPAddrType.java
new file mode 100644
index 000000000..edfbbe1b3
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/IPAddrType.java
@@ -0,0 +1,45 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum IPAddrType
+// {
+// IPv4 = 0,
+// IPv6 = 1
+// };
+
+// ===========================================================================
+public enum IPAddrType {
+ IPv4(0),
+ IPv6(1),
+ ;
+ private int mValue;
+
+ IPAddrType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static IPAddrType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return IPv4;
+ case 1: return IPv6;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, IPAddrType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationPayout.java b/src/main/java/org/stellar/sdk/xdr/InflationPayout.java
new file mode 100644
index 000000000..5484ae28d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InflationPayout.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct InflationPayout // or use PaymentResultAtom to limit types?
+// {
+// AccountID destination;
+// int64 amount;
+// };
+
+// ===========================================================================
+public class InflationPayout {
+ public InflationPayout () {}
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ public static void encode(XdrDataOutputStream stream, InflationPayout encodedInflationPayout) throws IOException{
+ AccountID.encode(stream, encodedInflationPayout.destination);
+ Int64.encode(stream, encodedInflationPayout.amount);
+ }
+ public static InflationPayout decode(XdrDataInputStream stream) throws IOException {
+ InflationPayout decodedInflationPayout = new InflationPayout();
+ decodedInflationPayout.destination = AccountID.decode(stream);
+ decodedInflationPayout.amount = Int64.decode(stream);
+ return decodedInflationPayout;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationResult.java b/src/main/java/org/stellar/sdk/xdr/InflationResult.java
new file mode 100644
index 000000000..0e8d691fb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InflationResult.java
@@ -0,0 +1,65 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union InflationResult switch (InflationResultCode code)
+// {
+// case INFLATION_SUCCESS:
+// InflationPayout payouts<>;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class InflationResult {
+ public InflationResult () {}
+ InflationResultCode code;
+ public InflationResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(InflationResultCode value) {
+ this.code = value;
+ }
+ private InflationPayout[] payouts;
+ public InflationPayout[] getPayouts() {
+ return this.payouts;
+ }
+ public void setPayouts(InflationPayout[] value) {
+ this.payouts = value;
+ }
+ public static void encode(XdrDataOutputStream stream, InflationResult encodedInflationResult) throws IOException {
+ stream.writeInt(encodedInflationResult.getDiscriminant().getValue());
+ switch (encodedInflationResult.getDiscriminant()) {
+ case INFLATION_SUCCESS:
+ int payoutssize = encodedInflationResult.getPayouts().length;
+ stream.writeInt(payoutssize);
+ for (int i = 0; i < payoutssize; i++) {
+ InflationPayout.encode(stream, encodedInflationResult.payouts[i]);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ public static InflationResult decode(XdrDataInputStream stream) throws IOException {
+ InflationResult decodedInflationResult = new InflationResult();
+ switch (decodedInflationResult.getDiscriminant()) {
+ case INFLATION_SUCCESS:
+ int payoutssize = stream.readInt();
+ decodedInflationResult.payouts = new InflationPayout[payoutssize];
+ for (int i = 0; i < payoutssize; i++) {
+ decodedInflationResult.payouts[i] = InflationPayout.decode(stream);
+ }
+ break;
+ default:
+ break;
+ }
+ return decodedInflationResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java b/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java
new file mode 100644
index 000000000..d146a9978
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/InflationResultCode.java
@@ -0,0 +1,47 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum InflationResultCode
+// {
+// // codes considered as "success" for the operation
+// INFLATION_SUCCESS = 0,
+// // codes considered as "failure" for the operation
+// INFLATION_NOT_TIME = -1
+// };
+
+// ===========================================================================
+public enum InflationResultCode {
+ INFLATION_SUCCESS(0),
+ INFLATION_NOT_TIME(-1),
+ ;
+ private int mValue;
+
+ InflationResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static InflationResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return INFLATION_SUCCESS;
+ case -1: return INFLATION_NOT_TIME;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, InflationResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int32.java b/src/main/java/org/stellar/sdk/xdr/Int32.java
new file mode 100644
index 000000000..be9ea4820
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Int32.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef int int32;
+
+// ===========================================================================
+public class Int32 {
+ private Integer int32;
+ public Integer getInt32() {
+ return this.int32;
+ }
+ public void setInt32(Integer value) {
+ this.int32 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Int32 encodedInt32) throws IOException {
+ stream.writeInt(encodedInt32.int32);
+ }
+ public static Int32 decode(XdrDataInputStream stream) throws IOException {
+ Int32 decodedInt32 = new Int32();
+ decodedInt32.int32 = stream.readInt();
+ return decodedInt32;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Int64.java b/src/main/java/org/stellar/sdk/xdr/Int64.java
new file mode 100644
index 000000000..88d0b7ce4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Int64.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef hyper int64;
+
+// ===========================================================================
+public class Int64 {
+ private Long int64;
+ public Long getInt64() {
+ return this.int64;
+ }
+ public void setInt64(Long value) {
+ this.int64 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Int64 encodedInt64) throws IOException {
+ stream.writeLong(encodedInt64.int64);
+ }
+ public static Int64 decode(XdrDataInputStream stream) throws IOException {
+ Int64 decodedInt64 = new Int64();
+ decodedInt64.int64 = stream.readLong();
+ return decodedInt64;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java
new file mode 100644
index 000000000..587ae80c8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntry.java
@@ -0,0 +1,159 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct LedgerEntry
+// {
+// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
+//
+// union switch (LedgerEntryType type)
+// {
+// case ACCOUNT:
+// AccountEntry account;
+// case TRUSTLINE:
+// TrustLineEntry trustLine;
+// case OFFER:
+// OfferEntry offer;
+// }
+// data;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class LedgerEntry {
+ public LedgerEntry () {}
+ private Uint32 lastModifiedLedgerSeq;
+ public Uint32 getLastModifiedLedgerSeq() {
+ return this.lastModifiedLedgerSeq;
+ }
+ public void setLastModifiedLedgerSeq(Uint32 value) {
+ this.lastModifiedLedgerSeq = value;
+ }
+ private LedgerEntryData data;
+ public LedgerEntryData getData() {
+ return this.data;
+ }
+ public void setData(LedgerEntryData value) {
+ this.data = value;
+ }
+ private LedgerEntryExt ext;
+ public LedgerEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(LedgerEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerEntry encodedLedgerEntry) throws IOException{
+ Uint32.encode(stream, encodedLedgerEntry.lastModifiedLedgerSeq);
+ LedgerEntryData.encode(stream, encodedLedgerEntry.data);
+ LedgerEntryExt.encode(stream, encodedLedgerEntry.ext);
+ }
+ public static LedgerEntry decode(XdrDataInputStream stream) throws IOException {
+ LedgerEntry decodedLedgerEntry = new LedgerEntry();
+ decodedLedgerEntry.lastModifiedLedgerSeq = Uint32.decode(stream);
+ decodedLedgerEntry.data = LedgerEntryData.decode(stream);
+ decodedLedgerEntry.ext = LedgerEntryExt.decode(stream);
+ return decodedLedgerEntry;
+ }
+
+ public static class LedgerEntryData {
+ public LedgerEntryData () {}
+ LedgerEntryType type;
+ public LedgerEntryType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(LedgerEntryType value) {
+ this.type = value;
+ }
+ private AccountEntry account;
+ public AccountEntry getAccount() {
+ return this.account;
+ }
+ public void setAccount(AccountEntry value) {
+ this.account = value;
+ }
+ private TrustLineEntry trustLine;
+ public TrustLineEntry getTrustLine() {
+ return this.trustLine;
+ }
+ public void setTrustLine(TrustLineEntry value) {
+ this.trustLine = value;
+ }
+ private OfferEntry offer;
+ public OfferEntry getOffer() {
+ return this.offer;
+ }
+ public void setOffer(OfferEntry value) {
+ this.offer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerEntryData encodedLedgerEntryData) throws IOException {
+ stream.writeInt(encodedLedgerEntryData.getDiscriminant().getValue());
+ switch (encodedLedgerEntryData.getDiscriminant()) {
+ case ACCOUNT:
+ AccountEntry.encode(stream, encodedLedgerEntryData.account);
+ break;
+ case TRUSTLINE:
+ TrustLineEntry.encode(stream, encodedLedgerEntryData.trustLine);
+ break;
+ case OFFER:
+ OfferEntry.encode(stream, encodedLedgerEntryData.offer);
+ break;
+ }
+ }
+ public static LedgerEntryData decode(XdrDataInputStream stream) throws IOException {
+ LedgerEntryData decodedLedgerEntryData = new LedgerEntryData();
+ switch (decodedLedgerEntryData.getDiscriminant()) {
+ case ACCOUNT:
+ decodedLedgerEntryData.account = AccountEntry.decode(stream);
+ break;
+ case TRUSTLINE:
+ decodedLedgerEntryData.trustLine = TrustLineEntry.decode(stream);
+ break;
+ case OFFER:
+ decodedLedgerEntryData.offer = OfferEntry.decode(stream);
+ break;
+ }
+ return decodedLedgerEntryData;
+ }
+
+ }
+ public static class LedgerEntryExt {
+ public LedgerEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerEntryExt encodedLedgerEntryExt) throws IOException {
+ stream.writeInt(encodedLedgerEntryExt.getDiscriminant().intValue());
+ switch (encodedLedgerEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static LedgerEntryExt decode(XdrDataInputStream stream) throws IOException {
+ LedgerEntryExt decodedLedgerEntryExt = new LedgerEntryExt();
+ switch (decodedLedgerEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedLedgerEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java
new file mode 100644
index 000000000..455be4a9b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChange.java
@@ -0,0 +1,81 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union LedgerEntryChange switch (LedgerEntryChangeType type)
+// {
+// case LEDGER_ENTRY_CREATED:
+// LedgerEntry created;
+// case LEDGER_ENTRY_UPDATED:
+// LedgerEntry updated;
+// case LEDGER_ENTRY_REMOVED:
+// LedgerKey removed;
+// };
+
+// ===========================================================================
+public class LedgerEntryChange {
+ public LedgerEntryChange () {}
+ LedgerEntryChangeType type;
+ public LedgerEntryChangeType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(LedgerEntryChangeType value) {
+ this.type = value;
+ }
+ private LedgerEntry created;
+ public LedgerEntry getCreated() {
+ return this.created;
+ }
+ public void setCreated(LedgerEntry value) {
+ this.created = value;
+ }
+ private LedgerEntry updated;
+ public LedgerEntry getUpdated() {
+ return this.updated;
+ }
+ public void setUpdated(LedgerEntry value) {
+ this.updated = value;
+ }
+ private LedgerKey removed;
+ public LedgerKey getRemoved() {
+ return this.removed;
+ }
+ public void setRemoved(LedgerKey value) {
+ this.removed = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerEntryChange encodedLedgerEntryChange) throws IOException {
+ stream.writeInt(encodedLedgerEntryChange.getDiscriminant().getValue());
+ switch (encodedLedgerEntryChange.getDiscriminant()) {
+ case LEDGER_ENTRY_CREATED:
+ LedgerEntry.encode(stream, encodedLedgerEntryChange.created);
+ break;
+ case LEDGER_ENTRY_UPDATED:
+ LedgerEntry.encode(stream, encodedLedgerEntryChange.updated);
+ break;
+ case LEDGER_ENTRY_REMOVED:
+ LedgerKey.encode(stream, encodedLedgerEntryChange.removed);
+ break;
+ }
+ }
+ public static LedgerEntryChange decode(XdrDataInputStream stream) throws IOException {
+ LedgerEntryChange decodedLedgerEntryChange = new LedgerEntryChange();
+ switch (decodedLedgerEntryChange.getDiscriminant()) {
+ case LEDGER_ENTRY_CREATED:
+ decodedLedgerEntryChange.created = LedgerEntry.decode(stream);
+ break;
+ case LEDGER_ENTRY_UPDATED:
+ decodedLedgerEntryChange.updated = LedgerEntry.decode(stream);
+ break;
+ case LEDGER_ENTRY_REMOVED:
+ decodedLedgerEntryChange.removed = LedgerKey.decode(stream);
+ break;
+ }
+ return decodedLedgerEntryChange;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java
new file mode 100644
index 000000000..cee16cc12
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChangeType.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum LedgerEntryChangeType
+// {
+// LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger
+// LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger
+// LEDGER_ENTRY_REMOVED = 2 // entry was removed from the ledger
+// };
+
+// ===========================================================================
+public enum LedgerEntryChangeType {
+ LEDGER_ENTRY_CREATED(0),
+ LEDGER_ENTRY_UPDATED(1),
+ LEDGER_ENTRY_REMOVED(2),
+ ;
+ private int mValue;
+
+ LedgerEntryChangeType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static LedgerEntryChangeType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return LEDGER_ENTRY_CREATED;
+ case 1: return LEDGER_ENTRY_UPDATED;
+ case 2: return LEDGER_ENTRY_REMOVED;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, LedgerEntryChangeType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java
new file mode 100644
index 000000000..1cd780b40
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryChanges.java
@@ -0,0 +1,38 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef LedgerEntryChange LedgerEntryChanges<>;
+
+// ===========================================================================
+public class LedgerEntryChanges {
+ private LedgerEntryChange[] LedgerEntryChanges;
+ public LedgerEntryChange[] getLedgerEntryChanges() {
+ return this.LedgerEntryChanges;
+ }
+ public void setLedgerEntryChanges(LedgerEntryChange[] value) {
+ this.LedgerEntryChanges = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerEntryChanges encodedLedgerEntryChanges) throws IOException {
+ int LedgerEntryChangessize = encodedLedgerEntryChanges.getLedgerEntryChanges().length;
+ stream.writeInt(LedgerEntryChangessize);
+ for (int i = 0; i < LedgerEntryChangessize; i++) {
+ LedgerEntryChange.encode(stream, encodedLedgerEntryChanges.LedgerEntryChanges[i]);
+ }
+ }
+ public static LedgerEntryChanges decode(XdrDataInputStream stream) throws IOException {
+ LedgerEntryChanges decodedLedgerEntryChanges = new LedgerEntryChanges();
+ int LedgerEntryChangessize = stream.readInt();
+ decodedLedgerEntryChanges.LedgerEntryChanges = new LedgerEntryChange[LedgerEntryChangessize];
+ for (int i = 0; i < LedgerEntryChangessize; i++) {
+ decodedLedgerEntryChanges.LedgerEntryChanges[i] = LedgerEntryChange.decode(stream);
+ }
+ return decodedLedgerEntryChanges;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java b/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java
new file mode 100644
index 000000000..3ee17f4e4
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerEntryType.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum LedgerEntryType
+// {
+// ACCOUNT = 0,
+// TRUSTLINE = 1,
+// OFFER = 2
+// };
+
+// ===========================================================================
+public enum LedgerEntryType {
+ ACCOUNT(0),
+ TRUSTLINE(1),
+ OFFER(2),
+ ;
+ private int mValue;
+
+ LedgerEntryType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static LedgerEntryType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ACCOUNT;
+ case 1: return TRUSTLINE;
+ case 2: return OFFER;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, LedgerEntryType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java
new file mode 100644
index 000000000..aa4692ee5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeader.java
@@ -0,0 +1,227 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct LedgerHeader
+// {
+// uint32 ledgerVersion; // the protocol version of the ledger
+// Hash previousLedgerHash; // hash of the previous ledger header
+// StellarValue scpValue; // what consensus agreed to
+// Hash txSetResultHash; // the TransactionResultSet that led to this ledger
+// Hash bucketListHash; // hash of the ledger state
+//
+// uint32 ledgerSeq; // sequence number of this ledger
+//
+// int64 totalCoins; // total number of stroops in existence.
+// // 10,000,000 stroops in 1 XLM
+//
+// int64 feePool; // fees burned since last inflation run
+// uint32 inflationSeq; // inflation sequence number
+//
+// uint64 idPool; // last used global ID, used for generating objects
+//
+// uint32 baseFee; // base fee per operation in stroops
+// uint32 baseReserve; // account base reserve in stroops
+//
+// uint32 maxTxSetSize; // maximum size a transaction set can be
+//
+// Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back
+// // in time without walking the chain back ledger by ledger
+// // each slot contains the oldest ledger that is mod of
+// // either 50 5000 50000 or 500000 depending on index
+// // skipList[0] mod(50), skipList[1] mod(5000), etc
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class LedgerHeader {
+ public LedgerHeader () {}
+ private Uint32 ledgerVersion;
+ public Uint32 getLedgerVersion() {
+ return this.ledgerVersion;
+ }
+ public void setLedgerVersion(Uint32 value) {
+ this.ledgerVersion = value;
+ }
+ private Hash previousLedgerHash;
+ public Hash getPreviousLedgerHash() {
+ return this.previousLedgerHash;
+ }
+ public void setPreviousLedgerHash(Hash value) {
+ this.previousLedgerHash = value;
+ }
+ private StellarValue scpValue;
+ public StellarValue getScpValue() {
+ return this.scpValue;
+ }
+ public void setScpValue(StellarValue value) {
+ this.scpValue = value;
+ }
+ private Hash txSetResultHash;
+ public Hash getTxSetResultHash() {
+ return this.txSetResultHash;
+ }
+ public void setTxSetResultHash(Hash value) {
+ this.txSetResultHash = value;
+ }
+ private Hash bucketListHash;
+ public Hash getBucketListHash() {
+ return this.bucketListHash;
+ }
+ public void setBucketListHash(Hash value) {
+ this.bucketListHash = value;
+ }
+ private Uint32 ledgerSeq;
+ public Uint32 getLedgerSeq() {
+ return this.ledgerSeq;
+ }
+ public void setLedgerSeq(Uint32 value) {
+ this.ledgerSeq = value;
+ }
+ private Int64 totalCoins;
+ public Int64 getTotalCoins() {
+ return this.totalCoins;
+ }
+ public void setTotalCoins(Int64 value) {
+ this.totalCoins = value;
+ }
+ private Int64 feePool;
+ public Int64 getFeePool() {
+ return this.feePool;
+ }
+ public void setFeePool(Int64 value) {
+ this.feePool = value;
+ }
+ private Uint32 inflationSeq;
+ public Uint32 getInflationSeq() {
+ return this.inflationSeq;
+ }
+ public void setInflationSeq(Uint32 value) {
+ this.inflationSeq = value;
+ }
+ private Uint64 idPool;
+ public Uint64 getIdPool() {
+ return this.idPool;
+ }
+ public void setIdPool(Uint64 value) {
+ this.idPool = value;
+ }
+ private Uint32 baseFee;
+ public Uint32 getBaseFee() {
+ return this.baseFee;
+ }
+ public void setBaseFee(Uint32 value) {
+ this.baseFee = value;
+ }
+ private Uint32 baseReserve;
+ public Uint32 getBaseReserve() {
+ return this.baseReserve;
+ }
+ public void setBaseReserve(Uint32 value) {
+ this.baseReserve = value;
+ }
+ private Uint32 maxTxSetSize;
+ public Uint32 getMaxTxSetSize() {
+ return this.maxTxSetSize;
+ }
+ public void setMaxTxSetSize(Uint32 value) {
+ this.maxTxSetSize = value;
+ }
+ private Hash[] skipList;
+ public Hash[] getSkipList() {
+ return this.skipList;
+ }
+ public void setSkipList(Hash[] value) {
+ this.skipList = value;
+ }
+ private LedgerHeaderExt ext;
+ public LedgerHeaderExt getExt() {
+ return this.ext;
+ }
+ public void setExt(LedgerHeaderExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerHeader encodedLedgerHeader) throws IOException{
+ Uint32.encode(stream, encodedLedgerHeader.ledgerVersion);
+ Hash.encode(stream, encodedLedgerHeader.previousLedgerHash);
+ StellarValue.encode(stream, encodedLedgerHeader.scpValue);
+ Hash.encode(stream, encodedLedgerHeader.txSetResultHash);
+ Hash.encode(stream, encodedLedgerHeader.bucketListHash);
+ Uint32.encode(stream, encodedLedgerHeader.ledgerSeq);
+ Int64.encode(stream, encodedLedgerHeader.totalCoins);
+ Int64.encode(stream, encodedLedgerHeader.feePool);
+ Uint32.encode(stream, encodedLedgerHeader.inflationSeq);
+ Uint64.encode(stream, encodedLedgerHeader.idPool);
+ Uint32.encode(stream, encodedLedgerHeader.baseFee);
+ Uint32.encode(stream, encodedLedgerHeader.baseReserve);
+ Uint32.encode(stream, encodedLedgerHeader.maxTxSetSize);
+ int skipListsize = encodedLedgerHeader.getSkipList().length;
+ for (int i = 0; i < skipListsize; i++) {
+ Hash.encode(stream, encodedLedgerHeader.skipList[i]);
+ }
+ LedgerHeaderExt.encode(stream, encodedLedgerHeader.ext);
+ }
+ public static LedgerHeader decode(XdrDataInputStream stream) throws IOException {
+ LedgerHeader decodedLedgerHeader = new LedgerHeader();
+ decodedLedgerHeader.ledgerVersion = Uint32.decode(stream);
+ decodedLedgerHeader.previousLedgerHash = Hash.decode(stream);
+ decodedLedgerHeader.scpValue = StellarValue.decode(stream);
+ decodedLedgerHeader.txSetResultHash = Hash.decode(stream);
+ decodedLedgerHeader.bucketListHash = Hash.decode(stream);
+ decodedLedgerHeader.ledgerSeq = Uint32.decode(stream);
+ decodedLedgerHeader.totalCoins = Int64.decode(stream);
+ decodedLedgerHeader.feePool = Int64.decode(stream);
+ decodedLedgerHeader.inflationSeq = Uint32.decode(stream);
+ decodedLedgerHeader.idPool = Uint64.decode(stream);
+ decodedLedgerHeader.baseFee = Uint32.decode(stream);
+ decodedLedgerHeader.baseReserve = Uint32.decode(stream);
+ decodedLedgerHeader.maxTxSetSize = Uint32.decode(stream);
+ int skipListsize = 4;
+ decodedLedgerHeader.skipList = new Hash[skipListsize];
+ for (int i = 0; i < skipListsize; i++) {
+ decodedLedgerHeader.skipList[i] = Hash.decode(stream);
+ }
+ decodedLedgerHeader.ext = LedgerHeaderExt.decode(stream);
+ return decodedLedgerHeader;
+ }
+
+ public static class LedgerHeaderExt {
+ public LedgerHeaderExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerHeaderExt encodedLedgerHeaderExt) throws IOException {
+ stream.writeInt(encodedLedgerHeaderExt.getDiscriminant().intValue());
+ switch (encodedLedgerHeaderExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static LedgerHeaderExt decode(XdrDataInputStream stream) throws IOException {
+ LedgerHeaderExt decodedLedgerHeaderExt = new LedgerHeaderExt();
+ switch (decodedLedgerHeaderExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedLedgerHeaderExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java
new file mode 100644
index 000000000..a8a686365
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerHeaderHistoryEntry.java
@@ -0,0 +1,88 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct LedgerHeaderHistoryEntry
+// {
+// Hash hash;
+// LedgerHeader header;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class LedgerHeaderHistoryEntry {
+ public LedgerHeaderHistoryEntry () {}
+ private Hash hash;
+ public Hash getHash() {
+ return this.hash;
+ }
+ public void setHash(Hash value) {
+ this.hash = value;
+ }
+ private LedgerHeader header;
+ public LedgerHeader getHeader() {
+ return this.header;
+ }
+ public void setHeader(LedgerHeader value) {
+ this.header = value;
+ }
+ private LedgerHeaderHistoryEntryExt ext;
+ public LedgerHeaderHistoryEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(LedgerHeaderHistoryEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerHeaderHistoryEntry encodedLedgerHeaderHistoryEntry) throws IOException{
+ Hash.encode(stream, encodedLedgerHeaderHistoryEntry.hash);
+ LedgerHeader.encode(stream, encodedLedgerHeaderHistoryEntry.header);
+ LedgerHeaderHistoryEntryExt.encode(stream, encodedLedgerHeaderHistoryEntry.ext);
+ }
+ public static LedgerHeaderHistoryEntry decode(XdrDataInputStream stream) throws IOException {
+ LedgerHeaderHistoryEntry decodedLedgerHeaderHistoryEntry = new LedgerHeaderHistoryEntry();
+ decodedLedgerHeaderHistoryEntry.hash = Hash.decode(stream);
+ decodedLedgerHeaderHistoryEntry.header = LedgerHeader.decode(stream);
+ decodedLedgerHeaderHistoryEntry.ext = LedgerHeaderHistoryEntryExt.decode(stream);
+ return decodedLedgerHeaderHistoryEntry;
+ }
+
+ public static class LedgerHeaderHistoryEntryExt {
+ public LedgerHeaderHistoryEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerHeaderHistoryEntryExt encodedLedgerHeaderHistoryEntryExt) throws IOException {
+ stream.writeInt(encodedLedgerHeaderHistoryEntryExt.getDiscriminant().intValue());
+ switch (encodedLedgerHeaderHistoryEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static LedgerHeaderHistoryEntryExt decode(XdrDataInputStream stream) throws IOException {
+ LedgerHeaderHistoryEntryExt decodedLedgerHeaderHistoryEntryExt = new LedgerHeaderHistoryEntryExt();
+ switch (decodedLedgerHeaderHistoryEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedLedgerHeaderHistoryEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerKey.java b/src/main/java/org/stellar/sdk/xdr/LedgerKey.java
new file mode 100644
index 000000000..bb32030a7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerKey.java
@@ -0,0 +1,170 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union LedgerKey switch (LedgerEntryType type)
+// {
+// case ACCOUNT:
+// struct
+// {
+// AccountID accountID;
+// } account;
+//
+// case TRUSTLINE:
+// struct
+// {
+// AccountID accountID;
+// Asset asset;
+// } trustLine;
+//
+// case OFFER:
+// struct
+// {
+// AccountID sellerID;
+// uint64 offerID;
+// } offer;
+// };
+
+// ===========================================================================
+public class LedgerKey {
+ public LedgerKey () {}
+ LedgerEntryType type;
+ public LedgerEntryType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(LedgerEntryType value) {
+ this.type = value;
+ }
+ private LedgerKeyAccount account;
+ public LedgerKeyAccount getAccount() {
+ return this.account;
+ }
+ public void setAccount(LedgerKeyAccount value) {
+ this.account = value;
+ }
+ private LedgerKeyTrustLine trustLine;
+ public LedgerKeyTrustLine getTrustLine() {
+ return this.trustLine;
+ }
+ public void setTrustLine(LedgerKeyTrustLine value) {
+ this.trustLine = value;
+ }
+ private LedgerKeyOffer offer;
+ public LedgerKeyOffer getOffer() {
+ return this.offer;
+ }
+ public void setOffer(LedgerKeyOffer value) {
+ this.offer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerKey encodedLedgerKey) throws IOException {
+ stream.writeInt(encodedLedgerKey.getDiscriminant().getValue());
+ switch (encodedLedgerKey.getDiscriminant()) {
+ case ACCOUNT:
+ LedgerKeyAccount.encode(stream, encodedLedgerKey.account);
+ break;
+ case TRUSTLINE:
+ LedgerKeyTrustLine.encode(stream, encodedLedgerKey.trustLine);
+ break;
+ case OFFER:
+ LedgerKeyOffer.encode(stream, encodedLedgerKey.offer);
+ break;
+ }
+ }
+ public static LedgerKey decode(XdrDataInputStream stream) throws IOException {
+ LedgerKey decodedLedgerKey = new LedgerKey();
+ switch (decodedLedgerKey.getDiscriminant()) {
+ case ACCOUNT:
+ decodedLedgerKey.account = LedgerKeyAccount.decode(stream);
+ break;
+ case TRUSTLINE:
+ decodedLedgerKey.trustLine = LedgerKeyTrustLine.decode(stream);
+ break;
+ case OFFER:
+ decodedLedgerKey.offer = LedgerKeyOffer.decode(stream);
+ break;
+ }
+ return decodedLedgerKey;
+ }
+
+ public static class LedgerKeyAccount {
+ public LedgerKeyAccount () {}
+ private AccountID accountID;
+ public AccountID getAccountID() {
+ return this.accountID;
+ }
+ public void setAccountID(AccountID value) {
+ this.accountID = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerKeyAccount encodedLedgerKeyAccount) throws IOException{
+ AccountID.encode(stream, encodedLedgerKeyAccount.accountID);
+ }
+ public static LedgerKeyAccount decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyAccount decodedLedgerKeyAccount = new LedgerKeyAccount();
+ decodedLedgerKeyAccount.accountID = AccountID.decode(stream);
+ return decodedLedgerKeyAccount;
+ }
+
+ }
+ public static class LedgerKeyTrustLine {
+ public LedgerKeyTrustLine () {}
+ private AccountID accountID;
+ public AccountID getAccountID() {
+ return this.accountID;
+ }
+ public void setAccountID(AccountID value) {
+ this.accountID = value;
+ }
+ private Asset asset;
+ public Asset getAsset() {
+ return this.asset;
+ }
+ public void setAsset(Asset value) {
+ this.asset = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerKeyTrustLine encodedLedgerKeyTrustLine) throws IOException{
+ AccountID.encode(stream, encodedLedgerKeyTrustLine.accountID);
+ Asset.encode(stream, encodedLedgerKeyTrustLine.asset);
+ }
+ public static LedgerKeyTrustLine decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyTrustLine decodedLedgerKeyTrustLine = new LedgerKeyTrustLine();
+ decodedLedgerKeyTrustLine.accountID = AccountID.decode(stream);
+ decodedLedgerKeyTrustLine.asset = Asset.decode(stream);
+ return decodedLedgerKeyTrustLine;
+ }
+
+ }
+ public static class LedgerKeyOffer {
+ public LedgerKeyOffer () {}
+ private AccountID sellerID;
+ public AccountID getSellerID() {
+ return this.sellerID;
+ }
+ public void setSellerID(AccountID value) {
+ this.sellerID = value;
+ }
+ private Uint64 offerID;
+ public Uint64 getOfferID() {
+ return this.offerID;
+ }
+ public void setOfferID(Uint64 value) {
+ this.offerID = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerKeyOffer encodedLedgerKeyOffer) throws IOException{
+ AccountID.encode(stream, encodedLedgerKeyOffer.sellerID);
+ Uint64.encode(stream, encodedLedgerKeyOffer.offerID);
+ }
+ public static LedgerKeyOffer decode(XdrDataInputStream stream) throws IOException {
+ LedgerKeyOffer decodedLedgerKeyOffer = new LedgerKeyOffer();
+ decodedLedgerKeyOffer.sellerID = AccountID.decode(stream);
+ decodedLedgerKeyOffer.offerID = Uint64.decode(stream);
+ return decodedLedgerKeyOffer;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java b/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java
new file mode 100644
index 000000000..5582df276
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerUpgrade.java
@@ -0,0 +1,81 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union LedgerUpgrade switch (LedgerUpgradeType type)
+// {
+// case LEDGER_UPGRADE_VERSION:
+// uint32 newLedgerVersion; // update ledgerVersion
+// case LEDGER_UPGRADE_BASE_FEE:
+// uint32 newBaseFee; // update baseFee
+// case LEDGER_UPGRADE_MAX_TX_SET_SIZE:
+// uint32 newMaxTxSetSize; // update maxTxSetSize
+// };
+
+// ===========================================================================
+public class LedgerUpgrade {
+ public LedgerUpgrade () {}
+ LedgerUpgradeType type;
+ public LedgerUpgradeType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(LedgerUpgradeType value) {
+ this.type = value;
+ }
+ private Uint32 newLedgerVersion;
+ public Uint32 getNewLedgerVersion() {
+ return this.newLedgerVersion;
+ }
+ public void setNewLedgerVersion(Uint32 value) {
+ this.newLedgerVersion = value;
+ }
+ private Uint32 newBaseFee;
+ public Uint32 getNewBaseFee() {
+ return this.newBaseFee;
+ }
+ public void setNewBaseFee(Uint32 value) {
+ this.newBaseFee = value;
+ }
+ private Uint32 newMaxTxSetSize;
+ public Uint32 getNewMaxTxSetSize() {
+ return this.newMaxTxSetSize;
+ }
+ public void setNewMaxTxSetSize(Uint32 value) {
+ this.newMaxTxSetSize = value;
+ }
+ public static void encode(XdrDataOutputStream stream, LedgerUpgrade encodedLedgerUpgrade) throws IOException {
+ stream.writeInt(encodedLedgerUpgrade.getDiscriminant().getValue());
+ switch (encodedLedgerUpgrade.getDiscriminant()) {
+ case LEDGER_UPGRADE_VERSION:
+ Uint32.encode(stream, encodedLedgerUpgrade.newLedgerVersion);
+ break;
+ case LEDGER_UPGRADE_BASE_FEE:
+ Uint32.encode(stream, encodedLedgerUpgrade.newBaseFee);
+ break;
+ case LEDGER_UPGRADE_MAX_TX_SET_SIZE:
+ Uint32.encode(stream, encodedLedgerUpgrade.newMaxTxSetSize);
+ break;
+ }
+ }
+ public static LedgerUpgrade decode(XdrDataInputStream stream) throws IOException {
+ LedgerUpgrade decodedLedgerUpgrade = new LedgerUpgrade();
+ switch (decodedLedgerUpgrade.getDiscriminant()) {
+ case LEDGER_UPGRADE_VERSION:
+ decodedLedgerUpgrade.newLedgerVersion = Uint32.decode(stream);
+ break;
+ case LEDGER_UPGRADE_BASE_FEE:
+ decodedLedgerUpgrade.newBaseFee = Uint32.decode(stream);
+ break;
+ case LEDGER_UPGRADE_MAX_TX_SET_SIZE:
+ decodedLedgerUpgrade.newMaxTxSetSize = Uint32.decode(stream);
+ break;
+ }
+ return decodedLedgerUpgrade;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java b/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java
new file mode 100644
index 000000000..14282fa92
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/LedgerUpgradeType.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum LedgerUpgradeType
+// {
+// LEDGER_UPGRADE_VERSION = 1,
+// LEDGER_UPGRADE_BASE_FEE = 2,
+// LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3
+// };
+
+// ===========================================================================
+public enum LedgerUpgradeType {
+ LEDGER_UPGRADE_VERSION(1),
+ LEDGER_UPGRADE_BASE_FEE(2),
+ LEDGER_UPGRADE_MAX_TX_SET_SIZE(3),
+ ;
+ private int mValue;
+
+ LedgerUpgradeType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static LedgerUpgradeType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 1: return LEDGER_UPGRADE_VERSION;
+ case 2: return LEDGER_UPGRADE_BASE_FEE;
+ case 3: return LEDGER_UPGRADE_MAX_TX_SET_SIZE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, LedgerUpgradeType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java
new file mode 100644
index 000000000..7956d4d9f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferEffect.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ManageOfferEffect
+// {
+// MANAGE_OFFER_CREATED = 0,
+// MANAGE_OFFER_UPDATED = 1,
+// MANAGE_OFFER_DELETED = 2
+// };
+
+// ===========================================================================
+public enum ManageOfferEffect {
+ MANAGE_OFFER_CREATED(0),
+ MANAGE_OFFER_UPDATED(1),
+ MANAGE_OFFER_DELETED(2),
+ ;
+ private int mValue;
+
+ ManageOfferEffect(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ManageOfferEffect decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return MANAGE_OFFER_CREATED;
+ case 1: return MANAGE_OFFER_UPDATED;
+ case 2: return MANAGE_OFFER_DELETED;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ManageOfferEffect value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java
new file mode 100644
index 000000000..b0567771a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferOp.java
@@ -0,0 +1,76 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct ManageOfferOp
+// {
+// Asset selling;
+// Asset buying;
+// int64 amount; // amount being sold. if set to 0, delete the offer
+// Price price; // price of thing being sold in terms of what you are buying
+//
+// // 0=create a new offer, otherwise edit an existing offer
+// uint64 offerID;
+// };
+
+// ===========================================================================
+public class ManageOfferOp {
+ public ManageOfferOp () {}
+ private Asset selling;
+ public Asset getSelling() {
+ return this.selling;
+ }
+ public void setSelling(Asset value) {
+ this.selling = value;
+ }
+ private Asset buying;
+ public Asset getBuying() {
+ return this.buying;
+ }
+ public void setBuying(Asset value) {
+ this.buying = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ private Price price;
+ public Price getPrice() {
+ return this.price;
+ }
+ public void setPrice(Price value) {
+ this.price = value;
+ }
+ private Uint64 offerID;
+ public Uint64 getOfferID() {
+ return this.offerID;
+ }
+ public void setOfferID(Uint64 value) {
+ this.offerID = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ManageOfferOp encodedManageOfferOp) throws IOException{
+ Asset.encode(stream, encodedManageOfferOp.selling);
+ Asset.encode(stream, encodedManageOfferOp.buying);
+ Int64.encode(stream, encodedManageOfferOp.amount);
+ Price.encode(stream, encodedManageOfferOp.price);
+ Uint64.encode(stream, encodedManageOfferOp.offerID);
+ }
+ public static ManageOfferOp decode(XdrDataInputStream stream) throws IOException {
+ ManageOfferOp decodedManageOfferOp = new ManageOfferOp();
+ decodedManageOfferOp.selling = Asset.decode(stream);
+ decodedManageOfferOp.buying = Asset.decode(stream);
+ decodedManageOfferOp.amount = Int64.decode(stream);
+ decodedManageOfferOp.price = Price.decode(stream);
+ decodedManageOfferOp.offerID = Uint64.decode(stream);
+ return decodedManageOfferOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java
new file mode 100644
index 000000000..9de4913ae
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferResult.java
@@ -0,0 +1,57 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union ManageOfferResult switch (ManageOfferResultCode code)
+// {
+// case MANAGE_OFFER_SUCCESS:
+// ManageOfferSuccessResult success;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class ManageOfferResult {
+ public ManageOfferResult () {}
+ ManageOfferResultCode code;
+ public ManageOfferResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(ManageOfferResultCode value) {
+ this.code = value;
+ }
+ private ManageOfferSuccessResult success;
+ public ManageOfferSuccessResult getSuccess() {
+ return this.success;
+ }
+ public void setSuccess(ManageOfferSuccessResult value) {
+ this.success = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ManageOfferResult encodedManageOfferResult) throws IOException {
+ stream.writeInt(encodedManageOfferResult.getDiscriminant().getValue());
+ switch (encodedManageOfferResult.getDiscriminant()) {
+ case MANAGE_OFFER_SUCCESS:
+ ManageOfferSuccessResult.encode(stream, encodedManageOfferResult.success);
+ break;
+ default:
+ break;
+ }
+ }
+ public static ManageOfferResult decode(XdrDataInputStream stream) throws IOException {
+ ManageOfferResult decodedManageOfferResult = new ManageOfferResult();
+ switch (decodedManageOfferResult.getDiscriminant()) {
+ case MANAGE_OFFER_SUCCESS:
+ decodedManageOfferResult.success = ManageOfferSuccessResult.decode(stream);
+ break;
+ default:
+ break;
+ }
+ return decodedManageOfferResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java
new file mode 100644
index 000000000..78b95feb2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferResultCode.java
@@ -0,0 +1,84 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ManageOfferResultCode
+// {
+// // codes considered as "success" for the operation
+// MANAGE_OFFER_SUCCESS = 0,
+//
+// // codes considered as "failure" for the operation
+// MANAGE_OFFER_MALFORMED = -1, // generated offer would be invalid
+// MANAGE_OFFER_SELL_NO_TRUST = -2, // no trust line for what we're selling
+// MANAGE_OFFER_BUY_NO_TRUST = -3, // no trust line for what we're buying
+// MANAGE_OFFER_SELL_NOT_AUTHORIZED = -4, // not authorized to sell
+// MANAGE_OFFER_BUY_NOT_AUTHORIZED = -5, // not authorized to buy
+// MANAGE_OFFER_LINE_FULL = -6, // can't receive more of what it's buying
+// MANAGE_OFFER_UNDERFUNDED = -7, // doesn't hold what it's trying to sell
+// MANAGE_OFFER_CROSS_SELF = -8, // would cross an offer from the same user
+// MANAGE_OFFER_SELL_NO_ISSUER = -9, // no issuer for what we're selling
+// MANAGE_OFFER_BUY_NO_ISSUER = -10, // no issuer for what we're buying
+//
+// // update errors
+// MANAGE_OFFER_NOT_FOUND = -11, // offerID does not match an existing offer
+//
+// MANAGE_OFFER_LOW_RESERVE = -12 // not enough funds to create a new Offer
+// };
+
+// ===========================================================================
+public enum ManageOfferResultCode {
+ MANAGE_OFFER_SUCCESS(0),
+ MANAGE_OFFER_MALFORMED(-1),
+ MANAGE_OFFER_SELL_NO_TRUST(-2),
+ MANAGE_OFFER_BUY_NO_TRUST(-3),
+ MANAGE_OFFER_SELL_NOT_AUTHORIZED(-4),
+ MANAGE_OFFER_BUY_NOT_AUTHORIZED(-5),
+ MANAGE_OFFER_LINE_FULL(-6),
+ MANAGE_OFFER_UNDERFUNDED(-7),
+ MANAGE_OFFER_CROSS_SELF(-8),
+ MANAGE_OFFER_SELL_NO_ISSUER(-9),
+ MANAGE_OFFER_BUY_NO_ISSUER(-10),
+ MANAGE_OFFER_NOT_FOUND(-11),
+ MANAGE_OFFER_LOW_RESERVE(-12),
+ ;
+ private int mValue;
+
+ ManageOfferResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ManageOfferResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return MANAGE_OFFER_SUCCESS;
+ case -1: return MANAGE_OFFER_MALFORMED;
+ case -2: return MANAGE_OFFER_SELL_NO_TRUST;
+ case -3: return MANAGE_OFFER_BUY_NO_TRUST;
+ case -4: return MANAGE_OFFER_SELL_NOT_AUTHORIZED;
+ case -5: return MANAGE_OFFER_BUY_NOT_AUTHORIZED;
+ case -6: return MANAGE_OFFER_LINE_FULL;
+ case -7: return MANAGE_OFFER_UNDERFUNDED;
+ case -8: return MANAGE_OFFER_CROSS_SELF;
+ case -9: return MANAGE_OFFER_SELL_NO_ISSUER;
+ case -10: return MANAGE_OFFER_BUY_NO_ISSUER;
+ case -11: return MANAGE_OFFER_NOT_FOUND;
+ case -12: return MANAGE_OFFER_LOW_RESERVE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ManageOfferResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java b/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java
new file mode 100644
index 000000000..48b490498
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ManageOfferSuccessResult.java
@@ -0,0 +1,104 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct ManageOfferSuccessResult
+// {
+// // offers that got claimed while creating this offer
+// ClaimOfferAtom offersClaimed<>;
+//
+// union switch (ManageOfferEffect effect)
+// {
+// case MANAGE_OFFER_CREATED:
+// case MANAGE_OFFER_UPDATED:
+// OfferEntry offer;
+// default:
+// void;
+// }
+// offer;
+// };
+
+// ===========================================================================
+public class ManageOfferSuccessResult {
+ public ManageOfferSuccessResult () {}
+ private ClaimOfferAtom[] offersClaimed;
+ public ClaimOfferAtom[] getOffersClaimed() {
+ return this.offersClaimed;
+ }
+ public void setOffersClaimed(ClaimOfferAtom[] value) {
+ this.offersClaimed = value;
+ }
+ private ManageOfferSuccessResultOffer offer;
+ public ManageOfferSuccessResultOffer getOffer() {
+ return this.offer;
+ }
+ public void setOffer(ManageOfferSuccessResultOffer value) {
+ this.offer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ManageOfferSuccessResult encodedManageOfferSuccessResult) throws IOException{
+ int offersClaimedsize = encodedManageOfferSuccessResult.getOffersClaimed().length;
+ stream.writeInt(offersClaimedsize);
+ for (int i = 0; i < offersClaimedsize; i++) {
+ ClaimOfferAtom.encode(stream, encodedManageOfferSuccessResult.offersClaimed[i]);
+ }
+ ManageOfferSuccessResultOffer.encode(stream, encodedManageOfferSuccessResult.offer);
+ }
+ public static ManageOfferSuccessResult decode(XdrDataInputStream stream) throws IOException {
+ ManageOfferSuccessResult decodedManageOfferSuccessResult = new ManageOfferSuccessResult();
+ int offersClaimedsize = stream.readInt();
+ decodedManageOfferSuccessResult.offersClaimed = new ClaimOfferAtom[offersClaimedsize];
+ for (int i = 0; i < offersClaimedsize; i++) {
+ decodedManageOfferSuccessResult.offersClaimed[i] = ClaimOfferAtom.decode(stream);
+ }
+ decodedManageOfferSuccessResult.offer = ManageOfferSuccessResultOffer.decode(stream);
+ return decodedManageOfferSuccessResult;
+ }
+
+ public static class ManageOfferSuccessResultOffer {
+ public ManageOfferSuccessResultOffer () {}
+ ManageOfferEffect effect;
+ public ManageOfferEffect getDiscriminant() {
+ return this.effect;
+ }
+ public void setDiscriminant(ManageOfferEffect value) {
+ this.effect = value;
+ }
+ private OfferEntry offer;
+ public OfferEntry getOffer() {
+ return this.offer;
+ }
+ public void setOffer(OfferEntry value) {
+ this.offer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, ManageOfferSuccessResultOffer encodedManageOfferSuccessResultOffer) throws IOException {
+ stream.writeInt(encodedManageOfferSuccessResultOffer.getDiscriminant().getValue());
+ switch (encodedManageOfferSuccessResultOffer.getDiscriminant()) {
+ case MANAGE_OFFER_CREATED:
+ case MANAGE_OFFER_UPDATED:
+ OfferEntry.encode(stream, encodedManageOfferSuccessResultOffer.offer);
+ break;
+ default:
+ break;
+ }
+ }
+ public static ManageOfferSuccessResultOffer decode(XdrDataInputStream stream) throws IOException {
+ ManageOfferSuccessResultOffer decodedManageOfferSuccessResultOffer = new ManageOfferSuccessResultOffer();
+ switch (decodedManageOfferSuccessResultOffer.getDiscriminant()) {
+ case MANAGE_OFFER_CREATED:
+ case MANAGE_OFFER_UPDATED:
+ decodedManageOfferSuccessResultOffer.offer = OfferEntry.decode(stream);
+ break;
+ default:
+ break;
+ }
+ return decodedManageOfferSuccessResultOffer;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Memo.java b/src/main/java/org/stellar/sdk/xdr/Memo.java
new file mode 100644
index 000000000..e04bf25be
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Memo.java
@@ -0,0 +1,102 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union Memo switch (MemoType type)
+// {
+// case MEMO_NONE:
+// void;
+// case MEMO_TEXT:
+// string text<28>;
+// case MEMO_ID:
+// uint64 id;
+// case MEMO_HASH:
+// Hash hash; // the hash of what to pull from the content server
+// case MEMO_RETURN:
+// Hash retHash; // the hash of the tx you are rejecting
+// };
+
+// ===========================================================================
+public class Memo {
+ public Memo () {}
+ MemoType type;
+ public MemoType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(MemoType value) {
+ this.type = value;
+ }
+ private String text;
+ public String getText() {
+ return this.text;
+ }
+ public void setText(String value) {
+ this.text = value;
+ }
+ private Uint64 id;
+ public Uint64 getId() {
+ return this.id;
+ }
+ public void setId(Uint64 value) {
+ this.id = value;
+ }
+ private Hash hash;
+ public Hash getHash() {
+ return this.hash;
+ }
+ public void setHash(Hash value) {
+ this.hash = value;
+ }
+ private Hash retHash;
+ public Hash getRetHash() {
+ return this.retHash;
+ }
+ public void setRetHash(Hash value) {
+ this.retHash = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Memo encodedMemo) throws IOException {
+ stream.writeInt(encodedMemo.getDiscriminant().getValue());
+ switch (encodedMemo.getDiscriminant()) {
+ case MEMO_NONE:
+ break;
+ case MEMO_TEXT:
+ stream.writeString(encodedMemo.text);
+ break;
+ case MEMO_ID:
+ Uint64.encode(stream, encodedMemo.id);
+ break;
+ case MEMO_HASH:
+ Hash.encode(stream, encodedMemo.hash);
+ break;
+ case MEMO_RETURN:
+ Hash.encode(stream, encodedMemo.retHash);
+ break;
+ }
+ }
+ public static Memo decode(XdrDataInputStream stream) throws IOException {
+ Memo decodedMemo = new Memo();
+ switch (decodedMemo.getDiscriminant()) {
+ case MEMO_NONE:
+ break;
+ case MEMO_TEXT:
+ decodedMemo.text = stream.readString();
+ break;
+ case MEMO_ID:
+ decodedMemo.id = Uint64.decode(stream);
+ break;
+ case MEMO_HASH:
+ decodedMemo.hash = Hash.decode(stream);
+ break;
+ case MEMO_RETURN:
+ decodedMemo.retHash = Hash.decode(stream);
+ break;
+ }
+ return decodedMemo;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/MemoType.java b/src/main/java/org/stellar/sdk/xdr/MemoType.java
new file mode 100644
index 000000000..f08a17453
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/MemoType.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum MemoType
+// {
+// MEMO_NONE = 0,
+// MEMO_TEXT = 1,
+// MEMO_ID = 2,
+// MEMO_HASH = 3,
+// MEMO_RETURN = 4
+// };
+
+// ===========================================================================
+public enum MemoType {
+ MEMO_NONE(0),
+ MEMO_TEXT(1),
+ MEMO_ID(2),
+ MEMO_HASH(3),
+ MEMO_RETURN(4),
+ ;
+ private int mValue;
+
+ MemoType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static MemoType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return MEMO_NONE;
+ case 1: return MEMO_TEXT;
+ case 2: return MEMO_ID;
+ case 3: return MEMO_HASH;
+ case 4: return MEMO_RETURN;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, MemoType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/MessageType.java b/src/main/java/org/stellar/sdk/xdr/MessageType.java
new file mode 100644
index 000000000..75206298c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/MessageType.java
@@ -0,0 +1,80 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum MessageType
+// {
+// ERROR_MSG = 0,
+// HELLO = 1,
+// AUTH = 2,
+// DONT_HAVE = 3,
+//
+// GET_PEERS = 4, // gets a list of peers this guy knows about
+// PEERS = 5,
+//
+// GET_TX_SET = 6, // gets a particular txset by hash
+// TX_SET = 7,
+//
+// TRANSACTION = 8, // pass on a tx you have heard about
+//
+// // SCP
+// GET_SCP_QUORUMSET = 9,
+// SCP_QUORUMSET = 10,
+// SCP_MESSAGE = 11
+// };
+
+// ===========================================================================
+public enum MessageType {
+ ERROR_MSG(0),
+ HELLO(1),
+ AUTH(2),
+ DONT_HAVE(3),
+ GET_PEERS(4),
+ PEERS(5),
+ GET_TX_SET(6),
+ TX_SET(7),
+ TRANSACTION(8),
+ GET_SCP_QUORUMSET(9),
+ SCP_QUORUMSET(10),
+ SCP_MESSAGE(11),
+ ;
+ private int mValue;
+
+ MessageType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static MessageType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return ERROR_MSG;
+ case 1: return HELLO;
+ case 2: return AUTH;
+ case 3: return DONT_HAVE;
+ case 4: return GET_PEERS;
+ case 5: return PEERS;
+ case 6: return GET_TX_SET;
+ case 7: return TX_SET;
+ case 8: return TRANSACTION;
+ case 9: return GET_SCP_QUORUMSET;
+ case 10: return SCP_QUORUMSET;
+ case 11: return SCP_MESSAGE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, MessageType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/NodeID.java b/src/main/java/org/stellar/sdk/xdr/NodeID.java
new file mode 100644
index 000000000..20244af46
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/NodeID.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef PublicKey NodeID;
+
+// ===========================================================================
+public class NodeID {
+ private PublicKey NodeID;
+ public PublicKey getNodeID() {
+ return this.NodeID;
+ }
+ public void setNodeID(PublicKey value) {
+ this.NodeID = value;
+ }
+ public static void encode(XdrDataOutputStream stream, NodeID encodedNodeID) throws IOException {
+ PublicKey.encode(stream, encodedNodeID.NodeID);
+ }
+ public static NodeID decode(XdrDataInputStream stream) throws IOException {
+ NodeID decodedNodeID = new NodeID();
+ decodedNodeID.NodeID = PublicKey.decode(stream);
+ return decodedNodeID;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OfferEntry.java b/src/main/java/org/stellar/sdk/xdr/OfferEntry.java
new file mode 100644
index 000000000..bea836664
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OfferEntry.java
@@ -0,0 +1,144 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct OfferEntry
+// {
+// AccountID sellerID;
+// uint64 offerID;
+// Asset selling; // A
+// Asset buying; // B
+// int64 amount; // amount of A
+//
+// /* price for this offer:
+// price of A in terms of B
+// price=AmountB/AmountA=priceNumerator/priceDenominator
+// price is after fees
+// */
+// Price price;
+// uint32 flags; // see OfferEntryFlags
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class OfferEntry {
+ public OfferEntry () {}
+ private AccountID sellerID;
+ public AccountID getSellerID() {
+ return this.sellerID;
+ }
+ public void setSellerID(AccountID value) {
+ this.sellerID = value;
+ }
+ private Uint64 offerID;
+ public Uint64 getOfferID() {
+ return this.offerID;
+ }
+ public void setOfferID(Uint64 value) {
+ this.offerID = value;
+ }
+ private Asset selling;
+ public Asset getSelling() {
+ return this.selling;
+ }
+ public void setSelling(Asset value) {
+ this.selling = value;
+ }
+ private Asset buying;
+ public Asset getBuying() {
+ return this.buying;
+ }
+ public void setBuying(Asset value) {
+ this.buying = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ private Price price;
+ public Price getPrice() {
+ return this.price;
+ }
+ public void setPrice(Price value) {
+ this.price = value;
+ }
+ private Uint32 flags;
+ public Uint32 getFlags() {
+ return this.flags;
+ }
+ public void setFlags(Uint32 value) {
+ this.flags = value;
+ }
+ private OfferEntryExt ext;
+ public OfferEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(OfferEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OfferEntry encodedOfferEntry) throws IOException{
+ AccountID.encode(stream, encodedOfferEntry.sellerID);
+ Uint64.encode(stream, encodedOfferEntry.offerID);
+ Asset.encode(stream, encodedOfferEntry.selling);
+ Asset.encode(stream, encodedOfferEntry.buying);
+ Int64.encode(stream, encodedOfferEntry.amount);
+ Price.encode(stream, encodedOfferEntry.price);
+ Uint32.encode(stream, encodedOfferEntry.flags);
+ OfferEntryExt.encode(stream, encodedOfferEntry.ext);
+ }
+ public static OfferEntry decode(XdrDataInputStream stream) throws IOException {
+ OfferEntry decodedOfferEntry = new OfferEntry();
+ decodedOfferEntry.sellerID = AccountID.decode(stream);
+ decodedOfferEntry.offerID = Uint64.decode(stream);
+ decodedOfferEntry.selling = Asset.decode(stream);
+ decodedOfferEntry.buying = Asset.decode(stream);
+ decodedOfferEntry.amount = Int64.decode(stream);
+ decodedOfferEntry.price = Price.decode(stream);
+ decodedOfferEntry.flags = Uint32.decode(stream);
+ decodedOfferEntry.ext = OfferEntryExt.decode(stream);
+ return decodedOfferEntry;
+ }
+
+ public static class OfferEntryExt {
+ public OfferEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OfferEntryExt encodedOfferEntryExt) throws IOException {
+ stream.writeInt(encodedOfferEntryExt.getDiscriminant().intValue());
+ switch (encodedOfferEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static OfferEntryExt decode(XdrDataInputStream stream) throws IOException {
+ OfferEntryExt decodedOfferEntryExt = new OfferEntryExt();
+ switch (decodedOfferEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedOfferEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java b/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java
new file mode 100644
index 000000000..2dfc110fd
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OfferEntryFlags.java
@@ -0,0 +1,43 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum OfferEntryFlags
+// {
+// // issuer has authorized account to perform transactions with its credit
+// PASSIVE_FLAG = 1
+// };
+
+// ===========================================================================
+public enum OfferEntryFlags {
+ PASSIVE_FLAG(1),
+ ;
+ private int mValue;
+
+ OfferEntryFlags(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static OfferEntryFlags decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 1: return PASSIVE_FLAG;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, OfferEntryFlags value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Operation.java b/src/main/java/org/stellar/sdk/xdr/Operation.java
new file mode 100644
index 000000000..68eb38ced
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Operation.java
@@ -0,0 +1,223 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Operation
+// {
+// // sourceAccount is the account used to run the operation
+// // if not set, the runtime defaults to "sourceAccount" specified at
+// // the transaction level
+// AccountID* sourceAccount;
+//
+// union switch (OperationType type)
+// {
+// case CREATE_ACCOUNT:
+// CreateAccountOp createAccountOp;
+// case PAYMENT:
+// PaymentOp paymentOp;
+// case PATH_PAYMENT:
+// PathPaymentOp pathPaymentOp;
+// case MANAGE_OFFER:
+// ManageOfferOp manageOfferOp;
+// case CREATE_PASSIVE_OFFER:
+// CreatePassiveOfferOp createPassiveOfferOp;
+// case SET_OPTIONS:
+// SetOptionsOp setOptionsOp;
+// case CHANGE_TRUST:
+// ChangeTrustOp changeTrustOp;
+// case ALLOW_TRUST:
+// AllowTrustOp allowTrustOp;
+// case ACCOUNT_MERGE:
+// AccountID destination;
+// case INFLATION:
+// void;
+// }
+// body;
+// };
+
+// ===========================================================================
+public class Operation {
+ public Operation () {}
+ private AccountID sourceAccount;
+ public AccountID getSourceAccount() {
+ return this.sourceAccount;
+ }
+ public void setSourceAccount(AccountID value) {
+ this.sourceAccount = value;
+ }
+ private OperationBody body;
+ public OperationBody getBody() {
+ return this.body;
+ }
+ public void setBody(OperationBody value) {
+ this.body = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Operation encodedOperation) throws IOException{
+ if (encodedOperation.sourceAccount != null) {
+ stream.writeInt(1);
+ AccountID.encode(stream, encodedOperation.sourceAccount);
+ } else {
+ stream.writeInt(0);
+ }
+ OperationBody.encode(stream, encodedOperation.body);
+ }
+ public static Operation decode(XdrDataInputStream stream) throws IOException {
+ Operation decodedOperation = new Operation();
+ int sourceAccountPresent = stream.readInt();
+ if (sourceAccountPresent != 0) {
+ decodedOperation.sourceAccount = AccountID.decode(stream);
+ }
+ decodedOperation.body = OperationBody.decode(stream);
+ return decodedOperation;
+ }
+
+ public static class OperationBody {
+ public OperationBody () {}
+ OperationType type;
+ public OperationType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(OperationType value) {
+ this.type = value;
+ }
+ private CreateAccountOp createAccountOp;
+ public CreateAccountOp getCreateAccountOp() {
+ return this.createAccountOp;
+ }
+ public void setCreateAccountOp(CreateAccountOp value) {
+ this.createAccountOp = value;
+ }
+ private PaymentOp paymentOp;
+ public PaymentOp getPaymentOp() {
+ return this.paymentOp;
+ }
+ public void setPaymentOp(PaymentOp value) {
+ this.paymentOp = value;
+ }
+ private PathPaymentOp pathPaymentOp;
+ public PathPaymentOp getPathPaymentOp() {
+ return this.pathPaymentOp;
+ }
+ public void setPathPaymentOp(PathPaymentOp value) {
+ this.pathPaymentOp = value;
+ }
+ private ManageOfferOp manageOfferOp;
+ public ManageOfferOp getManageOfferOp() {
+ return this.manageOfferOp;
+ }
+ public void setManageOfferOp(ManageOfferOp value) {
+ this.manageOfferOp = value;
+ }
+ private CreatePassiveOfferOp createPassiveOfferOp;
+ public CreatePassiveOfferOp getCreatePassiveOfferOp() {
+ return this.createPassiveOfferOp;
+ }
+ public void setCreatePassiveOfferOp(CreatePassiveOfferOp value) {
+ this.createPassiveOfferOp = value;
+ }
+ private SetOptionsOp setOptionsOp;
+ public SetOptionsOp getSetOptionsOp() {
+ return this.setOptionsOp;
+ }
+ public void setSetOptionsOp(SetOptionsOp value) {
+ this.setOptionsOp = value;
+ }
+ private ChangeTrustOp changeTrustOp;
+ public ChangeTrustOp getChangeTrustOp() {
+ return this.changeTrustOp;
+ }
+ public void setChangeTrustOp(ChangeTrustOp value) {
+ this.changeTrustOp = value;
+ }
+ private AllowTrustOp allowTrustOp;
+ public AllowTrustOp getAllowTrustOp() {
+ return this.allowTrustOp;
+ }
+ public void setAllowTrustOp(AllowTrustOp value) {
+ this.allowTrustOp = value;
+ }
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OperationBody encodedOperationBody) throws IOException {
+ stream.writeInt(encodedOperationBody.getDiscriminant().getValue());
+ switch (encodedOperationBody.getDiscriminant()) {
+ case CREATE_ACCOUNT:
+ CreateAccountOp.encode(stream, encodedOperationBody.createAccountOp);
+ break;
+ case PAYMENT:
+ PaymentOp.encode(stream, encodedOperationBody.paymentOp);
+ break;
+ case PATH_PAYMENT:
+ PathPaymentOp.encode(stream, encodedOperationBody.pathPaymentOp);
+ break;
+ case MANAGE_OFFER:
+ ManageOfferOp.encode(stream, encodedOperationBody.manageOfferOp);
+ break;
+ case CREATE_PASSIVE_OFFER:
+ CreatePassiveOfferOp.encode(stream, encodedOperationBody.createPassiveOfferOp);
+ break;
+ case SET_OPTIONS:
+ SetOptionsOp.encode(stream, encodedOperationBody.setOptionsOp);
+ break;
+ case CHANGE_TRUST:
+ ChangeTrustOp.encode(stream, encodedOperationBody.changeTrustOp);
+ break;
+ case ALLOW_TRUST:
+ AllowTrustOp.encode(stream, encodedOperationBody.allowTrustOp);
+ break;
+ case ACCOUNT_MERGE:
+ AccountID.encode(stream, encodedOperationBody.destination);
+ break;
+ case INFLATION:
+ break;
+ }
+ }
+ public static OperationBody decode(XdrDataInputStream stream) throws IOException {
+ OperationBody decodedOperationBody = new OperationBody();
+ switch (decodedOperationBody.getDiscriminant()) {
+ case CREATE_ACCOUNT:
+ decodedOperationBody.createAccountOp = CreateAccountOp.decode(stream);
+ break;
+ case PAYMENT:
+ decodedOperationBody.paymentOp = PaymentOp.decode(stream);
+ break;
+ case PATH_PAYMENT:
+ decodedOperationBody.pathPaymentOp = PathPaymentOp.decode(stream);
+ break;
+ case MANAGE_OFFER:
+ decodedOperationBody.manageOfferOp = ManageOfferOp.decode(stream);
+ break;
+ case CREATE_PASSIVE_OFFER:
+ decodedOperationBody.createPassiveOfferOp = CreatePassiveOfferOp.decode(stream);
+ break;
+ case SET_OPTIONS:
+ decodedOperationBody.setOptionsOp = SetOptionsOp.decode(stream);
+ break;
+ case CHANGE_TRUST:
+ decodedOperationBody.changeTrustOp = ChangeTrustOp.decode(stream);
+ break;
+ case ALLOW_TRUST:
+ decodedOperationBody.allowTrustOp = AllowTrustOp.decode(stream);
+ break;
+ case ACCOUNT_MERGE:
+ decodedOperationBody.destination = AccountID.decode(stream);
+ break;
+ case INFLATION:
+ break;
+ }
+ return decodedOperationBody;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationMeta.java b/src/main/java/org/stellar/sdk/xdr/OperationMeta.java
new file mode 100644
index 000000000..d57e9f3b0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OperationMeta.java
@@ -0,0 +1,34 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct OperationMeta
+// {
+// LedgerEntryChanges changes;
+// };
+
+// ===========================================================================
+public class OperationMeta {
+ public OperationMeta () {}
+ private LedgerEntryChanges changes;
+ public LedgerEntryChanges getChanges() {
+ return this.changes;
+ }
+ public void setChanges(LedgerEntryChanges value) {
+ this.changes = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OperationMeta encodedOperationMeta) throws IOException{
+ LedgerEntryChanges.encode(stream, encodedOperationMeta.changes);
+ }
+ public static OperationMeta decode(XdrDataInputStream stream) throws IOException {
+ OperationMeta decodedOperationMeta = new OperationMeta();
+ decodedOperationMeta.changes = LedgerEntryChanges.decode(stream);
+ return decodedOperationMeta;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationResult.java b/src/main/java/org/stellar/sdk/xdr/OperationResult.java
new file mode 100644
index 000000000..bfd49187f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OperationResult.java
@@ -0,0 +1,233 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union OperationResult switch (OperationResultCode code)
+// {
+// case opINNER:
+// union switch (OperationType type)
+// {
+// case CREATE_ACCOUNT:
+// CreateAccountResult createAccountResult;
+// case PAYMENT:
+// PaymentResult paymentResult;
+// case PATH_PAYMENT:
+// PathPaymentResult pathPaymentResult;
+// case MANAGE_OFFER:
+// ManageOfferResult manageOfferResult;
+// case CREATE_PASSIVE_OFFER:
+// ManageOfferResult createPassiveOfferResult;
+// case SET_OPTIONS:
+// SetOptionsResult setOptionsResult;
+// case CHANGE_TRUST:
+// ChangeTrustResult changeTrustResult;
+// case ALLOW_TRUST:
+// AllowTrustResult allowTrustResult;
+// case ACCOUNT_MERGE:
+// AccountMergeResult accountMergeResult;
+// case INFLATION:
+// InflationResult inflationResult;
+// }
+// tr;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class OperationResult {
+ public OperationResult () {}
+ OperationResultCode code;
+ public OperationResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(OperationResultCode value) {
+ this.code = value;
+ }
+ private OperationResultTr tr;
+ public OperationResultTr getTr() {
+ return this.tr;
+ }
+ public void setTr(OperationResultTr value) {
+ this.tr = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OperationResult encodedOperationResult) throws IOException {
+ stream.writeInt(encodedOperationResult.getDiscriminant().getValue());
+ switch (encodedOperationResult.getDiscriminant()) {
+ case opINNER:
+ OperationResultTr.encode(stream, encodedOperationResult.tr);
+ break;
+ default:
+ break;
+ }
+ }
+ public static OperationResult decode(XdrDataInputStream stream) throws IOException {
+ OperationResult decodedOperationResult = new OperationResult();
+ switch (decodedOperationResult.getDiscriminant()) {
+ case opINNER:
+ decodedOperationResult.tr = OperationResultTr.decode(stream);
+ break;
+ default:
+ break;
+ }
+ return decodedOperationResult;
+ }
+
+ public static class OperationResultTr {
+ public OperationResultTr () {}
+ OperationType type;
+ public OperationType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(OperationType value) {
+ this.type = value;
+ }
+ private CreateAccountResult createAccountResult;
+ public CreateAccountResult getCreateAccountResult() {
+ return this.createAccountResult;
+ }
+ public void setCreateAccountResult(CreateAccountResult value) {
+ this.createAccountResult = value;
+ }
+ private PaymentResult paymentResult;
+ public PaymentResult getPaymentResult() {
+ return this.paymentResult;
+ }
+ public void setPaymentResult(PaymentResult value) {
+ this.paymentResult = value;
+ }
+ private PathPaymentResult pathPaymentResult;
+ public PathPaymentResult getPathPaymentResult() {
+ return this.pathPaymentResult;
+ }
+ public void setPathPaymentResult(PathPaymentResult value) {
+ this.pathPaymentResult = value;
+ }
+ private ManageOfferResult manageOfferResult;
+ public ManageOfferResult getManageOfferResult() {
+ return this.manageOfferResult;
+ }
+ public void setManageOfferResult(ManageOfferResult value) {
+ this.manageOfferResult = value;
+ }
+ private ManageOfferResult createPassiveOfferResult;
+ public ManageOfferResult getCreatePassiveOfferResult() {
+ return this.createPassiveOfferResult;
+ }
+ public void setCreatePassiveOfferResult(ManageOfferResult value) {
+ this.createPassiveOfferResult = value;
+ }
+ private SetOptionsResult setOptionsResult;
+ public SetOptionsResult getSetOptionsResult() {
+ return this.setOptionsResult;
+ }
+ public void setSetOptionsResult(SetOptionsResult value) {
+ this.setOptionsResult = value;
+ }
+ private ChangeTrustResult changeTrustResult;
+ public ChangeTrustResult getChangeTrustResult() {
+ return this.changeTrustResult;
+ }
+ public void setChangeTrustResult(ChangeTrustResult value) {
+ this.changeTrustResult = value;
+ }
+ private AllowTrustResult allowTrustResult;
+ public AllowTrustResult getAllowTrustResult() {
+ return this.allowTrustResult;
+ }
+ public void setAllowTrustResult(AllowTrustResult value) {
+ this.allowTrustResult = value;
+ }
+ private AccountMergeResult accountMergeResult;
+ public AccountMergeResult getAccountMergeResult() {
+ return this.accountMergeResult;
+ }
+ public void setAccountMergeResult(AccountMergeResult value) {
+ this.accountMergeResult = value;
+ }
+ private InflationResult inflationResult;
+ public InflationResult getInflationResult() {
+ return this.inflationResult;
+ }
+ public void setInflationResult(InflationResult value) {
+ this.inflationResult = value;
+ }
+ public static void encode(XdrDataOutputStream stream, OperationResultTr encodedOperationResultTr) throws IOException {
+ stream.writeInt(encodedOperationResultTr.getDiscriminant().getValue());
+ switch (encodedOperationResultTr.getDiscriminant()) {
+ case CREATE_ACCOUNT:
+ CreateAccountResult.encode(stream, encodedOperationResultTr.createAccountResult);
+ break;
+ case PAYMENT:
+ PaymentResult.encode(stream, encodedOperationResultTr.paymentResult);
+ break;
+ case PATH_PAYMENT:
+ PathPaymentResult.encode(stream, encodedOperationResultTr.pathPaymentResult);
+ break;
+ case MANAGE_OFFER:
+ ManageOfferResult.encode(stream, encodedOperationResultTr.manageOfferResult);
+ break;
+ case CREATE_PASSIVE_OFFER:
+ ManageOfferResult.encode(stream, encodedOperationResultTr.createPassiveOfferResult);
+ break;
+ case SET_OPTIONS:
+ SetOptionsResult.encode(stream, encodedOperationResultTr.setOptionsResult);
+ break;
+ case CHANGE_TRUST:
+ ChangeTrustResult.encode(stream, encodedOperationResultTr.changeTrustResult);
+ break;
+ case ALLOW_TRUST:
+ AllowTrustResult.encode(stream, encodedOperationResultTr.allowTrustResult);
+ break;
+ case ACCOUNT_MERGE:
+ AccountMergeResult.encode(stream, encodedOperationResultTr.accountMergeResult);
+ break;
+ case INFLATION:
+ InflationResult.encode(stream, encodedOperationResultTr.inflationResult);
+ break;
+ }
+ }
+ public static OperationResultTr decode(XdrDataInputStream stream) throws IOException {
+ OperationResultTr decodedOperationResultTr = new OperationResultTr();
+ switch (decodedOperationResultTr.getDiscriminant()) {
+ case CREATE_ACCOUNT:
+ decodedOperationResultTr.createAccountResult = CreateAccountResult.decode(stream);
+ break;
+ case PAYMENT:
+ decodedOperationResultTr.paymentResult = PaymentResult.decode(stream);
+ break;
+ case PATH_PAYMENT:
+ decodedOperationResultTr.pathPaymentResult = PathPaymentResult.decode(stream);
+ break;
+ case MANAGE_OFFER:
+ decodedOperationResultTr.manageOfferResult = ManageOfferResult.decode(stream);
+ break;
+ case CREATE_PASSIVE_OFFER:
+ decodedOperationResultTr.createPassiveOfferResult = ManageOfferResult.decode(stream);
+ break;
+ case SET_OPTIONS:
+ decodedOperationResultTr.setOptionsResult = SetOptionsResult.decode(stream);
+ break;
+ case CHANGE_TRUST:
+ decodedOperationResultTr.changeTrustResult = ChangeTrustResult.decode(stream);
+ break;
+ case ALLOW_TRUST:
+ decodedOperationResultTr.allowTrustResult = AllowTrustResult.decode(stream);
+ break;
+ case ACCOUNT_MERGE:
+ decodedOperationResultTr.accountMergeResult = AccountMergeResult.decode(stream);
+ break;
+ case INFLATION:
+ decodedOperationResultTr.inflationResult = InflationResult.decode(stream);
+ break;
+ }
+ return decodedOperationResultTr;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java b/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java
new file mode 100644
index 000000000..04f05a51a
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OperationResultCode.java
@@ -0,0 +1,49 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum OperationResultCode
+// {
+// opINNER = 0, // inner object result is valid
+//
+// opBAD_AUTH = -1, // too few valid signatures / wrong network
+// opNO_ACCOUNT = -2 // source account was not found
+// };
+
+// ===========================================================================
+public enum OperationResultCode {
+ opINNER(0),
+ opBAD_AUTH(-1),
+ opNO_ACCOUNT(-2),
+ ;
+ private int mValue;
+
+ OperationResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static OperationResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return opINNER;
+ case -1: return opBAD_AUTH;
+ case -2: return opNO_ACCOUNT;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, OperationResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/OperationType.java b/src/main/java/org/stellar/sdk/xdr/OperationType.java
new file mode 100644
index 000000000..f6332b79e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/OperationType.java
@@ -0,0 +1,69 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum OperationType
+// {
+// CREATE_ACCOUNT = 0,
+// PAYMENT = 1,
+// PATH_PAYMENT = 2,
+// MANAGE_OFFER = 3,
+// CREATE_PASSIVE_OFFER = 4,
+// SET_OPTIONS = 5,
+// CHANGE_TRUST = 6,
+// ALLOW_TRUST = 7,
+// ACCOUNT_MERGE = 8,
+// INFLATION = 9
+// };
+
+// ===========================================================================
+public enum OperationType {
+ CREATE_ACCOUNT(0),
+ PAYMENT(1),
+ PATH_PAYMENT(2),
+ MANAGE_OFFER(3),
+ CREATE_PASSIVE_OFFER(4),
+ SET_OPTIONS(5),
+ CHANGE_TRUST(6),
+ ALLOW_TRUST(7),
+ ACCOUNT_MERGE(8),
+ INFLATION(9),
+ ;
+ private int mValue;
+
+ OperationType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static OperationType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return CREATE_ACCOUNT;
+ case 1: return PAYMENT;
+ case 2: return PATH_PAYMENT;
+ case 3: return MANAGE_OFFER;
+ case 4: return CREATE_PASSIVE_OFFER;
+ case 5: return SET_OPTIONS;
+ case 6: return CHANGE_TRUST;
+ case 7: return ALLOW_TRUST;
+ case 8: return ACCOUNT_MERGE;
+ case 9: return INFLATION;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, OperationType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentOp.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentOp.java
new file mode 100644
index 000000000..4cf44b5e9
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentOp.java
@@ -0,0 +1,96 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct PathPaymentOp
+// {
+// Asset sendAsset; // asset we pay with
+// int64 sendMax; // the maximum amount of sendAsset to
+// // send (excluding fees).
+// // The operation will fail if can't be met
+//
+// AccountID destination; // recipient of the payment
+// Asset destAsset; // what they end up with
+// int64 destAmount; // amount they end up with
+//
+// Asset path<5>; // additional hops it must go through to get there
+// };
+
+// ===========================================================================
+public class PathPaymentOp {
+ public PathPaymentOp () {}
+ private Asset sendAsset;
+ public Asset getSendAsset() {
+ return this.sendAsset;
+ }
+ public void setSendAsset(Asset value) {
+ this.sendAsset = value;
+ }
+ private Int64 sendMax;
+ public Int64 getSendMax() {
+ return this.sendMax;
+ }
+ public void setSendMax(Int64 value) {
+ this.sendMax = value;
+ }
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ private Asset destAsset;
+ public Asset getDestAsset() {
+ return this.destAsset;
+ }
+ public void setDestAsset(Asset value) {
+ this.destAsset = value;
+ }
+ private Int64 destAmount;
+ public Int64 getDestAmount() {
+ return this.destAmount;
+ }
+ public void setDestAmount(Int64 value) {
+ this.destAmount = value;
+ }
+ private Asset[] path;
+ public Asset[] getPath() {
+ return this.path;
+ }
+ public void setPath(Asset[] value) {
+ this.path = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PathPaymentOp encodedPathPaymentOp) throws IOException{
+ Asset.encode(stream, encodedPathPaymentOp.sendAsset);
+ Int64.encode(stream, encodedPathPaymentOp.sendMax);
+ AccountID.encode(stream, encodedPathPaymentOp.destination);
+ Asset.encode(stream, encodedPathPaymentOp.destAsset);
+ Int64.encode(stream, encodedPathPaymentOp.destAmount);
+ int pathsize = encodedPathPaymentOp.getPath().length;
+ stream.writeInt(pathsize);
+ for (int i = 0; i < pathsize; i++) {
+ Asset.encode(stream, encodedPathPaymentOp.path[i]);
+ }
+ }
+ public static PathPaymentOp decode(XdrDataInputStream stream) throws IOException {
+ PathPaymentOp decodedPathPaymentOp = new PathPaymentOp();
+ decodedPathPaymentOp.sendAsset = Asset.decode(stream);
+ decodedPathPaymentOp.sendMax = Int64.decode(stream);
+ decodedPathPaymentOp.destination = AccountID.decode(stream);
+ decodedPathPaymentOp.destAsset = Asset.decode(stream);
+ decodedPathPaymentOp.destAmount = Int64.decode(stream);
+ int pathsize = stream.readInt();
+ decodedPathPaymentOp.path = new Asset[pathsize];
+ for (int i = 0; i < pathsize; i++) {
+ decodedPathPaymentOp.path[i] = Asset.decode(stream);
+ }
+ return decodedPathPaymentOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java
new file mode 100644
index 000000000..09a107679
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentResult.java
@@ -0,0 +1,113 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union PathPaymentResult switch (PathPaymentResultCode code)
+// {
+// case PATH_PAYMENT_SUCCESS:
+// struct
+// {
+// ClaimOfferAtom offers<>;
+// SimplePaymentResult last;
+// } success;
+// case PATH_PAYMENT_NO_ISSUER:
+// Asset noIssuer; // the asset that caused the error
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class PathPaymentResult {
+ public PathPaymentResult () {}
+ PathPaymentResultCode code;
+ public PathPaymentResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(PathPaymentResultCode value) {
+ this.code = value;
+ }
+ private PathPaymentResultSuccess success;
+ public PathPaymentResultSuccess getSuccess() {
+ return this.success;
+ }
+ public void setSuccess(PathPaymentResultSuccess value) {
+ this.success = value;
+ }
+ private Asset noIssuer;
+ public Asset getNoIssuer() {
+ return this.noIssuer;
+ }
+ public void setNoIssuer(Asset value) {
+ this.noIssuer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PathPaymentResult encodedPathPaymentResult) throws IOException {
+ stream.writeInt(encodedPathPaymentResult.getDiscriminant().getValue());
+ switch (encodedPathPaymentResult.getDiscriminant()) {
+ case PATH_PAYMENT_SUCCESS:
+ PathPaymentResultSuccess.encode(stream, encodedPathPaymentResult.success);
+ break;
+ case PATH_PAYMENT_NO_ISSUER:
+ Asset.encode(stream, encodedPathPaymentResult.noIssuer);
+ break;
+ default:
+ break;
+ }
+ }
+ public static PathPaymentResult decode(XdrDataInputStream stream) throws IOException {
+ PathPaymentResult decodedPathPaymentResult = new PathPaymentResult();
+ switch (decodedPathPaymentResult.getDiscriminant()) {
+ case PATH_PAYMENT_SUCCESS:
+ decodedPathPaymentResult.success = PathPaymentResultSuccess.decode(stream);
+ break;
+ case PATH_PAYMENT_NO_ISSUER:
+ decodedPathPaymentResult.noIssuer = Asset.decode(stream);
+ break;
+ default:
+ break;
+ }
+ return decodedPathPaymentResult;
+ }
+
+ public static class PathPaymentResultSuccess {
+ public PathPaymentResultSuccess () {}
+ private ClaimOfferAtom[] offers;
+ public ClaimOfferAtom[] getOffers() {
+ return this.offers;
+ }
+ public void setOffers(ClaimOfferAtom[] value) {
+ this.offers = value;
+ }
+ private SimplePaymentResult last;
+ public SimplePaymentResult getLast() {
+ return this.last;
+ }
+ public void setLast(SimplePaymentResult value) {
+ this.last = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PathPaymentResultSuccess encodedPathPaymentResultSuccess) throws IOException{
+ int offerssize = encodedPathPaymentResultSuccess.getOffers().length;
+ stream.writeInt(offerssize);
+ for (int i = 0; i < offerssize; i++) {
+ ClaimOfferAtom.encode(stream, encodedPathPaymentResultSuccess.offers[i]);
+ }
+ SimplePaymentResult.encode(stream, encodedPathPaymentResultSuccess.last);
+ }
+ public static PathPaymentResultSuccess decode(XdrDataInputStream stream) throws IOException {
+ PathPaymentResultSuccess decodedPathPaymentResultSuccess = new PathPaymentResultSuccess();
+ int offerssize = stream.readInt();
+ decodedPathPaymentResultSuccess.offers = new ClaimOfferAtom[offerssize];
+ for (int i = 0; i < offerssize; i++) {
+ decodedPathPaymentResultSuccess.offers[i] = ClaimOfferAtom.decode(stream);
+ }
+ decodedPathPaymentResultSuccess.last = SimplePaymentResult.decode(stream);
+ return decodedPathPaymentResultSuccess;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java b/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java
new file mode 100644
index 000000000..026297001
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PathPaymentResultCode.java
@@ -0,0 +1,81 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum PathPaymentResultCode
+// {
+// // codes considered as "success" for the operation
+// PATH_PAYMENT_SUCCESS = 0, // success
+//
+// // codes considered as "failure" for the operation
+// PATH_PAYMENT_MALFORMED = -1, // bad input
+// PATH_PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
+// PATH_PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
+// PATH_PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
+// PATH_PAYMENT_NO_DESTINATION = -5, // destination account does not exist
+// PATH_PAYMENT_NO_TRUST = -6, // dest missing a trust line for asset
+// PATH_PAYMENT_NOT_AUTHORIZED = -7, // dest not authorized to hold asset
+// PATH_PAYMENT_LINE_FULL = -8, // dest would go above their limit
+// PATH_PAYMENT_NO_ISSUER = -9, // missing issuer on one asset
+// PATH_PAYMENT_TOO_FEW_OFFERS = -10, // not enough offers to satisfy path
+// PATH_PAYMENT_OFFER_CROSS_SELF = -11, // would cross one of its own offers
+// PATH_PAYMENT_OVER_SENDMAX = -12 // could not satisfy sendmax
+// };
+
+// ===========================================================================
+public enum PathPaymentResultCode {
+ PATH_PAYMENT_SUCCESS(0),
+ PATH_PAYMENT_MALFORMED(-1),
+ PATH_PAYMENT_UNDERFUNDED(-2),
+ PATH_PAYMENT_SRC_NO_TRUST(-3),
+ PATH_PAYMENT_SRC_NOT_AUTHORIZED(-4),
+ PATH_PAYMENT_NO_DESTINATION(-5),
+ PATH_PAYMENT_NO_TRUST(-6),
+ PATH_PAYMENT_NOT_AUTHORIZED(-7),
+ PATH_PAYMENT_LINE_FULL(-8),
+ PATH_PAYMENT_NO_ISSUER(-9),
+ PATH_PAYMENT_TOO_FEW_OFFERS(-10),
+ PATH_PAYMENT_OFFER_CROSS_SELF(-11),
+ PATH_PAYMENT_OVER_SENDMAX(-12),
+ ;
+ private int mValue;
+
+ PathPaymentResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static PathPaymentResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return PATH_PAYMENT_SUCCESS;
+ case -1: return PATH_PAYMENT_MALFORMED;
+ case -2: return PATH_PAYMENT_UNDERFUNDED;
+ case -3: return PATH_PAYMENT_SRC_NO_TRUST;
+ case -4: return PATH_PAYMENT_SRC_NOT_AUTHORIZED;
+ case -5: return PATH_PAYMENT_NO_DESTINATION;
+ case -6: return PATH_PAYMENT_NO_TRUST;
+ case -7: return PATH_PAYMENT_NOT_AUTHORIZED;
+ case -8: return PATH_PAYMENT_LINE_FULL;
+ case -9: return PATH_PAYMENT_NO_ISSUER;
+ case -10: return PATH_PAYMENT_TOO_FEW_OFFERS;
+ case -11: return PATH_PAYMENT_OFFER_CROSS_SELF;
+ case -12: return PATH_PAYMENT_OVER_SENDMAX;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, PathPaymentResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentOp.java b/src/main/java/org/stellar/sdk/xdr/PaymentOp.java
new file mode 100644
index 000000000..93266dbfe
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentOp.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct PaymentOp
+// {
+// AccountID destination; // recipient of the payment
+// Asset asset; // what they end up with
+// int64 amount; // amount they end up with
+// };
+
+// ===========================================================================
+public class PaymentOp {
+ public PaymentOp () {}
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ private Asset asset;
+ public Asset getAsset() {
+ return this.asset;
+ }
+ public void setAsset(Asset value) {
+ this.asset = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PaymentOp encodedPaymentOp) throws IOException{
+ AccountID.encode(stream, encodedPaymentOp.destination);
+ Asset.encode(stream, encodedPaymentOp.asset);
+ Int64.encode(stream, encodedPaymentOp.amount);
+ }
+ public static PaymentOp decode(XdrDataInputStream stream) throws IOException {
+ PaymentOp decodedPaymentOp = new PaymentOp();
+ decodedPaymentOp.destination = AccountID.decode(stream);
+ decodedPaymentOp.asset = Asset.decode(stream);
+ decodedPaymentOp.amount = Int64.decode(stream);
+ return decodedPaymentOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentResult.java b/src/main/java/org/stellar/sdk/xdr/PaymentResult.java
new file mode 100644
index 000000000..3c2c85ce8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentResult.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union PaymentResult switch (PaymentResultCode code)
+// {
+// case PAYMENT_SUCCESS:
+// void;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class PaymentResult {
+ public PaymentResult () {}
+ PaymentResultCode code;
+ public PaymentResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(PaymentResultCode value) {
+ this.code = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PaymentResult encodedPaymentResult) throws IOException {
+ stream.writeInt(encodedPaymentResult.getDiscriminant().getValue());
+ switch (encodedPaymentResult.getDiscriminant()) {
+ case PAYMENT_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ }
+ public static PaymentResult decode(XdrDataInputStream stream) throws IOException {
+ PaymentResult decodedPaymentResult = new PaymentResult();
+ switch (decodedPaymentResult.getDiscriminant()) {
+ case PAYMENT_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ return decodedPaymentResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java b/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java
new file mode 100644
index 000000000..4bff90f29
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PaymentResultCode.java
@@ -0,0 +1,72 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum PaymentResultCode
+// {
+// // codes considered as "success" for the operation
+// PAYMENT_SUCCESS = 0, // payment successfuly completed
+//
+// // codes considered as "failure" for the operation
+// PAYMENT_MALFORMED = -1, // bad input
+// PAYMENT_UNDERFUNDED = -2, // not enough funds in source account
+// PAYMENT_SRC_NO_TRUST = -3, // no trust line on source account
+// PAYMENT_SRC_NOT_AUTHORIZED = -4, // source not authorized to transfer
+// PAYMENT_NO_DESTINATION = -5, // destination account does not exist
+// PAYMENT_NO_TRUST = -6, // destination missing a trust line for asset
+// PAYMENT_NOT_AUTHORIZED = -7, // destination not authorized to hold asset
+// PAYMENT_LINE_FULL = -8, // destination would go above their limit
+// PAYMENT_NO_ISSUER = -9 // missing issuer on asset
+// };
+
+// ===========================================================================
+public enum PaymentResultCode {
+ PAYMENT_SUCCESS(0),
+ PAYMENT_MALFORMED(-1),
+ PAYMENT_UNDERFUNDED(-2),
+ PAYMENT_SRC_NO_TRUST(-3),
+ PAYMENT_SRC_NOT_AUTHORIZED(-4),
+ PAYMENT_NO_DESTINATION(-5),
+ PAYMENT_NO_TRUST(-6),
+ PAYMENT_NOT_AUTHORIZED(-7),
+ PAYMENT_LINE_FULL(-8),
+ PAYMENT_NO_ISSUER(-9),
+ ;
+ private int mValue;
+
+ PaymentResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static PaymentResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return PAYMENT_SUCCESS;
+ case -1: return PAYMENT_MALFORMED;
+ case -2: return PAYMENT_UNDERFUNDED;
+ case -3: return PAYMENT_SRC_NO_TRUST;
+ case -4: return PAYMENT_SRC_NOT_AUTHORIZED;
+ case -5: return PAYMENT_NO_DESTINATION;
+ case -6: return PAYMENT_NO_TRUST;
+ case -7: return PAYMENT_NOT_AUTHORIZED;
+ case -8: return PAYMENT_LINE_FULL;
+ case -9: return PAYMENT_NO_ISSUER;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, PaymentResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PeerAddress.java b/src/main/java/org/stellar/sdk/xdr/PeerAddress.java
new file mode 100644
index 000000000..616b8d58e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PeerAddress.java
@@ -0,0 +1,115 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct PeerAddress
+// {
+// union switch (IPAddrType type)
+// {
+// case IPv4:
+// opaque ipv4[4];
+// case IPv6:
+// opaque ipv6[16];
+// } ip;
+// uint32 port;
+// uint32 numFailures;
+// };
+
+// ===========================================================================
+public class PeerAddress {
+ public PeerAddress () {}
+ private PeerAddressIp ip;
+ public PeerAddressIp getIp() {
+ return this.ip;
+ }
+ public void setIp(PeerAddressIp value) {
+ this.ip = value;
+ }
+ private Uint32 port;
+ public Uint32 getPort() {
+ return this.port;
+ }
+ public void setPort(Uint32 value) {
+ this.port = value;
+ }
+ private Uint32 numFailures;
+ public Uint32 getNumFailures() {
+ return this.numFailures;
+ }
+ public void setNumFailures(Uint32 value) {
+ this.numFailures = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PeerAddress encodedPeerAddress) throws IOException{
+ PeerAddressIp.encode(stream, encodedPeerAddress.ip);
+ Uint32.encode(stream, encodedPeerAddress.port);
+ Uint32.encode(stream, encodedPeerAddress.numFailures);
+ }
+ public static PeerAddress decode(XdrDataInputStream stream) throws IOException {
+ PeerAddress decodedPeerAddress = new PeerAddress();
+ decodedPeerAddress.ip = PeerAddressIp.decode(stream);
+ decodedPeerAddress.port = Uint32.decode(stream);
+ decodedPeerAddress.numFailures = Uint32.decode(stream);
+ return decodedPeerAddress;
+ }
+
+ public static class PeerAddressIp {
+ public PeerAddressIp () {}
+ IPAddrType type;
+ public IPAddrType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(IPAddrType value) {
+ this.type = value;
+ }
+ private byte[] ipv4;
+ public byte[] getIpv4() {
+ return this.ipv4;
+ }
+ public void setIpv4(byte[] value) {
+ this.ipv4 = value;
+ }
+ private byte[] ipv6;
+ public byte[] getIpv6() {
+ return this.ipv6;
+ }
+ public void setIpv6(byte[] value) {
+ this.ipv6 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PeerAddressIp encodedPeerAddressIp) throws IOException {
+ stream.writeInt(encodedPeerAddressIp.getDiscriminant().getValue());
+ switch (encodedPeerAddressIp.getDiscriminant()) {
+ case IPv4:
+ int ipv4size = encodedPeerAddressIp.ipv4.length;
+ stream.write(encodedPeerAddressIp.getIpv4(), 0, ipv4size);
+ break;
+ case IPv6:
+ int ipv6size = encodedPeerAddressIp.ipv6.length;
+ stream.write(encodedPeerAddressIp.getIpv6(), 0, ipv6size);
+ break;
+ }
+ }
+ public static PeerAddressIp decode(XdrDataInputStream stream) throws IOException {
+ PeerAddressIp decodedPeerAddressIp = new PeerAddressIp();
+ switch (decodedPeerAddressIp.getDiscriminant()) {
+ case IPv4:
+ int ipv4size = 4;
+ decodedPeerAddressIp.ipv4 = new byte[ipv4size];
+ stream.read(decodedPeerAddressIp.ipv4, 0, ipv4size);
+ break;
+ case IPv6:
+ int ipv6size = 16;
+ decodedPeerAddressIp.ipv6 = new byte[ipv6size];
+ stream.read(decodedPeerAddressIp.ipv6, 0, ipv6size);
+ break;
+ }
+ return decodedPeerAddressIp;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Price.java b/src/main/java/org/stellar/sdk/xdr/Price.java
new file mode 100644
index 000000000..7cd558165
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Price.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Price
+// {
+// int32 n; // numerator
+// int32 d; // denominator
+// };
+
+// ===========================================================================
+public class Price {
+ public Price () {}
+ private Int32 n;
+ public Int32 getN() {
+ return this.n;
+ }
+ public void setN(Int32 value) {
+ this.n = value;
+ }
+ private Int32 d;
+ public Int32 getD() {
+ return this.d;
+ }
+ public void setD(Int32 value) {
+ this.d = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Price encodedPrice) throws IOException{
+ Int32.encode(stream, encodedPrice.n);
+ Int32.encode(stream, encodedPrice.d);
+ }
+ public static Price decode(XdrDataInputStream stream) throws IOException {
+ Price decodedPrice = new Price();
+ decodedPrice.n = Int32.decode(stream);
+ decodedPrice.d = Int32.decode(stream);
+ return decodedPrice;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/PublicKey.java b/src/main/java/org/stellar/sdk/xdr/PublicKey.java
new file mode 100644
index 000000000..6e69d2d5e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/PublicKey.java
@@ -0,0 +1,51 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union PublicKey switch (CryptoKeyType type)
+// {
+// case KEY_TYPE_ED25519:
+// uint256 ed25519;
+// };
+
+// ===========================================================================
+public class PublicKey {
+ public PublicKey () {}
+ CryptoKeyType type;
+ public CryptoKeyType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(CryptoKeyType value) {
+ this.type = value;
+ }
+ private Uint256 ed25519;
+ public Uint256 getEd25519() {
+ return this.ed25519;
+ }
+ public void setEd25519(Uint256 value) {
+ this.ed25519 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, PublicKey encodedPublicKey) throws IOException {
+ stream.writeInt(encodedPublicKey.getDiscriminant().getValue());
+ switch (encodedPublicKey.getDiscriminant()) {
+ case KEY_TYPE_ED25519:
+ Uint256.encode(stream, encodedPublicKey.ed25519);
+ break;
+ }
+ }
+ public static PublicKey decode(XdrDataInputStream stream) throws IOException {
+ PublicKey decodedPublicKey = new PublicKey();
+ switch (decodedPublicKey.getDiscriminant()) {
+ case KEY_TYPE_ED25519:
+ decodedPublicKey.ed25519 = Uint256.decode(stream);
+ break;
+ }
+ return decodedPublicKey;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPBallot.java b/src/main/java/org/stellar/sdk/xdr/SCPBallot.java
new file mode 100644
index 000000000..2ab1face8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPBallot.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SCPBallot
+// {
+// uint32 counter; // n
+// Value value; // x
+// };
+
+// ===========================================================================
+public class SCPBallot {
+ public SCPBallot () {}
+ private Uint32 counter;
+ public Uint32 getCounter() {
+ return this.counter;
+ }
+ public void setCounter(Uint32 value) {
+ this.counter = value;
+ }
+ private Value value;
+ public Value getValue() {
+ return this.value;
+ }
+ public void setValue(Value value) {
+ this.value = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPBallot encodedSCPBallot) throws IOException{
+ Uint32.encode(stream, encodedSCPBallot.counter);
+ Value.encode(stream, encodedSCPBallot.value);
+ }
+ public static SCPBallot decode(XdrDataInputStream stream) throws IOException {
+ SCPBallot decodedSCPBallot = new SCPBallot();
+ decodedSCPBallot.counter = Uint32.decode(stream);
+ decodedSCPBallot.value = Value.decode(stream);
+ return decodedSCPBallot;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java b/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java
new file mode 100644
index 000000000..bedc991dc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPEnvelope.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SCPEnvelope
+// {
+// SCPStatement statement;
+// Signature signature;
+// };
+
+// ===========================================================================
+public class SCPEnvelope {
+ public SCPEnvelope () {}
+ private SCPStatement statement;
+ public SCPStatement getStatement() {
+ return this.statement;
+ }
+ public void setStatement(SCPStatement value) {
+ this.statement = value;
+ }
+ private Signature signature;
+ public Signature getSignature() {
+ return this.signature;
+ }
+ public void setSignature(Signature value) {
+ this.signature = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPEnvelope encodedSCPEnvelope) throws IOException{
+ SCPStatement.encode(stream, encodedSCPEnvelope.statement);
+ Signature.encode(stream, encodedSCPEnvelope.signature);
+ }
+ public static SCPEnvelope decode(XdrDataInputStream stream) throws IOException {
+ SCPEnvelope decodedSCPEnvelope = new SCPEnvelope();
+ decodedSCPEnvelope.statement = SCPStatement.decode(stream);
+ decodedSCPEnvelope.signature = Signature.decode(stream);
+ return decodedSCPEnvelope;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPNomination.java b/src/main/java/org/stellar/sdk/xdr/SCPNomination.java
new file mode 100644
index 000000000..d596ee3ab
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPNomination.java
@@ -0,0 +1,70 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SCPNomination
+// {
+// Hash quorumSetHash; // D
+// Value votes<>; // X
+// Value accepted<>; // Y
+// };
+
+// ===========================================================================
+public class SCPNomination {
+ public SCPNomination () {}
+ private Hash quorumSetHash;
+ public Hash getQuorumSetHash() {
+ return this.quorumSetHash;
+ }
+ public void setQuorumSetHash(Hash value) {
+ this.quorumSetHash = value;
+ }
+ private Value[] votes;
+ public Value[] getVotes() {
+ return this.votes;
+ }
+ public void setVotes(Value[] value) {
+ this.votes = value;
+ }
+ private Value[] accepted;
+ public Value[] getAccepted() {
+ return this.accepted;
+ }
+ public void setAccepted(Value[] value) {
+ this.accepted = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPNomination encodedSCPNomination) throws IOException{
+ Hash.encode(stream, encodedSCPNomination.quorumSetHash);
+ int votessize = encodedSCPNomination.getVotes().length;
+ stream.writeInt(votessize);
+ for (int i = 0; i < votessize; i++) {
+ Value.encode(stream, encodedSCPNomination.votes[i]);
+ }
+ int acceptedsize = encodedSCPNomination.getAccepted().length;
+ stream.writeInt(acceptedsize);
+ for (int i = 0; i < acceptedsize; i++) {
+ Value.encode(stream, encodedSCPNomination.accepted[i]);
+ }
+ }
+ public static SCPNomination decode(XdrDataInputStream stream) throws IOException {
+ SCPNomination decodedSCPNomination = new SCPNomination();
+ decodedSCPNomination.quorumSetHash = Hash.decode(stream);
+ int votessize = stream.readInt();
+ decodedSCPNomination.votes = new Value[votessize];
+ for (int i = 0; i < votessize; i++) {
+ decodedSCPNomination.votes[i] = Value.decode(stream);
+ }
+ int acceptedsize = stream.readInt();
+ decodedSCPNomination.accepted = new Value[acceptedsize];
+ for (int i = 0; i < acceptedsize; i++) {
+ decodedSCPNomination.accepted[i] = Value.decode(stream);
+ }
+ return decodedSCPNomination;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java b/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java
new file mode 100644
index 000000000..7bb86f9a7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPQuorumSet.java
@@ -0,0 +1,70 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SCPQuorumSet
+// {
+// uint32 threshold;
+// PublicKey validators<>;
+// SCPQuorumSet innerSets<>;
+// };
+
+// ===========================================================================
+public class SCPQuorumSet {
+ public SCPQuorumSet () {}
+ private Uint32 threshold;
+ public Uint32 getThreshold() {
+ return this.threshold;
+ }
+ public void setThreshold(Uint32 value) {
+ this.threshold = value;
+ }
+ private PublicKey[] validators;
+ public PublicKey[] getValidators() {
+ return this.validators;
+ }
+ public void setValidators(PublicKey[] value) {
+ this.validators = value;
+ }
+ private SCPQuorumSet[] innerSets;
+ public SCPQuorumSet[] getInnerSets() {
+ return this.innerSets;
+ }
+ public void setInnerSets(SCPQuorumSet[] value) {
+ this.innerSets = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPQuorumSet encodedSCPQuorumSet) throws IOException{
+ Uint32.encode(stream, encodedSCPQuorumSet.threshold);
+ int validatorssize = encodedSCPQuorumSet.getValidators().length;
+ stream.writeInt(validatorssize);
+ for (int i = 0; i < validatorssize; i++) {
+ PublicKey.encode(stream, encodedSCPQuorumSet.validators[i]);
+ }
+ int innerSetssize = encodedSCPQuorumSet.getInnerSets().length;
+ stream.writeInt(innerSetssize);
+ for (int i = 0; i < innerSetssize; i++) {
+ SCPQuorumSet.encode(stream, encodedSCPQuorumSet.innerSets[i]);
+ }
+ }
+ public static SCPQuorumSet decode(XdrDataInputStream stream) throws IOException {
+ SCPQuorumSet decodedSCPQuorumSet = new SCPQuorumSet();
+ decodedSCPQuorumSet.threshold = Uint32.decode(stream);
+ int validatorssize = stream.readInt();
+ decodedSCPQuorumSet.validators = new PublicKey[validatorssize];
+ for (int i = 0; i < validatorssize; i++) {
+ decodedSCPQuorumSet.validators[i] = PublicKey.decode(stream);
+ }
+ int innerSetssize = stream.readInt();
+ decodedSCPQuorumSet.innerSets = new SCPQuorumSet[innerSetssize];
+ for (int i = 0; i < innerSetssize; i++) {
+ decodedSCPQuorumSet.innerSets[i] = SCPQuorumSet.decode(stream);
+ }
+ return decodedSCPQuorumSet;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPStatement.java b/src/main/java/org/stellar/sdk/xdr/SCPStatement.java
new file mode 100644
index 000000000..5f5fe1a79
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPStatement.java
@@ -0,0 +1,325 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SCPStatement
+// {
+// NodeID nodeID; // v
+// uint64 slotIndex; // i
+//
+// union switch (SCPStatementType type)
+// {
+// case SCP_ST_PREPARE:
+// struct
+// {
+// Hash quorumSetHash; // D
+// SCPBallot ballot; // b
+// SCPBallot* prepared; // p
+// SCPBallot* preparedPrime; // p'
+// uint32 nC; // n_c
+// uint32 nP; // n_P
+// } prepare;
+// case SCP_ST_CONFIRM:
+// struct
+// {
+// Hash quorumSetHash; // D
+// uint32 nPrepared; // n_p
+// SCPBallot commit; // c
+// uint32 nP; // n_P
+// } confirm;
+// case SCP_ST_EXTERNALIZE:
+// struct
+// {
+// SCPBallot commit; // c
+// uint32 nP; // n_P
+// // not from the paper, but useful to build tooling to
+// // traverse the graph based off only the latest statement
+// Hash commitQuorumSetHash; // D used before EXTERNALIZE
+// } externalize;
+// case SCP_ST_NOMINATE:
+// SCPNomination nominate;
+// }
+// pledges;
+// };
+
+// ===========================================================================
+public class SCPStatement {
+ public SCPStatement () {}
+ private NodeID nodeID;
+ public NodeID getNodeID() {
+ return this.nodeID;
+ }
+ public void setNodeID(NodeID value) {
+ this.nodeID = value;
+ }
+ private Uint64 slotIndex;
+ public Uint64 getSlotIndex() {
+ return this.slotIndex;
+ }
+ public void setSlotIndex(Uint64 value) {
+ this.slotIndex = value;
+ }
+ private SCPStatementPledges pledges;
+ public SCPStatementPledges getPledges() {
+ return this.pledges;
+ }
+ public void setPledges(SCPStatementPledges value) {
+ this.pledges = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPStatement encodedSCPStatement) throws IOException{
+ NodeID.encode(stream, encodedSCPStatement.nodeID);
+ Uint64.encode(stream, encodedSCPStatement.slotIndex);
+ SCPStatementPledges.encode(stream, encodedSCPStatement.pledges);
+ }
+ public static SCPStatement decode(XdrDataInputStream stream) throws IOException {
+ SCPStatement decodedSCPStatement = new SCPStatement();
+ decodedSCPStatement.nodeID = NodeID.decode(stream);
+ decodedSCPStatement.slotIndex = Uint64.decode(stream);
+ decodedSCPStatement.pledges = SCPStatementPledges.decode(stream);
+ return decodedSCPStatement;
+ }
+
+ public static class SCPStatementPledges {
+ public SCPStatementPledges () {}
+ SCPStatementType type;
+ public SCPStatementType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(SCPStatementType value) {
+ this.type = value;
+ }
+ private SCPStatementPrepare prepare;
+ public SCPStatementPrepare getPrepare() {
+ return this.prepare;
+ }
+ public void setPrepare(SCPStatementPrepare value) {
+ this.prepare = value;
+ }
+ private SCPStatementConfirm confirm;
+ public SCPStatementConfirm getConfirm() {
+ return this.confirm;
+ }
+ public void setConfirm(SCPStatementConfirm value) {
+ this.confirm = value;
+ }
+ private SCPStatementExternalize externalize;
+ public SCPStatementExternalize getExternalize() {
+ return this.externalize;
+ }
+ public void setExternalize(SCPStatementExternalize value) {
+ this.externalize = value;
+ }
+ private SCPNomination nominate;
+ public SCPNomination getNominate() {
+ return this.nominate;
+ }
+ public void setNominate(SCPNomination value) {
+ this.nominate = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPStatementPledges encodedSCPStatementPledges) throws IOException {
+ stream.writeInt(encodedSCPStatementPledges.getDiscriminant().getValue());
+ switch (encodedSCPStatementPledges.getDiscriminant()) {
+ case SCP_ST_PREPARE:
+ SCPStatementPrepare.encode(stream, encodedSCPStatementPledges.prepare);
+ break;
+ case SCP_ST_CONFIRM:
+ SCPStatementConfirm.encode(stream, encodedSCPStatementPledges.confirm);
+ break;
+ case SCP_ST_EXTERNALIZE:
+ SCPStatementExternalize.encode(stream, encodedSCPStatementPledges.externalize);
+ break;
+ case SCP_ST_NOMINATE:
+ SCPNomination.encode(stream, encodedSCPStatementPledges.nominate);
+ break;
+ }
+ }
+ public static SCPStatementPledges decode(XdrDataInputStream stream) throws IOException {
+ SCPStatementPledges decodedSCPStatementPledges = new SCPStatementPledges();
+ switch (decodedSCPStatementPledges.getDiscriminant()) {
+ case SCP_ST_PREPARE:
+ decodedSCPStatementPledges.prepare = SCPStatementPrepare.decode(stream);
+ break;
+ case SCP_ST_CONFIRM:
+ decodedSCPStatementPledges.confirm = SCPStatementConfirm.decode(stream);
+ break;
+ case SCP_ST_EXTERNALIZE:
+ decodedSCPStatementPledges.externalize = SCPStatementExternalize.decode(stream);
+ break;
+ case SCP_ST_NOMINATE:
+ decodedSCPStatementPledges.nominate = SCPNomination.decode(stream);
+ break;
+ }
+ return decodedSCPStatementPledges;
+ }
+
+ public static class SCPStatementPrepare {
+ public SCPStatementPrepare () {}
+ private Hash quorumSetHash;
+ public Hash getQuorumSetHash() {
+ return this.quorumSetHash;
+ }
+ public void setQuorumSetHash(Hash value) {
+ this.quorumSetHash = value;
+ }
+ private SCPBallot ballot;
+ public SCPBallot getBallot() {
+ return this.ballot;
+ }
+ public void setBallot(SCPBallot value) {
+ this.ballot = value;
+ }
+ private SCPBallot prepared;
+ public SCPBallot getPrepared() {
+ return this.prepared;
+ }
+ public void setPrepared(SCPBallot value) {
+ this.prepared = value;
+ }
+ private SCPBallot preparedPrime;
+ public SCPBallot getPreparedPrime() {
+ return this.preparedPrime;
+ }
+ public void setPreparedPrime(SCPBallot value) {
+ this.preparedPrime = value;
+ }
+ private Uint32 nC;
+ public Uint32 getNC() {
+ return this.nC;
+ }
+ public void setNC(Uint32 value) {
+ this.nC = value;
+ }
+ private Uint32 nP;
+ public Uint32 getNP() {
+ return this.nP;
+ }
+ public void setNP(Uint32 value) {
+ this.nP = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPStatementPrepare encodedSCPStatementPrepare) throws IOException{
+ Hash.encode(stream, encodedSCPStatementPrepare.quorumSetHash);
+ SCPBallot.encode(stream, encodedSCPStatementPrepare.ballot);
+ if (encodedSCPStatementPrepare.prepared != null) {
+ stream.writeInt(1);
+ SCPBallot.encode(stream, encodedSCPStatementPrepare.prepared);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSCPStatementPrepare.preparedPrime != null) {
+ stream.writeInt(1);
+ SCPBallot.encode(stream, encodedSCPStatementPrepare.preparedPrime);
+ } else {
+ stream.writeInt(0);
+ }
+ Uint32.encode(stream, encodedSCPStatementPrepare.nC);
+ Uint32.encode(stream, encodedSCPStatementPrepare.nP);
+ }
+ public static SCPStatementPrepare decode(XdrDataInputStream stream) throws IOException {
+ SCPStatementPrepare decodedSCPStatementPrepare = new SCPStatementPrepare();
+ decodedSCPStatementPrepare.quorumSetHash = Hash.decode(stream);
+ decodedSCPStatementPrepare.ballot = SCPBallot.decode(stream);
+ int preparedPresent = stream.readInt();
+ if (preparedPresent != 0) {
+ decodedSCPStatementPrepare.prepared = SCPBallot.decode(stream);
+ }
+ int preparedPrimePresent = stream.readInt();
+ if (preparedPrimePresent != 0) {
+ decodedSCPStatementPrepare.preparedPrime = SCPBallot.decode(stream);
+ }
+ decodedSCPStatementPrepare.nC = Uint32.decode(stream);
+ decodedSCPStatementPrepare.nP = Uint32.decode(stream);
+ return decodedSCPStatementPrepare;
+ }
+
+ }
+ public static class SCPStatementConfirm {
+ public SCPStatementConfirm () {}
+ private Hash quorumSetHash;
+ public Hash getQuorumSetHash() {
+ return this.quorumSetHash;
+ }
+ public void setQuorumSetHash(Hash value) {
+ this.quorumSetHash = value;
+ }
+ private Uint32 nPrepared;
+ public Uint32 getNPrepared() {
+ return this.nPrepared;
+ }
+ public void setNPrepared(Uint32 value) {
+ this.nPrepared = value;
+ }
+ private SCPBallot commit;
+ public SCPBallot getCommit() {
+ return this.commit;
+ }
+ public void setCommit(SCPBallot value) {
+ this.commit = value;
+ }
+ private Uint32 nP;
+ public Uint32 getNP() {
+ return this.nP;
+ }
+ public void setNP(Uint32 value) {
+ this.nP = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPStatementConfirm encodedSCPStatementConfirm) throws IOException{
+ Hash.encode(stream, encodedSCPStatementConfirm.quorumSetHash);
+ Uint32.encode(stream, encodedSCPStatementConfirm.nPrepared);
+ SCPBallot.encode(stream, encodedSCPStatementConfirm.commit);
+ Uint32.encode(stream, encodedSCPStatementConfirm.nP);
+ }
+ public static SCPStatementConfirm decode(XdrDataInputStream stream) throws IOException {
+ SCPStatementConfirm decodedSCPStatementConfirm = new SCPStatementConfirm();
+ decodedSCPStatementConfirm.quorumSetHash = Hash.decode(stream);
+ decodedSCPStatementConfirm.nPrepared = Uint32.decode(stream);
+ decodedSCPStatementConfirm.commit = SCPBallot.decode(stream);
+ decodedSCPStatementConfirm.nP = Uint32.decode(stream);
+ return decodedSCPStatementConfirm;
+ }
+
+ }
+ public static class SCPStatementExternalize {
+ public SCPStatementExternalize () {}
+ private SCPBallot commit;
+ public SCPBallot getCommit() {
+ return this.commit;
+ }
+ public void setCommit(SCPBallot value) {
+ this.commit = value;
+ }
+ private Uint32 nP;
+ public Uint32 getNP() {
+ return this.nP;
+ }
+ public void setNP(Uint32 value) {
+ this.nP = value;
+ }
+ private Hash commitQuorumSetHash;
+ public Hash getCommitQuorumSetHash() {
+ return this.commitQuorumSetHash;
+ }
+ public void setCommitQuorumSetHash(Hash value) {
+ this.commitQuorumSetHash = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SCPStatementExternalize encodedSCPStatementExternalize) throws IOException{
+ SCPBallot.encode(stream, encodedSCPStatementExternalize.commit);
+ Uint32.encode(stream, encodedSCPStatementExternalize.nP);
+ Hash.encode(stream, encodedSCPStatementExternalize.commitQuorumSetHash);
+ }
+ public static SCPStatementExternalize decode(XdrDataInputStream stream) throws IOException {
+ SCPStatementExternalize decodedSCPStatementExternalize = new SCPStatementExternalize();
+ decodedSCPStatementExternalize.commit = SCPBallot.decode(stream);
+ decodedSCPStatementExternalize.nP = Uint32.decode(stream);
+ decodedSCPStatementExternalize.commitQuorumSetHash = Hash.decode(stream);
+ return decodedSCPStatementExternalize;
+ }
+
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java b/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java
new file mode 100644
index 000000000..701770aa8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SCPStatementType.java
@@ -0,0 +1,51 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum SCPStatementType
+// {
+// SCP_ST_PREPARE = 0,
+// SCP_ST_CONFIRM = 1,
+// SCP_ST_EXTERNALIZE = 2,
+// SCP_ST_NOMINATE = 3
+// };
+
+// ===========================================================================
+public enum SCPStatementType {
+ SCP_ST_PREPARE(0),
+ SCP_ST_CONFIRM(1),
+ SCP_ST_EXTERNALIZE(2),
+ SCP_ST_NOMINATE(3),
+ ;
+ private int mValue;
+
+ SCPStatementType(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static SCPStatementType decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return SCP_ST_PREPARE;
+ case 1: return SCP_ST_CONFIRM;
+ case 2: return SCP_ST_EXTERNALIZE;
+ case 3: return SCP_ST_NOMINATE;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, SCPStatementType value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java b/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java
new file mode 100644
index 000000000..6c130579b
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SequenceNumber.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef uint64 SequenceNumber;
+
+// ===========================================================================
+public class SequenceNumber {
+ private Uint64 SequenceNumber;
+ public Uint64 getSequenceNumber() {
+ return this.SequenceNumber;
+ }
+ public void setSequenceNumber(Uint64 value) {
+ this.SequenceNumber = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SequenceNumber encodedSequenceNumber) throws IOException {
+ Uint64.encode(stream, encodedSequenceNumber.SequenceNumber);
+ }
+ public static SequenceNumber decode(XdrDataInputStream stream) throws IOException {
+ SequenceNumber decodedSequenceNumber = new SequenceNumber();
+ decodedSequenceNumber.SequenceNumber = Uint64.decode(stream);
+ return decodedSequenceNumber;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java
new file mode 100644
index 000000000..7071b1aec
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsOp.java
@@ -0,0 +1,193 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SetOptionsOp
+// {
+// AccountID* inflationDest; // sets the inflation destination
+//
+// uint32* clearFlags; // which flags to clear
+// uint32* setFlags; // which flags to set
+//
+// // account threshold manipulation
+// uint32* masterWeight; // weight of the master account
+// uint32* lowThreshold;
+// uint32* medThreshold;
+// uint32* highThreshold;
+//
+// string32* homeDomain; // sets the home domain
+//
+// // Add, update or remove a signer for the account
+// // signer is deleted if the weight is 0
+// Signer* signer;
+// };
+
+// ===========================================================================
+public class SetOptionsOp {
+ public SetOptionsOp () {}
+ private AccountID inflationDest;
+ public AccountID getInflationDest() {
+ return this.inflationDest;
+ }
+ public void setInflationDest(AccountID value) {
+ this.inflationDest = value;
+ }
+ private Uint32 clearFlags;
+ public Uint32 getClearFlags() {
+ return this.clearFlags;
+ }
+ public void setClearFlags(Uint32 value) {
+ this.clearFlags = value;
+ }
+ private Uint32 setFlags;
+ public Uint32 getSetFlags() {
+ return this.setFlags;
+ }
+ public void setSetFlags(Uint32 value) {
+ this.setFlags = value;
+ }
+ private Uint32 masterWeight;
+ public Uint32 getMasterWeight() {
+ return this.masterWeight;
+ }
+ public void setMasterWeight(Uint32 value) {
+ this.masterWeight = value;
+ }
+ private Uint32 lowThreshold;
+ public Uint32 getLowThreshold() {
+ return this.lowThreshold;
+ }
+ public void setLowThreshold(Uint32 value) {
+ this.lowThreshold = value;
+ }
+ private Uint32 medThreshold;
+ public Uint32 getMedThreshold() {
+ return this.medThreshold;
+ }
+ public void setMedThreshold(Uint32 value) {
+ this.medThreshold = value;
+ }
+ private Uint32 highThreshold;
+ public Uint32 getHighThreshold() {
+ return this.highThreshold;
+ }
+ public void setHighThreshold(Uint32 value) {
+ this.highThreshold = value;
+ }
+ private String32 homeDomain;
+ public String32 getHomeDomain() {
+ return this.homeDomain;
+ }
+ public void setHomeDomain(String32 value) {
+ this.homeDomain = value;
+ }
+ private Signer signer;
+ public Signer getSigner() {
+ return this.signer;
+ }
+ public void setSigner(Signer value) {
+ this.signer = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SetOptionsOp encodedSetOptionsOp) throws IOException{
+ if (encodedSetOptionsOp.inflationDest != null) {
+ stream.writeInt(1);
+ AccountID.encode(stream, encodedSetOptionsOp.inflationDest);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.clearFlags != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.clearFlags);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.setFlags != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.setFlags);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.masterWeight != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.masterWeight);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.lowThreshold != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.lowThreshold);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.medThreshold != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.medThreshold);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.highThreshold != null) {
+ stream.writeInt(1);
+ Uint32.encode(stream, encodedSetOptionsOp.highThreshold);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.homeDomain != null) {
+ stream.writeInt(1);
+ String32.encode(stream, encodedSetOptionsOp.homeDomain);
+ } else {
+ stream.writeInt(0);
+ }
+ if (encodedSetOptionsOp.signer != null) {
+ stream.writeInt(1);
+ Signer.encode(stream, encodedSetOptionsOp.signer);
+ } else {
+ stream.writeInt(0);
+ }
+ }
+ public static SetOptionsOp decode(XdrDataInputStream stream) throws IOException {
+ SetOptionsOp decodedSetOptionsOp = new SetOptionsOp();
+ int inflationDestPresent = stream.readInt();
+ if (inflationDestPresent != 0) {
+ decodedSetOptionsOp.inflationDest = AccountID.decode(stream);
+ }
+ int clearFlagsPresent = stream.readInt();
+ if (clearFlagsPresent != 0) {
+ decodedSetOptionsOp.clearFlags = Uint32.decode(stream);
+ }
+ int setFlagsPresent = stream.readInt();
+ if (setFlagsPresent != 0) {
+ decodedSetOptionsOp.setFlags = Uint32.decode(stream);
+ }
+ int masterWeightPresent = stream.readInt();
+ if (masterWeightPresent != 0) {
+ decodedSetOptionsOp.masterWeight = Uint32.decode(stream);
+ }
+ int lowThresholdPresent = stream.readInt();
+ if (lowThresholdPresent != 0) {
+ decodedSetOptionsOp.lowThreshold = Uint32.decode(stream);
+ }
+ int medThresholdPresent = stream.readInt();
+ if (medThresholdPresent != 0) {
+ decodedSetOptionsOp.medThreshold = Uint32.decode(stream);
+ }
+ int highThresholdPresent = stream.readInt();
+ if (highThresholdPresent != 0) {
+ decodedSetOptionsOp.highThreshold = Uint32.decode(stream);
+ }
+ int homeDomainPresent = stream.readInt();
+ if (homeDomainPresent != 0) {
+ decodedSetOptionsOp.homeDomain = String32.decode(stream);
+ }
+ int signerPresent = stream.readInt();
+ if (signerPresent != 0) {
+ decodedSetOptionsOp.signer = Signer.decode(stream);
+ }
+ return decodedSetOptionsOp;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java
new file mode 100644
index 000000000..40e4e57a7
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsResult.java
@@ -0,0 +1,48 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union SetOptionsResult switch (SetOptionsResultCode code)
+// {
+// case SET_OPTIONS_SUCCESS:
+// void;
+// default:
+// void;
+// };
+
+// ===========================================================================
+public class SetOptionsResult {
+ public SetOptionsResult () {}
+ SetOptionsResultCode code;
+ public SetOptionsResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(SetOptionsResultCode value) {
+ this.code = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SetOptionsResult encodedSetOptionsResult) throws IOException {
+ stream.writeInt(encodedSetOptionsResult.getDiscriminant().getValue());
+ switch (encodedSetOptionsResult.getDiscriminant()) {
+ case SET_OPTIONS_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ }
+ public static SetOptionsResult decode(XdrDataInputStream stream) throws IOException {
+ SetOptionsResult decodedSetOptionsResult = new SetOptionsResult();
+ switch (decodedSetOptionsResult.getDiscriminant()) {
+ case SET_OPTIONS_SUCCESS:
+ break;
+ default:
+ break;
+ }
+ return decodedSetOptionsResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java b/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java
new file mode 100644
index 000000000..8ab2adbdd
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SetOptionsResultCode.java
@@ -0,0 +1,71 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum SetOptionsResultCode
+// {
+// // codes considered as "success" for the operation
+// SET_OPTIONS_SUCCESS = 0,
+// // codes considered as "failure" for the operation
+// SET_OPTIONS_LOW_RESERVE = -1, // not enough funds to add a signer
+// SET_OPTIONS_TOO_MANY_SIGNERS = -2, // max number of signers already reached
+// SET_OPTIONS_BAD_FLAGS = -3, // invalid combination of clear/set flags
+// SET_OPTIONS_INVALID_INFLATION = -4, // inflation account does not exist
+// SET_OPTIONS_CANT_CHANGE = -5, // can no longer change this option
+// SET_OPTIONS_UNKNOWN_FLAG = -6, // can't set an unknown flag
+// SET_OPTIONS_THRESHOLD_OUT_OF_RANGE = -7, // bad value for weight/threshold
+// SET_OPTIONS_BAD_SIGNER = -8, // signer cannot be masterkey
+// SET_OPTIONS_INVALID_HOME_DOMAIN = -9 // malformed home domain
+// };
+
+// ===========================================================================
+public enum SetOptionsResultCode {
+ SET_OPTIONS_SUCCESS(0),
+ SET_OPTIONS_LOW_RESERVE(-1),
+ SET_OPTIONS_TOO_MANY_SIGNERS(-2),
+ SET_OPTIONS_BAD_FLAGS(-3),
+ SET_OPTIONS_INVALID_INFLATION(-4),
+ SET_OPTIONS_CANT_CHANGE(-5),
+ SET_OPTIONS_UNKNOWN_FLAG(-6),
+ SET_OPTIONS_THRESHOLD_OUT_OF_RANGE(-7),
+ SET_OPTIONS_BAD_SIGNER(-8),
+ SET_OPTIONS_INVALID_HOME_DOMAIN(-9),
+ ;
+ private int mValue;
+
+ SetOptionsResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static SetOptionsResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return SET_OPTIONS_SUCCESS;
+ case -1: return SET_OPTIONS_LOW_RESERVE;
+ case -2: return SET_OPTIONS_TOO_MANY_SIGNERS;
+ case -3: return SET_OPTIONS_BAD_FLAGS;
+ case -4: return SET_OPTIONS_INVALID_INFLATION;
+ case -5: return SET_OPTIONS_CANT_CHANGE;
+ case -6: return SET_OPTIONS_UNKNOWN_FLAG;
+ case -7: return SET_OPTIONS_THRESHOLD_OUT_OF_RANGE;
+ case -8: return SET_OPTIONS_BAD_SIGNER;
+ case -9: return SET_OPTIONS_INVALID_HOME_DOMAIN;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, SetOptionsResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Signature.java b/src/main/java/org/stellar/sdk/xdr/Signature.java
new file mode 100644
index 000000000..34cc005d8
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Signature.java
@@ -0,0 +1,34 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque Signature<64>;
+
+// ===========================================================================
+public class Signature {
+ private byte[] Signature;
+ public byte[] getSignature() {
+ return this.Signature;
+ }
+ public void setSignature(byte[] value) {
+ this.Signature = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Signature encodedSignature) throws IOException {
+ int Signaturesize = encodedSignature.Signature.length;
+ stream.writeInt(Signaturesize);
+ stream.write(encodedSignature.getSignature(), 0, Signaturesize);
+ }
+ public static Signature decode(XdrDataInputStream stream) throws IOException {
+ Signature decodedSignature = new Signature();
+ int Signaturesize = stream.readInt();
+ decodedSignature.Signature = new byte[Signaturesize];
+ stream.read(decodedSignature.Signature, 0, Signaturesize);
+ return decodedSignature;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SignatureHint.java b/src/main/java/org/stellar/sdk/xdr/SignatureHint.java
new file mode 100644
index 000000000..e7aacc0a2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SignatureHint.java
@@ -0,0 +1,33 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque SignatureHint[4];
+
+// ===========================================================================
+public class SignatureHint {
+ private byte[] SignatureHint;
+ public byte[] getSignatureHint() {
+ return this.SignatureHint;
+ }
+ public void setSignatureHint(byte[] value) {
+ this.SignatureHint = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SignatureHint encodedSignatureHint) throws IOException {
+ int SignatureHintsize = encodedSignatureHint.SignatureHint.length;
+ stream.write(encodedSignatureHint.getSignatureHint(), 0, SignatureHintsize);
+ }
+ public static SignatureHint decode(XdrDataInputStream stream) throws IOException {
+ SignatureHint decodedSignatureHint = new SignatureHint();
+ int SignatureHintsize = 4;
+ decodedSignatureHint.SignatureHint = new byte[SignatureHintsize];
+ stream.read(decodedSignatureHint.SignatureHint, 0, SignatureHintsize);
+ return decodedSignatureHint;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Signer.java b/src/main/java/org/stellar/sdk/xdr/Signer.java
new file mode 100644
index 000000000..5a183d476
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Signer.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Signer
+// {
+// AccountID pubKey;
+// uint32 weight; // really only need 1byte
+// };
+
+// ===========================================================================
+public class Signer {
+ public Signer () {}
+ private AccountID pubKey;
+ public AccountID getPubKey() {
+ return this.pubKey;
+ }
+ public void setPubKey(AccountID value) {
+ this.pubKey = value;
+ }
+ private Uint32 weight;
+ public Uint32 getWeight() {
+ return this.weight;
+ }
+ public void setWeight(Uint32 value) {
+ this.weight = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Signer encodedSigner) throws IOException{
+ AccountID.encode(stream, encodedSigner.pubKey);
+ Uint32.encode(stream, encodedSigner.weight);
+ }
+ public static Signer decode(XdrDataInputStream stream) throws IOException {
+ Signer decodedSigner = new Signer();
+ decodedSigner.pubKey = AccountID.decode(stream);
+ decodedSigner.weight = Uint32.decode(stream);
+ return decodedSigner;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java b/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java
new file mode 100644
index 000000000..e25e7c0fd
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/SimplePaymentResult.java
@@ -0,0 +1,54 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct SimplePaymentResult
+// {
+// AccountID destination;
+// Asset asset;
+// int64 amount;
+// };
+
+// ===========================================================================
+public class SimplePaymentResult {
+ public SimplePaymentResult () {}
+ private AccountID destination;
+ public AccountID getDestination() {
+ return this.destination;
+ }
+ public void setDestination(AccountID value) {
+ this.destination = value;
+ }
+ private Asset asset;
+ public Asset getAsset() {
+ return this.asset;
+ }
+ public void setAsset(Asset value) {
+ this.asset = value;
+ }
+ private Int64 amount;
+ public Int64 getAmount() {
+ return this.amount;
+ }
+ public void setAmount(Int64 value) {
+ this.amount = value;
+ }
+ public static void encode(XdrDataOutputStream stream, SimplePaymentResult encodedSimplePaymentResult) throws IOException{
+ AccountID.encode(stream, encodedSimplePaymentResult.destination);
+ Asset.encode(stream, encodedSimplePaymentResult.asset);
+ Int64.encode(stream, encodedSimplePaymentResult.amount);
+ }
+ public static SimplePaymentResult decode(XdrDataInputStream stream) throws IOException {
+ SimplePaymentResult decodedSimplePaymentResult = new SimplePaymentResult();
+ decodedSimplePaymentResult.destination = AccountID.decode(stream);
+ decodedSimplePaymentResult.asset = Asset.decode(stream);
+ decodedSimplePaymentResult.amount = Int64.decode(stream);
+ return decodedSimplePaymentResult;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/StellarMessage.java b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java
new file mode 100644
index 000000000..ac5fc2b06
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/StellarMessage.java
@@ -0,0 +1,219 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union StellarMessage switch (MessageType type)
+// {
+// case ERROR_MSG:
+// Error error;
+// case HELLO:
+// Hello hello;
+// case AUTH:
+// Auth auth;
+// case DONT_HAVE:
+// DontHave dontHave;
+// case GET_PEERS:
+// void;
+// case PEERS:
+// PeerAddress peers<>;
+//
+// case GET_TX_SET:
+// uint256 txSetHash;
+// case TX_SET:
+// TransactionSet txSet;
+//
+// case TRANSACTION:
+// TransactionEnvelope transaction;
+//
+// // SCP
+// case GET_SCP_QUORUMSET:
+// uint256 qSetHash;
+// case SCP_QUORUMSET:
+// SCPQuorumSet qSet;
+// case SCP_MESSAGE:
+// SCPEnvelope envelope;
+// };
+
+// ===========================================================================
+public class StellarMessage {
+ public StellarMessage () {}
+ MessageType type;
+ public MessageType getDiscriminant() {
+ return this.type;
+ }
+ public void setDiscriminant(MessageType value) {
+ this.type = value;
+ }
+ private Error error;
+ public Error getError() {
+ return this.error;
+ }
+ public void setError(Error value) {
+ this.error = value;
+ }
+ private Hello hello;
+ public Hello getHello() {
+ return this.hello;
+ }
+ public void setHello(Hello value) {
+ this.hello = value;
+ }
+ private Auth auth;
+ public Auth getAuth() {
+ return this.auth;
+ }
+ public void setAuth(Auth value) {
+ this.auth = value;
+ }
+ private DontHave dontHave;
+ public DontHave getDontHave() {
+ return this.dontHave;
+ }
+ public void setDontHave(DontHave value) {
+ this.dontHave = value;
+ }
+ private PeerAddress[] peers;
+ public PeerAddress[] getPeers() {
+ return this.peers;
+ }
+ public void setPeers(PeerAddress[] value) {
+ this.peers = value;
+ }
+ private Uint256 txSetHash;
+ public Uint256 getTxSetHash() {
+ return this.txSetHash;
+ }
+ public void setTxSetHash(Uint256 value) {
+ this.txSetHash = value;
+ }
+ private TransactionSet txSet;
+ public TransactionSet getTxSet() {
+ return this.txSet;
+ }
+ public void setTxSet(TransactionSet value) {
+ this.txSet = value;
+ }
+ private TransactionEnvelope transaction;
+ public TransactionEnvelope getTransaction() {
+ return this.transaction;
+ }
+ public void setTransaction(TransactionEnvelope value) {
+ this.transaction = value;
+ }
+ private Uint256 qSetHash;
+ public Uint256 getQSetHash() {
+ return this.qSetHash;
+ }
+ public void setQSetHash(Uint256 value) {
+ this.qSetHash = value;
+ }
+ private SCPQuorumSet qSet;
+ public SCPQuorumSet getQSet() {
+ return this.qSet;
+ }
+ public void setQSet(SCPQuorumSet value) {
+ this.qSet = value;
+ }
+ private SCPEnvelope envelope;
+ public SCPEnvelope getEnvelope() {
+ return this.envelope;
+ }
+ public void setEnvelope(SCPEnvelope value) {
+ this.envelope = value;
+ }
+ public static void encode(XdrDataOutputStream stream, StellarMessage encodedStellarMessage) throws IOException {
+ stream.writeInt(encodedStellarMessage.getDiscriminant().getValue());
+ switch (encodedStellarMessage.getDiscriminant()) {
+ case ERROR_MSG:
+ Error.encode(stream, encodedStellarMessage.error);
+ break;
+ case HELLO:
+ Hello.encode(stream, encodedStellarMessage.hello);
+ break;
+ case AUTH:
+ Auth.encode(stream, encodedStellarMessage.auth);
+ break;
+ case DONT_HAVE:
+ DontHave.encode(stream, encodedStellarMessage.dontHave);
+ break;
+ case GET_PEERS:
+ break;
+ case PEERS:
+ int peerssize = encodedStellarMessage.getPeers().length;
+ stream.writeInt(peerssize);
+ for (int i = 0; i < peerssize; i++) {
+ PeerAddress.encode(stream, encodedStellarMessage.peers[i]);
+ }
+ break;
+ case GET_TX_SET:
+ Uint256.encode(stream, encodedStellarMessage.txSetHash);
+ break;
+ case TX_SET:
+ TransactionSet.encode(stream, encodedStellarMessage.txSet);
+ break;
+ case TRANSACTION:
+ TransactionEnvelope.encode(stream, encodedStellarMessage.transaction);
+ break;
+ case GET_SCP_QUORUMSET:
+ Uint256.encode(stream, encodedStellarMessage.qSetHash);
+ break;
+ case SCP_QUORUMSET:
+ SCPQuorumSet.encode(stream, encodedStellarMessage.qSet);
+ break;
+ case SCP_MESSAGE:
+ SCPEnvelope.encode(stream, encodedStellarMessage.envelope);
+ break;
+ }
+ }
+ public static StellarMessage decode(XdrDataInputStream stream) throws IOException {
+ StellarMessage decodedStellarMessage = new StellarMessage();
+ switch (decodedStellarMessage.getDiscriminant()) {
+ case ERROR_MSG:
+ decodedStellarMessage.error = Error.decode(stream);
+ break;
+ case HELLO:
+ decodedStellarMessage.hello = Hello.decode(stream);
+ break;
+ case AUTH:
+ decodedStellarMessage.auth = Auth.decode(stream);
+ break;
+ case DONT_HAVE:
+ decodedStellarMessage.dontHave = DontHave.decode(stream);
+ break;
+ case GET_PEERS:
+ break;
+ case PEERS:
+ int peerssize = stream.readInt();
+ decodedStellarMessage.peers = new PeerAddress[peerssize];
+ for (int i = 0; i < peerssize; i++) {
+ decodedStellarMessage.peers[i] = PeerAddress.decode(stream);
+ }
+ break;
+ case GET_TX_SET:
+ decodedStellarMessage.txSetHash = Uint256.decode(stream);
+ break;
+ case TX_SET:
+ decodedStellarMessage.txSet = TransactionSet.decode(stream);
+ break;
+ case TRANSACTION:
+ decodedStellarMessage.transaction = TransactionEnvelope.decode(stream);
+ break;
+ case GET_SCP_QUORUMSET:
+ decodedStellarMessage.qSetHash = Uint256.decode(stream);
+ break;
+ case SCP_QUORUMSET:
+ decodedStellarMessage.qSet = SCPQuorumSet.decode(stream);
+ break;
+ case SCP_MESSAGE:
+ decodedStellarMessage.envelope = SCPEnvelope.decode(stream);
+ break;
+ }
+ return decodedStellarMessage;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/StellarValue.java b/src/main/java/org/stellar/sdk/xdr/StellarValue.java
new file mode 100644
index 000000000..b6b1ed975
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/StellarValue.java
@@ -0,0 +1,112 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct StellarValue
+// {
+// Hash txSetHash; // transaction set to apply to previous ledger
+// uint64 closeTime; // network close time
+//
+// // upgrades to apply to the previous ledger (usually empty)
+// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop
+// // unknown steps during consensus if needed.
+// // see notes below on 'LedgerUpgrade' for more detail
+// // max size is dictated by number of upgrade types (+ room for future)
+// UpgradeType upgrades<6>;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class StellarValue {
+ public StellarValue () {}
+ private Hash txSetHash;
+ public Hash getTxSetHash() {
+ return this.txSetHash;
+ }
+ public void setTxSetHash(Hash value) {
+ this.txSetHash = value;
+ }
+ private Uint64 closeTime;
+ public Uint64 getCloseTime() {
+ return this.closeTime;
+ }
+ public void setCloseTime(Uint64 value) {
+ this.closeTime = value;
+ }
+ private UpgradeType[] upgrades;
+ public UpgradeType[] getUpgrades() {
+ return this.upgrades;
+ }
+ public void setUpgrades(UpgradeType[] value) {
+ this.upgrades = value;
+ }
+ private StellarValueExt ext;
+ public StellarValueExt getExt() {
+ return this.ext;
+ }
+ public void setExt(StellarValueExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, StellarValue encodedStellarValue) throws IOException{
+ Hash.encode(stream, encodedStellarValue.txSetHash);
+ Uint64.encode(stream, encodedStellarValue.closeTime);
+ int upgradessize = encodedStellarValue.getUpgrades().length;
+ stream.writeInt(upgradessize);
+ for (int i = 0; i < upgradessize; i++) {
+ UpgradeType.encode(stream, encodedStellarValue.upgrades[i]);
+ }
+ StellarValueExt.encode(stream, encodedStellarValue.ext);
+ }
+ public static StellarValue decode(XdrDataInputStream stream) throws IOException {
+ StellarValue decodedStellarValue = new StellarValue();
+ decodedStellarValue.txSetHash = Hash.decode(stream);
+ decodedStellarValue.closeTime = Uint64.decode(stream);
+ int upgradessize = stream.readInt();
+ decodedStellarValue.upgrades = new UpgradeType[upgradessize];
+ for (int i = 0; i < upgradessize; i++) {
+ decodedStellarValue.upgrades[i] = UpgradeType.decode(stream);
+ }
+ decodedStellarValue.ext = StellarValueExt.decode(stream);
+ return decodedStellarValue;
+ }
+
+ public static class StellarValueExt {
+ public StellarValueExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, StellarValueExt encodedStellarValueExt) throws IOException {
+ stream.writeInt(encodedStellarValueExt.getDiscriminant().intValue());
+ switch (encodedStellarValueExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static StellarValueExt decode(XdrDataInputStream stream) throws IOException {
+ StellarValueExt decodedStellarValueExt = new StellarValueExt();
+ switch (decodedStellarValueExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedStellarValueExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/String32.java b/src/main/java/org/stellar/sdk/xdr/String32.java
new file mode 100644
index 000000000..2e974cdeb
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/String32.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef string string32<32>;
+
+// ===========================================================================
+public class String32 {
+ private String string32;
+ public String getString32() {
+ return this.string32;
+ }
+ public void setString32(String value) {
+ this.string32 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, String32 encodedString32) throws IOException {
+ stream.writeString(encodedString32.string32);
+ }
+ public static String32 decode(XdrDataInputStream stream) throws IOException {
+ String32 decodedString32 = new String32();
+ decodedString32.string32 = stream.readString();
+ return decodedString32;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java b/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java
new file mode 100644
index 000000000..7046e94a2
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ThresholdIndexes.java
@@ -0,0 +1,51 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ThresholdIndexes
+// {
+// THRESHOLD_MASTER_WEIGHT = 0,
+// THRESHOLD_LOW = 1,
+// THRESHOLD_MED = 2,
+// THRESHOLD_HIGH = 3
+// };
+
+// ===========================================================================
+public enum ThresholdIndexes {
+ THRESHOLD_MASTER_WEIGHT(0),
+ THRESHOLD_LOW(1),
+ THRESHOLD_MED(2),
+ THRESHOLD_HIGH(3),
+ ;
+ private int mValue;
+
+ ThresholdIndexes(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ThresholdIndexes decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return THRESHOLD_MASTER_WEIGHT;
+ case 1: return THRESHOLD_LOW;
+ case 2: return THRESHOLD_MED;
+ case 3: return THRESHOLD_HIGH;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ThresholdIndexes value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java b/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java
new file mode 100644
index 000000000..89e5f8921
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/ThresholdIndices.java
@@ -0,0 +1,51 @@
+// Automatically generated on 2015-11-05T11:21:06-08:00
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum ThresholdIndexes
+// {
+// THRESHOLD_MASTER_WEIGHT = 0,
+// THRESHOLD_LOW = 1,
+// THRESHOLD_MED = 2,
+// THRESHOLD_HIGH = 3
+// };
+
+// ===========================================================================
+public enum ThresholdIndices {
+ THRESHOLD_MASTER_WEIGHT(0),
+ THRESHOLD_LOW(1),
+ THRESHOLD_MED(2),
+ THRESHOLD_HIGH(3),
+ ;
+ private int mValue;
+
+ ThresholdIndices(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static ThresholdIndices decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return THRESHOLD_MASTER_WEIGHT;
+ case 1: return THRESHOLD_LOW;
+ case 2: return THRESHOLD_MED;
+ case 3: return THRESHOLD_HIGH;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, ThresholdIndices value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Thresholds.java b/src/main/java/org/stellar/sdk/xdr/Thresholds.java
new file mode 100644
index 000000000..9e7656a8d
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Thresholds.java
@@ -0,0 +1,33 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque Thresholds[4];
+
+// ===========================================================================
+public class Thresholds {
+ private byte[] Thresholds;
+ public byte[] getThresholds() {
+ return this.Thresholds;
+ }
+ public void setThresholds(byte[] value) {
+ this.Thresholds = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Thresholds encodedThresholds) throws IOException {
+ int Thresholdssize = encodedThresholds.Thresholds.length;
+ stream.write(encodedThresholds.getThresholds(), 0, Thresholdssize);
+ }
+ public static Thresholds decode(XdrDataInputStream stream) throws IOException {
+ Thresholds decodedThresholds = new Thresholds();
+ int Thresholdssize = 4;
+ decodedThresholds.Thresholds = new byte[Thresholdssize];
+ stream.read(decodedThresholds.Thresholds, 0, Thresholdssize);
+ return decodedThresholds;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TimeBounds.java b/src/main/java/org/stellar/sdk/xdr/TimeBounds.java
new file mode 100644
index 000000000..8b4d5e2fc
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TimeBounds.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TimeBounds
+// {
+// uint64 minTime;
+// uint64 maxTime;
+// };
+
+// ===========================================================================
+public class TimeBounds {
+ public TimeBounds () {}
+ private Uint64 minTime;
+ public Uint64 getMinTime() {
+ return this.minTime;
+ }
+ public void setMinTime(Uint64 value) {
+ this.minTime = value;
+ }
+ private Uint64 maxTime;
+ public Uint64 getMaxTime() {
+ return this.maxTime;
+ }
+ public void setMaxTime(Uint64 value) {
+ this.maxTime = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TimeBounds encodedTimeBounds) throws IOException{
+ Uint64.encode(stream, encodedTimeBounds.minTime);
+ Uint64.encode(stream, encodedTimeBounds.maxTime);
+ }
+ public static TimeBounds decode(XdrDataInputStream stream) throws IOException {
+ TimeBounds decodedTimeBounds = new TimeBounds();
+ decodedTimeBounds.minTime = Uint64.decode(stream);
+ decodedTimeBounds.maxTime = Uint64.decode(stream);
+ return decodedTimeBounds;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Transaction.java b/src/main/java/org/stellar/sdk/xdr/Transaction.java
new file mode 100644
index 000000000..eb874b54c
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Transaction.java
@@ -0,0 +1,153 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct Transaction
+// {
+// // account used to run the transaction
+// AccountID sourceAccount;
+//
+// // the fee the sourceAccount will pay
+// uint32 fee;
+//
+// // sequence number to consume in the account
+// SequenceNumber seqNum;
+//
+// // validity range (inclusive) for the last ledger close time
+// TimeBounds* timeBounds;
+//
+// Memo memo;
+//
+// Operation operations<100>;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class Transaction {
+ public Transaction () {}
+ private AccountID sourceAccount;
+ public AccountID getSourceAccount() {
+ return this.sourceAccount;
+ }
+ public void setSourceAccount(AccountID value) {
+ this.sourceAccount = value;
+ }
+ private Uint32 fee;
+ public Uint32 getFee() {
+ return this.fee;
+ }
+ public void setFee(Uint32 value) {
+ this.fee = value;
+ }
+ private SequenceNumber seqNum;
+ public SequenceNumber getSeqNum() {
+ return this.seqNum;
+ }
+ public void setSeqNum(SequenceNumber value) {
+ this.seqNum = value;
+ }
+ private TimeBounds timeBounds;
+ public TimeBounds getTimeBounds() {
+ return this.timeBounds;
+ }
+ public void setTimeBounds(TimeBounds value) {
+ this.timeBounds = value;
+ }
+ private Memo memo;
+ public Memo getMemo() {
+ return this.memo;
+ }
+ public void setMemo(Memo value) {
+ this.memo = value;
+ }
+ private Operation[] operations;
+ public Operation[] getOperations() {
+ return this.operations;
+ }
+ public void setOperations(Operation[] value) {
+ this.operations = value;
+ }
+ private TransactionExt ext;
+ public TransactionExt getExt() {
+ return this.ext;
+ }
+ public void setExt(TransactionExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Transaction encodedTransaction) throws IOException{
+ AccountID.encode(stream, encodedTransaction.sourceAccount);
+ Uint32.encode(stream, encodedTransaction.fee);
+ SequenceNumber.encode(stream, encodedTransaction.seqNum);
+ if (encodedTransaction.timeBounds != null) {
+ stream.writeInt(1);
+ TimeBounds.encode(stream, encodedTransaction.timeBounds);
+ } else {
+ stream.writeInt(0);
+ }
+ Memo.encode(stream, encodedTransaction.memo);
+ int operationssize = encodedTransaction.getOperations().length;
+ stream.writeInt(operationssize);
+ for (int i = 0; i < operationssize; i++) {
+ Operation.encode(stream, encodedTransaction.operations[i]);
+ }
+ TransactionExt.encode(stream, encodedTransaction.ext);
+ }
+ public static Transaction decode(XdrDataInputStream stream) throws IOException {
+ Transaction decodedTransaction = new Transaction();
+ decodedTransaction.sourceAccount = AccountID.decode(stream);
+ decodedTransaction.fee = Uint32.decode(stream);
+ decodedTransaction.seqNum = SequenceNumber.decode(stream);
+ int timeBoundsPresent = stream.readInt();
+ if (timeBoundsPresent != 0) {
+ decodedTransaction.timeBounds = TimeBounds.decode(stream);
+ }
+ decodedTransaction.memo = Memo.decode(stream);
+ int operationssize = stream.readInt();
+ decodedTransaction.operations = new Operation[operationssize];
+ for (int i = 0; i < operationssize; i++) {
+ decodedTransaction.operations[i] = Operation.decode(stream);
+ }
+ decodedTransaction.ext = TransactionExt.decode(stream);
+ return decodedTransaction;
+ }
+
+ public static class TransactionExt {
+ public TransactionExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionExt encodedTransactionExt) throws IOException {
+ stream.writeInt(encodedTransactionExt.getDiscriminant().intValue());
+ switch (encodedTransactionExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static TransactionExt decode(XdrDataInputStream stream) throws IOException {
+ TransactionExt decodedTransactionExt = new TransactionExt();
+ switch (decodedTransactionExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedTransactionExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java b/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java
new file mode 100644
index 000000000..c45fe67d5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionEnvelope.java
@@ -0,0 +1,52 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionEnvelope
+// {
+// Transaction tx;
+// DecoratedSignature signatures<20>;
+// };
+
+// ===========================================================================
+public class TransactionEnvelope {
+ public TransactionEnvelope () {}
+ private Transaction tx;
+ public Transaction getTx() {
+ return this.tx;
+ }
+ public void setTx(Transaction value) {
+ this.tx = value;
+ }
+ private DecoratedSignature[] signatures;
+ public DecoratedSignature[] getSignatures() {
+ return this.signatures;
+ }
+ public void setSignatures(DecoratedSignature[] value) {
+ this.signatures = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionEnvelope encodedTransactionEnvelope) throws IOException{
+ Transaction.encode(stream, encodedTransactionEnvelope.tx);
+ int signaturessize = encodedTransactionEnvelope.getSignatures().length;
+ stream.writeInt(signaturessize);
+ for (int i = 0; i < signaturessize; i++) {
+ DecoratedSignature.encode(stream, encodedTransactionEnvelope.signatures[i]);
+ }
+ }
+ public static TransactionEnvelope decode(XdrDataInputStream stream) throws IOException {
+ TransactionEnvelope decodedTransactionEnvelope = new TransactionEnvelope();
+ decodedTransactionEnvelope.tx = Transaction.decode(stream);
+ int signaturessize = stream.readInt();
+ decodedTransactionEnvelope.signatures = new DecoratedSignature[signaturessize];
+ for (int i = 0; i < signaturessize; i++) {
+ decodedTransactionEnvelope.signatures[i] = DecoratedSignature.decode(stream);
+ }
+ return decodedTransactionEnvelope;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java
new file mode 100644
index 000000000..31e277ae6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryEntry.java
@@ -0,0 +1,88 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionHistoryEntry
+// {
+// uint32 ledgerSeq;
+// TransactionSet txSet;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class TransactionHistoryEntry {
+ public TransactionHistoryEntry () {}
+ private Uint32 ledgerSeq;
+ public Uint32 getLedgerSeq() {
+ return this.ledgerSeq;
+ }
+ public void setLedgerSeq(Uint32 value) {
+ this.ledgerSeq = value;
+ }
+ private TransactionSet txSet;
+ public TransactionSet getTxSet() {
+ return this.txSet;
+ }
+ public void setTxSet(TransactionSet value) {
+ this.txSet = value;
+ }
+ private TransactionHistoryEntryExt ext;
+ public TransactionHistoryEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(TransactionHistoryEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionHistoryEntry encodedTransactionHistoryEntry) throws IOException{
+ Uint32.encode(stream, encodedTransactionHistoryEntry.ledgerSeq);
+ TransactionSet.encode(stream, encodedTransactionHistoryEntry.txSet);
+ TransactionHistoryEntryExt.encode(stream, encodedTransactionHistoryEntry.ext);
+ }
+ public static TransactionHistoryEntry decode(XdrDataInputStream stream) throws IOException {
+ TransactionHistoryEntry decodedTransactionHistoryEntry = new TransactionHistoryEntry();
+ decodedTransactionHistoryEntry.ledgerSeq = Uint32.decode(stream);
+ decodedTransactionHistoryEntry.txSet = TransactionSet.decode(stream);
+ decodedTransactionHistoryEntry.ext = TransactionHistoryEntryExt.decode(stream);
+ return decodedTransactionHistoryEntry;
+ }
+
+ public static class TransactionHistoryEntryExt {
+ public TransactionHistoryEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionHistoryEntryExt encodedTransactionHistoryEntryExt) throws IOException {
+ stream.writeInt(encodedTransactionHistoryEntryExt.getDiscriminant().intValue());
+ switch (encodedTransactionHistoryEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static TransactionHistoryEntryExt decode(XdrDataInputStream stream) throws IOException {
+ TransactionHistoryEntryExt decodedTransactionHistoryEntryExt = new TransactionHistoryEntryExt();
+ switch (decodedTransactionHistoryEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedTransactionHistoryEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java
new file mode 100644
index 000000000..2c5adc4b0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionHistoryResultEntry.java
@@ -0,0 +1,88 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionHistoryResultEntry
+// {
+// uint32 ledgerSeq;
+// TransactionResultSet txResultSet;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class TransactionHistoryResultEntry {
+ public TransactionHistoryResultEntry () {}
+ private Uint32 ledgerSeq;
+ public Uint32 getLedgerSeq() {
+ return this.ledgerSeq;
+ }
+ public void setLedgerSeq(Uint32 value) {
+ this.ledgerSeq = value;
+ }
+ private TransactionResultSet txResultSet;
+ public TransactionResultSet getTxResultSet() {
+ return this.txResultSet;
+ }
+ public void setTxResultSet(TransactionResultSet value) {
+ this.txResultSet = value;
+ }
+ private TransactionHistoryResultEntryExt ext;
+ public TransactionHistoryResultEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(TransactionHistoryResultEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionHistoryResultEntry encodedTransactionHistoryResultEntry) throws IOException{
+ Uint32.encode(stream, encodedTransactionHistoryResultEntry.ledgerSeq);
+ TransactionResultSet.encode(stream, encodedTransactionHistoryResultEntry.txResultSet);
+ TransactionHistoryResultEntryExt.encode(stream, encodedTransactionHistoryResultEntry.ext);
+ }
+ public static TransactionHistoryResultEntry decode(XdrDataInputStream stream) throws IOException {
+ TransactionHistoryResultEntry decodedTransactionHistoryResultEntry = new TransactionHistoryResultEntry();
+ decodedTransactionHistoryResultEntry.ledgerSeq = Uint32.decode(stream);
+ decodedTransactionHistoryResultEntry.txResultSet = TransactionResultSet.decode(stream);
+ decodedTransactionHistoryResultEntry.ext = TransactionHistoryResultEntryExt.decode(stream);
+ return decodedTransactionHistoryResultEntry;
+ }
+
+ public static class TransactionHistoryResultEntryExt {
+ public TransactionHistoryResultEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionHistoryResultEntryExt encodedTransactionHistoryResultEntryExt) throws IOException {
+ stream.writeInt(encodedTransactionHistoryResultEntryExt.getDiscriminant().intValue());
+ switch (encodedTransactionHistoryResultEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static TransactionHistoryResultEntryExt decode(XdrDataInputStream stream) throws IOException {
+ TransactionHistoryResultEntryExt decodedTransactionHistoryResultEntryExt = new TransactionHistoryResultEntryExt();
+ switch (decodedTransactionHistoryResultEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedTransactionHistoryResultEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java b/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java
new file mode 100644
index 000000000..8f2eea914
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionMeta.java
@@ -0,0 +1,59 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// union TransactionMeta switch (int v)
+// {
+// case 0:
+// OperationMeta operations<>;
+// };
+
+// ===========================================================================
+public class TransactionMeta {
+ public TransactionMeta () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ private OperationMeta[] operations;
+ public OperationMeta[] getOperations() {
+ return this.operations;
+ }
+ public void setOperations(OperationMeta[] value) {
+ this.operations = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionMeta encodedTransactionMeta) throws IOException {
+ stream.writeInt(encodedTransactionMeta.getDiscriminant().intValue());
+ switch (encodedTransactionMeta.getDiscriminant()) {
+ case 0:
+ int operationssize = encodedTransactionMeta.getOperations().length;
+ stream.writeInt(operationssize);
+ for (int i = 0; i < operationssize; i++) {
+ OperationMeta.encode(stream, encodedTransactionMeta.operations[i]);
+ }
+ break;
+ }
+ }
+ public static TransactionMeta decode(XdrDataInputStream stream) throws IOException {
+ TransactionMeta decodedTransactionMeta = new TransactionMeta();
+ switch (decodedTransactionMeta.getDiscriminant()) {
+ case 0:
+ int operationssize = stream.readInt();
+ decodedTransactionMeta.operations = new OperationMeta[operationssize];
+ for (int i = 0; i < operationssize; i++) {
+ decodedTransactionMeta.operations[i] = OperationMeta.decode(stream);
+ }
+ break;
+ }
+ return decodedTransactionMeta;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResult.java b/src/main/java/org/stellar/sdk/xdr/TransactionResult.java
new file mode 100644
index 000000000..55168f96e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResult.java
@@ -0,0 +1,146 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionResult
+// {
+// int64 feeCharged; // actual fee charged for the transaction
+//
+// union switch (TransactionResultCode code)
+// {
+// case txSUCCESS:
+// case txFAILED:
+// OperationResult results<>;
+// default:
+// void;
+// }
+// result;
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class TransactionResult {
+ public TransactionResult () {}
+ private Int64 feeCharged;
+ public Int64 getFeeCharged() {
+ return this.feeCharged;
+ }
+ public void setFeeCharged(Int64 value) {
+ this.feeCharged = value;
+ }
+ private TransactionResultResult result;
+ public TransactionResultResult getResult() {
+ return this.result;
+ }
+ public void setResult(TransactionResultResult value) {
+ this.result = value;
+ }
+ private TransactionResultExt ext;
+ public TransactionResultExt getExt() {
+ return this.ext;
+ }
+ public void setExt(TransactionResultExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionResult encodedTransactionResult) throws IOException{
+ Int64.encode(stream, encodedTransactionResult.feeCharged);
+ TransactionResultResult.encode(stream, encodedTransactionResult.result);
+ TransactionResultExt.encode(stream, encodedTransactionResult.ext);
+ }
+ public static TransactionResult decode(XdrDataInputStream stream) throws IOException {
+ TransactionResult decodedTransactionResult = new TransactionResult();
+ decodedTransactionResult.feeCharged = Int64.decode(stream);
+ decodedTransactionResult.result = TransactionResultResult.decode(stream);
+ decodedTransactionResult.ext = TransactionResultExt.decode(stream);
+ return decodedTransactionResult;
+ }
+
+ public static class TransactionResultResult {
+ public TransactionResultResult () {}
+ TransactionResultCode code;
+ public TransactionResultCode getDiscriminant() {
+ return this.code;
+ }
+ public void setDiscriminant(TransactionResultCode value) {
+ this.code = value;
+ }
+ private OperationResult[] results;
+ public OperationResult[] getResults() {
+ return this.results;
+ }
+ public void setResults(OperationResult[] value) {
+ this.results = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionResultResult encodedTransactionResultResult) throws IOException {
+ stream.writeInt(encodedTransactionResultResult.getDiscriminant().getValue());
+ switch (encodedTransactionResultResult.getDiscriminant()) {
+ case txSUCCESS:
+ case txFAILED:
+ int resultssize = encodedTransactionResultResult.getResults().length;
+ stream.writeInt(resultssize);
+ for (int i = 0; i < resultssize; i++) {
+ OperationResult.encode(stream, encodedTransactionResultResult.results[i]);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ public static TransactionResultResult decode(XdrDataInputStream stream) throws IOException {
+ TransactionResultResult decodedTransactionResultResult = new TransactionResultResult();
+ switch (decodedTransactionResultResult.getDiscriminant()) {
+ case txSUCCESS:
+ case txFAILED:
+ int resultssize = stream.readInt();
+ decodedTransactionResultResult.results = new OperationResult[resultssize];
+ for (int i = 0; i < resultssize; i++) {
+ decodedTransactionResultResult.results[i] = OperationResult.decode(stream);
+ }
+ break;
+ default:
+ break;
+ }
+ return decodedTransactionResultResult;
+ }
+
+ }
+ public static class TransactionResultExt {
+ public TransactionResultExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionResultExt encodedTransactionResultExt) throws IOException {
+ stream.writeInt(encodedTransactionResultExt.getDiscriminant().intValue());
+ switch (encodedTransactionResultExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static TransactionResultExt decode(XdrDataInputStream stream) throws IOException {
+ TransactionResultExt decodedTransactionResultExt = new TransactionResultExt();
+ switch (decodedTransactionResultExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedTransactionResultExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java
new file mode 100644
index 000000000..916570c86
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultCode.java
@@ -0,0 +1,78 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum TransactionResultCode
+// {
+// txSUCCESS = 0, // all operations succeeded
+//
+// txFAILED = -1, // one of the operations failed (none were applied)
+//
+// txTOO_EARLY = -2, // ledger closeTime before minTime
+// txTOO_LATE = -3, // ledger closeTime after maxTime
+// txMISSING_OPERATION = -4, // no operation was specified
+// txBAD_SEQ = -5, // sequence number does not match source account
+//
+// txBAD_AUTH = -6, // too few valid signatures / wrong network
+// txINSUFFICIENT_BALANCE = -7, // fee would bring account below reserve
+// txNO_ACCOUNT = -8, // source account not found
+// txINSUFFICIENT_FEE = -9, // fee is too small
+// txBAD_AUTH_EXTRA = -10, // unused signatures attached to transaction
+// txINTERNAL_ERROR = -11 // an unknown error occured
+// };
+
+// ===========================================================================
+public enum TransactionResultCode {
+ txSUCCESS(0),
+ txFAILED(-1),
+ txTOO_EARLY(-2),
+ txTOO_LATE(-3),
+ txMISSING_OPERATION(-4),
+ txBAD_SEQ(-5),
+ txBAD_AUTH(-6),
+ txINSUFFICIENT_BALANCE(-7),
+ txNO_ACCOUNT(-8),
+ txINSUFFICIENT_FEE(-9),
+ txBAD_AUTH_EXTRA(-10),
+ txINTERNAL_ERROR(-11),
+ ;
+ private int mValue;
+
+ TransactionResultCode(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static TransactionResultCode decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 0: return txSUCCESS;
+ case -1: return txFAILED;
+ case -2: return txTOO_EARLY;
+ case -3: return txTOO_LATE;
+ case -4: return txMISSING_OPERATION;
+ case -5: return txBAD_SEQ;
+ case -6: return txBAD_AUTH;
+ case -7: return txINSUFFICIENT_BALANCE;
+ case -8: return txNO_ACCOUNT;
+ case -9: return txINSUFFICIENT_FEE;
+ case -10: return txBAD_AUTH_EXTRA;
+ case -11: return txINTERNAL_ERROR;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, TransactionResultCode value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java
new file mode 100644
index 000000000..f7b0183cf
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultPair.java
@@ -0,0 +1,44 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionResultPair
+// {
+// Hash transactionHash;
+// TransactionResult result; // result for the transaction
+// };
+
+// ===========================================================================
+public class TransactionResultPair {
+ public TransactionResultPair () {}
+ private Hash transactionHash;
+ public Hash getTransactionHash() {
+ return this.transactionHash;
+ }
+ public void setTransactionHash(Hash value) {
+ this.transactionHash = value;
+ }
+ private TransactionResult result;
+ public TransactionResult getResult() {
+ return this.result;
+ }
+ public void setResult(TransactionResult value) {
+ this.result = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionResultPair encodedTransactionResultPair) throws IOException{
+ Hash.encode(stream, encodedTransactionResultPair.transactionHash);
+ TransactionResult.encode(stream, encodedTransactionResultPair.result);
+ }
+ public static TransactionResultPair decode(XdrDataInputStream stream) throws IOException {
+ TransactionResultPair decodedTransactionResultPair = new TransactionResultPair();
+ decodedTransactionResultPair.transactionHash = Hash.decode(stream);
+ decodedTransactionResultPair.result = TransactionResult.decode(stream);
+ return decodedTransactionResultPair;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java b/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java
new file mode 100644
index 000000000..f5aa9282e
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionResultSet.java
@@ -0,0 +1,42 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionResultSet
+// {
+// TransactionResultPair results;
+// };
+
+// ===========================================================================
+public class TransactionResultSet {
+ public TransactionResultSet () {}
+ private TransactionResultPair[] results;
+ public TransactionResultPair[] getResults() {
+ return this.results;
+ }
+ public void setResults(TransactionResultPair[] value) {
+ this.results = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionResultSet encodedTransactionResultSet) throws IOException{
+ int resultssize = encodedTransactionResultSet.getResults().length;
+ stream.writeInt(resultssize);
+ for (int i = 0; i < resultssize; i++) {
+ TransactionResultPair.encode(stream, encodedTransactionResultSet.results[i]);
+ }
+ }
+ public static TransactionResultSet decode(XdrDataInputStream stream) throws IOException {
+ TransactionResultSet decodedTransactionResultSet = new TransactionResultSet();
+ int resultssize = stream.readInt();
+ decodedTransactionResultSet.results = new TransactionResultPair[resultssize];
+ for (int i = 0; i < resultssize; i++) {
+ decodedTransactionResultSet.results[i] = TransactionResultPair.decode(stream);
+ }
+ return decodedTransactionResultSet;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TransactionSet.java b/src/main/java/org/stellar/sdk/xdr/TransactionSet.java
new file mode 100644
index 000000000..3d8e311b9
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TransactionSet.java
@@ -0,0 +1,52 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TransactionSet
+// {
+// Hash previousLedgerHash;
+// TransactionEnvelope txs;
+// };
+
+// ===========================================================================
+public class TransactionSet {
+ public TransactionSet () {}
+ private Hash previousLedgerHash;
+ public Hash getPreviousLedgerHash() {
+ return this.previousLedgerHash;
+ }
+ public void setPreviousLedgerHash(Hash value) {
+ this.previousLedgerHash = value;
+ }
+ private TransactionEnvelope[] txs;
+ public TransactionEnvelope[] getTxs() {
+ return this.txs;
+ }
+ public void setTxs(TransactionEnvelope[] value) {
+ this.txs = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TransactionSet encodedTransactionSet) throws IOException{
+ Hash.encode(stream, encodedTransactionSet.previousLedgerHash);
+ int txssize = encodedTransactionSet.getTxs().length;
+ stream.writeInt(txssize);
+ for (int i = 0; i < txssize; i++) {
+ TransactionEnvelope.encode(stream, encodedTransactionSet.txs[i]);
+ }
+ }
+ public static TransactionSet decode(XdrDataInputStream stream) throws IOException {
+ TransactionSet decodedTransactionSet = new TransactionSet();
+ decodedTransactionSet.previousLedgerHash = Hash.decode(stream);
+ int txssize = stream.readInt();
+ decodedTransactionSet.txs = new TransactionEnvelope[txssize];
+ for (int i = 0; i < txssize; i++) {
+ decodedTransactionSet.txs[i] = TransactionEnvelope.decode(stream);
+ }
+ return decodedTransactionSet;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java b/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java
new file mode 100644
index 000000000..91b639731
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineEntry.java
@@ -0,0 +1,120 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// struct TrustLineEntry
+// {
+// AccountID accountID; // account this trustline belongs to
+// Asset asset; // type of asset (with issuer)
+// int64 balance; // how much of this asset the user has.
+// // Asset defines the unit for this;
+//
+// int64 limit; // balance cannot be above this
+// uint32 flags; // see TrustLineFlags
+//
+// // reserved for future use
+// union switch (int v)
+// {
+// case 0:
+// void;
+// }
+// ext;
+// };
+
+// ===========================================================================
+public class TrustLineEntry {
+ public TrustLineEntry () {}
+ private AccountID accountID;
+ public AccountID getAccountID() {
+ return this.accountID;
+ }
+ public void setAccountID(AccountID value) {
+ this.accountID = value;
+ }
+ private Asset asset;
+ public Asset getAsset() {
+ return this.asset;
+ }
+ public void setAsset(Asset value) {
+ this.asset = value;
+ }
+ private Int64 balance;
+ public Int64 getBalance() {
+ return this.balance;
+ }
+ public void setBalance(Int64 value) {
+ this.balance = value;
+ }
+ private Int64 limit;
+ public Int64 getLimit() {
+ return this.limit;
+ }
+ public void setLimit(Int64 value) {
+ this.limit = value;
+ }
+ private Uint32 flags;
+ public Uint32 getFlags() {
+ return this.flags;
+ }
+ public void setFlags(Uint32 value) {
+ this.flags = value;
+ }
+ private TrustLineEntryExt ext;
+ public TrustLineEntryExt getExt() {
+ return this.ext;
+ }
+ public void setExt(TrustLineEntryExt value) {
+ this.ext = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TrustLineEntry encodedTrustLineEntry) throws IOException{
+ AccountID.encode(stream, encodedTrustLineEntry.accountID);
+ Asset.encode(stream, encodedTrustLineEntry.asset);
+ Int64.encode(stream, encodedTrustLineEntry.balance);
+ Int64.encode(stream, encodedTrustLineEntry.limit);
+ Uint32.encode(stream, encodedTrustLineEntry.flags);
+ TrustLineEntryExt.encode(stream, encodedTrustLineEntry.ext);
+ }
+ public static TrustLineEntry decode(XdrDataInputStream stream) throws IOException {
+ TrustLineEntry decodedTrustLineEntry = new TrustLineEntry();
+ decodedTrustLineEntry.accountID = AccountID.decode(stream);
+ decodedTrustLineEntry.asset = Asset.decode(stream);
+ decodedTrustLineEntry.balance = Int64.decode(stream);
+ decodedTrustLineEntry.limit = Int64.decode(stream);
+ decodedTrustLineEntry.flags = Uint32.decode(stream);
+ decodedTrustLineEntry.ext = TrustLineEntryExt.decode(stream);
+ return decodedTrustLineEntry;
+ }
+
+ public static class TrustLineEntryExt {
+ public TrustLineEntryExt () {}
+ Integer v;
+ public Integer getDiscriminant() {
+ return this.v;
+ }
+ public void setDiscriminant(Integer value) {
+ this.v = value;
+ }
+ public static void encode(XdrDataOutputStream stream, TrustLineEntryExt encodedTrustLineEntryExt) throws IOException {
+ stream.writeInt(encodedTrustLineEntryExt.getDiscriminant().intValue());
+ switch (encodedTrustLineEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ }
+ public static TrustLineEntryExt decode(XdrDataInputStream stream) throws IOException {
+ TrustLineEntryExt decodedTrustLineEntryExt = new TrustLineEntryExt();
+ switch (decodedTrustLineEntryExt.getDiscriminant()) {
+ case 0:
+ break;
+ }
+ return decodedTrustLineEntryExt;
+ }
+
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java b/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java
new file mode 100644
index 000000000..bbc48f2c6
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/TrustLineFlags.java
@@ -0,0 +1,43 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// enum TrustLineFlags
+// {
+// // issuer has authorized account to perform transactions with its credit
+// AUTHORIZED_FLAG = 1
+// };
+
+// ===========================================================================
+public enum TrustLineFlags {
+ AUTHORIZED_FLAG(1),
+ ;
+ private int mValue;
+
+ TrustLineFlags(int value) {
+ mValue = value;
+ }
+
+ public int getValue() {
+ return mValue;
+ }
+
+ static TrustLineFlags decode(XdrDataInputStream stream) throws IOException {
+ int value = stream.readInt();
+ switch (value) {
+ case 1: return AUTHORIZED_FLAG;
+ default:
+ throw new RuntimeException("Unknown enum value: " + value);
+ }
+ }
+
+ static void encode(XdrDataOutputStream stream, TrustLineFlags value) throws IOException {
+ stream.writeInt(value.getValue());
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint256.java b/src/main/java/org/stellar/sdk/xdr/Uint256.java
new file mode 100644
index 000000000..5812ccb15
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Uint256.java
@@ -0,0 +1,33 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque uint256[32];
+
+// ===========================================================================
+public class Uint256 {
+ private byte[] uint256;
+ public byte[] getUint256() {
+ return this.uint256;
+ }
+ public void setUint256(byte[] value) {
+ this.uint256 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Uint256 encodedUint256) throws IOException {
+ int uint256size = encodedUint256.uint256.length;
+ stream.write(encodedUint256.getUint256(), 0, uint256size);
+ }
+ public static Uint256 decode(XdrDataInputStream stream) throws IOException {
+ Uint256 decodedUint256 = new Uint256();
+ int uint256size = 32;
+ decodedUint256.uint256 = new byte[uint256size];
+ stream.read(decodedUint256.uint256, 0, uint256size);
+ return decodedUint256;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint32.java b/src/main/java/org/stellar/sdk/xdr/Uint32.java
new file mode 100644
index 000000000..87b654451
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Uint32.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef unsigned int uint32;
+
+// ===========================================================================
+public class Uint32 {
+ private Integer uint32;
+ public Integer getUint32() {
+ return this.uint32;
+ }
+ public void setUint32(Integer value) {
+ this.uint32 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Uint32 encodedUint32) throws IOException {
+ stream.writeInt(encodedUint32.uint32);
+ }
+ public static Uint32 decode(XdrDataInputStream stream) throws IOException {
+ Uint32 decodedUint32 = new Uint32();
+ decodedUint32.uint32 = stream.readInt();
+ return decodedUint32;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Uint64.java b/src/main/java/org/stellar/sdk/xdr/Uint64.java
new file mode 100644
index 000000000..dd80d0eb0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Uint64.java
@@ -0,0 +1,30 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef unsigned hyper uint64;
+
+// ===========================================================================
+public class Uint64 {
+ private Long uint64;
+ public Long getUint64() {
+ return this.uint64;
+ }
+ public void setUint64(Long value) {
+ this.uint64 = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Uint64 encodedUint64) throws IOException {
+ stream.writeLong(encodedUint64.uint64);
+ }
+ public static Uint64 decode(XdrDataInputStream stream) throws IOException {
+ Uint64 decodedUint64 = new Uint64();
+ decodedUint64.uint64 = stream.readLong();
+ return decodedUint64;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/UpgradeType.java b/src/main/java/org/stellar/sdk/xdr/UpgradeType.java
new file mode 100644
index 000000000..08d7553f0
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/UpgradeType.java
@@ -0,0 +1,34 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque UpgradeType<128>;
+
+// ===========================================================================
+public class UpgradeType {
+ private byte[] UpgradeType;
+ public byte[] getUpgradeType() {
+ return this.UpgradeType;
+ }
+ public void setUpgradeType(byte[] value) {
+ this.UpgradeType = value;
+ }
+ public static void encode(XdrDataOutputStream stream, UpgradeType encodedUpgradeType) throws IOException {
+ int UpgradeTypesize = encodedUpgradeType.UpgradeType.length;
+ stream.writeInt(UpgradeTypesize);
+ stream.write(encodedUpgradeType.getUpgradeType(), 0, UpgradeTypesize);
+ }
+ public static UpgradeType decode(XdrDataInputStream stream) throws IOException {
+ UpgradeType decodedUpgradeType = new UpgradeType();
+ int UpgradeTypesize = stream.readInt();
+ decodedUpgradeType.UpgradeType = new byte[UpgradeTypesize];
+ stream.read(decodedUpgradeType.UpgradeType, 0, UpgradeTypesize);
+ return decodedUpgradeType;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/Value.java b/src/main/java/org/stellar/sdk/xdr/Value.java
new file mode 100644
index 000000000..3ecebd3d5
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/Value.java
@@ -0,0 +1,34 @@
+// Automatically generated by xdrgen
+// DO NOT EDIT or your changes may be overwritten
+
+package org.stellar.sdk.xdr;
+
+
+import java.io.IOException;
+
+// === xdr source ============================================================
+
+// typedef opaque Value<>;
+
+// ===========================================================================
+public class Value {
+ private byte[] Value;
+ public byte[] getValue() {
+ return this.Value;
+ }
+ public void setValue(byte[] value) {
+ this.Value = value;
+ }
+ public static void encode(XdrDataOutputStream stream, Value encodedValue) throws IOException {
+ int Valuesize = encodedValue.Value.length;
+ stream.writeInt(Valuesize);
+ stream.write(encodedValue.getValue(), 0, Valuesize);
+ }
+ public static Value decode(XdrDataInputStream stream) throws IOException {
+ Value decodedValue = new Value();
+ int Valuesize = stream.readInt();
+ decodedValue.Value = new byte[Valuesize];
+ stream.read(decodedValue.Value, 0, Valuesize);
+ return decodedValue;
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrDataInputStream.java b/src/main/java/org/stellar/sdk/xdr/XdrDataInputStream.java
new file mode 100644
index 000000000..73c1cc3fa
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/XdrDataInputStream.java
@@ -0,0 +1,134 @@
+package org.stellar.sdk.xdr;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+public class XdrDataInputStream extends DataInputStream {
+
+ // The underlying input stream
+ private final XdrInputStream mIn;
+
+ // The total bytes read so far.
+ private final int mCount;
+
+ /**
+ * Creates a XdrDataInputStream that uses the specified
+ * underlying InputStream.
+ *
+ * @param in the specified input stream
+ */
+ public XdrDataInputStream(InputStream in) {
+ super(new XdrInputStream(in));
+ mIn = (XdrInputStream) super.in;
+ mCount = 0;
+ }
+
+ public String readString() throws IOException {
+ int l = readInt();
+ byte[] ascii = new byte[l];
+ readFully(ascii);
+ pad();
+ return new String(ascii, Charset.forName("US-ASCII"));
+ }
+
+ public int[] readIntArray() throws IOException {
+ int l = readInt();
+ return readIntArray(l);
+ }
+
+ public int[] readIntArray(int l) throws IOException {
+ int[] arr = new int[l];
+ for (int i = 0; i < l; i++) {
+ arr[i] = readInt();
+ }
+ return arr;
+ }
+
+ public float[] readFloatArray() throws IOException {
+ int l = readInt();
+ return readFloatArray(l);
+ }
+
+ public float[] readFloatArray(int l) throws IOException {
+ float[] arr = new float[l];
+ for (int i = 0; i < l; i++) {
+ arr[i] = readFloat();
+ }
+ return arr;
+ }
+
+ public double[] readDoubleArray() throws IOException {
+ int l = readInt();
+ return readDoubleArray(l);
+ }
+
+ public double[] readDoubleArray(int l) throws IOException {
+ double[] arr = new double[l];
+ for (int i = 0; i < l; i++) {
+ arr[i] = readDouble();
+ }
+ return arr;
+ }
+
+ /**
+ * Skips ahead to bring the stream to 4 byte alignment.
+ */
+ public void pad() throws IOException {
+ mIn.pad();
+ }
+
+ @Override
+ public int read() throws IOException {
+ return super.read();
+ }
+
+ /**
+ * Need to provide a custom impl of InputStream as DataInputStream's read methods
+ * are final and we need to keep track of the count for padding purposes.
+ */
+ private static final class XdrInputStream extends InputStream {
+
+ // The underlying input stream
+ private final InputStream mIn;
+
+ // The amount of bytes read so far.
+ private int mCount;
+
+ public XdrInputStream(InputStream in) {
+ mIn = in;
+ mCount = 0;
+ }
+
+ @Override
+ public int read() throws IOException {
+ int read = mIn.read();
+ if (read >= 0) {
+ mCount++;
+ }
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ return read(b, 0, b.length);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int read = mIn.read(b, off, len);
+ mCount += read;
+ return read;
+ }
+
+ public void pad() throws IOException {
+ int pad = 0;
+ int mod = mCount % 4;
+ if (mod > 0) {
+ pad = 4-mod;
+ }
+ skip(pad);
+ }
+ }
+}
diff --git a/src/main/java/org/stellar/sdk/xdr/XdrDataOutputStream.java b/src/main/java/org/stellar/sdk/xdr/XdrDataOutputStream.java
new file mode 100644
index 000000000..fc3a4230f
--- /dev/null
+++ b/src/main/java/org/stellar/sdk/xdr/XdrDataOutputStream.java
@@ -0,0 +1,99 @@
+package org.stellar.sdk.xdr;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class XdrDataOutputStream extends DataOutputStream {
+
+ private final XdrOutputStream mOut;
+
+ public XdrDataOutputStream(OutputStream out) {
+ super(new XdrOutputStream(out));
+ mOut = (XdrOutputStream) super.out;
+ }
+
+ public void writeString(String s) throws IOException {
+ byte[] chars = s.getBytes();
+ writeInt(chars.length);
+ write(chars);
+ pad();
+ }
+
+ public void writeIntArray(int[] a) throws IOException {
+ writeInt(a.length);
+ writeIntArray(a, a.length);
+ }
+
+ public void writeIntArray(int[] a, int l) throws IOException {
+ for (int i = 0; i < l; i++) {
+ writeInt(a[i]);
+ }
+ }
+
+ public void writeFloatArray(float[] a) throws IOException {
+ writeInt(a.length);
+ writeFloatArray(a, a.length);
+ }
+
+ public void writeFloatArray(float[] a, int l) throws IOException {
+ for (int i = 0; i < l; i++) {
+ writeFloat(a[i]);
+ }
+ }
+
+ public void writeDoubleArray(double[] a) throws IOException {
+ writeInt(a.length);
+ writeDoubleArray(a, a.length);
+ }
+
+ public void writeDoubleArray(double[] a, int l) throws IOException {
+ for (int i = 0; i < l; i++) {
+ writeDouble(a[i]);
+ }
+ }
+
+ public void pad() throws IOException {
+ mOut.pad();
+ }
+
+ private static final class XdrOutputStream extends OutputStream {
+
+ private final OutputStream mOut;
+
+ private int mCount;
+
+ public XdrOutputStream(OutputStream out) {
+ mOut = out;
+ mCount = 0;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ mOut.write(b);
+ mCount++;
+ }
+
+ @Override
+ public void write(byte[] b) throws IOException {
+ mOut.write(b);
+ mCount += b.length;
+ }
+
+ public void write(byte[] b, int offset, int length) throws IOException {
+ mOut.write(b, offset, length);
+ mCount += length;
+ }
+
+ public void pad() throws IOException {
+ int pad = 0;
+ int mod = mCount % 4;
+ if (mod > 0) {
+ pad = 4-mod;
+ }
+ while (pad-- > 0) {
+ write(0);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/AssetTest.java b/src/test/java/org/stellar/sdk/AssetTest.java
new file mode 100644
index 000000000..55854e35d
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/AssetTest.java
@@ -0,0 +1,60 @@
+package org.stellar.sdk;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by andrewrogers on 7/1/15.
+ */
+public class AssetTest {
+
+ @Test
+ public void testAssetTypeNative() {
+ AssetTypeNative asset = new AssetTypeNative();
+ org.stellar.sdk.xdr.Asset xdr = asset.toXdr();
+ Asset parsedAsset = Asset.fromXdr(xdr);
+ assertTrue(parsedAsset instanceof AssetTypeNative);
+ }
+
+ @Test
+ public void testAssetTypeCreditAlphaNum4() {
+ String code = "USDA";
+ KeyPair issuer = KeyPair.random();
+ AssetTypeCreditAlphaNum4 asset = new AssetTypeCreditAlphaNum4(code, issuer);
+ org.stellar.sdk.xdr.Asset xdr = asset.toXdr();
+ AssetTypeCreditAlphaNum4 parsedAsset = (AssetTypeCreditAlphaNum4) Asset.fromXdr(xdr);
+ assertEquals(code, asset.getCode());
+ assertEquals(issuer.getAccountId(), parsedAsset.getIssuer().getAccountId());
+ }
+
+ @Test
+ public void testAssetTypeCreditAlphaNum12() {
+ String code = "TESTTEST";
+ KeyPair issuer = KeyPair.random();
+ AssetTypeCreditAlphaNum12 asset = new AssetTypeCreditAlphaNum12(code, issuer);
+ org.stellar.sdk.xdr.Asset xdr = asset.toXdr();
+ AssetTypeCreditAlphaNum12 parsedAsset = (AssetTypeCreditAlphaNum12) Asset.fromXdr(xdr);
+ assertEquals(code, asset.getCode());
+ assertEquals(issuer.getAccountId(), parsedAsset.getIssuer().getAccountId());
+ }
+
+ @Test
+ public void testAssetEquals() {
+ KeyPair issuer1 = KeyPair.random();
+ KeyPair issuer2 = KeyPair.random();
+
+ assertTrue(new AssetTypeNative().equals(new AssetTypeNative()));
+ assertTrue(new AssetTypeCreditAlphaNum4("USD", issuer1).equals(new AssetTypeCreditAlphaNum4("USD", issuer1)));
+ assertTrue(new AssetTypeCreditAlphaNum12("ABCDE", issuer1).equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer1)));
+
+ assertFalse(new AssetTypeNative().equals(new AssetTypeCreditAlphaNum4("USD", issuer1)));
+ assertFalse(new AssetTypeNative().equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer1)));
+ assertFalse(new AssetTypeCreditAlphaNum4("EUR", issuer1).equals(new AssetTypeCreditAlphaNum4("USD", issuer1)));
+ assertFalse(new AssetTypeCreditAlphaNum4("EUR", issuer1).equals(new AssetTypeCreditAlphaNum4("EUR", issuer2)));
+ assertFalse(new AssetTypeCreditAlphaNum12("ABCDE", issuer1).equals(new AssetTypeCreditAlphaNum12("EDCBA", issuer1)));
+ assertFalse(new AssetTypeCreditAlphaNum12("ABCDE", issuer1).equals(new AssetTypeCreditAlphaNum12("ABCDE", issuer2)));
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/KeyPairTest.java b/src/test/java/org/stellar/sdk/KeyPairTest.java
new file mode 100644
index 000000000..e5cb10803
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/KeyPairTest.java
@@ -0,0 +1,68 @@
+package org.stellar.sdk;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class KeyPairTest {
+
+ private static final String SEED = "1123740522f11bfef6b3671f51e159ccf589ccf8965262dd5f97d1721d383dd4";
+
+ @Test
+ public void testSign() {
+ String expectedSig = "587d4b472eeef7d07aafcd0b049640b0bb3f39784118c2e2b73a04fa2f64c9c538b4b2d0f5335e968a480021fdc23e98c0ddf424cb15d8131df8cb6c4bb58309";
+ KeyPair keypair = KeyPair.fromSecretSeed(Util.hexToBytes(SEED));
+ String data = "hello world";
+ byte[] sig = keypair.sign(data.getBytes());
+ Assert.assertArrayEquals(Util.hexToBytes(expectedSig), sig);
+ }
+
+ @Test
+ public void testVerifyTrue() throws Exception {
+ String sig = "587d4b472eeef7d07aafcd0b049640b0bb3f39784118c2e2b73a04fa2f64c9c538b4b2d0f5335e968a480021fdc23e98c0ddf424cb15d8131df8cb6c4bb58309";
+ String data = "hello world";
+ KeyPair keypair = KeyPair.fromSecretSeed(Util.hexToBytes(SEED));
+ Assert.assertTrue(keypair.verify(data.getBytes(), Util.hexToBytes(sig)));
+ }
+
+ @Test
+ public void testVerifyFalse() throws Exception {
+ String badSig = "687d4b472eeef7d07aafcd0b049640b0bb3f39784118c2e2b73a04fa2f64c9c538b4b2d0f5335e968a480021fdc23e98c0ddf424cb15d8131df8cb6c4bb58309";
+ byte[] corrupt = {0x00};
+ String data = "hello world";
+ KeyPair keypair = KeyPair.fromSecretSeed(Util.hexToBytes(SEED));
+ Assert.assertFalse(keypair.verify(data.getBytes(), Util.hexToBytes(badSig)));
+ Assert.assertFalse(keypair.verify(data.getBytes(), corrupt));
+ }
+
+ @Test
+ public void testFromSecretSeed() throws Exception {
+ Map keypairs = new HashMap();
+ keypairs.put("SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE", "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D");
+ keypairs.put("SDTQN6XUC3D2Z6TIG3XLUTJIMHOSON2FMSKCTM2OHKKH2UX56RQ7R5Y4", "GDEAOZWTVHQZGGJY6KG4NAGJQ6DXATXAJO3AMW7C4IXLKMPWWB4FDNFZ");
+ keypairs.put("SDIREFASXYQVEI6RWCQW7F37E6YNXECQJ4SPIOFMMMJRU5CMDQVW32L5", "GD2EVR7DGDLNKWEG366FIKXO2KCUAIE3HBUQP4RNY7LEZR5LDKBYHMM6");
+ keypairs.put("SDAPE6RHEJ7745VQEKCI2LMYKZB3H6H366I33A42DG7XKV57673XLCC2", "GDLXVH2BTLCLZM53GF7ELZFF4BW4MHH2WXEA4Z5Z3O6DPNZNR44A56UJ");
+ keypairs.put("SDYZ5IYOML3LTWJ6WIAC2YWORKVO7GJRTPPGGNJQERH72I6ZCQHDAJZN", "GABXJTV7ELEB2TQZKJYEGXBUIG6QODJULKJDI65KZMIZZG2EACJU5EA7");
+
+ for (String seed : keypairs.keySet()) {
+ String accountId = keypairs.get(seed);
+ KeyPair keypair = KeyPair.fromSecretSeed(seed);
+ assertEquals(accountId, keypair.getAccountId());
+ }
+ }
+
+ @Test
+ public void testCanSign() throws Exception {
+ KeyPair keypair;
+ keypair = KeyPair.fromSecretSeed("SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE");
+ assertTrue(keypair.canSign());
+ keypair = KeyPair.fromAccountId("GABXJTV7ELEB2TQZKJYEGXBUIG6QODJULKJDI65KZMIZZG2EACJU5EA7");
+ assertFalse(keypair.canSign());
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/MemoTest.java b/src/test/java/org/stellar/sdk/MemoTest.java
new file mode 100644
index 000000000..a0ade6035
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/MemoTest.java
@@ -0,0 +1,110 @@
+package org.stellar.sdk;
+
+import org.apache.commons.codec.DecoderException;
+import org.junit.Test;
+import org.stellar.sdk.xdr.MemoType;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class MemoTest {
+ @Test
+ public void testMemoNone() {
+ MemoNone memo = Memo.none();
+ assertEquals(MemoType.MEMO_NONE, memo.toXdr().getDiscriminant());
+ }
+
+ @Test
+ public void testMemoTextSuccess() {
+ MemoText memo = Memo.text("test");
+ assertEquals(MemoType.MEMO_TEXT, memo.toXdr().getDiscriminant());
+ assertEquals("test", memo.getText());
+ }
+
+ @Test
+ public void testMemoTextUtf8() {
+ MemoText memo = Memo.text("三");
+ assertEquals(MemoType.MEMO_TEXT, memo.toXdr().getDiscriminant());
+ assertEquals("三", memo.getText());
+ }
+
+ @Test
+ public void testMemoTextTooLong() {
+ try {
+ Memo.text("12345678901234567890123456789");
+ fail();
+ } catch (RuntimeException exception) {
+ assertTrue(exception.getMessage().contains("text must be <= 28 bytes."));
+ }
+ }
+
+ @Test
+ public void testMemoTextTooLongUtf8() {
+ try {
+ Memo.text("价值交易的开源协议!!");
+ fail();
+ } catch (RuntimeException exception) {
+ assertTrue(exception.getMessage().contains("text must be <= 28 bytes."));
+ }
+ }
+
+ @Test
+ public void testMemoId() {
+ MemoId memo = Memo.id(9223372036854775807L);
+ assertEquals(9223372036854775807L, memo.getId());
+ assertEquals(MemoType.MEMO_ID, memo.toXdr().getDiscriminant());
+ assertEquals(new Long(9223372036854775807L), memo.toXdr().getId().getUint64());
+ }
+
+ @Test
+ public void testMemoHashSuccess() throws DecoderException {
+ MemoHash memo = Memo.hash("4142434445464748494a4b4c");
+ assertEquals(MemoType.MEMO_HASH, memo.toXdr().getDiscriminant());
+ String test = "ABCDEFGHIJKL";
+ assertEquals(test, Util.paddedByteArrayToString(memo.getBytes()));
+ assertEquals("4142434445464748494a4b4c", memo.getTrimmedHexValue());
+ }
+
+ @Test
+ public void testMemoHashBytesSuccess() {
+ byte[] bytes = new byte[10];
+ Arrays.fill(bytes, (byte) 'A');
+ MemoHash memo = Memo.hash(bytes);
+ assertEquals(MemoType.MEMO_HASH, memo.toXdr().getDiscriminant());
+ assertEquals("AAAAAAAAAA", Util.paddedByteArrayToString(memo.getBytes()));
+ assertEquals("4141414141414141414100000000000000000000000000000000000000000000", memo.getHexValue());
+ assertEquals("41414141414141414141", memo.getTrimmedHexValue());
+ }
+
+ @Test
+ public void testMemoHashTooLong() {
+ byte[] longer = new byte[33];
+ Arrays.fill(longer, (byte) 0);
+ try {
+ Memo.hash(longer);
+ fail();
+ } catch (MemoTooLongException exception) {
+ assertTrue(exception.getMessage().contains("MEMO_HASH can contain 32 bytes at max."));
+ }
+ }
+
+ @Test
+ public void testMemoHashInvalidHex() {
+ try {
+ Memo.hash("test");
+ fail();
+ } catch (DecoderException e) {
+
+ }
+ }
+
+ @Test
+ public void testMemoReturnHashSuccess() throws DecoderException {
+ MemoReturnHash memo = Memo.returnHash("4142434445464748494a4b4c");
+ assertEquals(MemoType.MEMO_RETURN, memo.toXdr().getDiscriminant());
+ assertEquals("4142434445464748494a4b4c", memo.getTrimmedHexValue());
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/NetworkTest.java b/src/test/java/org/stellar/sdk/NetworkTest.java
new file mode 100644
index 000000000..f107ea54e
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/NetworkTest.java
@@ -0,0 +1,24 @@
+package org.stellar.sdk;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class NetworkTest {
+
+ public void tearDown() {
+ Network.useTestNetwork();
+ }
+
+ @Test
+ public void testDefaultTestNetwork() {
+ assertEquals("Test SDF Network ; September 2015", Network.current().getNetworkPassphrase());
+ }
+
+ @Test
+ public void testSwitchToPublicNetwork() {
+ Network.usePublicNetwork();
+ assertEquals("Public Global Stellar Network ; September 2015", Network.current().getNetworkPassphrase());
+ Network.useTestNetwork();
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/OperationTest.java b/src/test/java/org/stellar/sdk/OperationTest.java
new file mode 100644
index 000000000..335b3e167
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/OperationTest.java
@@ -0,0 +1,416 @@
+package org.stellar.sdk;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class OperationTest {
+
+ @Test
+ public void testCreateAccountOperation() throws FormatException, IOException, AssetCodeLengthInvalidException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+
+ String startingAmount = "1000";
+ CreateAccountOperation operation = new CreateAccountOperation.Builder(destination, startingAmount)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ CreateAccountOperation parsedOperation = (CreateAccountOperation) Operation.fromXdr(xdr);
+
+ assertEquals(10000000000L, xdr.getBody().getCreateAccountOp().getStartingBalance().getInt64().longValue());
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId());
+ assertEquals(startingAmount, parsedOperation.getStartingBalance());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAAAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAACVAvkAA==",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testPaymentOperation() throws FormatException, IOException, AssetCodeLengthInvalidException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+
+ Asset asset = new AssetTypeNative();
+ String amount = "1000";
+
+ PaymentOperation operation = new PaymentOperation.Builder(destination, asset, amount)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ PaymentOperation parsedOperation = (PaymentOperation) Operation.fromXdr(xdr);
+
+ assertEquals(10000000000L, xdr.getBody().getPaymentOp().getAmount().getInt64().longValue());
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId());
+ assertTrue(parsedOperation.getAsset() instanceof AssetTypeNative);
+ assertEquals(amount, parsedOperation.getAmount());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAEAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAAAAAAAAlQL5AA=",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testPathPaymentOperation() throws FormatException, IOException, AssetCodeLengthInvalidException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+ // GCGZLB3X2B3UFOFSHHQ6ZGEPEX7XYPEH6SBFMIV74EUDOFZJA3VNL6X4
+ KeyPair issuer = KeyPair.fromSecretSeed("SBOBVZUN6WKVMI6KIL2GHBBEETEV6XKQGILITNH6LO6ZA22DBMSDCPAG");
+
+ // GAVAQKT2M7B4V3NN7RNNXPU5CWNDKC27MYHKLF5UNYXH4FNLFVDXKRSV
+ KeyPair pathIssuer1 = KeyPair.fromSecretSeed("SALDLG5XU5AEJWUOHAJPSC4HJ2IK3Z6BXXP4GWRHFT7P7ILSCFFQ7TC5");
+ // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR
+ KeyPair pathIssuer2 = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ");
+
+ Asset sendAsset = new AssetTypeNative();
+ String sendMax = "0.0001";
+ Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer);
+ String destAmount = "0.0001";
+ Asset[] path = {new AssetTypeCreditAlphaNum4("USD", pathIssuer1), new AssetTypeCreditAlphaNum12("TESTTEST", pathIssuer2)};
+
+ PathPaymentOperation operation = new PathPaymentOperation.Builder(
+ sendAsset, sendMax, destination, destAsset, destAmount)
+ .setPath(path)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ PathPaymentOperation parsedOperation = (PathPaymentOperation) Operation.fromXdr(xdr);
+
+ assertEquals(1000L, xdr.getBody().getPathPaymentOp().getSendMax().getInt64().longValue());
+ assertEquals(1000L, xdr.getBody().getPathPaymentOp().getDestAmount().getInt64().longValue());
+ assertTrue(parsedOperation.getSendAsset() instanceof AssetTypeNative);
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId());
+ assertEquals(sendMax, parsedOperation.getSendMax());
+ assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4);
+ assertEquals(destAmount, parsedOperation.getDestAmount());
+ assertEquals(path.length, parsedOperation.getPath().length);
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAIAAAAAAAAAAAAAA+gAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAABVVNEAAAAAACNlYd30HdCuLI54eyYjyX/fDyH9IJWIr/hKDcXKQbq1QAAAAAAAAPoAAAAAgAAAAFVU0QAAAAAACoIKnpnw8rtrfxa276dFZo1C19mDqWXtG4ufhWrLUd1AAAAAlRFU1RURVNUAAAAAAAAAABE/ttVl8BLV0csW/xgXtbXOVf1lMyDluMiafl0IDVFIg==",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testPathPaymentEmptyPathOperation() throws FormatException, IOException, AssetCodeLengthInvalidException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+ // GCGZLB3X2B3UFOFSHHQ6ZGEPEX7XYPEH6SBFMIV74EUDOFZJA3VNL6X4
+ KeyPair issuer = KeyPair.fromSecretSeed("SBOBVZUN6WKVMI6KIL2GHBBEETEV6XKQGILITNH6LO6ZA22DBMSDCPAG");
+
+ // GAVAQKT2M7B4V3NN7RNNXPU5CWNDKC27MYHKLF5UNYXH4FNLFVDXKRSV
+ KeyPair pathIssuer1 = KeyPair.fromSecretSeed("SALDLG5XU5AEJWUOHAJPSC4HJ2IK3Z6BXXP4GWRHFT7P7ILSCFFQ7TC5");
+ // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR
+ KeyPair pathIssuer2 = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ");
+
+ Asset sendAsset = new AssetTypeNative();
+ String sendMax = "0.0001";
+ Asset destAsset = new AssetTypeCreditAlphaNum4("USD", issuer);
+ String destAmount = "0.0001";
+
+ PathPaymentOperation operation = new PathPaymentOperation.Builder(
+ sendAsset, sendMax, destination, destAsset, destAmount)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ PathPaymentOperation parsedOperation = (PathPaymentOperation) Operation.fromXdr(xdr);
+
+ assertEquals(1000L, xdr.getBody().getPathPaymentOp().getSendMax().getInt64().longValue());
+ assertEquals(1000L, xdr.getBody().getPathPaymentOp().getDestAmount().getInt64().longValue());
+ assertTrue(parsedOperation.getSendAsset() instanceof AssetTypeNative);
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId());
+ assertEquals(sendMax, parsedOperation.getSendMax());
+ assertTrue(parsedOperation.getDestAsset() instanceof AssetTypeCreditAlphaNum4);
+ assertEquals(destAmount, parsedOperation.getDestAmount());
+ assertEquals(0, parsedOperation.getPath().length);
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAIAAAAAAAAAAAAAA+gAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAABVVNEAAAAAACNlYd30HdCuLI54eyYjyX/fDyH9IJWIr/hKDcXKQbq1QAAAAAAAAPoAAAAAA==",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testChangeTrustOperation() throws FormatException, IOException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+
+ Asset asset = new AssetTypeNative();
+ String limit = "922337203685.4775807";
+
+ ChangeTrustOperation operation = new ChangeTrustOperation.Builder(asset, limit)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ ChangeTrustOperation parsedOperation = (ChangeTrustOperation) Operation.fromXdr(xdr);
+
+ assertEquals(9223372036854775807L, xdr.getBody().getChangeTrustOp().getLimit().getInt64().longValue());
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertTrue(parsedOperation.getAsset() instanceof AssetTypeNative);
+ assertEquals(limit, parsedOperation.getLimit());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAYAAAAAf/////////8=",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testAllowTrustOperation() throws IOException, FormatException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair trustor = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+
+ String assetCode = "USDA";
+ boolean authorize = true;
+
+ AllowTrustOperation operation = new AllowTrustOperation.Builder(trustor, assetCode, authorize)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ AllowTrustOperation parsedOperation = (AllowTrustOperation) Operation.fromXdr(xdr);
+
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+ assertEquals(trustor.getAccountId(), parsedOperation.getTrustor().getAccountId());
+ assertEquals(assetCode, parsedOperation.getAssetCode());
+ assertEquals(authorize, parsedOperation.getAuthorize());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAcAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAABVVNEQQAAAAE=",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testSetOptionsOperation() throws FormatException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair inflationDestination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+ // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR
+ KeyPair signer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ");
+
+ Integer clearFlags = 1;
+ Integer setFlags = 1;
+ Integer masterKeyWeight = 1;
+ Integer lowThreshold = 2;
+ Integer mediumThreshold = 3;
+ Integer highThreshold = 4;
+ String homeDomain = "stellar.org";
+ Integer signerWeight = 1;
+
+ SetOptionsOperation operation = new SetOptionsOperation.Builder()
+ .setInflationDestination(inflationDestination)
+ .setClearFlags(clearFlags)
+ .setSetFlags(setFlags)
+ .setMasterKeyWeight(masterKeyWeight)
+ .setLowThreshold(lowThreshold)
+ .setMediumThreshold(mediumThreshold)
+ .setHighThreshold(highThreshold)
+ .setHomeDomain(homeDomain)
+ .setSigner(signer, signerWeight)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ SetOptionsOperation parsedOperation = (SetOptionsOperation) SetOptionsOperation.fromXdr(xdr);
+
+ assertEquals(inflationDestination.getAccountId(), parsedOperation.getInflationDestination().getAccountId());
+ assertEquals(clearFlags, parsedOperation.getClearFlags());
+ assertEquals(setFlags, parsedOperation.getSetFlags());
+ assertEquals(masterKeyWeight, parsedOperation.getMasterKeyWeight());
+ assertEquals(lowThreshold, parsedOperation.getLowThreshold());
+ assertEquals(mediumThreshold, parsedOperation.getMediumThreshold());
+ assertEquals(highThreshold, parsedOperation.getHighThreshold());
+ assertEquals(homeDomain, parsedOperation.getHomeDomain());
+ assertEquals(signer.getAccountId(), parsedOperation.getSigner().getAccountId());
+ assertEquals(signerWeight, parsedOperation.getSignerWeight());
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAABAAAAAO3gUmG83C+VCqO6FztuMtXJF/l7grZA7MjRzqdZ9W8QAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAIAAAABAAAAAwAAAAEAAAAEAAAAAQAAAAtzdGVsbGFyLm9yZwAAAAABAAAAAET+21WXwEtXRyxb/GBe1tc5V/WUzIOW4yJp+XQgNUUiAAAAAQ==",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testSetOptionsOperationSingleField() {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+
+ String homeDomain = "stellar.org";
+
+ SetOptionsOperation operation = new SetOptionsOperation.Builder()
+ .setHomeDomain(homeDomain)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ SetOptionsOperation parsedOperation = (SetOptionsOperation) SetOptionsOperation.fromXdr(xdr);
+
+ assertEquals(null, parsedOperation.getInflationDestination());
+ assertEquals(null, parsedOperation.getClearFlags());
+ assertEquals(null, parsedOperation.getSetFlags());
+ assertEquals(null, parsedOperation.getMasterKeyWeight());
+ assertEquals(null, parsedOperation.getLowThreshold());
+ assertEquals(null, parsedOperation.getMediumThreshold());
+ assertEquals(null, parsedOperation.getHighThreshold());
+ assertEquals(homeDomain, parsedOperation.getHomeDomain());
+ assertEquals(null, parsedOperation.getSigner());
+ assertEquals(null, parsedOperation.getSignerWeight());
+ assertEquals(source.getAccountId(), parsedOperation.getSourceAccount().getAccountId());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAtzdGVsbGFyLm9yZwAAAAAA",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testManageOfferOperation() throws IOException, FormatException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR
+ KeyPair issuer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ");
+
+ Asset selling = new AssetTypeNative();
+ Asset buying = Asset.createNonNativeAsset("USD", issuer);
+ String amount = "0.00001";
+ String price = "0.85334384"; // n=5333399 d=6250000
+ Price priceObj = Price.fromString(price);
+ long offerId = 1;
+
+ ManageOfferOperation operation = new ManageOfferOperation.Builder(selling, buying, amount, price)
+ .setOfferId(offerId)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ ManageOfferOperation parsedOperation = (ManageOfferOperation) ManageOfferOperation.fromXdr(xdr);
+
+ assertEquals(100L, xdr.getBody().getManageOfferOp().getAmount().getInt64().longValue());
+ assertTrue(parsedOperation.getSelling() instanceof AssetTypeNative);
+ assertTrue(parsedOperation.getBuying() instanceof AssetTypeCreditAlphaNum4);
+ assertTrue(parsedOperation.getBuying().equals(buying));
+ assertEquals(amount, parsedOperation.getAmount());
+ assertEquals(price, parsedOperation.getPrice());
+ assertEquals(priceObj.getNumerator(), 5333399);
+ assertEquals(priceObj.getDenominator(), 6250000);
+ assertEquals(offerId, parsedOperation.getOfferId());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAMAAAAAAAAAAVVTRAAAAAAARP7bVZfAS1dHLFv8YF7W1zlX9ZTMg5bjImn5dCA1RSIAAAAAAAAAZABRYZcAX14QAAAAAAAAAAE=",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testCreatePassiveOfferOperation() throws IOException, FormatException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GBCP5W2VS7AEWV2HFRN7YYC623LTSV7VSTGIHFXDEJU7S5BAGVCSETRR
+ KeyPair issuer = KeyPair.fromSecretSeed("SA64U7C5C7BS5IHWEPA7YWFN3Z6FE5L6KAMYUIT4AQ7KVTVLD23C6HEZ");
+
+ Asset selling = new AssetTypeNative();
+ Asset buying = Asset.createNonNativeAsset("USD", issuer);
+ String amount = "0.00001";
+ String price = "2.93850088"; // n=36731261 d=12500000
+ Price priceObj = Price.fromString(price);
+
+ CreatePassiveOfferOperation operation = new CreatePassiveOfferOperation.Builder(selling, buying, amount, price)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+ CreatePassiveOfferOperation parsedOperation = (CreatePassiveOfferOperation) CreatePassiveOfferOperation.fromXdr(xdr);
+
+ assertEquals(100L, xdr.getBody().getCreatePassiveOfferOp().getAmount().getInt64().longValue());
+ assertTrue(parsedOperation.getSelling() instanceof AssetTypeNative);
+ assertTrue(parsedOperation.getBuying() instanceof AssetTypeCreditAlphaNum4);
+ assertTrue(parsedOperation.getBuying().equals(buying));
+ assertEquals(amount, parsedOperation.getAmount());
+ assertEquals(price, parsedOperation.getPrice());
+ assertEquals(priceObj.getNumerator(), 36731261);
+ assertEquals(priceObj.getDenominator(), 12500000);
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAQAAAAAAAAAAVVTRAAAAAAARP7bVZfAS1dHLFv8YF7W1zlX9ZTMg5bjImn5dCA1RSIAAAAAAAAAZAIweX0Avrwg",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testAccountMergeOperation() throws IOException, FormatException {
+ // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF
+ KeyPair source = KeyPair.fromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK");
+ // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR
+ KeyPair destination = KeyPair.fromSecretSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII");
+
+ AccountMergeOperation operation = new AccountMergeOperation.Builder(destination)
+ .setSourceAccount(source)
+ .build();
+
+ org.stellar.sdk.xdr.Operation xdr = operation.toXdr();
+
+ AccountMergeOperation parsedOperation = (AccountMergeOperation) Operation.fromXdr(xdr);
+
+ assertEquals(destination.getAccountId(), parsedOperation.getDestination().getAccountId());
+
+ assertEquals(
+ "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAgAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxA=",
+ operation.toXdrBase64());
+ }
+
+ @Test
+ public void testToXdrAmount() {
+ assertEquals(0L, Operation.toXdrAmount("0"));
+ assertEquals(1L, Operation.toXdrAmount("0.0000001"));
+ assertEquals(10000000L, Operation.toXdrAmount("1"));
+ assertEquals(11234567L, Operation.toXdrAmount("1.1234567"));
+ assertEquals(729912843007381L, Operation.toXdrAmount("72991284.3007381"));
+ assertEquals(729912843007381L, Operation.toXdrAmount("72991284.30073810"));
+ assertEquals(1014016711446800155L, Operation.toXdrAmount("101401671144.6800155"));
+ assertEquals(9223372036854775807L, Operation.toXdrAmount("922337203685.4775807"));
+
+ try {
+ Operation.toXdrAmount("0.00000001");
+ fail();
+ }
+ catch (ArithmeticException e) {}
+ catch (Exception e) { fail(); }
+
+ try {
+ Operation.toXdrAmount("72991284.30073811");
+ fail();
+ }
+ catch (ArithmeticException e) {}
+ catch (Exception e) { fail(); }
+ }
+
+ @Test
+ public void testFromXdrAmount() {
+ assertEquals("0", Operation.fromXdrAmount(0L));
+ assertEquals("0.0000001", Operation.fromXdrAmount(1L));
+ assertEquals("1", Operation.fromXdrAmount(10000000L));
+ assertEquals("1.1234567", Operation.fromXdrAmount(11234567L));
+ assertEquals("72991284.3007381", Operation.fromXdrAmount(729912843007381L));
+ assertEquals("101401671144.6800155", Operation.fromXdrAmount(1014016711446800155L));
+ assertEquals("922337203685.4775807", Operation.fromXdrAmount(9223372036854775807L));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/stellar/sdk/PriceTest.java b/src/test/java/org/stellar/sdk/PriceTest.java
new file mode 100644
index 000000000..3539beed3
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/PriceTest.java
@@ -0,0 +1,54 @@
+package org.stellar.sdk;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class PriceTest {
+ @Test
+ public void testFromDouble() {
+ PriceTestCase[] tests = {
+ new PriceTestCase("0", new Price(0,1)),
+ new PriceTestCase("0.1", new Price(1,10)),
+ new PriceTestCase("0.01", new Price(1,100)),
+ new PriceTestCase("0.001", new Price(1,1000)),
+ new PriceTestCase("543.01793", new Price(54301793,100000)),
+ new PriceTestCase("319.69983", new Price(31969983,100000)),
+ new PriceTestCase("0.93", new Price(93,100)),
+ new PriceTestCase("0.5", new Price(1,2)),
+ new PriceTestCase("1.730", new Price(173,100)),
+ new PriceTestCase("0.85334384", new Price(5333399,6250000)),
+ new PriceTestCase("5.5", new Price(11,2)),
+ new PriceTestCase("2.72783", new Price(272783,100000)),
+ new PriceTestCase("638082.0", new Price(638082,1)),
+ new PriceTestCase("2.93850088", new Price(36731261,12500000)),
+ new PriceTestCase("58.04", new Price(1451,25)),
+ new PriceTestCase("41.265", new Price(8253,200)),
+ new PriceTestCase("5.1476", new Price(12869,2500)),
+ new PriceTestCase("95.14", new Price(4757,50)),
+ new PriceTestCase("0.74580", new Price(3729,5000)),
+ new PriceTestCase("4119.0", new Price(4119,1)),
+ new PriceTestCase("1073742464.5", new Price(1073742464,1)),
+ new PriceTestCase("1635962526.2", new Price(1635962526,1)),
+ new PriceTestCase("2147483647", new Price(2147483647,1))
+ };
+
+ for (PriceTestCase test : tests) {
+ Price price = Price.fromString(test.input);
+ assertEquals(
+ test.expectedPrice.getNumerator()+"/"+test.expectedPrice.getDenominator(),
+ price.getNumerator()+"/"+price.getDenominator()
+ );
+ }
+ }
+
+ private class PriceTestCase {
+ public String input;
+ public Price expectedPrice;
+
+ public PriceTestCase(String input, Price expectedPrice) {
+ this.input = input;
+ this.expectedPrice = expectedPrice;
+ }
+ }
+}
diff --git a/src/test/java/org/stellar/sdk/ServerTest.java b/src/test/java/org/stellar/sdk/ServerTest.java
index b432ec45f..1dbbafacf 100644
--- a/src/test/java/org/stellar/sdk/ServerTest.java
+++ b/src/test/java/org/stellar/sdk/ServerTest.java
@@ -13,10 +13,7 @@
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.stellar.base.CreateAccountOperation;
-import org.stellar.base.KeyPair;
-import org.stellar.base.Memo;
-import org.stellar.base.Transaction;
+import org.stellar.sdk.responses.SubmitTransactionResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
diff --git a/src/test/java/org/stellar/sdk/StrKeyTest.java b/src/test/java/org/stellar/sdk/StrKeyTest.java
new file mode 100644
index 000000000..dc9a9a106
--- /dev/null
+++ b/src/test/java/org/stellar/sdk/StrKeyTest.java
@@ -0,0 +1,40 @@
+package org.stellar.sdk;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class StrKeyTest {
+ @Test
+ public void testDecodeEncode() throws IOException, FormatException {
+ String seed = "SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE";
+ byte[] secret = StrKey.decodeCheck(StrKey.VersionByte.SEED, seed.toCharArray());
+ char[] encoded = StrKey.encodeCheck(StrKey.VersionByte.SEED, secret);
+ assertEquals(seed, String.valueOf(encoded));
+ }
+
+ @Test()
+ public void testDecodeInvalidVersionByte() {
+ String address = "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D";
+ try {
+ StrKey.decodeCheck(StrKey.VersionByte.SEED, address.toCharArray());
+ fail();
+ } catch (FormatException e) {}
+ }
+
+ @Test()
+ public void testDecodeInvalidSeed() {
+ String seed = "SAA6NXOBOXP3RXGAXBW6PGFI5BPK4ODVAWITS4VDOMN5C2M4B66ZML";
+ try {
+ StrKey.decodeCheck(StrKey.VersionByte.SEED, seed.toCharArray());
+ fail();
+ } catch (FormatException e) {}
+ }
+
+ // TODO more tests
+}
diff --git a/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java
index a7c40b9ee..78605e625 100644
--- a/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/EffectsRequestBuilderTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -23,7 +23,7 @@ public void testEffects() {
public void testForAccount() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.effects()
- .forAccount(KeyPair.fromAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
+ .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
.limit(200)
.order(RequestBuilder.Order.DESC)
.buildUri();
diff --git a/src/test/java/org/stellar/sdk/requests/LedgersRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/LedgersRequestBuilderTest.java
index af11012bb..6a7731ae6 100644
--- a/src/test/java/org/stellar/sdk/requests/LedgersRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/LedgersRequestBuilderTest.java
@@ -1,7 +1,6 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.sdk.Ledger;
import org.stellar.sdk.Server;
import java.net.URI;
diff --git a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
index 4811ae631..72a7df4eb 100644
--- a/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/OperationsRequestBuilderTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -23,7 +23,7 @@ public void testOperations() {
public void testForAccount() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.operations()
- .forAccount(KeyPair.fromAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
+ .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
.limit(200)
.order(RequestBuilder.Order.DESC)
.buildUri();
diff --git a/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java
index 4fffe21c5..1bb11ba9d 100644
--- a/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/OrderBookRequestBuilderTest.java
@@ -1,8 +1,8 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.Asset;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -14,8 +14,8 @@ public class OrderBookRequestBuilderTest {
public void testOrderBook() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.orderBook()
- .buyingAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")))
- .sellingAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")))
+ .buyingAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")))
+ .sellingAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")))
.cursor("13537736921089")
.limit(200)
.order(RequestBuilder.Order.ASC)
@@ -38,8 +38,8 @@ public void testTrades() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.orderBook()
.trades()
- .buyingAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")))
- .sellingAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")))
+ .buyingAsset(Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAUPA4HERNBDPVO4IUA3MJXBCRRK5W54EVXTDK6IIUTGDQRB6D5W242W")))
+ .sellingAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDRRHSJMHXDTQBT4JTCILNGF5AS54FEMTXL7KOLMF6TFTHRK6SSUSUZZ")))
.cursor("13537736921089")
.limit(200)
.order(RequestBuilder.Order.ASC)
diff --git a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
index 4ec1e7998..e46445d3d 100644
--- a/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/PathsRequestBuilderTest.java
@@ -1,8 +1,8 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.Asset;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -14,10 +14,10 @@ public class PathsRequestBuilderTest {
public void testAccounts() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.paths()
- .destinationAccount(KeyPair.fromAddress("GB24QI3BJNKBY4YNJZ2I37HFIYK56BL2OURFML76X46RQQKDLVT7WKJF"))
- .sourceAccount(KeyPair.fromAddress("GD4KO3IOYYWIYVI236Y35K2DU6VNYRH3BPNFJSH57J5BLLCQHBIOK3IN"))
+ .destinationAccount(KeyPair.fromAccountId("GB24QI3BJNKBY4YNJZ2I37HFIYK56BL2OURFML76X46RQQKDLVT7WKJF"))
+ .sourceAccount(KeyPair.fromAccountId("GD4KO3IOYYWIYVI236Y35K2DU6VNYRH3BPNFJSH57J5BLLCQHBIOK3IN"))
.destinationAmount("20.50")
- .destinationAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH")))
+ .destinationAsset(Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GAYSHLG75RPSMXWJ5KX7O7STE6RSZTD6NE4CTWAXFZYYVYIFRUVJIBJH")))
.cursor("13537736921089")
.limit(200)
.order(RequestBuilder.Order.ASC)
diff --git a/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java
index dcd7be418..0b9fcb022 100644
--- a/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/PaymentsRequestBuilderTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -23,7 +23,7 @@ public void testPayments() {
public void testForAccount() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.payments()
- .forAccount(KeyPair.fromAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
+ .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
.limit(200)
.order(RequestBuilder.Order.DESC)
.buildUri();
diff --git a/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java b/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java
index 64f8cb781..ced46a73e 100644
--- a/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java
+++ b/src/test/java/org/stellar/sdk/requests/TransactionsRequestBuilderTest.java
@@ -1,7 +1,7 @@
package org.stellar.sdk.requests;
import org.junit.Test;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import java.net.URI;
@@ -23,7 +23,7 @@ public void testTransactions() {
public void testForAccount() {
Server server = new Server("https://horizon-testnet.stellar.org");
URI uri = server.transactions()
- .forAccount(KeyPair.fromAddress("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
+ .forAccount(KeyPair.fromAccountId("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H"))
.limit(200)
.order(RequestBuilder.Order.DESC)
.buildUri();
diff --git a/src/test/java/org/stellar/sdk/AccountDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
similarity index 95%
rename from src/test/java/org/stellar/sdk/AccountDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
index ecac3df14..ff5aae52f 100644
--- a/src/test/java/org/stellar/sdk/AccountDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/AccountDeserializerTest.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import junit.framework.TestCase;
@@ -7,8 +7,8 @@
public class AccountDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Account account = GsonSingleton.getInstance().fromJson(json, Account.class);
- assertEquals(account.getKeypair().getAddress(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
+ AccountResponse account = GsonSingleton.getInstance().fromJson(json, AccountResponse.class);
+ assertEquals(account.getKeypair().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
assertEquals(account.getPagingToken(), "1");
assertEquals(account.getSequenceNumber(), new Long(2319149195853854L));
assertEquals(account.getSubentryCount(), new Integer(0));
diff --git a/src/test/java/org/stellar/sdk/AccountsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
similarity index 92%
rename from src/test/java/org/stellar/sdk/AccountsPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
index d53c66a01..bf59055cd 100644
--- a/src/test/java/org/stellar/sdk/AccountsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/AccountsPageDeserializerTest.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
@@ -9,11 +9,11 @@
public class AccountsPageDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Page accountsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page accountsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
- assertEquals(accountsPage.getRecords().get(0).getKeypair().getAddress(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
+ assertEquals(accountsPage.getRecords().get(0).getKeypair().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
assertEquals(accountsPage.getRecords().get(0).getPagingToken(), "1");
- assertEquals(accountsPage.getRecords().get(9).getKeypair().getAddress(), "GACFGMEV7A5H44O3K4EN6GRQ4SA543YJBZTKGNKPEMEQEAJFO4Q7ENG6");
+ assertEquals(accountsPage.getRecords().get(9).getKeypair().getAccountId(), "GACFGMEV7A5H44O3K4EN6GRQ4SA543YJBZTKGNKPEMEQEAJFO4Q7ENG6");
assertEquals(accountsPage.getLinks().getNext().getHref(), "/accounts?order=asc&limit=10&cursor=86861418598401");
assertEquals(accountsPage.getLinks().getPrev().getHref(), "/accounts?order=desc&limit=10&cursor=1");
assertEquals(accountsPage.getLinks().getSelf().getHref(), "/accounts?order=asc&limit=10&cursor=");
diff --git a/src/test/java/org/stellar/sdk/EffectDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
similarity index 84%
rename from src/test/java/org/stellar/sdk/EffectDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
index a4d42820c..232a7d790 100644
--- a/src/test/java/org/stellar/sdk/EffectDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/EffectDeserializerTest.java
@@ -1,12 +1,12 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import junit.framework.TestCase;
import org.junit.Test;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.effects.*;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
+import org.stellar.sdk.responses.effects.*;
public class EffectDeserializerTest extends TestCase {
@Test
@@ -31,9 +31,9 @@ public void testDeserializeAccountCreatedEffect() {
" \"starting_balance\": \"30.0\"\n" +
" }";
- AccountCreatedEffect effect = (AccountCreatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountCreatedEffectResponse effect = (AccountCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ");
+ assertEquals(effect.getAccount().getAccountId(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ");
assertEquals(effect.getStartingBalance(), "30.0");
assertEquals(effect.getPagingToken(), "65571265847297-1");
@@ -63,9 +63,9 @@ public void testDeserializeAccountRemovedEffect() {
" \"type_i\": 1\n"+
" }";
- AccountRemovedEffect effect = (AccountRemovedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountRemovedEffectResponse effect = (AccountRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ");
+ assertEquals(effect.getAccount().getAccountId(), "GCBQ6JRBPF3SXQBQ6SO5MRBE7WVV4UCHYOSHQGXSZNPZLFRYVYOWBZRQ");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/65571265847297");
assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=65571265847297-1");
@@ -95,10 +95,10 @@ public void testDeserializeAccountCreditedEffect() {
" \"amount\": \"1000.0\"\n" +
" }";
- AccountCreditedEffect effect = (AccountCreditedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountCreditedEffectResponse effect = (AccountCreditedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GDLGTRIBFH24364GPWPUS45GUFC2GU4ARPGWTXVCPLGTUHX3IOS3ON47");
- assertEquals(effect.getAsset(), new AssetTypeNative());
+ assertEquals(effect.getAccount().getAccountId(), "GDLGTRIBFH24364GPWPUS45GUFC2GU4ARPGWTXVCPLGTUHX3IOS3ON47");
+ TestCase.assertEquals(effect.getAsset(), new AssetTypeNative());
assertEquals(effect.getAmount(), "1000.0");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/13563506724865");
@@ -129,9 +129,9 @@ public void testDeserializeAccountDebitedEffect() {
" \"amount\": \"30.0\"\n" +
" }";
- AccountDebitedEffect effect = (AccountDebitedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountDebitedEffectResponse effect = (AccountDebitedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H");
+ assertEquals(effect.getAccount().getAccountId(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H");
assertEquals(effect.getAsset(), new AssetTypeNative());
assertEquals(effect.getAmount(), "30.0");
@@ -164,9 +164,9 @@ public void testDeserializeAccountThresholdsUpdatedEffect() {
" \"type_i\": 4\n" +
" }";
- AccountThresholdsUpdatedEffect effect = (AccountThresholdsUpdatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountThresholdsUpdatedEffectResponse effect = (AccountThresholdsUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getLowThreshold(), new Integer(2));
assertEquals(effect.getMedThreshold(), new Integer(3));
assertEquals(effect.getHighThreshold(), new Integer(4));
@@ -198,9 +198,9 @@ public void testDeserializeAccountHomeDomainUpdatedEffect() {
" \"home_domain\": \"stellar.org\"\n" +
" }";
- AccountHomeDomainUpdatedEffect effect = (AccountHomeDomainUpdatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountHomeDomainUpdatedEffectResponse effect = (AccountHomeDomainUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getHomeDomain(), "stellar.org");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/18970870550529");
@@ -231,9 +231,9 @@ public void testDeserializeAccountFlagsUpdatedEffect() {
" \"auth_revokable_flag\": true\n" +
" }";
- AccountFlagsUpdatedEffect effect = (AccountFlagsUpdatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ AccountFlagsUpdatedEffectResponse effect = (AccountFlagsUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getAuthRequiredFlag(), new Boolean(false));
assertEquals(effect.getAuthRevokableFlag(), new Boolean(true));
@@ -265,9 +265,9 @@ public void testDeserializeSignerCreatedEffect() {
" \"public_key\": \"GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU\"\n" +
" }";
- SignerCreatedEffect effect = (SignerCreatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ SignerCreatedEffectResponse effect = (SignerCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU");
+ assertEquals(effect.getAccount().getAccountId(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU");
assertEquals(effect.getWeight(), new Integer(1));
assertEquals(effect.getPublicKey(), "GB24LPGAHYTWRYOXIDKXLI55SBRWW42T3TZKDAAW3BOJX4ADVIATFTLU");
@@ -299,9 +299,9 @@ public void testDeserializeSignerRemovedEffect() {
" \"public_key\": \"GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6\"\n" +
" }";
- SignerRemovedEffect effect = (SignerRemovedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ SignerRemovedEffectResponse effect = (SignerRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6");
+ assertEquals(effect.getAccount().getAccountId(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6");
assertEquals(effect.getWeight(), new Integer(0));
assertEquals(effect.getPublicKey(), "GCFKT6BN2FEASCEVDNHEC4LLFT2KLUUPEMKM4OJPEJ65H2AEZ7IH4RV6");
@@ -333,9 +333,9 @@ public void testDeserializeSignerUpdatedEffect() {
" \"public_key\": \"GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO\"\n" +
" }";
- SignerUpdatedEffect effect = (SignerUpdatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ SignerUpdatedEffectResponse effect = (SignerUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getWeight(), new Integer(2));
assertEquals(effect.getPublicKey(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
@@ -369,10 +369,10 @@ public void testDeserializeTrustlineCreatedEffect() {
" \"limit\": \"1000.0\"\n" +
" }";
- TrustlineCreatedEffect effect = (TrustlineCreatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TrustlineCreatedEffectResponse effect = (TrustlineCreatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ TestCase.assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
assertEquals(effect.getLimit(), "1000.0");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
@@ -405,10 +405,10 @@ public void testDeserializeTrustlineRemovedEffect() {
" \"limit\": \"0.0\"\n" +
" }";
- TrustlineRemovedEffect effect = (TrustlineRemovedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TrustlineRemovedEffectResponse effect = (TrustlineRemovedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
assertEquals(effect.getLimit(), "0.0");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
@@ -441,10 +441,10 @@ public void testDeserializeTrustlineUpdatedEffect() {
" \"limit\": \"100.0\"\n" +
" }";
- TrustlineUpdatedEffect effect = (TrustlineUpdatedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TrustlineUpdatedEffectResponse effect = (TrustlineUpdatedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAddress("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
assertEquals(effect.getLimit(), "100.0");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
@@ -476,12 +476,12 @@ public void testDeserializeTrustlineAuthorizedEffect() {
" \"trustor\": \"GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR\"\n" +
" }";
- TrustlineAuthorizedEffect effect = (TrustlineAuthorizedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TrustlineAuthorizedEffectResponse effect = (TrustlineAuthorizedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getAssetType(), "credit_alphanum12");
assertEquals(effect.getAssetCode(), "TESTTEST");
- assertEquals(effect.getTrustor().getAddress(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR");
+ assertEquals(effect.getTrustor().getAccountId(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2");
@@ -512,12 +512,12 @@ public void testDeserializeTrustlineDeauthorizedEffect() {
" \"trustor\": \"GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR\"\n" +
" }";
- TrustlineDeauthorizedEffect effect = (TrustlineDeauthorizedEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TrustlineDeauthorizedEffectResponse effect = (TrustlineDeauthorizedEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
assertEquals(effect.getAssetType(), "credit_alphanum4");
assertEquals(effect.getAssetCode(), "EUR");
- assertEquals(effect.getTrustor().getAddress(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR");
+ assertEquals(effect.getTrustor().getAccountId(), "GB3E4AB4VWXJDUVN4Z3CPBU5HTMWVEQXONZYVDFMHQD6333KHCOL3UBR");
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2");
@@ -555,15 +555,15 @@ public void testDeserializeTradeEffect() {
" \"bought_asset_issuer\": \"GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7\"\n" +
" }";
- TradeEffect effect = (TradeEffect) GsonSingleton.getInstance().fromJson(json, Effect.class);
+ TradeEffectResponse effect = (TradeEffectResponse) GsonSingleton.getInstance().fromJson(json, EffectResponse.class);
- assertEquals(effect.getAccount().getAddress(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
- assertEquals(effect.getSeller().getAddress(), "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB");
+ assertEquals(effect.getAccount().getAccountId(), "GA6U5X6WOPNKKDKQULBR7IDHDBAQKOWPHYEC7WSXHZBFEYFD3XVZAKOO");
+ assertEquals(effect.getSeller().getAccountId(), "GCVHDLN6EHZBYW2M3BQIY32C23E4GPIRZZDBNF2Q73DAZ5VJDRGSMYRB");
assertEquals(effect.getOfferId(), new Long(1));
assertEquals(effect.getSoldAmount(), "1000.0");
- assertEquals(effect.getSoldAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS")));
+ assertEquals(effect.getSoldAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GCWVFBJ24754I5GXG4JOEB72GJCL3MKWC7VAEYWKGQHPVH3ENPNBSKWS")));
assertEquals(effect.getBoughtAmount(), "60.0");
- assertEquals(effect.getBoughtAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAddress("GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7")));
+ assertEquals(effect.getBoughtAsset(), Asset.createNonNativeAsset("TESTTEST", KeyPair.fromAccountId("GAHXPUDP3AK6F2QQM4FIRBGPNGKLRDDSTQCVKEXXKKRHJZUUQ23D5BU7")));
assertEquals(effect.getLinks().getOperation().getHref(), "http://horizon-testnet.stellar.org/operations/33788507721730");
assertEquals(effect.getLinks().getSucceeds().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&cursor=33788507721730-2");
diff --git a/src/test/java/org/stellar/sdk/EffectsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java
similarity index 94%
rename from src/test/java/org/stellar/sdk/EffectsPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java
index fffb36ba5..da650407b 100644
--- a/src/test/java/org/stellar/sdk/EffectsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/EffectsPageDeserializerTest.java
@@ -1,26 +1,26 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Test;
-import org.stellar.sdk.effects.AccountCreatedEffect;
-import org.stellar.sdk.effects.Effect;
-import org.stellar.sdk.effects.SignerCreatedEffect;
+import org.stellar.sdk.responses.effects.AccountCreatedEffectResponse;
+import org.stellar.sdk.responses.effects.EffectResponse;
+import org.stellar.sdk.responses.effects.SignerCreatedEffectResponse;
public class EffectsPageDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Page effectsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page effectsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
- SignerCreatedEffect signerCreatedEffect = (SignerCreatedEffect) effectsPage.getRecords().get(0);
+ SignerCreatedEffectResponse signerCreatedEffect = (SignerCreatedEffectResponse) effectsPage.getRecords().get(0);
assertEquals(signerCreatedEffect.getPublicKey(), "GAZHVTAM3NRJ6W643LOVA76T2W3TUKPF34ED5VNE4ZKJ2B5T2EUQHIQI");
assertEquals(signerCreatedEffect.getPagingToken(), "3964757325385729-3");
- AccountCreatedEffect accountCreatedEffect = (AccountCreatedEffect) effectsPage.getRecords().get(8);
+ AccountCreatedEffectResponse accountCreatedEffect = (AccountCreatedEffectResponse) effectsPage.getRecords().get(8);
assertEquals(accountCreatedEffect.getStartingBalance(), "10000.0");
- assertEquals(accountCreatedEffect.getAccount().getAddress(), "GDIQJ6G5AWSBRMHIZYWVWCFN64Q4BZ4TYEAQRO5GVR4EWR23RKBJ2A4R");
+ assertEquals(accountCreatedEffect.getAccount().getAccountId(), "GDIQJ6G5AWSBRMHIZYWVWCFN64Q4BZ4TYEAQRO5GVR4EWR23RKBJ2A4R");
assertEquals(effectsPage.getLinks().getNext().getHref(), "http://horizon-testnet.stellar.org/effects?order=desc&limit=10&cursor=3962163165138945-3");
}
diff --git a/src/test/java/org/stellar/sdk/LedgerDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/LedgerDeserializerTest.java
similarity index 95%
rename from src/test/java/org/stellar/sdk/LedgerDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/LedgerDeserializerTest.java
index 738ba71df..c7538ce0d 100644
--- a/src/test/java/org/stellar/sdk/LedgerDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/LedgerDeserializerTest.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import junit.framework.TestCase;
@@ -40,7 +40,7 @@ public void testDeserialize() {
" \"max_tx_set_size\": 50\n" +
"}";
- Ledger ledger = GsonSingleton.getInstance().fromJson(json, Ledger.class);
+ LedgerResponse ledger = GsonSingleton.getInstance().fromJson(json, LedgerResponse.class);
assertEquals(ledger.getHash(), "686bb246db89b099cd3963a4633eb5e4315d89dfd3c00594c80b41a483847bfa");
assertEquals(ledger.getPagingToken(), "3860428274794496");
assertEquals(ledger.getPrevHash(), "50c8695eb32171a19858413e397cc50b504ceacc819010bdf8ff873aff7858d7");
diff --git a/src/test/java/org/stellar/sdk/LedgerPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/LedgerPageDeserializerTest.java
similarity index 99%
rename from src/test/java/org/stellar/sdk/LedgerPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/LedgerPageDeserializerTest.java
index e0a27aaf8..5eecc0e93 100644
--- a/src/test/java/org/stellar/sdk/LedgerPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/LedgerPageDeserializerTest.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
@@ -9,7 +9,7 @@
public class LedgerPageDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Page ledgersPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page ledgersPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
assertEquals(ledgersPage.getRecords().get(0).getHash(), "f6fc9a29b5ecec90348e17a10a60e019c5cb8ea24f66a1063e92c13391b09b8d");
assertEquals(ledgersPage.getRecords().get(0).getPagingToken(), "3862202096287744");
assertEquals(ledgersPage.getRecords().get(9).getHash(), "8552b7d130e602ed068bcfec729b3056d0c8b94d77f06d91cd1ec8323c2d6177");
diff --git a/src/test/java/org/stellar/sdk/OperationDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
similarity index 80%
rename from src/test/java/org/stellar/sdk/OperationDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
index 45e476e53..28d7317bd 100644
--- a/src/test/java/org/stellar/sdk/OperationDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/OperationDeserializerTest.java
@@ -1,12 +1,23 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import junit.framework.TestCase;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.KeyPair;
+
import org.junit.Test;
-import org.stellar.base.Asset;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.base.KeyPair;
-import org.stellar.sdk.operations.*;
+import org.stellar.sdk.responses.operations.AccountMergeOperationResponse;
+import org.stellar.sdk.responses.operations.AllowTrustOperationResponse;
+import org.stellar.sdk.responses.operations.ChangeTrustOperationResponse;
+import org.stellar.sdk.responses.operations.CreateAccountOperationResponse;
+import org.stellar.sdk.responses.operations.CreatePassiveOfferOperationResponse;
+import org.stellar.sdk.responses.operations.InflationOperationResponse;
+import org.stellar.sdk.responses.operations.ManageOfferOperationResponse;
+import org.stellar.sdk.responses.operations.OperationResponse;
+import org.stellar.sdk.responses.operations.PathPaymentOperationResponse;
+import org.stellar.sdk.responses.operations.PaymentOperationResponse;
+import org.stellar.sdk.responses.operations.SetOptionsOperationResponse;
public class OperationDeserializerTest extends TestCase {
@Test
@@ -39,15 +50,15 @@ public void testDeserializeCreateAccountOperation() {
" \"type\": \"create_account\",\n" +
" \"type_i\": 0\n" +
"}";
- CreateAccountOperation operation = (CreateAccountOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ CreateAccountOperationResponse operation = (CreateAccountOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getSourceAccount().getAddress(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD");
+ assertEquals(operation.getSourceAccount().getAccountId(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD");
assertEquals(operation.getPagingToken(), "3936840037961729");
assertEquals(operation.getId(), new Long(3936840037961729L));
- assertEquals(operation.getAccount().getAddress(), "GAR4DDXYNSN2CORG3XQFLAPWYKTUMLZYHYWV4Y2YJJ4JO6ZJFXMJD7PT");
+ assertEquals(operation.getAccount().getAccountId(), "GAR4DDXYNSN2CORG3XQFLAPWYKTUMLZYHYWV4Y2YJJ4JO6ZJFXMJD7PT");
assertEquals(operation.getStartingBalance(), "299454.904954");
- assertEquals(operation.getFunder().getAddress(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD");
+ assertEquals(operation.getFunder().getAccountId(), "GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD");
assertEquals(operation.getLinks().getEffects().getHref(), "/operations/3936840037961729/effects{?cursor,limit,order}");
assertEquals(operation.getLinks().getPrecedes().getHref(), "/operations?cursor=3936840037961729&order=asc");
@@ -87,13 +98,13 @@ public void testDeserializePaymentOperation() {
" \"type\": \"payment\",\n" +
" \"type_i\": 1\n" +
" }";
- PaymentOperation operation = (PaymentOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ PaymentOperationResponse operation = (PaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getSourceAccount().getAddress(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ");
+ assertEquals(operation.getSourceAccount().getAccountId(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ");
assertEquals(operation.getId(), new Long(3940808587743233L));
- assertEquals(operation.getFrom().getAddress(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ");
- assertEquals(operation.getTo().getAddress(), "GDWNY2POLGK65VVKIH5KQSH7VWLKRTQ5M6ADLJAYC2UEHEBEARCZJWWI");
+ assertEquals(operation.getFrom().getAccountId(), "GB6NVEN5HSUBKMYCE5ZOWSK5K23TBWRUQLZY3KNMXUZ3AQ2ESC4MY4AQ");
+ assertEquals(operation.getTo().getAccountId(), "GDWNY2POLGK65VVKIH5KQSH7VWLKRTQ5M6ADLJAYC2UEHEBEARCZJWWI");
assertEquals(operation.getAmount(), "100.0");
assertEquals(operation.getAsset(), new AssetTypeNative());
}
@@ -131,12 +142,12 @@ public void testDeserializeNonNativePaymentOperation() {
" \"amount\": \"1000000000.0\"\n" +
" }";
- PaymentOperation operation = (PaymentOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ PaymentOperationResponse operation = (PaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getFrom().getAddress(), "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA");
- assertEquals(operation.getTo().getAddress(), "GBHUSIZZ7FS2OMLZVZ4HLWJMXQ336NFSXHYERD7GG54NRITDTEWWBBI6");
+ assertEquals(operation.getFrom().getAccountId(), "GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA");
+ assertEquals(operation.getTo().getAccountId(), "GBHUSIZZ7FS2OMLZVZ4HLWJMXQ336NFSXHYERD7GG54NRITDTEWWBBI6");
assertEquals(operation.getAmount(), "1000000000.0");
- assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
+ assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GAZN3PPIDQCSP5JD4ETQQQ2IU2RMFYQTAL4NNQZUGLLO2XJJJ3RDSDGA")));
}
@Test
@@ -172,12 +183,12 @@ public void testDeserializeAllowTrustOperation() {
" \"authorize\": true\n" +
" }";
- AllowTrustOperation operation = (AllowTrustOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ AllowTrustOperationResponse operation = (AllowTrustOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getTrustee().getAddress(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM");
- assertEquals(operation.getTrustor().getAddress(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F");
+ assertEquals(operation.getTrustee().getAccountId(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM");
+ assertEquals(operation.getTrustor().getAccountId(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F");
assertEquals(operation.isAuthorize(), true);
- assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")));
+ assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")));
}
@Test
@@ -213,12 +224,12 @@ public void testDeserializeChangeTrustOperation() {
" \"trustor\": \"GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F\"\n" +
" }";
- ChangeTrustOperation operation = (ChangeTrustOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ ChangeTrustOperationResponse operation = (ChangeTrustOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getTrustee().getAddress(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM");
- assertEquals(operation.getTrustor().getAddress(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F");
+ assertEquals(operation.getTrustee().getAccountId(), "GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM");
+ assertEquals(operation.getTrustor().getAccountId(), "GDZ55LVXECRTW4G36EZPTHI4XIYS5JUC33TUS22UOETVFVOQ77JXWY4F");
assertEquals(operation.getLimit(), "922337203685.4775807");
- assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")));
+ assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDIROJW2YHMSFZJJ4R5XWWNUVND5I45YEWS5DSFKXCHMADZ5V374U2LM")));
}
@Test
@@ -262,12 +273,12 @@ public void testDeserializeSetOptionsOperation() {
" ]"+
" }";
- SetOptionsOperation operation = (SetOptionsOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ SetOptionsOperationResponse operation = (SetOptionsOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getSigner().getAddress(), "GD3ZYXVC7C3ECD5I4E5NGPBFJJSULJ6HJI2FBHGKYFV34DSIWB4YEKJZ");
+ assertEquals(operation.getSigner().getAccountId(), "GD3ZYXVC7C3ECD5I4E5NGPBFJJSULJ6HJI2FBHGKYFV34DSIWB4YEKJZ");
assertEquals(operation.getSignerWeight(), new Integer(1));
assertEquals(operation.getHomeDomain(), "stellar.org");
- assertEquals(operation.getInflationDestination().getAddress(), "GBYWSY4NPLLPTP22QYANGTT7PEHND64P4D4B6LFEUHGUZRVYJK2H4TBE");
+ assertEquals(operation.getInflationDestination().getAccountId(), "GBYWSY4NPLLPTP22QYANGTT7PEHND64P4D4B6LFEUHGUZRVYJK2H4TBE");
assertEquals(operation.getLowThreshold(), new Integer(1));
assertEquals(operation.getMedThreshold(), new Integer(2));
assertEquals(operation.getHighThreshold(), new Integer(3));
@@ -305,10 +316,10 @@ public void testDeserializeAccountMergeOperation() {
" \"into\": \"GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN\"\n" +
" }";
- AccountMergeOperation operation = (AccountMergeOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ AccountMergeOperationResponse operation = (AccountMergeOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getAccount().getAddress(), "GD6GKRABNDVYDETEZJQEPS7IBQMERCN44R5RCI4LJNX6BMYQM2KPGGZ2");
- assertEquals(operation.getInto().getAddress(), "GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN");
+ assertEquals(operation.getAccount().getAccountId(), "GD6GKRABNDVYDETEZJQEPS7IBQMERCN44R5RCI4LJNX6BMYQM2KPGGZ2");
+ assertEquals(operation.getInto().getAccountId(), "GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN");
}
@Test
@@ -344,11 +355,11 @@ public void testDeserializeManageOfferOperation() {
" \"selling_asset_type\": \"native\"\n" +
" }";
- ManageOfferOperation operation = (ManageOfferOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ ManageOfferOperationResponse operation = (ManageOfferOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
assertEquals(operation.getOfferId(), new Integer(0));
assertEquals(operation.getAmount(), "100.0");
- assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("CNY", KeyPair.fromAddress("GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN")));
+ assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("CNY", KeyPair.fromAccountId("GAZWSWPDQTBHFIPBY4FEDFW2J6E2LE7SZHJWGDZO6Q63W7DBSRICO2KN")));
assertEquals(operation.getSellingAsset(), new AssetTypeNative());
}
@@ -389,14 +400,14 @@ public void testDeserializePathPaymentOperation() {
" \"type\": \"path_payment\"\n" +
"}";
- PathPaymentOperation operation = (PathPaymentOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ PathPaymentOperationResponse operation = (PathPaymentOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
- assertEquals(operation.getFrom().getAddress(), "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU");
- assertEquals(operation.getTo().getAddress(), "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2");
+ assertEquals(operation.getFrom().getAccountId(), "GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU");
+ assertEquals(operation.getTo().getAccountId(), "GA5WBPYA5Y4WAEHXWR2UKO2UO4BUGHUQ74EUPKON2QHV4WRHOIRNKKH2");
assertEquals(operation.getAmount(), "10.0");
assertEquals(operation.getSourceAmount(), "100.0");
- assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG")));
- assertEquals(operation.getSendAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")));
+ assertEquals(operation.getAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GCQPYGH4K57XBDENKKX55KDTWOTK5WDWRQOH2LHEDX3EKVIQRLMESGBG")));
+ assertEquals(operation.getSendAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GC23QF2HUE52AMXUFUH3AYJAXXGXXV2VHXYYR6EYXETPKDXZSAW67XO4")));
}
@Test
@@ -437,10 +448,10 @@ public void testDeserializeCreatePassiveOfferOperation() {
" \"type\": \"create_passive_offer\"\n" +
"}";
- CreatePassiveOfferOperation operation = (CreatePassiveOfferOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ CreatePassiveOfferOperationResponse operation = (CreatePassiveOfferOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
assertEquals(operation.getAmount(), "11.27827");
- assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GDS5JW5E6DRSSN5XK4LW7E6VUMFKKE2HU5WCOVFTO7P2RP7OXVCBLJ3Y")));
+ assertEquals(operation.getBuyingAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDS5JW5E6DRSSN5XK4LW7E6VUMFKKE2HU5WCOVFTO7P2RP7OXVCBLJ3Y")));
assertEquals(operation.getSellingAsset(), new AssetTypeNative());
}
@@ -471,7 +482,7 @@ public void testDeserializeInflationOperation() {
" \"type\": \"inflation\"\n" +
"}";
- InflationOperation operation = (InflationOperation) GsonSingleton.getInstance().fromJson(json, Operation.class);
+ InflationOperationResponse operation = (InflationOperationResponse) GsonSingleton.getInstance().fromJson(json, OperationResponse.class);
assertEquals(operation.getId(), new Long(12884914177L));
}
diff --git a/src/test/java/org/stellar/sdk/OperationsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java
similarity index 93%
rename from src/test/java/org/stellar/sdk/OperationsPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java
index c8ae831fa..fb1f5c415 100644
--- a/src/test/java/org/stellar/sdk/OperationsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/OperationsPageDeserializerTest.java
@@ -1,31 +1,31 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Test;
-import org.stellar.base.AssetTypeNative;
-import org.stellar.sdk.operations.CreateAccountOperation;
-import org.stellar.sdk.operations.Operation;
-import org.stellar.sdk.operations.PaymentOperation;
+import org.stellar.sdk.AssetTypeNative;
+import org.stellar.sdk.responses.operations.CreateAccountOperationResponse;
+import org.stellar.sdk.responses.operations.OperationResponse;
+import org.stellar.sdk.responses.operations.PaymentOperationResponse;
public class OperationsPageDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Page operationsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page operationsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
- CreateAccountOperation createAccountOperation = (CreateAccountOperation) operationsPage.getRecords().get(0);
+ CreateAccountOperationResponse createAccountOperation = (CreateAccountOperationResponse) operationsPage.getRecords().get(0);
assertEquals(createAccountOperation.getStartingBalance(), "10000.0");
assertEquals(createAccountOperation.getPagingToken(), "3717508943056897");
- assertEquals(createAccountOperation.getAccount().getAddress(), "GDFH4NIYMIIAKRVEJJZOIGWKXGQUF3XHJG6ZM6CEA64AMTVDN44LHOQE");
- assertEquals(createAccountOperation.getFunder().getAddress(), "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K");
+ assertEquals(createAccountOperation.getAccount().getAccountId(), "GDFH4NIYMIIAKRVEJJZOIGWKXGQUF3XHJG6ZM6CEA64AMTVDN44LHOQE");
+ assertEquals(createAccountOperation.getFunder().getAccountId(), "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K");
- PaymentOperation paymentOperation = (PaymentOperation) operationsPage.getRecords().get(4);
+ PaymentOperationResponse paymentOperation = (PaymentOperationResponse) operationsPage.getRecords().get(4);
assertEquals(paymentOperation.getAmount(), "10.123");
- assertEquals(paymentOperation.getAsset(), new AssetTypeNative());
- assertEquals(paymentOperation.getFrom().getAddress(), "GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R");
- assertEquals(paymentOperation.getTo().getAddress(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H");
+ TestCase.assertEquals(paymentOperation.getAsset(), new AssetTypeNative());
+ assertEquals(paymentOperation.getFrom().getAccountId(), "GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R");
+ assertEquals(paymentOperation.getTo().getAccountId(), "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H");
}
String json = "{\n" +
diff --git a/src/test/java/org/stellar/sdk/PathsPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java
similarity index 78%
rename from src/test/java/org/stellar/sdk/PathsPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java
index 36795404d..5646d990d 100644
--- a/src/test/java/org/stellar/sdk/PathsPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/PathsPageDeserializerTest.java
@@ -1,10 +1,11 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
+import org.junit.Assert;
import org.junit.Test;
-import org.stellar.base.Asset;
-import org.stellar.base.KeyPair;
+import org.stellar.sdk.Asset;
+import org.stellar.sdk.KeyPair;
import static org.junit.Assert.assertEquals;
@@ -12,28 +13,28 @@ public class PathsPageDeserializerTest {
@Test
public void testDeserialize() {
- Page pathsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page pathsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
assertEquals(pathsPage.getRecords().get(0).getDestinationAmount(), "20.0000000");
- assertEquals(pathsPage.getRecords().get(0).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
+ Assert.assertEquals(pathsPage.getRecords().get(0).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
assertEquals(pathsPage.getRecords().get(0).getPath().size(), 0);
assertEquals(pathsPage.getRecords().get(0).getSourceAmount(), "30.0000000");
- assertEquals(pathsPage.getRecords().get(0).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
+ assertEquals(pathsPage.getRecords().get(0).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
assertEquals(pathsPage.getRecords().get(1).getDestinationAmount(), "50.0000000");
- assertEquals(pathsPage.getRecords().get(1).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GBFMFKDUFYYITWRQXL4775CVUV3A3WGGXNJUAP4KTXNEQ2HG7JRBITGH")));
+ assertEquals(pathsPage.getRecords().get(1).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GBFMFKDUFYYITWRQXL4775CVUV3A3WGGXNJUAP4KTXNEQ2HG7JRBITGH")));
assertEquals(pathsPage.getRecords().get(1).getPath().size(), 1);
- assertEquals(pathsPage.getRecords().get(1).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAddress("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
+ assertEquals(pathsPage.getRecords().get(1).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAccountId("GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN")));
assertEquals(pathsPage.getRecords().get(1).getSourceAmount(), "60.0000000");
- assertEquals(pathsPage.getRecords().get(1).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GBRAOXQDNQZRDIOK64HZI4YRDTBFWNUYH3OIHQLY4VEK5AIGMQHCLGXI")));
+ assertEquals(pathsPage.getRecords().get(1).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GBRAOXQDNQZRDIOK64HZI4YRDTBFWNUYH3OIHQLY4VEK5AIGMQHCLGXI")));
assertEquals(pathsPage.getRecords().get(2).getDestinationAmount(), "200.0000000");
- assertEquals(pathsPage.getRecords().get(2).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAddress("GBRCOBK7C7UE72PB5JCPQU3ZI45ZCEM7HKQ3KYV3YD3XB7EBOPBEDN2G")));
+ assertEquals(pathsPage.getRecords().get(2).getDestinationAsset(), Asset.createNonNativeAsset("EUR", KeyPair.fromAccountId("GBRCOBK7C7UE72PB5JCPQU3ZI45ZCEM7HKQ3KYV3YD3XB7EBOPBEDN2G")));
assertEquals(pathsPage.getRecords().get(2).getPath().size(), 2);
- assertEquals(pathsPage.getRecords().get(2).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAddress("GAX7B3ZT3EOZW5POAMV4NGPPKCYUOYW2QQDIAF23JAXF72NMGRYPYOPM")));
- assertEquals(pathsPage.getRecords().get(2).getPath().get(1), Asset.createNonNativeAsset("PLN", KeyPair.fromAddress("GACWIA2XGDFWWN3WKPX63JTK4S2J5NDPNOIVYMZY6RVTS7LWF2VHZLV3")));
+ assertEquals(pathsPage.getRecords().get(2).getPath().get(0), Asset.createNonNativeAsset("GBP", KeyPair.fromAccountId("GAX7B3ZT3EOZW5POAMV4NGPPKCYUOYW2QQDIAF23JAXF72NMGRYPYOPM")));
+ assertEquals(pathsPage.getRecords().get(2).getPath().get(1), Asset.createNonNativeAsset("PLN", KeyPair.fromAccountId("GACWIA2XGDFWWN3WKPX63JTK4S2J5NDPNOIVYMZY6RVTS7LWF2VHZLV3")));
assertEquals(pathsPage.getRecords().get(2).getSourceAmount(), "300.0000000");
- assertEquals(pathsPage.getRecords().get(2).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAddress("GC7J5IHS3GABSX7AZLRINXWLHFTL3WWXLU4QX2UGSDEAIAQW2Q72U3KH")));
+ assertEquals(pathsPage.getRecords().get(2).getSourceAsset(), Asset.createNonNativeAsset("USD", KeyPair.fromAccountId("GC7J5IHS3GABSX7AZLRINXWLHFTL3WWXLU4QX2UGSDEAIAQW2Q72U3KH")));
}
String json = "{\n" +
diff --git a/src/test/java/org/stellar/sdk/TransactionDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
similarity index 95%
rename from src/test/java/org/stellar/sdk/TransactionDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
index 01f0d2e30..0307d7608 100644
--- a/src/test/java/org/stellar/sdk/TransactionDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/TransactionDeserializerTest.java
@@ -1,20 +1,20 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import junit.framework.TestCase;
import org.junit.Test;
-import org.stellar.base.MemoHash;
-import org.stellar.base.MemoNone;
+import org.stellar.sdk.MemoHash;
+import org.stellar.sdk.MemoNone;
public class TransactionDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Transaction transaction = GsonSingleton.getInstance().fromJson(json, Transaction.class);
+ TransactionResponse transaction = GsonSingleton.getInstance().fromJson(json, TransactionResponse.class);
assertEquals(transaction.getHash(), "5c2e4dad596941ef944d72741c8f8f1a4282f8f2f141e81d827f44bf365d626b");
assertEquals(transaction.getLedger(), new Long(915744));
assertEquals(transaction.getCreatedAt(), "2015-11-20T17:01:28Z");
assertEquals(transaction.getPagingToken(), "3933090531512320");
- assertEquals(transaction.getSourceAccount().getAddress(), "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK");
+ assertEquals(transaction.getSourceAccount().getAccountId(), "GCUB7JL4APK7LKJ6MZF7Q2JTLHAGNBIUA7XIXD5SQTG52GQ2DAT6XZMK");
assertEquals(transaction.getSourceAccountSequence(), new Long(2373051035426646L));
assertEquals(transaction.getFeePaid(), new Long(100));
assertEquals(transaction.getOperationCount(), new Integer(1));
@@ -37,7 +37,7 @@ public void testDeserialize() {
@Test
public void testDeserializeWithoutMemo() {
- Transaction transaction = GsonSingleton.getInstance().fromJson(jsonMemoNone, Transaction.class);
+ TransactionResponse transaction = GsonSingleton.getInstance().fromJson(jsonMemoNone, TransactionResponse.class);
assertTrue(transaction.getMemo() instanceof MemoNone);
}
diff --git a/src/test/java/org/stellar/sdk/TransactionPageDeserializerTest.java b/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java
similarity index 98%
rename from src/test/java/org/stellar/sdk/TransactionPageDeserializerTest.java
rename to src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java
index b5e63c172..13d6cf6f5 100644
--- a/src/test/java/org/stellar/sdk/TransactionPageDeserializerTest.java
+++ b/src/test/java/org/stellar/sdk/responses/TransactionPageDeserializerTest.java
@@ -1,4 +1,4 @@
-package org.stellar.sdk;
+package org.stellar.sdk.responses;
import com.google.gson.reflect.TypeToken;
@@ -9,12 +9,12 @@
public class TransactionPageDeserializerTest extends TestCase {
@Test
public void testDeserialize() {
- Page transactionsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
+ Page transactionsPage = GsonSingleton.getInstance().fromJson(json, new TypeToken>() {}.getType());
- assertEquals(transactionsPage.getRecords().get(0).getSourceAccount().getAddress(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
+ assertEquals(transactionsPage.getRecords().get(0).getSourceAccount().getAccountId(), "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
assertEquals(transactionsPage.getRecords().get(0).getPagingToken(), "12884905984");
assertEquals(transactionsPage.getRecords().get(0).getLinks().getAccount().getHref(), "/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7");
- assertEquals(transactionsPage.getRecords().get(9).getSourceAccount().getAddress(), "GAENIE5LBJIXLMJIAJ7225IUPA6CX7EGHUXRX5FLCZFFAQSG2ZUYSWFK");
+ assertEquals(transactionsPage.getRecords().get(9).getSourceAccount().getAccountId(), "GAENIE5LBJIXLMJIAJ7225IUPA6CX7EGHUXRX5FLCZFFAQSG2ZUYSWFK");
assertEquals(transactionsPage.getLinks().getNext().getHref(), "/transactions?order=asc&limit=10&cursor=81058917781504");
assertEquals(transactionsPage.getLinks().getPrev().getHref(), "/transactions?order=desc&limit=10&cursor=12884905984");