This library implements transactions and keys management for TokenD-related projects.
For Gradle add following lines to your project's build.gradle
:
allprojects {
repositories {
...
maven { url "https://maven.tokend.io" }
}
}
dependencies {
...
compile "org.tokend:wallet:3.7.0"
}
Key management and signing:
val SEED = "SBUFJEEK7FMWXPE4HGOWQZPHZ4V5TFKGSF664RAGT24NS662MKTQ7J6S".toCharArray()
private val DATA = "TokenD is awesome".toByteArray()
val account = Account.fromSecretSeed(SEED)
val decoratedSignature = account.signDecorated(DATA)
Transaction creation:
val SEED = "SBUFJEEK7FMWXPE4HGOWQZPHZ4V5TFKGSF664RAGT24NS662MKTQ7J6S".toCharArray()
val NETWORK = NetworkParams("Example Test Network")
val sourceAccount = Account.fromSecretSeed(SEED)
val operation = CreateBalanceOp(SOURCE_ACCOUNT_ID, "OLE")
val transaction = TransactionBuilder(NETWORK, sourceAccount.accountId)
.addOperation(Operation.OperationBody.ManageBalance(operation))
.setMemo(Memo.MemoText("TokenD is awesome"))
.addSigner(sourceAccount)
.build()
val envelope = transaction.getEnvelope().toBase64()
Decoding:
val txResultEncoded = "AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAJAAAAAAAAAADMOKDasWPzpJIqN9sWipdvcjEZRTnGBvUezXbEd6rKMAAAAAAAAAAA"
val txResult = TransactionResult.fromBase64(txResultEncoded)
As long as you don't decode XDRs (.fromXdr(...)
) no extra ProGuard
rules are required. Otherwise add following lines to your
project's proguard-rules.pro
:
# Wallet
-keep class org.tokend.wallet.xdr.* { *; }
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
XDR sources are located in TokenD XDR repository. You can generate new XDRs using our Docker-based XDR generator. Docker is required to perform this action.
In order to generate new XDRs run generateXDR
script with a source revision (tag or branch or commit) as an argument:
./generateXDR.sh master