Ad
Since Ripple-lib-java Is Unmaintained, How Do You Manually Sign A Transaction?
Looking for a lightweight way to manually sign an OfferCreate
... it would be clumsy to start some JavaScript engine in order to get it done.
Ad
Answer
Hmm ... even though it hasn't been maintained for 4 years it looks like it still works.
Clone ripple-lib-java
and do mvn install in ripple-bouncycastle
& ripple-core
Then copy the built JARs into <YourProject>/libs
Add local dependencies in Gradle Kotlin DSL:
repositories {
flatDir {
>repositories {
flatDir {
dirs("libs")
}
}
dependencies {
implementation(":ripple-bouncycastle-0.0.1-SNAPSHOT")
implementation(":ripple-core-0.0.1-SNAPSHOT")
runtime("org.json:json:20190722") // No newskool kotlinx-serialization here :(
}
Create & sign OfferCreate:
val offerCreate = OfferCreate()
offerCreate.account(AccountID.fromString("r3jpWpUysF4SAkUNbG4WhDZ5mAJ7rGUDx6"))
offerCreate.expiration(UInt32(get2MinExpiration()))
offerCreate.fee(Amount(BigDecimal("0.00001")))
offerCreate.flags(UInt32(0))
offerCreate.sequence(UInt32(1))
val amountXRP = BigDecimal(200)
val amountBTC = convert(amountXRP, RIPPLE_XRP, BITCOIN)
offerCreate.takerGets(Amount(amountXRP))
offerCreate.takerPays(Amount(amountBTC, Currency.fromString(BITCOIN), AccountID.fromString(BITCOIN_TRUSTED_ISSUER)))
val signedTransaction = offerCreate.sign("[***Secret***]")
println(offerCreate.toJSON())
println(signedTransaction.tx_blob)
A bit annoying that you can't do a toJSON()
on a SignedTransaction
. It can
t be a security thing, since sign()
only adds public key fields: https://xrpl.org/transaction-common-fields.html#signers-field
Ad
source: stackoverflow.com
Related Questions
- → Since ripple-lib-java is unmaintained, how do you manually sign a transaction?
- → Is it possible to use Maven to develop Frontend/Web apps?
- → Kotlin lazy default property
- → Firebase & Retrieving Elements
- → Caused by: rx.exceptions.MissingBackpressureException
- → How to get input from user in Android Studio in numeric value and Convert it into variable int in kotlin?
- → Android - how to implement multiple ViewHolder one for header layout another for model layout in Firestore RecyclerView adapter
- → Inject only certain params in constructor
- → how to access arraylist data in kotlin
- → Passing List of Objects to Fragment
- → AES encryption. PHP and KotlinJava differences
- → Can I defer the view binding in an adapter using Kotlin Android Extension
- → How to fix lost time in date after converting?
Ad