diff --git a/JNI/cpp/RippleSigner.c b/JNI/cpp/RippleSigner.c new file mode 100644 index 00000000000..d1a48bc9a53 --- /dev/null +++ b/JNI/cpp/RippleSigner.c @@ -0,0 +1,35 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. +// +// This is a GENERATED FILE, changes made here WILL BE LOST. +// + +#include +#include +#include + +#include + +#include "TWJNI.h" +#include "RippleSigner.h" + +jobject JNICALL Java_wallet_core_jni_RippleSigner_sign(JNIEnv *env, jclass thisClass, jobject input) { + jclass inputClass = (*env)->GetObjectClass(env, input); + jmethodID inputToByteArrayMethodID = (*env)->GetMethodID(env, inputClass, "toByteArray", "()[B"); + jbyteArray inputByteArray = (*env)->CallObjectMethod(env, input, inputToByteArrayMethodID); + TWData *inputData = TWDataCreateWithJByteArray(env, inputByteArray); + jbyteArray resultData = TWDataJByteArray(TWRippleSignerSign(inputData), env); + jclass resultClass = (*env)->FindClass(env, "wallet/core/jni/proto/Proto$SigningOutput"); + jmethodID parseFromMethodID = (*env)->GetStaticMethodID(env, resultClass, "parseFrom", "([B)Lwallet/core/jni/proto/Proto$SigningOutput;"); + jobject result = (*env)->CallStaticObjectMethod(env, resultClass, parseFromMethodID, resultData); + + (*env)->DeleteLocalRef(env, resultClass); + (*env)->DeleteLocalRef(env, inputByteArray); + (*env)->DeleteLocalRef(env, inputClass); + + return result; +} + diff --git a/JNI/cpp/RippleSigner.h b/JNI/cpp/RippleSigner.h new file mode 100644 index 00000000000..2690c587043 --- /dev/null +++ b/JNI/cpp/RippleSigner.h @@ -0,0 +1,24 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. +// +// This is a GENERATED FILE, changes made here WILL BE LOST. +// + +#ifndef JNI_TW_RIPPLESIGNER_H +#define JNI_TW_RIPPLESIGNER_H + +#include +#include + +TW_EXTERN_C_BEGIN + +JNIEXPORT +jobject JNICALL Java_wallet_core_jni_RippleSigner_sign(JNIEnv *env, jclass thisClass, jobject input); + + +TW_EXTERN_C_END + +#endif // JNI_TW_RIPPLESIGNER_H diff --git a/JNI/java/com/wallet/crypto/trustapp/proto/Ripple.java b/JNI/java/com/wallet/crypto/trustapp/proto/Ripple.java new file mode 100644 index 00000000000..a8d34ace786 --- /dev/null +++ b/JNI/java/com/wallet/crypto/trustapp/proto/Ripple.java @@ -0,0 +1,1702 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Ripple.proto + +package com.wallet.crypto.trustapp.proto; + +public final class Ripple { + private Ripple() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SigningInputOrBuilder extends + // @@protoc_insertion_point(interface_extends:TW.Ripple.Proto.SigningInput) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 amount = 1; + */ + long getAmount(); + + /** + * int64 fee = 2; + */ + long getFee(); + + /** + * int32 sequence = 3; + */ + int getSequence(); + + /** + * int32 last_ledger_sequence = 4; + */ + int getLastLedgerSequence(); + + /** + * string account = 5; + */ + java.lang.String getAccount(); + /** + * string account = 5; + */ + com.google.protobuf.ByteString + getAccountBytes(); + + /** + * string destination = 6; + */ + java.lang.String getDestination(); + /** + * string destination = 6; + */ + com.google.protobuf.ByteString + getDestinationBytes(); + + /** + * int64 destination_tag = 7; + */ + long getDestinationTag(); + + /** + * int64 flags = 8; + */ + long getFlags(); + + /** + * bytes private_key = 9; + */ + com.google.protobuf.ByteString getPrivateKey(); + } + /** + *
+   * Input data necessary to create a signed transaction.
+   * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningInput} + */ + public static final class SigningInput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:TW.Ripple.Proto.SigningInput) + SigningInputOrBuilder { + private static final long serialVersionUID = 0L; + // Use SigningInput.newBuilder() to construct. + private SigningInput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SigningInput() { + amount_ = 0L; + fee_ = 0L; + sequence_ = 0; + lastLedgerSequence_ = 0; + account_ = ""; + destination_ = ""; + destinationTag_ = 0L; + flags_ = 0L; + privateKey_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SigningInput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + amount_ = input.readInt64(); + break; + } + case 16: { + + fee_ = input.readInt64(); + break; + } + case 24: { + + sequence_ = input.readInt32(); + break; + } + case 32: { + + lastLedgerSequence_ = input.readInt32(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + account_ = s; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + destination_ = s; + break; + } + case 56: { + + destinationTag_ = input.readInt64(); + break; + } + case 64: { + + flags_ = input.readInt64(); + break; + } + case 74: { + + privateKey_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.wallet.crypto.trustapp.proto.Ripple.SigningInput.class, com.wallet.crypto.trustapp.proto.Ripple.SigningInput.Builder.class); + } + + public static final int AMOUNT_FIELD_NUMBER = 1; + private long amount_; + /** + * int64 amount = 1; + */ + public long getAmount() { + return amount_; + } + + public static final int FEE_FIELD_NUMBER = 2; + private long fee_; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + + public static final int SEQUENCE_FIELD_NUMBER = 3; + private int sequence_; + /** + * int32 sequence = 3; + */ + public int getSequence() { + return sequence_; + } + + public static final int LAST_LEDGER_SEQUENCE_FIELD_NUMBER = 4; + private int lastLedgerSequence_; + /** + * int32 last_ledger_sequence = 4; + */ + public int getLastLedgerSequence() { + return lastLedgerSequence_; + } + + public static final int ACCOUNT_FIELD_NUMBER = 5; + private volatile java.lang.Object account_; + /** + * string account = 5; + */ + public java.lang.String getAccount() { + java.lang.Object ref = account_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + account_ = s; + return s; + } + } + /** + * string account = 5; + */ + public com.google.protobuf.ByteString + getAccountBytes() { + java.lang.Object ref = account_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + account_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESTINATION_FIELD_NUMBER = 6; + private volatile java.lang.Object destination_; + /** + * string destination = 6; + */ + public java.lang.String getDestination() { + java.lang.Object ref = destination_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + destination_ = s; + return s; + } + } + /** + * string destination = 6; + */ + public com.google.protobuf.ByteString + getDestinationBytes() { + java.lang.Object ref = destination_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + destination_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESTINATION_TAG_FIELD_NUMBER = 7; + private long destinationTag_; + /** + * int64 destination_tag = 7; + */ + public long getDestinationTag() { + return destinationTag_; + } + + public static final int FLAGS_FIELD_NUMBER = 8; + private long flags_; + /** + * int64 flags = 8; + */ + public long getFlags() { + return flags_; + } + + public static final int PRIVATE_KEY_FIELD_NUMBER = 9; + private com.google.protobuf.ByteString privateKey_; + /** + * bytes private_key = 9; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (amount_ != 0L) { + output.writeInt64(1, amount_); + } + if (fee_ != 0L) { + output.writeInt64(2, fee_); + } + if (sequence_ != 0) { + output.writeInt32(3, sequence_); + } + if (lastLedgerSequence_ != 0) { + output.writeInt32(4, lastLedgerSequence_); + } + if (!getAccountBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, account_); + } + if (!getDestinationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, destination_); + } + if (destinationTag_ != 0L) { + output.writeInt64(7, destinationTag_); + } + if (flags_ != 0L) { + output.writeInt64(8, flags_); + } + if (!privateKey_.isEmpty()) { + output.writeBytes(9, privateKey_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, amount_); + } + if (fee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, fee_); + } + if (sequence_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, sequence_); + } + if (lastLedgerSequence_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, lastLedgerSequence_); + } + if (!getAccountBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, account_); + } + if (!getDestinationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, destination_); + } + if (destinationTag_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, destinationTag_); + } + if (flags_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, flags_); + } + if (!privateKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, privateKey_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.wallet.crypto.trustapp.proto.Ripple.SigningInput)) { + return super.equals(obj); + } + com.wallet.crypto.trustapp.proto.Ripple.SigningInput other = (com.wallet.crypto.trustapp.proto.Ripple.SigningInput) obj; + + boolean result = true; + result = result && (getAmount() + == other.getAmount()); + result = result && (getFee() + == other.getFee()); + result = result && (getSequence() + == other.getSequence()); + result = result && (getLastLedgerSequence() + == other.getLastLedgerSequence()); + result = result && getAccount() + .equals(other.getAccount()); + result = result && getDestination() + .equals(other.getDestination()); + result = result && (getDestinationTag() + == other.getDestinationTag()); + result = result && (getFlags() + == other.getFlags()); + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (37 * hash) + FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFee()); + hash = (37 * hash) + SEQUENCE_FIELD_NUMBER; + hash = (53 * hash) + getSequence(); + hash = (37 * hash) + LAST_LEDGER_SEQUENCE_FIELD_NUMBER; + hash = (53 * hash) + getLastLedgerSequence(); + hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getAccount().hashCode(); + hash = (37 * hash) + DESTINATION_FIELD_NUMBER; + hash = (53 * hash) + getDestination().hashCode(); + hash = (37 * hash) + DESTINATION_TAG_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getDestinationTag()); + hash = (37 * hash) + FLAGS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFlags()); + hash = (37 * hash) + PRIVATE_KEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.wallet.crypto.trustapp.proto.Ripple.SigningInput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Input data necessary to create a signed transaction.
+     * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningInput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:TW.Ripple.Proto.SigningInput) + com.wallet.crypto.trustapp.proto.Ripple.SigningInputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.wallet.crypto.trustapp.proto.Ripple.SigningInput.class, com.wallet.crypto.trustapp.proto.Ripple.SigningInput.Builder.class); + } + + // Construct using com.wallet.crypto.trustapp.proto.Ripple.SigningInput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + amount_ = 0L; + + fee_ = 0L; + + sequence_ = 0; + + lastLedgerSequence_ = 0; + + account_ = ""; + + destination_ = ""; + + destinationTag_ = 0L; + + flags_ = 0L; + + privateKey_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningInput getDefaultInstanceForType() { + return com.wallet.crypto.trustapp.proto.Ripple.SigningInput.getDefaultInstance(); + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningInput build() { + com.wallet.crypto.trustapp.proto.Ripple.SigningInput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningInput buildPartial() { + com.wallet.crypto.trustapp.proto.Ripple.SigningInput result = new com.wallet.crypto.trustapp.proto.Ripple.SigningInput(this); + result.amount_ = amount_; + result.fee_ = fee_; + result.sequence_ = sequence_; + result.lastLedgerSequence_ = lastLedgerSequence_; + result.account_ = account_; + result.destination_ = destination_; + result.destinationTag_ = destinationTag_; + result.flags_ = flags_; + result.privateKey_ = privateKey_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.wallet.crypto.trustapp.proto.Ripple.SigningInput) { + return mergeFrom((com.wallet.crypto.trustapp.proto.Ripple.SigningInput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.wallet.crypto.trustapp.proto.Ripple.SigningInput other) { + if (other == com.wallet.crypto.trustapp.proto.Ripple.SigningInput.getDefaultInstance()) return this; + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + if (other.getFee() != 0L) { + setFee(other.getFee()); + } + if (other.getSequence() != 0) { + setSequence(other.getSequence()); + } + if (other.getLastLedgerSequence() != 0) { + setLastLedgerSequence(other.getLastLedgerSequence()); + } + if (!other.getAccount().isEmpty()) { + account_ = other.account_; + onChanged(); + } + if (!other.getDestination().isEmpty()) { + destination_ = other.destination_; + onChanged(); + } + if (other.getDestinationTag() != 0L) { + setDestinationTag(other.getDestinationTag()); + } + if (other.getFlags() != 0L) { + setFlags(other.getFlags()); + } + if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) { + setPrivateKey(other.getPrivateKey()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.wallet.crypto.trustapp.proto.Ripple.SigningInput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.wallet.crypto.trustapp.proto.Ripple.SigningInput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long amount_ ; + /** + * int64 amount = 1; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 1; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 1; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + + private long fee_ ; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + /** + * int64 fee = 2; + */ + public Builder setFee(long value) { + + fee_ = value; + onChanged(); + return this; + } + /** + * int64 fee = 2; + */ + public Builder clearFee() { + + fee_ = 0L; + onChanged(); + return this; + } + + private int sequence_ ; + /** + * int32 sequence = 3; + */ + public int getSequence() { + return sequence_; + } + /** + * int32 sequence = 3; + */ + public Builder setSequence(int value) { + + sequence_ = value; + onChanged(); + return this; + } + /** + * int32 sequence = 3; + */ + public Builder clearSequence() { + + sequence_ = 0; + onChanged(); + return this; + } + + private int lastLedgerSequence_ ; + /** + * int32 last_ledger_sequence = 4; + */ + public int getLastLedgerSequence() { + return lastLedgerSequence_; + } + /** + * int32 last_ledger_sequence = 4; + */ + public Builder setLastLedgerSequence(int value) { + + lastLedgerSequence_ = value; + onChanged(); + return this; + } + /** + * int32 last_ledger_sequence = 4; + */ + public Builder clearLastLedgerSequence() { + + lastLedgerSequence_ = 0; + onChanged(); + return this; + } + + private java.lang.Object account_ = ""; + /** + * string account = 5; + */ + public java.lang.String getAccount() { + java.lang.Object ref = account_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + account_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string account = 5; + */ + public com.google.protobuf.ByteString + getAccountBytes() { + java.lang.Object ref = account_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + account_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string account = 5; + */ + public Builder setAccount( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + account_ = value; + onChanged(); + return this; + } + /** + * string account = 5; + */ + public Builder clearAccount() { + + account_ = getDefaultInstance().getAccount(); + onChanged(); + return this; + } + /** + * string account = 5; + */ + public Builder setAccountBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + account_ = value; + onChanged(); + return this; + } + + private java.lang.Object destination_ = ""; + /** + * string destination = 6; + */ + public java.lang.String getDestination() { + java.lang.Object ref = destination_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + destination_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string destination = 6; + */ + public com.google.protobuf.ByteString + getDestinationBytes() { + java.lang.Object ref = destination_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + destination_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string destination = 6; + */ + public Builder setDestination( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + destination_ = value; + onChanged(); + return this; + } + /** + * string destination = 6; + */ + public Builder clearDestination() { + + destination_ = getDefaultInstance().getDestination(); + onChanged(); + return this; + } + /** + * string destination = 6; + */ + public Builder setDestinationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + destination_ = value; + onChanged(); + return this; + } + + private long destinationTag_ ; + /** + * int64 destination_tag = 7; + */ + public long getDestinationTag() { + return destinationTag_; + } + /** + * int64 destination_tag = 7; + */ + public Builder setDestinationTag(long value) { + + destinationTag_ = value; + onChanged(); + return this; + } + /** + * int64 destination_tag = 7; + */ + public Builder clearDestinationTag() { + + destinationTag_ = 0L; + onChanged(); + return this; + } + + private long flags_ ; + /** + * int64 flags = 8; + */ + public long getFlags() { + return flags_; + } + /** + * int64 flags = 8; + */ + public Builder setFlags(long value) { + + flags_ = value; + onChanged(); + return this; + } + /** + * int64 flags = 8; + */ + public Builder clearFlags() { + + flags_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes private_key = 9; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + /** + * bytes private_key = 9; + */ + public Builder setPrivateKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * bytes private_key = 9; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:TW.Ripple.Proto.SigningInput) + } + + // @@protoc_insertion_point(class_scope:TW.Ripple.Proto.SigningInput) + private static final com.wallet.crypto.trustapp.proto.Ripple.SigningInput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.wallet.crypto.trustapp.proto.Ripple.SigningInput(); + } + + public static com.wallet.crypto.trustapp.proto.Ripple.SigningInput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SigningInput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SigningInput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningInput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SigningOutputOrBuilder extends + // @@protoc_insertion_point(interface_extends:TW.Ripple.Proto.SigningOutput) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes encoded = 1; + */ + com.google.protobuf.ByteString getEncoded(); + } + /** + *
+   * Transaction signing output.
+   * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningOutput} + */ + public static final class SigningOutput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:TW.Ripple.Proto.SigningOutput) + SigningOutputOrBuilder { + private static final long serialVersionUID = 0L; + // Use SigningOutput.newBuilder() to construct. + private SigningOutput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SigningOutput() { + encoded_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SigningOutput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + + encoded_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.class, com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.Builder.class); + } + + public static final int ENCODED_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString encoded_; + /** + * bytes encoded = 1; + */ + public com.google.protobuf.ByteString getEncoded() { + return encoded_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!encoded_.isEmpty()) { + output.writeBytes(1, encoded_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!encoded_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, encoded_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.wallet.crypto.trustapp.proto.Ripple.SigningOutput)) { + return super.equals(obj); + } + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput other = (com.wallet.crypto.trustapp.proto.Ripple.SigningOutput) obj; + + boolean result = true; + result = result && getEncoded() + .equals(other.getEncoded()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENCODED_FIELD_NUMBER; + hash = (53 * hash) + getEncoded().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.wallet.crypto.trustapp.proto.Ripple.SigningOutput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Transaction signing output.
+     * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningOutput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:TW.Ripple.Proto.SigningOutput) + com.wallet.crypto.trustapp.proto.Ripple.SigningOutputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.class, com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.Builder.class); + } + + // Construct using com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + encoded_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.wallet.crypto.trustapp.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningOutput getDefaultInstanceForType() { + return com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.getDefaultInstance(); + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningOutput build() { + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningOutput buildPartial() { + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput result = new com.wallet.crypto.trustapp.proto.Ripple.SigningOutput(this); + result.encoded_ = encoded_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.wallet.crypto.trustapp.proto.Ripple.SigningOutput) { + return mergeFrom((com.wallet.crypto.trustapp.proto.Ripple.SigningOutput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.wallet.crypto.trustapp.proto.Ripple.SigningOutput other) { + if (other == com.wallet.crypto.trustapp.proto.Ripple.SigningOutput.getDefaultInstance()) return this; + if (other.getEncoded() != com.google.protobuf.ByteString.EMPTY) { + setEncoded(other.getEncoded()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.wallet.crypto.trustapp.proto.Ripple.SigningOutput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.wallet.crypto.trustapp.proto.Ripple.SigningOutput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString encoded_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes encoded = 1; + */ + public com.google.protobuf.ByteString getEncoded() { + return encoded_; + } + /** + * bytes encoded = 1; + */ + public Builder setEncoded(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + encoded_ = value; + onChanged(); + return this; + } + /** + * bytes encoded = 1; + */ + public Builder clearEncoded() { + + encoded_ = getDefaultInstance().getEncoded(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:TW.Ripple.Proto.SigningOutput) + } + + // @@protoc_insertion_point(class_scope:TW.Ripple.Proto.SigningOutput) + private static final com.wallet.crypto.trustapp.proto.Ripple.SigningOutput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.wallet.crypto.trustapp.proto.Ripple.SigningOutput(); + } + + public static com.wallet.crypto.trustapp.proto.Ripple.SigningOutput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SigningOutput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SigningOutput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.wallet.crypto.trustapp.proto.Ripple.SigningOutput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_TW_Ripple_Proto_SigningInput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014Ripple.proto\022\017TW.Ripple.Proto\"\276\001\n\014Sign" + + "ingInput\022\016\n\006amount\030\001 \001(\003\022\013\n\003fee\030\002 \001(\003\022\020\n" + + "\010sequence\030\003 \001(\005\022\034\n\024last_ledger_sequence\030" + + "\004 \001(\005\022\017\n\007account\030\005 \001(\t\022\023\n\013destination\030\006 " + + "\001(\t\022\027\n\017destination_tag\030\007 \001(\003\022\r\n\005flags\030\010 " + + "\001(\003\022\023\n\013private_key\030\t \001(\014\" \n\rSigningOutpu" + + "t\022\017\n\007encoded\030\001 \001(\014B\"\n com.wallet.crypto." + + "trustapp.protob\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_TW_Ripple_Proto_SigningInput_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_TW_Ripple_Proto_SigningInput_descriptor, + new java.lang.String[] { "Amount", "Fee", "Sequence", "LastLedgerSequence", "Account", "Destination", "DestinationTag", "Flags", "PrivateKey", }); + internal_static_TW_Ripple_Proto_SigningOutput_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_TW_Ripple_Proto_SigningOutput_descriptor, + new java.lang.String[] { "Encoded", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/JNI/java/wallet/core/jni/CoinType.java b/JNI/java/wallet/core/jni/CoinType.java index 98fdbe01715..b1bafe948df 100644 --- a/JNI/java/wallet/core/jni/CoinType.java +++ b/JNI/java/wallet/core/jni/CoinType.java @@ -23,7 +23,6 @@ public enum CoinType { ICON (74), LITECOIN (2), POA (178), - TEST (1), THUNDERTOKEN (1001), TOMOCHAIN (889), TRON (195), diff --git a/JNI/java/wallet/core/jni/RippleSigner.java b/JNI/java/wallet/core/jni/RippleSigner.java new file mode 100644 index 00000000000..cc039979f11 --- /dev/null +++ b/JNI/java/wallet/core/jni/RippleSigner.java @@ -0,0 +1,32 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. +// +// This is a GENERATED FILE, changes made here WILL BE LOST. +// + +package wallet.core.jni; + +import java.security.InvalidParameterException; +import java.util.HashSet; + +public class RippleSigner { + private long nativeHandle; + + private RippleSigner() { + nativeHandle = 0; + } + + static RippleSigner createFromNative(long nativeHandle) { + RippleSigner instance = new RippleSigner(); + instance.nativeHandle = nativeHandle; + return instance; + } + + + public static native wallet.core.jni.proto.Ripple.SigningOutput sign(wallet.core.jni.proto.Ripple.SigningInput input); + +} + diff --git a/JNI/java/wallet/core/jni/proto/Ripple.java b/JNI/java/wallet/core/jni/proto/Ripple.java new file mode 100644 index 00000000000..3c0011fdb3d --- /dev/null +++ b/JNI/java/wallet/core/jni/proto/Ripple.java @@ -0,0 +1,1702 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Ripple.proto + +package wallet.core.jni.proto; + +public final class Ripple { + private Ripple() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface SigningInputOrBuilder extends + // @@protoc_insertion_point(interface_extends:TW.Ripple.Proto.SigningInput) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 amount = 1; + */ + long getAmount(); + + /** + * int64 fee = 2; + */ + long getFee(); + + /** + * int32 sequence = 3; + */ + int getSequence(); + + /** + * int32 last_ledger_sequence = 4; + */ + int getLastLedgerSequence(); + + /** + * string account = 5; + */ + java.lang.String getAccount(); + /** + * string account = 5; + */ + com.google.protobuf.ByteString + getAccountBytes(); + + /** + * string destination = 6; + */ + java.lang.String getDestination(); + /** + * string destination = 6; + */ + com.google.protobuf.ByteString + getDestinationBytes(); + + /** + * int64 destination_tag = 7; + */ + long getDestinationTag(); + + /** + * int64 flags = 8; + */ + long getFlags(); + + /** + * bytes private_key = 9; + */ + com.google.protobuf.ByteString getPrivateKey(); + } + /** + *
+   * Input data necessary to create a signed transaction.
+   * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningInput} + */ + public static final class SigningInput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:TW.Ripple.Proto.SigningInput) + SigningInputOrBuilder { + private static final long serialVersionUID = 0L; + // Use SigningInput.newBuilder() to construct. + private SigningInput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SigningInput() { + amount_ = 0L; + fee_ = 0L; + sequence_ = 0; + lastLedgerSequence_ = 0; + account_ = ""; + destination_ = ""; + destinationTag_ = 0L; + flags_ = 0L; + privateKey_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SigningInput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + amount_ = input.readInt64(); + break; + } + case 16: { + + fee_ = input.readInt64(); + break; + } + case 24: { + + sequence_ = input.readInt32(); + break; + } + case 32: { + + lastLedgerSequence_ = input.readInt32(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + account_ = s; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + destination_ = s; + break; + } + case 56: { + + destinationTag_ = input.readInt64(); + break; + } + case 64: { + + flags_ = input.readInt64(); + break; + } + case 74: { + + privateKey_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + wallet.core.jni.proto.Ripple.SigningInput.class, wallet.core.jni.proto.Ripple.SigningInput.Builder.class); + } + + public static final int AMOUNT_FIELD_NUMBER = 1; + private long amount_; + /** + * int64 amount = 1; + */ + public long getAmount() { + return amount_; + } + + public static final int FEE_FIELD_NUMBER = 2; + private long fee_; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + + public static final int SEQUENCE_FIELD_NUMBER = 3; + private int sequence_; + /** + * int32 sequence = 3; + */ + public int getSequence() { + return sequence_; + } + + public static final int LAST_LEDGER_SEQUENCE_FIELD_NUMBER = 4; + private int lastLedgerSequence_; + /** + * int32 last_ledger_sequence = 4; + */ + public int getLastLedgerSequence() { + return lastLedgerSequence_; + } + + public static final int ACCOUNT_FIELD_NUMBER = 5; + private volatile java.lang.Object account_; + /** + * string account = 5; + */ + public java.lang.String getAccount() { + java.lang.Object ref = account_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + account_ = s; + return s; + } + } + /** + * string account = 5; + */ + public com.google.protobuf.ByteString + getAccountBytes() { + java.lang.Object ref = account_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + account_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESTINATION_FIELD_NUMBER = 6; + private volatile java.lang.Object destination_; + /** + * string destination = 6; + */ + public java.lang.String getDestination() { + java.lang.Object ref = destination_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + destination_ = s; + return s; + } + } + /** + * string destination = 6; + */ + public com.google.protobuf.ByteString + getDestinationBytes() { + java.lang.Object ref = destination_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + destination_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESTINATION_TAG_FIELD_NUMBER = 7; + private long destinationTag_; + /** + * int64 destination_tag = 7; + */ + public long getDestinationTag() { + return destinationTag_; + } + + public static final int FLAGS_FIELD_NUMBER = 8; + private long flags_; + /** + * int64 flags = 8; + */ + public long getFlags() { + return flags_; + } + + public static final int PRIVATE_KEY_FIELD_NUMBER = 9; + private com.google.protobuf.ByteString privateKey_; + /** + * bytes private_key = 9; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (amount_ != 0L) { + output.writeInt64(1, amount_); + } + if (fee_ != 0L) { + output.writeInt64(2, fee_); + } + if (sequence_ != 0) { + output.writeInt32(3, sequence_); + } + if (lastLedgerSequence_ != 0) { + output.writeInt32(4, lastLedgerSequence_); + } + if (!getAccountBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, account_); + } + if (!getDestinationBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, destination_); + } + if (destinationTag_ != 0L) { + output.writeInt64(7, destinationTag_); + } + if (flags_ != 0L) { + output.writeInt64(8, flags_); + } + if (!privateKey_.isEmpty()) { + output.writeBytes(9, privateKey_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (amount_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, amount_); + } + if (fee_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, fee_); + } + if (sequence_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, sequence_); + } + if (lastLedgerSequence_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, lastLedgerSequence_); + } + if (!getAccountBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, account_); + } + if (!getDestinationBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, destination_); + } + if (destinationTag_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(7, destinationTag_); + } + if (flags_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(8, flags_); + } + if (!privateKey_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(9, privateKey_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof wallet.core.jni.proto.Ripple.SigningInput)) { + return super.equals(obj); + } + wallet.core.jni.proto.Ripple.SigningInput other = (wallet.core.jni.proto.Ripple.SigningInput) obj; + + boolean result = true; + result = result && (getAmount() + == other.getAmount()); + result = result && (getFee() + == other.getFee()); + result = result && (getSequence() + == other.getSequence()); + result = result && (getLastLedgerSequence() + == other.getLastLedgerSequence()); + result = result && getAccount() + .equals(other.getAccount()); + result = result && getDestination() + .equals(other.getDestination()); + result = result && (getDestinationTag() + == other.getDestinationTag()); + result = result && (getFlags() + == other.getFlags()); + result = result && getPrivateKey() + .equals(other.getPrivateKey()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + AMOUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getAmount()); + hash = (37 * hash) + FEE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFee()); + hash = (37 * hash) + SEQUENCE_FIELD_NUMBER; + hash = (53 * hash) + getSequence(); + hash = (37 * hash) + LAST_LEDGER_SEQUENCE_FIELD_NUMBER; + hash = (53 * hash) + getLastLedgerSequence(); + hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; + hash = (53 * hash) + getAccount().hashCode(); + hash = (37 * hash) + DESTINATION_FIELD_NUMBER; + hash = (53 * hash) + getDestination().hashCode(); + hash = (37 * hash) + DESTINATION_TAG_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getDestinationTag()); + hash = (37 * hash) + FLAGS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getFlags()); + hash = (37 * hash) + PRIVATE_KEY_FIELD_NUMBER; + hash = (53 * hash) + getPrivateKey().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningInput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(wallet.core.jni.proto.Ripple.SigningInput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Input data necessary to create a signed transaction.
+     * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningInput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:TW.Ripple.Proto.SigningInput) + wallet.core.jni.proto.Ripple.SigningInputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + wallet.core.jni.proto.Ripple.SigningInput.class, wallet.core.jni.proto.Ripple.SigningInput.Builder.class); + } + + // Construct using wallet.core.jni.proto.Ripple.SigningInput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + amount_ = 0L; + + fee_ = 0L; + + sequence_ = 0; + + lastLedgerSequence_ = 0; + + account_ = ""; + + destination_ = ""; + + destinationTag_ = 0L; + + flags_ = 0L; + + privateKey_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningInput_descriptor; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningInput getDefaultInstanceForType() { + return wallet.core.jni.proto.Ripple.SigningInput.getDefaultInstance(); + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningInput build() { + wallet.core.jni.proto.Ripple.SigningInput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningInput buildPartial() { + wallet.core.jni.proto.Ripple.SigningInput result = new wallet.core.jni.proto.Ripple.SigningInput(this); + result.amount_ = amount_; + result.fee_ = fee_; + result.sequence_ = sequence_; + result.lastLedgerSequence_ = lastLedgerSequence_; + result.account_ = account_; + result.destination_ = destination_; + result.destinationTag_ = destinationTag_; + result.flags_ = flags_; + result.privateKey_ = privateKey_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof wallet.core.jni.proto.Ripple.SigningInput) { + return mergeFrom((wallet.core.jni.proto.Ripple.SigningInput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(wallet.core.jni.proto.Ripple.SigningInput other) { + if (other == wallet.core.jni.proto.Ripple.SigningInput.getDefaultInstance()) return this; + if (other.getAmount() != 0L) { + setAmount(other.getAmount()); + } + if (other.getFee() != 0L) { + setFee(other.getFee()); + } + if (other.getSequence() != 0) { + setSequence(other.getSequence()); + } + if (other.getLastLedgerSequence() != 0) { + setLastLedgerSequence(other.getLastLedgerSequence()); + } + if (!other.getAccount().isEmpty()) { + account_ = other.account_; + onChanged(); + } + if (!other.getDestination().isEmpty()) { + destination_ = other.destination_; + onChanged(); + } + if (other.getDestinationTag() != 0L) { + setDestinationTag(other.getDestinationTag()); + } + if (other.getFlags() != 0L) { + setFlags(other.getFlags()); + } + if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) { + setPrivateKey(other.getPrivateKey()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + wallet.core.jni.proto.Ripple.SigningInput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (wallet.core.jni.proto.Ripple.SigningInput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private long amount_ ; + /** + * int64 amount = 1; + */ + public long getAmount() { + return amount_; + } + /** + * int64 amount = 1; + */ + public Builder setAmount(long value) { + + amount_ = value; + onChanged(); + return this; + } + /** + * int64 amount = 1; + */ + public Builder clearAmount() { + + amount_ = 0L; + onChanged(); + return this; + } + + private long fee_ ; + /** + * int64 fee = 2; + */ + public long getFee() { + return fee_; + } + /** + * int64 fee = 2; + */ + public Builder setFee(long value) { + + fee_ = value; + onChanged(); + return this; + } + /** + * int64 fee = 2; + */ + public Builder clearFee() { + + fee_ = 0L; + onChanged(); + return this; + } + + private int sequence_ ; + /** + * int32 sequence = 3; + */ + public int getSequence() { + return sequence_; + } + /** + * int32 sequence = 3; + */ + public Builder setSequence(int value) { + + sequence_ = value; + onChanged(); + return this; + } + /** + * int32 sequence = 3; + */ + public Builder clearSequence() { + + sequence_ = 0; + onChanged(); + return this; + } + + private int lastLedgerSequence_ ; + /** + * int32 last_ledger_sequence = 4; + */ + public int getLastLedgerSequence() { + return lastLedgerSequence_; + } + /** + * int32 last_ledger_sequence = 4; + */ + public Builder setLastLedgerSequence(int value) { + + lastLedgerSequence_ = value; + onChanged(); + return this; + } + /** + * int32 last_ledger_sequence = 4; + */ + public Builder clearLastLedgerSequence() { + + lastLedgerSequence_ = 0; + onChanged(); + return this; + } + + private java.lang.Object account_ = ""; + /** + * string account = 5; + */ + public java.lang.String getAccount() { + java.lang.Object ref = account_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + account_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string account = 5; + */ + public com.google.protobuf.ByteString + getAccountBytes() { + java.lang.Object ref = account_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + account_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string account = 5; + */ + public Builder setAccount( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + account_ = value; + onChanged(); + return this; + } + /** + * string account = 5; + */ + public Builder clearAccount() { + + account_ = getDefaultInstance().getAccount(); + onChanged(); + return this; + } + /** + * string account = 5; + */ + public Builder setAccountBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + account_ = value; + onChanged(); + return this; + } + + private java.lang.Object destination_ = ""; + /** + * string destination = 6; + */ + public java.lang.String getDestination() { + java.lang.Object ref = destination_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + destination_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string destination = 6; + */ + public com.google.protobuf.ByteString + getDestinationBytes() { + java.lang.Object ref = destination_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + destination_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string destination = 6; + */ + public Builder setDestination( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + destination_ = value; + onChanged(); + return this; + } + /** + * string destination = 6; + */ + public Builder clearDestination() { + + destination_ = getDefaultInstance().getDestination(); + onChanged(); + return this; + } + /** + * string destination = 6; + */ + public Builder setDestinationBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + destination_ = value; + onChanged(); + return this; + } + + private long destinationTag_ ; + /** + * int64 destination_tag = 7; + */ + public long getDestinationTag() { + return destinationTag_; + } + /** + * int64 destination_tag = 7; + */ + public Builder setDestinationTag(long value) { + + destinationTag_ = value; + onChanged(); + return this; + } + /** + * int64 destination_tag = 7; + */ + public Builder clearDestinationTag() { + + destinationTag_ = 0L; + onChanged(); + return this; + } + + private long flags_ ; + /** + * int64 flags = 8; + */ + public long getFlags() { + return flags_; + } + /** + * int64 flags = 8; + */ + public Builder setFlags(long value) { + + flags_ = value; + onChanged(); + return this; + } + /** + * int64 flags = 8; + */ + public Builder clearFlags() { + + flags_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes private_key = 9; + */ + public com.google.protobuf.ByteString getPrivateKey() { + return privateKey_; + } + /** + * bytes private_key = 9; + */ + public Builder setPrivateKey(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + privateKey_ = value; + onChanged(); + return this; + } + /** + * bytes private_key = 9; + */ + public Builder clearPrivateKey() { + + privateKey_ = getDefaultInstance().getPrivateKey(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:TW.Ripple.Proto.SigningInput) + } + + // @@protoc_insertion_point(class_scope:TW.Ripple.Proto.SigningInput) + private static final wallet.core.jni.proto.Ripple.SigningInput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new wallet.core.jni.proto.Ripple.SigningInput(); + } + + public static wallet.core.jni.proto.Ripple.SigningInput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SigningInput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SigningInput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningInput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface SigningOutputOrBuilder extends + // @@protoc_insertion_point(interface_extends:TW.Ripple.Proto.SigningOutput) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes encoded = 1; + */ + com.google.protobuf.ByteString getEncoded(); + } + /** + *
+   * Transaction signing output.
+   * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningOutput} + */ + public static final class SigningOutput extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:TW.Ripple.Proto.SigningOutput) + SigningOutputOrBuilder { + private static final long serialVersionUID = 0L; + // Use SigningOutput.newBuilder() to construct. + private SigningOutput(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SigningOutput() { + encoded_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SigningOutput( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + + encoded_ = input.readBytes(); + break; + } + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + wallet.core.jni.proto.Ripple.SigningOutput.class, wallet.core.jni.proto.Ripple.SigningOutput.Builder.class); + } + + public static final int ENCODED_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString encoded_; + /** + * bytes encoded = 1; + */ + public com.google.protobuf.ByteString getEncoded() { + return encoded_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!encoded_.isEmpty()) { + output.writeBytes(1, encoded_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!encoded_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, encoded_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof wallet.core.jni.proto.Ripple.SigningOutput)) { + return super.equals(obj); + } + wallet.core.jni.proto.Ripple.SigningOutput other = (wallet.core.jni.proto.Ripple.SigningOutput) obj; + + boolean result = true; + result = result && getEncoded() + .equals(other.getEncoded()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENCODED_FIELD_NUMBER; + hash = (53 * hash) + getEncoded().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static wallet.core.jni.proto.Ripple.SigningOutput parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(wallet.core.jni.proto.Ripple.SigningOutput prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+     * Transaction signing output.
+     * 
+ * + * Protobuf type {@code TW.Ripple.Proto.SigningOutput} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:TW.Ripple.Proto.SigningOutput) + wallet.core.jni.proto.Ripple.SigningOutputOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable + .ensureFieldAccessorsInitialized( + wallet.core.jni.proto.Ripple.SigningOutput.class, wallet.core.jni.proto.Ripple.SigningOutput.Builder.class); + } + + // Construct using wallet.core.jni.proto.Ripple.SigningOutput.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + encoded_ = com.google.protobuf.ByteString.EMPTY; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return wallet.core.jni.proto.Ripple.internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningOutput getDefaultInstanceForType() { + return wallet.core.jni.proto.Ripple.SigningOutput.getDefaultInstance(); + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningOutput build() { + wallet.core.jni.proto.Ripple.SigningOutput result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningOutput buildPartial() { + wallet.core.jni.proto.Ripple.SigningOutput result = new wallet.core.jni.proto.Ripple.SigningOutput(this); + result.encoded_ = encoded_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return (Builder) super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof wallet.core.jni.proto.Ripple.SigningOutput) { + return mergeFrom((wallet.core.jni.proto.Ripple.SigningOutput)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(wallet.core.jni.proto.Ripple.SigningOutput other) { + if (other == wallet.core.jni.proto.Ripple.SigningOutput.getDefaultInstance()) return this; + if (other.getEncoded() != com.google.protobuf.ByteString.EMPTY) { + setEncoded(other.getEncoded()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + wallet.core.jni.proto.Ripple.SigningOutput parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (wallet.core.jni.proto.Ripple.SigningOutput) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString encoded_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes encoded = 1; + */ + public com.google.protobuf.ByteString getEncoded() { + return encoded_; + } + /** + * bytes encoded = 1; + */ + public Builder setEncoded(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + encoded_ = value; + onChanged(); + return this; + } + /** + * bytes encoded = 1; + */ + public Builder clearEncoded() { + + encoded_ = getDefaultInstance().getEncoded(); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:TW.Ripple.Proto.SigningOutput) + } + + // @@protoc_insertion_point(class_scope:TW.Ripple.Proto.SigningOutput) + private static final wallet.core.jni.proto.Ripple.SigningOutput DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new wallet.core.jni.proto.Ripple.SigningOutput(); + } + + public static wallet.core.jni.proto.Ripple.SigningOutput getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SigningOutput parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SigningOutput(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public wallet.core.jni.proto.Ripple.SigningOutput getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_TW_Ripple_Proto_SigningInput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_TW_Ripple_Proto_SigningOutput_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014Ripple.proto\022\017TW.Ripple.Proto\"\276\001\n\014Sign" + + "ingInput\022\016\n\006amount\030\001 \001(\003\022\013\n\003fee\030\002 \001(\003\022\020\n" + + "\010sequence\030\003 \001(\005\022\034\n\024last_ledger_sequence\030" + + "\004 \001(\005\022\017\n\007account\030\005 \001(\t\022\023\n\013destination\030\006 " + + "\001(\t\022\027\n\017destination_tag\030\007 \001(\003\022\r\n\005flags\030\010 " + + "\001(\003\022\023\n\013private_key\030\t \001(\014\" \n\rSigningOutpu" + + "t\022\017\n\007encoded\030\001 \001(\014B\027\n\025wallet.core.jni.pr" + + "otob\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_TW_Ripple_Proto_SigningInput_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_TW_Ripple_Proto_SigningInput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_TW_Ripple_Proto_SigningInput_descriptor, + new java.lang.String[] { "Amount", "Fee", "Sequence", "LastLedgerSequence", "Account", "Destination", "DestinationTag", "Flags", "PrivateKey", }); + internal_static_TW_Ripple_Proto_SigningOutput_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_TW_Ripple_Proto_SigningOutput_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_TW_Ripple_Proto_SigningOutput_descriptor, + new java.lang.String[] { "Encoded", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/README.md b/README.md index c6f99ed6a2e..4b2d1cc9da1 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,7 @@ Trust Wallet Core is a cross-platform library that implements low-level cryptogr ### Supported Blockchains - - + # Usage diff --git a/docs/Contributing.md b/docs/Contributing.md index 351c8a898da..c0ef9ab389d 100644 --- a/docs/Contributing.md +++ b/docs/Contributing.md @@ -52,6 +52,10 @@ Use the `bootstrap.sh` script in the root folder to quickly build and test. Afte * Android: `tools/android-test` * iOS: `tools/ios-test` +How to generate a Xcode project: + +`cmake -Bxcode -GXcode -DCMAKE_BUILD_TYPE=Debug -DGIT_SUBMODULE=OFF` + ## C Headers The wallet core code generator parses C headers for class and struct definitions. Headers need to be in the `include/TrustWalletCode` folder and start with the `TW` prefix followed by the class or sturct name. Inside each header file there needs to be exactly one class or struct defition. diff --git a/include/TrustWalletCore/TWRippleProto.h b/include/TrustWalletCore/TWRippleProto.h new file mode 100644 index 00000000000..8c5c9f14460 --- /dev/null +++ b/include/TrustWalletCore/TWRippleProto.h @@ -0,0 +1,12 @@ +// Copyright © 2017-2018 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include "TWData.h" + +typedef TWData *_Nonnull TW_Ripple_Proto_SigningInput; +typedef TWData *_Nonnull TW_Ripple_Proto_SigningOutput; diff --git a/include/TrustWalletCore/TWRippleSigner.h b/include/TrustWalletCore/TWRippleSigner.h new file mode 100644 index 00000000000..88f885a94f5 --- /dev/null +++ b/include/TrustWalletCore/TWRippleSigner.h @@ -0,0 +1,23 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include "TWBase.h" +#include "TWData.h" +#include "TWRippleProto.h" + +TW_EXTERN_C_BEGIN + +/// Helper class to sign Wanchain transactions. +TW_EXPORT_CLASS +struct TWRippleSigner; + +/// Signs a transaction. +TW_EXPORT_STATIC_METHOD +TW_Ripple_Proto_SigningOutput TWRippleSignerSign(TW_Ripple_Proto_SigningInput input); + +TW_EXTERN_C_END diff --git a/src/Bitcoin/TransactionSigner.cpp b/src/Bitcoin/TransactionSigner.cpp index 7bfb9dd04b6..df0512e0107 100644 --- a/src/Bitcoin/TransactionSigner.cpp +++ b/src/Bitcoin/TransactionSigner.cpp @@ -217,10 +217,10 @@ Data TransactionSigner::pushAll(const std::vector& results) { data.push_back(encodeNumber(result[0])); } else if (result.size() < OP_PUSHDATA1) { data.push_back(static_cast(result.size())); - } else if (result.size() <= 0xff) { // swiftlint:disable:this empty_count + } else if (result.size() <= 0xff) { data.push_back(OP_PUSHDATA1); data.push_back(static_cast(result.size())); - } else if (result.size() <= 0xffff) { // swiftlint:disable:this empty_count + } else if (result.size() <= 0xffff) { data.push_back(OP_PUSHDATA2); encode16(result.size(), data); } else { diff --git a/src/Ripple/BinaryCoding.h b/src/Ripple/BinaryCoding.h new file mode 100644 index 00000000000..7ce2edc3762 --- /dev/null +++ b/src/Ripple/BinaryCoding.h @@ -0,0 +1,77 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include +#include +#include + +namespace TW { +namespace Ripple { + +enum class FieldType; + +/// Encodes a 16-bit value into the provided buffer. +static inline void encode16(uint16_t val, std::vector& data) { + data.push_back (static_cast (val >> 8)); + data.push_back (static_cast (val & 0xff)); +} + +/// Encodes a 32-bit value into the provided buffer. +static inline void encode32(uint32_t val, std::vector& data) { + data.push_back(static_cast((val >> 24))); + data.push_back(static_cast((val >> 16) & 0xff)); + data.push_back(static_cast((val >> 8) & 0xff)); + data.push_back(static_cast(val)); +} + +/// Encodes a 64-bit value into the provided buffer. +static inline void encode64(uint64_t val, std::vector& data) { + data.push_back(static_cast((val >> 56))); + data.push_back(static_cast((val >> 48) & 0xff)); + data.push_back(static_cast((val >> 40) & 0xff)); + data.push_back(static_cast((val >> 32) & 0xff)); + data.push_back(static_cast((val >> 24) & 0xff)); + data.push_back(static_cast((val >> 16) & 0xff)); + data.push_back(static_cast((val >> 8) & 0xff)); + data.push_back(static_cast(val & 0xff)); +} + +/// Encodes a field type. +static inline void encodeType(FieldType type, int key, std::vector& data) { + const auto typeValue = static_cast(type); + if (key <= 0xf) { + data.push_back(static_cast((typeValue << 4) | key)); + } else { + data.push_back(static_cast(typeValue << 4)); + data.push_back(static_cast(key)); + } +} + +/// Encodes a variable length. +static inline void encodeVariableLength(int length, std::vector& data) { + if (length <= 192) { + data.push_back(static_cast (length)); + } else if (length <= 12480) { + length -= 193; + data.push_back(static_cast (length >> 8)); + data.push_back(static_cast (length & 0xff)); + } else if (length <= 918744) { + length -= 12481; + data.push_back(static_cast (length >> 16)); + data.push_back(static_cast ((length >> 8) & 0xff)); + data.push_back(static_cast (length & 0xff)); + } +} + +/// Encodes a variable length bytes. +static inline void encodeBytes(std::vector bytes, std::vector& data) { + encodeVariableLength(bytes.size(), data); + data.insert(data.end(), bytes.begin(), bytes.end()); +} + +}} // namespace diff --git a/src/Ripple/Signer.cpp b/src/Ripple/Signer.cpp new file mode 100644 index 00000000000..5aba000462f --- /dev/null +++ b/src/Ripple/Signer.cpp @@ -0,0 +1,28 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#include "Signer.h" +#include "BinaryCoding.h" +#include "../Hash.h" + +using namespace TW; +using namespace TW::Ripple; + +const int MIN_FEE = 10; +const int MAX_FEE = 1000000; +const int FLAG_FULLY_CANONICAL = 0x80000000; + +void Signer::sign(const PrivateKey& privateKey, Transaction& transaction) const noexcept { + /// See https://github.com/trezor/trezor-core/blob/master/src/apps/ripple/sign_tx.py#L59 + transaction.flags |= FLAG_FULLY_CANONICAL; + transaction.pub_key = privateKey.getPublicKey(true); + + auto unsignedTx = transaction.getPreImage(); + auto hash = Hash::sha512(unsignedTx); + auto half = Data(hash.begin(), hash.begin() + 32); + + transaction.signature = privateKey.signAsDER(half); +} diff --git a/src/Ripple/Signer.h b/src/Ripple/Signer.h new file mode 100644 index 00000000000..cd57f77a218 --- /dev/null +++ b/src/Ripple/Signer.h @@ -0,0 +1,29 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include "../Data.h" +#include "../Hash.h" +#include "../PrivateKey.h" +#include "Transaction.h" + +namespace TW { +namespace Ripple { + +/// Helper class that performs Ripple transaction signing. +class Signer { +public: + /// Signs the given transaction. + void sign(const PrivateKey& privateKey, Transaction& transaction) const noexcept; +}; + +}} // namespace + +/// Wrapper for C interface. +struct TWRippleSigner { + TW::Ripple::Signer impl; +}; diff --git a/src/Ripple/Transaction.cpp b/src/Ripple/Transaction.cpp new file mode 100644 index 00000000000..a948b862ac8 --- /dev/null +++ b/src/Ripple/Transaction.cpp @@ -0,0 +1,87 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#include "Transaction.h" +#include "BinaryCoding.h" +#include "../HexCoding.h" + +using namespace TW; +using namespace TW::Ripple; + +const int NETWORK_PREFIX = 0x53545800; +const int64_t MAX_ALLOWED_AMOUNT = 100000000000; + +Data Transaction::serialize() const { + auto data = Data(); + /// field must be sorted by field type then by field name + /// "type" + encodeType(FieldType::int16, 2, data); + encode16(uint16_t(TransactionType::payment), data); + /// "flags" + encodeType(FieldType::int32, 2, data); + encode32(flags, data); + /// "sequence" + encodeType(FieldType::int32, 4, data); + encode32(sequence, data); + /// "destinationTag" + if (destination_tag > 0) { + encodeType(FieldType::int32, 14, data); + encode32(destination_tag, data); + } + /// "lastLedgerSequence" + if (last_ledger_sequence > 0) { + encodeType(FieldType::int32, 27, data); + encode32(last_ledger_sequence, data); + } + /// "amount" + encodeType(FieldType::amount, 1, data); + append(data, serializeAmount(amount)); + /// "fee" + encodeType(FieldType::amount, 8, data); + append(data, serializeAmount(fee)); + /// "signingPubKey" + if (!pub_key.empty()) { + encodeType(FieldType::vl, 3, data); + encodeBytes(pub_key, data); + } + /// "txnSignature" + if (!signature.empty()) { + encodeType(FieldType::vl, 4, data); + encodeBytes(signature, data); + } + /// "account" + encodeType(FieldType::account, 1, data); + encodeBytes(serializeAddress(account), data); + /// "destination" + encodeType(FieldType::account, 3, data); + encodeBytes(serializeAddress(destination), data); + return data; +} + +Data Transaction::getPreImage() const { + auto preImage = Data(); + encode32(NETWORK_PREFIX, preImage); + append(preImage, serialize()); + return preImage; +} + +Data Transaction::serializeAmount(int64_t amount) { + if (amount > MAX_ALLOWED_AMOUNT || amount < 0) { + return Data(); + } + auto data = Data(); + encode64(uint64_t(amount), data); + /// clear first bit to indicate XRP + data[0] &= 0x7F; + /// set second bit to indicate positive number + data[0] |= 0x40; + return data; +} + +Data Transaction::serializeAddress(Address address) { + auto data = Data(&address.bytes[0] + 1, &address.bytes[21]); + return data; +} diff --git a/src/Ripple/Transaction.h b/src/Ripple/Transaction.h new file mode 100644 index 00000000000..6cb89c9df77 --- /dev/null +++ b/src/Ripple/Transaction.h @@ -0,0 +1,65 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#pragma once + +#include "../proto/Ripple.pb.h" +#include "../Data.h" +#include "Address.h" + +namespace TW { +namespace Ripple { + +enum class FieldType: int { + int16 = 1, + int32 = 2, + amount = 6, + vl = 7, + account = 8 +}; + +enum class TransactionType { + payment = 0 +}; + +class Transaction { + /// We only support transaction types other than the Payment transaction. + /// Non-XRP currencies are not supported. Float and negative amounts are not supported. + /// See https://github.com/trezor/trezor-core/tree/master/src/apps/ripple#transactions +public: + int64_t amount; + int64_t fee; + int64_t flags; + int32_t sequence; + int32_t last_ledger_sequence; + Address account; + Address destination; + int64_t destination_tag; + Data pub_key; + Data signature; + + Transaction() = default; + Transaction(int64_t amount, int64_t fee, int64_t flags, int32_t sequence, int32_t last_ledger_sequence, Address account, Address destination, int64_t destination_tag) + : amount(amount) + , fee(fee) + , flags(flags) + , sequence(sequence) + , last_ledger_sequence(last_ledger_sequence) + , account(account) + , destination(destination) + , destination_tag(destination_tag) + {} + +public: + /// simplified serialization format tailored for Payment transaction type exclusively. + Data serialize() const; + Data getPreImage() const; + + static Data serializeAmount(int64_t amount); + static Data serializeAddress(Address address); +}; + +}} // namespace diff --git a/src/Zcash/Transaction.h b/src/Zcash/Transaction.h index 9cb74468c35..49294ea43d0 100644 --- a/src/Zcash/Transaction.h +++ b/src/Zcash/Transaction.h @@ -70,8 +70,3 @@ struct Transaction { }; }} // namespace - -/// Wrapper for C interface. -struct TWZcashTransaction { - TW::Zcash::Transaction impl; -}; diff --git a/src/interface/TWCoinTypeConfiguration.cpp b/src/interface/TWCoinTypeConfiguration.cpp index 901270aaa72..5835e15f45b 100644 --- a/src/interface/TWCoinTypeConfiguration.cpp +++ b/src/interface/TWCoinTypeConfiguration.cpp @@ -54,8 +54,6 @@ int TWCoinTypeConfigurationGetDecimals(enum TWCoinType type) { case TWCoinTypeVeChain: case TWCoinTypeWanChain: return 18; - case TWCoinTypeRipple: - return 15; case TWCoinTypeBitcoinCash: case TWCoinTypeBitcoin: case TWCoinTypeDash: @@ -64,6 +62,7 @@ int TWCoinTypeConfigurationGetDecimals(enum TWCoinType type) { case TWCoinTypeZcoin: case TWCoinTypeZcash: return 8; + case TWCoinTypeRipple: case TWCoinTypeTron: return 6; case TWCoinTypeEOS: //TODO diff --git a/src/interface/TWRippleSigner.cpp b/src/interface/TWRippleSigner.cpp new file mode 100644 index 00000000000..12b2be51ea2 --- /dev/null +++ b/src/interface/TWRippleSigner.cpp @@ -0,0 +1,40 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#include + +#include "../Ripple/Signer.h" +#include "../proto/Ripple.pb.h" + +using namespace TW; +using namespace TW::Ripple; + +TW_Ripple_Proto_SigningOutput TWRippleSignerSign(TW_Ripple_Proto_SigningInput data) { + Proto::SigningInput input; + input.ParseFromArray(TWDataBytes(data), TWDataSize(data)); + + auto key = PrivateKey(Data(input.private_key().begin(), input.private_key().end())); + auto transaction = Transaction( + /* amount */input.amount(), + /* fee */input.fee(), + /* flags */input.flags(), + /* sequence */input.sequence(), + /* last_ledger_sequence */input.last_ledger_sequence(), + /* account */Address(input.account()), + /* destination */Address(input.destination()), + /* destination_tag*/input.destination_tag() + ); + + auto signer = Signer(); + signer.sign(key, transaction); + + auto protoOutput = Proto::SigningOutput(); + auto encoded = transaction.serialize(); + protoOutput.set_encoded(encoded.data(), encoded.size()); + + auto serialized = protoOutput.SerializeAsString(); + return TWDataCreateWithBytes(reinterpret_cast(serialized.data()), serialized.size()); +} diff --git a/src/proto/Ripple.proto b/src/proto/Ripple.proto new file mode 100644 index 00000000000..8d0be3c317e --- /dev/null +++ b/src/proto/Ripple.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package TW.Ripple.Proto; +option java_package = "wallet.core.jni.proto"; + +// Input data necessary to create a signed transaction. +message SigningInput { + int64 amount = 1; + + int64 fee = 2; + + int32 sequence = 3; + + int32 last_ledger_sequence = 4; + + string account = 5; + + string destination = 6; + + int64 destination_tag = 7; + + int64 flags = 8; + + bytes private_key = 9; +} + +// Transaction signing output. +message SigningOutput { + bytes encoded = 1; +} diff --git a/swift/Sources/CoinType.swift b/swift/Sources/CoinType.swift index 3a718194613..2aa08505acf 100644 --- a/swift/Sources/CoinType.swift +++ b/swift/Sources/CoinType.swift @@ -20,7 +20,6 @@ public enum CoinType: UInt32 { case icon = 74 case litecoin = 2 case poa = 178 - case test = 1 case thunderToken = 1001 case tomoChain = 889 case tron = 195 diff --git a/swift/Sources/Ripple.pb.swift b/swift/Sources/Ripple.pb.swift new file mode 100644 index 00000000000..e6b94cb1685 --- /dev/null +++ b/swift/Sources/Ripple.pb.swift @@ -0,0 +1,172 @@ +// DO NOT EDIT. +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: Ripple.proto +// +// For information on using the generated types, please see the documenation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that your are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Input data necessary to create a signed transaction. +public struct TW_Ripple_Proto_SigningInput { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var amount: Int64 = 0 + + public var fee: Int64 = 0 + + public var sequence: Int32 = 0 + + public var lastLedgerSequence: Int32 = 0 + + public var account: String = String() + + public var destination: String = String() + + public var destinationTag: Int64 = 0 + + public var flags: Int64 = 0 + + public var privateKey: Data = SwiftProtobuf.Internal.emptyData + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Transaction signing output. +public struct TW_Ripple_Proto_SigningOutput { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var encoded: Data = SwiftProtobuf.Internal.emptyData + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "TW.Ripple.Proto" + +extension TW_Ripple_Proto_SigningInput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SigningInput" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "amount"), + 2: .same(proto: "fee"), + 3: .same(proto: "sequence"), + 4: .standard(proto: "last_ledger_sequence"), + 5: .same(proto: "account"), + 6: .same(proto: "destination"), + 7: .standard(proto: "destination_tag"), + 8: .same(proto: "flags"), + 9: .standard(proto: "private_key"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + switch fieldNumber { + case 1: try decoder.decodeSingularInt64Field(value: &self.amount) + case 2: try decoder.decodeSingularInt64Field(value: &self.fee) + case 3: try decoder.decodeSingularInt32Field(value: &self.sequence) + case 4: try decoder.decodeSingularInt32Field(value: &self.lastLedgerSequence) + case 5: try decoder.decodeSingularStringField(value: &self.account) + case 6: try decoder.decodeSingularStringField(value: &self.destination) + case 7: try decoder.decodeSingularInt64Field(value: &self.destinationTag) + case 8: try decoder.decodeSingularInt64Field(value: &self.flags) + case 9: try decoder.decodeSingularBytesField(value: &self.privateKey) + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.amount != 0 { + try visitor.visitSingularInt64Field(value: self.amount, fieldNumber: 1) + } + if self.fee != 0 { + try visitor.visitSingularInt64Field(value: self.fee, fieldNumber: 2) + } + if self.sequence != 0 { + try visitor.visitSingularInt32Field(value: self.sequence, fieldNumber: 3) + } + if self.lastLedgerSequence != 0 { + try visitor.visitSingularInt32Field(value: self.lastLedgerSequence, fieldNumber: 4) + } + if !self.account.isEmpty { + try visitor.visitSingularStringField(value: self.account, fieldNumber: 5) + } + if !self.destination.isEmpty { + try visitor.visitSingularStringField(value: self.destination, fieldNumber: 6) + } + if self.destinationTag != 0 { + try visitor.visitSingularInt64Field(value: self.destinationTag, fieldNumber: 7) + } + if self.flags != 0 { + try visitor.visitSingularInt64Field(value: self.flags, fieldNumber: 8) + } + if !self.privateKey.isEmpty { + try visitor.visitSingularBytesField(value: self.privateKey, fieldNumber: 9) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: TW_Ripple_Proto_SigningInput, rhs: TW_Ripple_Proto_SigningInput) -> Bool { + if lhs.amount != rhs.amount {return false} + if lhs.fee != rhs.fee {return false} + if lhs.sequence != rhs.sequence {return false} + if lhs.lastLedgerSequence != rhs.lastLedgerSequence {return false} + if lhs.account != rhs.account {return false} + if lhs.destination != rhs.destination {return false} + if lhs.destinationTag != rhs.destinationTag {return false} + if lhs.flags != rhs.flags {return false} + if lhs.privateKey != rhs.privateKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension TW_Ripple_Proto_SigningOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".SigningOutput" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "encoded"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + switch fieldNumber { + case 1: try decoder.decodeSingularBytesField(value: &self.encoded) + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.encoded.isEmpty { + try visitor.visitSingularBytesField(value: self.encoded, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: TW_Ripple_Proto_SigningOutput, rhs: TW_Ripple_Proto_SigningOutput) -> Bool { + if lhs.encoded != rhs.encoded {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/swift/Sources/RippleSigner.swift b/swift/Sources/RippleSigner.swift new file mode 100644 index 00000000000..dccb18a7b28 --- /dev/null +++ b/swift/Sources/RippleSigner.swift @@ -0,0 +1,30 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. +// +// This is a GENERATED FILE, changes made here WILL BE LOST. +// + +import Foundation + +public final class RippleSigner { + + public static func sign(input: TW_Ripple_Proto_SigningInput) -> TW_Ripple_Proto_SigningOutput { + let inputData = TWDataCreateWithNSData(try! input.serializedData()) + defer { + TWDataDelete(inputData) + } + let resultData = TWDataNSData(TWRippleSignerSign(inputData)) + return try! TW_Ripple_Proto_SigningOutput(serializedData: resultData) + } + + let rawValue: OpaquePointer + + init(rawValue: OpaquePointer) { + self.rawValue = rawValue + } + + +} diff --git a/swift/Sources/TrustWalletCore.h b/swift/Sources/TrustWalletCore.h index aa785d1e767..f893b8f40e4 100644 --- a/swift/Sources/TrustWalletCore.h +++ b/swift/Sources/TrustWalletCore.h @@ -44,6 +44,7 @@ FOUNDATION_EXPORT const unsigned char TrustWalletCoreVersionString[]; #include #include #include +#include #include #include #include diff --git a/swift/Tests/RippleTests.swift b/swift/Tests/RippleTests.swift index 520b26a3bb5..c15edd4e484 100644 --- a/swift/Tests/RippleTests.swift +++ b/swift/Tests/RippleTests.swift @@ -7,6 +7,9 @@ import XCTest import TrustWalletCore +typealias RippleSigningInput = TW_Ripple_Proto_SigningInput +typealias RiipleSigningOutput = TW_Ripple_Proto_SigningOutput + class RippleTests: XCTestCase { func testAddress() { @@ -16,4 +19,18 @@ class RippleTests: XCTestCase { XCTAssertEqual(address?.description, "r36yxStAh7qgTQNHTzjZvXybCTzUFhrfav") } + + func testSigner() { + let input = RippleSigningInput.with { + $0.amount = 29_000_000 + $0.fee = 200_000 + $0.sequence = 1 // from account info api + $0.account = "rDpysuumkweqeC7XdNgYNtzL5GxbdsmrtF" + $0.destination = "rU893viamSnsfP3zjzM2KPxjqZjXSXK6VF" + $0.privateKey = Data(hexString: "e008b363373ceedbec3c3e9b1c28c9ff455b0a6bd612b205b7ab750144c284d7")! + } + + let output = RippleSigner.sign(input: input) + XCTAssertEqual(output.encoded.hexString, "12000022800000002400000001614000000001ba8140684000000000030d40732103417452a634b07d2f8bd9f0bfa2a31e1fe828bf3fa77beecb0d0fc32ee18ecfe074473045022100e5d9cdc97625ed1eabb4e649e45b46fc2cec80f9f97b642e84bfa15ae8c52d9e02206c0992307a01cbceb559788f36fccb197a8af6fc271dd2733362887c16008a2681148400b6b6d08d5d495653d73eda6804c249a5148883148132e4e20aecf29090ac428a9c43f230a829220d") + } } diff --git a/swift/TrustWalletCore.xcodeproj/project.pbxproj b/swift/TrustWalletCore.xcodeproj/project.pbxproj index a65c1d3c68f..212d4f127fb 100644 --- a/swift/TrustWalletCore.xcodeproj/project.pbxproj +++ b/swift/TrustWalletCore.xcodeproj/project.pbxproj @@ -370,6 +370,18 @@ BB21105E221C039B00571DF7 /* Address.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB21105C221C039B00571DF7 /* Address.cpp */; }; BB211060221C03D500571DF7 /* RippleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB21105F221C03D500571DF7 /* RippleTests.swift */; }; BB211062221C045000571DF7 /* RippleAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB211061221C045000571DF7 /* RippleAddress.swift */; }; + BB2422CF22217AE7000663D0 /* TWRippleSigner.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422CD22217AE7000663D0 /* TWRippleSigner.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BB2422D022217AE7000663D0 /* TWRippleProto.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422CE22217AE7000663D0 /* TWRippleProto.h */; settings = {ATTRIBUTES = (Public, ); }; }; + BB2422D322217B08000663D0 /* RippleSigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2422D122217B08000663D0 /* RippleSigner.swift */; }; + BB2422D422217B08000663D0 /* Ripple.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2422D222217B08000663D0 /* Ripple.pb.swift */; }; + BB2422D722217B4D000663D0 /* Ripple.pb.cc in Sources */ = {isa = PBXBuildFile; fileRef = BB2422D522217B4D000663D0 /* Ripple.pb.cc */; }; + BB2422D822217B4D000663D0 /* Ripple.pb.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422D622217B4D000663D0 /* Ripple.pb.h */; }; + BB2422DE22217B58000663D0 /* Signer.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422D922217B58000663D0 /* Signer.h */; }; + BB2422DF22217B58000663D0 /* Signer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB2422DA22217B58000663D0 /* Signer.cpp */; }; + BB2422E022217B58000663D0 /* Transaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB2422DB22217B58000663D0 /* Transaction.cpp */; }; + BB2422E122217B58000663D0 /* BinaryCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422DC22217B58000663D0 /* BinaryCoding.h */; }; + BB2422E222217B58000663D0 /* Transaction.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2422DD22217B58000663D0 /* Transaction.h */; }; + BB2422E422217B90000663D0 /* TWRippleSigner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB2422E322217B90000663D0 /* TWRippleSigner.cpp */; }; BB2E390B21F6EF17002A5139 /* TWZcashTAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = BB2E390A21F6EF17002A5139 /* TWZcashTAddress.h */; settings = {ATTRIBUTES = (Public, ); }; }; BB3F05B2220BD93E008C6971 /* TAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB3F05B0220BD93E008C6971 /* TAddress.cpp */; }; BB3F05B3220BD93E008C6971 /* TAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = BB3F05B1220BD93E008C6971 /* TAddress.h */; }; @@ -818,6 +830,18 @@ BB21105C221C039B00571DF7 /* Address.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Address.cpp; sourceTree = ""; }; BB21105F221C03D500571DF7 /* RippleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RippleTests.swift; sourceTree = ""; }; BB211061221C045000571DF7 /* RippleAddress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RippleAddress.swift; sourceTree = ""; }; + BB2422CD22217AE7000663D0 /* TWRippleSigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWRippleSigner.h; sourceTree = ""; }; + BB2422CE22217AE7000663D0 /* TWRippleProto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWRippleProto.h; sourceTree = ""; }; + BB2422D122217B08000663D0 /* RippleSigner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RippleSigner.swift; sourceTree = ""; }; + BB2422D222217B08000663D0 /* Ripple.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Ripple.pb.swift; sourceTree = ""; }; + BB2422D522217B4D000663D0 /* Ripple.pb.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Ripple.pb.cc; sourceTree = ""; }; + BB2422D622217B4D000663D0 /* Ripple.pb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Ripple.pb.h; sourceTree = ""; }; + BB2422D922217B58000663D0 /* Signer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Signer.h; sourceTree = ""; }; + BB2422DA22217B58000663D0 /* Signer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Signer.cpp; sourceTree = ""; }; + BB2422DB22217B58000663D0 /* Transaction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Transaction.cpp; sourceTree = ""; }; + BB2422DC22217B58000663D0 /* BinaryCoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinaryCoding.h; sourceTree = ""; }; + BB2422DD22217B58000663D0 /* Transaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Transaction.h; sourceTree = ""; }; + BB2422E322217B90000663D0 /* TWRippleSigner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TWRippleSigner.cpp; sourceTree = ""; }; BB2E390A21F6EF17002A5139 /* TWZcashTAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TWZcashTAddress.h; sourceTree = ""; }; BB3F05B0220BD93E008C6971 /* TAddress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TAddress.cpp; sourceTree = ""; }; BB3F05B1220BD93E008C6971 /* TAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TAddress.h; sourceTree = ""; }; @@ -857,6 +881,8 @@ 61376FDB220CE38900573D0F /* proto */ = { isa = PBXGroup; children = ( + BB2422D522217B4D000663D0 /* Ripple.pb.cc */, + BB2422D622217B4D000663D0 /* Ripple.pb.h */, 61722BF1220E45B900D7BA9A /* Binance.pb.cc */, 61722BEE220E45B900D7BA9A /* Binance.pb.h */, 61722BEF220E45B900D7BA9A /* Bitcoin.pb.cc */, @@ -916,6 +942,8 @@ 617358DF219DF043007BF637 /* TrustWalletCore */ = { isa = PBXGroup; children = ( + BB2422CE22217AE7000663D0 /* TWRippleProto.h */, + BB2422CD22217AE7000663D0 /* TWRippleSigner.h */, 61CABAB421ED36F40086D9A0 /* TWAES.h */, 617358E2219DF043007BF637 /* TWBase.h */, 61AAD39A21DEF6D300B69A34 /* TWBase58.h */, @@ -1187,6 +1215,8 @@ 61735CB7219F88C2007BF637 /* Sources */ = { isa = PBXGroup; children = ( + BB2422D222217B08000663D0 /* Ripple.pb.swift */, + BB2422D122217B08000663D0 /* RippleSigner.swift */, 61CABAB821ED37160086D9A0 /* AES.swift */, 61AAD3A421DEF72500B69A34 /* Base58.swift */, 6198EA8B21B811CD008CB60A /* Bech32Address.swift */, @@ -1296,6 +1326,7 @@ 61B159B321CC5DBB00CFE93B /* interface */ = { isa = PBXGroup; children = ( + BB2422E322217B90000663D0 /* TWRippleSigner.cpp */, 61CABAB621ED37070086D9A0 /* TWAES.cpp */, 61AAD3A221DEF70800B69A34 /* TWBase58.cpp */, 61722C01220E461A00D7BA9A /* TWBech32Address.cpp */, @@ -1524,6 +1555,11 @@ BB21105A221C039A00571DF7 /* Ripple */ = { isa = PBXGroup; children = ( + BB2422DC22217B58000663D0 /* BinaryCoding.h */, + BB2422DA22217B58000663D0 /* Signer.cpp */, + BB2422D922217B58000663D0 /* Signer.h */, + BB2422DB22217B58000663D0 /* Transaction.cpp */, + BB2422DD22217B58000663D0 /* Transaction.h */, BB21105B221C039A00571DF7 /* Address.h */, BB21105C221C039B00571DF7 /* Address.cpp */, ); @@ -1564,6 +1600,7 @@ 61B159D421CC5DBB00CFE93B /* Bech32Address.h in Headers */, 61735AF9219DF044007BF637 /* bip32.h in Headers */, 61735B04219DF044007BF637 /* rand.h in Headers */, + BB2422CF22217AE7000663D0 /* TWRippleSigner.h in Headers */, 61735B0B219DF044007BF637 /* secp256k1.h in Headers */, 61735C13219DF044007BF637 /* ed25519-hash-custom.h in Headers */, 61735AFA219DF044007BF637 /* ecdsa.h in Headers */, @@ -1619,6 +1656,7 @@ 61722BD9220E455500D7BA9A /* TWBinanceProto.h in Headers */, 61735CB921A33D47007BF637 /* TWHash.h in Headers */, 61CABACF21ED781B0086D9A0 /* TWCoinType.h in Headers */, + BB2422E122217B58000663D0 /* BinaryCoding.h in Headers */, 61CABABB21ED41E50086D9A0 /* TWKeyDerivation.h in Headers */, 61B159CE21CC5DBB00CFE93B /* TransactionSigner.h in Headers */, 61735C83219DF044007BF637 /* TrustWalletCore.h in Headers */, @@ -1653,6 +1691,7 @@ 616E125F21AE14E8009798FC /* TWString.h in Headers */, 61B159DC21CC5DBB00CFE93B /* PublicKey.h in Headers */, 61735BFE219DF044007BF637 /* script.h in Headers */, + BB2422E222217B58000663D0 /* Transaction.h in Headers */, 61735C32219DF044007BF637 /* options.h in Headers */, 61735C1E219DF044007BF637 /* ed25519-keccak.h in Headers */, 61722BD7220E455500D7BA9A /* TWZcashTransactionSigner.h in Headers */, @@ -1662,6 +1701,7 @@ 61735C76219DF044007BF637 /* rfc7539.h in Headers */, 61735AFE219DF044007BF637 /* base32.h in Headers */, 61735B0F219DF044007BF637 /* ecrypt-sync.h in Headers */, + BB2422DE22217B58000663D0 /* Signer.h in Headers */, 61722BD8220E455500D7BA9A /* TWBitcoinProto.h in Headers */, 61FE4B1F221F732D00C65017 /* TWWanchainSigner.h in Headers */, 61735AFB219DF044007BF637 /* pbkdf2.h in Headers */, @@ -1676,6 +1716,7 @@ 61B159DF21CC5DBB00CFE93B /* PrivateKey.h in Headers */, 61CABACC21ED781B0086D9A0 /* TWHDVersion.h in Headers */, 61CABAC121ED42520086D9A0 /* scrypt.h in Headers */, + BB2422D022217AE7000663D0 /* TWRippleProto.h in Headers */, 61EE6B2221DEB46A001FBB79 /* UnspentSelector.h in Headers */, 61A9B3622200D85A00E601B3 /* Address.h in Headers */, 617744442220977E00C210D9 /* uint256.h in Headers */, @@ -1686,6 +1727,7 @@ 61B159DE21CC5DBB00CFE93B /* Hash.h in Headers */, 61735B0E219DF044007BF637 /* ecrypt-config.h in Headers */, 61735C49219DF044007BF637 /* range_proof.h in Headers */, + BB2422D822217B4D000663D0 /* Ripple.pb.h in Headers */, 61735B02219DF044007BF637 /* bip39.h in Headers */, 61735AF3219DF044007BF637 /* modm-donna-32bit.h in Headers */, 610AEF7421C8A934008ABB74 /* TWBitcoinTransactionSigner.h in Headers */, @@ -1961,6 +2003,7 @@ 61735BFC219DF044007BF637 /* hasher.c in Sources */, 6198EA7E21B6B9C2008CB60A /* Data.swift in Sources */, 61B159D021CC5DBB00CFE93B /* OutPoint.cpp in Sources */, + BB2422D422217B08000663D0 /* Ripple.pb.swift in Sources */, 61722BE8220E457D00D7BA9A /* EthereumChainID.swift in Sources */, 61FE4B21221F733E00C65017 /* WanchainSigner.swift in Sources */, 61FE4B4422208E5000C65017 /* VeChain.pb.cc in Sources */, @@ -1980,6 +2023,7 @@ 61735C12219DF044007BF637 /* ed25519-keccak.c in Sources */, 61735C57219DF044007BF637 /* blake2b.c in Sources */, 61B159EA21CC5DBB00CFE93B /* PublicKey.cpp in Sources */, + BB2422DF22217B58000663D0 /* Signer.cpp in Sources */, 61735C43219DF044007BF637 /* serialize.c in Sources */, 61735C75219DF044007BF637 /* chacha_merged.c in Sources */, 61735C47219DF044007BF637 /* xmr.c in Sources */, @@ -1990,6 +2034,7 @@ 61735C5E219DF044007BF637 /* address.c in Sources */, 61735C0C219DF044007BF637 /* curve25519-donna-scalarmult-base.c in Sources */, BBA9012121FDAE4200D2CEF7 /* Transaction.cpp in Sources */, + BB2422E422217B90000663D0 /* TWRippleSigner.cpp in Sources */, 61722C0E220E461A00D7BA9A /* TWZcashTransactionSigner.cpp in Sources */, 616E122C21A78094009798FC /* Hash.swift in Sources */, 61735C0E219DF044007BF637 /* ed25519-donna-32bit-tables.c in Sources */, @@ -2003,15 +2048,18 @@ 6198EA6121B21702008CB60A /* TWFoundationString.m in Sources */, 61CABAD821ED782E0086D9A0 /* HDVersion.swift in Sources */, 61EE6B2321DEB46A001FBB79 /* UnspentSelector.cpp in Sources */, + BB2422D322217B08000663D0 /* RippleSigner.swift in Sources */, 615D9B9B21CED9C700878D22 /* Address.cpp in Sources */, 61735C6F219DF044007BF637 /* aes_modes.c in Sources */, 61CABAB921ED37160086D9A0 /* AES.swift in Sources */, + BB2422D722217B4D000663D0 /* Ripple.pb.cc in Sources */, 61722C06220E461A00D7BA9A /* TWTendermintAddress.cpp in Sources */, 61B159E121CC5DBB00CFE93B /* TWString+Hex.cpp in Sources */, 61A9B3522200103000E601B3 /* Transaction.cpp in Sources */, 61E44461221CD49E006A4FF1 /* Signer.cpp in Sources */, 61B159E221CC5DBB00CFE93B /* TWPublicKey.cpp in Sources */, 61735C90219E1658007BF637 /* UInt256.swift in Sources */, + BB2422E022217B58000663D0 /* Transaction.cpp in Sources */, 61735C39219DF044007BF637 /* ripemd160.c in Sources */, 61977CCF21C9B9EF00C385D5 /* BitcoinAddress.swift in Sources */, 61CABAD721ED782E0086D9A0 /* P2SHPrefix.swift in Sources */, diff --git a/tests/Ripple/TransactionTests.cpp b/tests/Ripple/TransactionTests.cpp new file mode 100644 index 00000000000..d0949e83e65 --- /dev/null +++ b/tests/Ripple/TransactionTests.cpp @@ -0,0 +1,104 @@ +// Copyright © 2017-2019 Trust. +// +// This file is part of Trust. The full Trust copyright notice, including +// terms governing use, modification, and redistribution, is contained in the +// file LICENSE at the root of the source code distribution tree. + +#include "gtest/gtest.h" +#include "../src/Ripple/Address.h" +#include "../src/Ripple/Transaction.h" +#include "../src/Ripple/BinaryCoding.h" +#include "../src/HexCoding.h" +#include "../src/PrivateKey.h" +#include "../src/PublicKey.h" + +using namespace std; +using namespace TW; +using namespace TW::Ripple; + +TEST(RippleTransaction, serializeAmount) { + /// From https://github.com/trezor/trezor-core/blob/master/tests/test_apps.ripple.serializer.py + auto data0 = Transaction::serializeAmount(0); + auto data1 = Transaction::serializeAmount(1); + auto data2 = Transaction::serializeAmount(93493429243); + auto data3 = Transaction::serializeAmount(25000000); + + ASSERT_EQ(hex(data0), "4000000000000000"); + ASSERT_EQ(hex(data1), "4000000000000001"); + ASSERT_EQ(hex(data2), "40000015c4a483fb"); + ASSERT_EQ(hex(data3), "40000000017d7840"); +} + +TEST(RippleTransaction, serialize) { + /// From https://github.com/trezor/trezor-core/blob/master/tests/test_apps.ripple.serializer.py + auto account = Address("r9TeThyi5xiuUUrFjtPKZiHcDxs7K9H6Rb"); + auto destination = Address("r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C"); + auto tx1 = Transaction( + /* amount */25000000, + /* fee */10, + /* flags */0, + /* sequence */2, + /* last_ledger_sequence */0, + /* account */account, + /* destination */destination, + /* destination_tag*/0 + ); + auto serialized1 = tx1.serialize(); + ASSERT_EQ(hex(serialized1), "120000220000000024000000026140000000017d784068400000000000000a81145ccb151f6e9d603f394ae778acf10d3bece874f68314e851bbbe79e328e43d68f43445368133df5fba5a"); + + auto tx2 = Transaction( + /* amount */200000, + /* fee */15, + /* flags */0, + /* sequence */144, + /* last_ledger_sequence */0, + /* account */Address("rGWTUVmm1fB5QUjMYn8KfnyrFNgDiD9H9e"), + /* destination */Address("rw71Qs1UYQrSQ9hSgRohqNNQcyjCCfffkQ"), + /* destination_tag*/0 + ); + auto serialized2 = tx2.serialize(); + ASSERT_EQ(hex(serialized2), "12000022000000002400000090614000000000030d4068400000000000000f8114aa1bd19d9e87be8069fdbf6843653c43837c03c6831467fe6ec28e0464dd24fb2d62a492aac697cfad02"); + + auto tx3 = Transaction( + /* amount */25000000, + /* fee */12, + /* flags */0, + /* sequence */1, + /* last_ledger_sequence */0, + /* account */Address("r4BPgS7DHebQiU31xWELvZawwSG2fSPJ7C"), + /* destination */Address("rBqSFEFg2B6GBMobtxnU1eLA1zbNC9NDGM"), + /* destination_tag*/4146942154 + ); + auto serialized3 = tx3.serialize(); + ASSERT_EQ(hex(serialized3), "120000220000000024000000012ef72d50ca6140000000017d784068400000000000000c8114e851bbbe79e328e43d68f43445368133df5fba5a831476dac5e814cd4aa74142c3ab45e69a900e637aa2"); +} + +TEST(RippleTransaction, preImage) { + auto account = Address("r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ"); + auto destination = Address("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"); + auto tx1 = Transaction( + /* amount */1000, + /* fee */10, + /* flags */2147483648, + /* sequence */1, + /* last_ledger_sequence */0, + /* account */account, + /* destination */destination, + /* destination_tag*/0 + ); + tx1.pub_key = parse_hex("ed5f5ac8b98974a3ca843326d9b88cebd0560177b973ee0b149f782cfaa06dc66a"); + auto unsignedTx = tx1.getPreImage(); + + ASSERT_EQ(hex(unsignedTx), + /* prefix */ "53545800" + /* tx type */ "120000" + /* flags */ "2280000000" + /* sequence */ "2400000001" + /* amount */ "6140000000000003e8" + /* fee */ "68400000000000000a" + /* pub key */ "7321ed5f5ac8b98974a3ca843326d9b88cebd0560177b973ee0b149f782cfaa06dc66a" + /* account */ "81145b812c9d57731e27a2da8b1830195f88ef32a3b6" + /* destination */ "8314b5f762798a53d543a014caf8b297cff8f2f937e8" + ); + ASSERT_EQ(unsignedTx.size(), 114); +}