From 3076777c53b24a4f591cbd493c77de55aac336fc Mon Sep 17 00:00:00 2001 From: pokkst Date: Thu, 22 Sep 2022 05:15:16 -0500 Subject: [PATCH] Sweep selected outputs --- app/src/main/cpp/monerujo.cpp | 29 +++++++++++++++++++ .../java/net/mynero/wallet/model/Wallet.java | 5 ++++ external-libs/VERSION | 2 +- external-libs/include/wallet2_api.h | 26 +++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/monerujo.cpp b/app/src/main/cpp/monerujo.cpp index 13cb0e7..b94a6d7 100644 --- a/app/src/main/cpp/monerujo.cpp +++ b/app/src/main/cpp/monerujo.cpp @@ -979,6 +979,35 @@ Java_net_mynero_wallet_model_Wallet_createTransactionJ(JNIEnv *env, jobject inst return reinterpret_cast(tx); } +JNIEXPORT jlong JNICALL +Java_net_mynero_wallet_model_Wallet_createTransactionSingleJ(JNIEnv *env, jobject instance, + jstring key_image, jstring dst_addr, + jint priority) { + const char *_key_image = env->GetStringUTFChars(key_image, nullptr); + const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr); + Monero::PendingTransaction::Priority _priority = + static_cast(priority); + Monero::Wallet *wallet = getHandle(env, instance); + Monero::PendingTransaction *tx = wallet->createTransactionSingle(_key_image, _dst_addr, _priority); + env->ReleaseStringUTFChars(key_image, _key_image); + env->ReleaseStringUTFChars(dst_addr, _dst_addr); + return reinterpret_cast(tx); +} + +JNIEXPORT jlong JNICALL +Java_net_mynero_wallet_model_Wallet_createTransactionSelectedJ(JNIEnv *env, jobject instance, + jobject key_images, jstring dst_addr, + jint priority) { + const std::vector _key_images = java2cpp(env, key_images); + const char *_dst_addr = env->GetStringUTFChars(dst_addr, nullptr); + Monero::PendingTransaction::Priority _priority = + static_cast(priority); + Monero::Wallet *wallet = getHandle(env, instance); + Monero::PendingTransaction *tx = wallet->createTransactionSelected(_key_images, _dst_addr, _priority); + env->ReleaseStringUTFChars(dst_addr, _dst_addr); + return reinterpret_cast(tx); +} + JNIEXPORT jlong JNICALL Java_net_mynero_wallet_model_Wallet_createSweepTransaction(JNIEnv *env, jobject instance, jstring dst_addr, jstring payment_id, diff --git a/app/src/main/java/net/mynero/wallet/model/Wallet.java b/app/src/main/java/net/mynero/wallet/model/Wallet.java index 5774e48..1114657 100644 --- a/app/src/main/java/net/mynero/wallet/model/Wallet.java +++ b/app/src/main/java/net/mynero/wallet/model/Wallet.java @@ -25,6 +25,7 @@ import net.mynero.wallet.data.TxData; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.Locale; import lombok.Getter; @@ -302,6 +303,10 @@ public class Wallet { int mixin_count, int priority, int accountIndex); + private native long createTransactionSingleJ(String key_image, String dst_addr, int priority); + + private native long createTransactionSelectedJ(List key_images, String dst_addr, int priority); + public PendingTransaction createSweepUnmixableTransaction() { disposePendingTransaction(); long txHandle = createSweepUnmixableTransactionJ(); diff --git a/external-libs/VERSION b/external-libs/VERSION index 654ebac..737a491 100644 --- a/external-libs/VERSION +++ b/external-libs/VERSION @@ -1 +1 @@ -MONERUJO_monero main with monero release-v0.18.1.0-mynero +MONERUJO_monero feature/select-utxos with monero release-v0.18.1.0-mynero diff --git a/external-libs/include/wallet2_api.h b/external-libs/include/wallet2_api.h index 7a4fce6..8d634b3 100644 --- a/external-libs/include/wallet2_api.h +++ b/external-libs/include/wallet2_api.h @@ -907,6 +907,32 @@ struct Wallet uint32_t subaddr_account = 0, std::set subaddr_indices = {}) = 0; + /*! + * \brief createTransactionSingle creates transaction with single input + * \param key_image key image as string + * \param dst_addr destination address as string + * \param priority + * \return PendingTransaction object. caller is responsible to check PendingTransaction::status() + * after object returned + */ + + virtual PendingTransaction * createTransactionSingle(const std::string &key_image, const std::string &dst_addr, + size_t outputs = 1, PendingTransaction::Priority = PendingTransaction::Priority_Low) = 0; + + + /*! + * \brief createTransactionSelected creates transaction with selected inputs + * \param key_images vector of key images as string + * \param dst_addr destination address as string + * \param outputs split amount into this many outputs of equal amount + * \param priority transaction priority + * \return PendingTransaction object. caller is responsible to check PendingTransaction::status() + * after object returned + */ + + virtual PendingTransaction * createTransactionSelected(const std::vector &key_images, const std::string &dst_addr, + size_t outputs = 1, PendingTransaction::Priority = PendingTransaction::Priority_Low) = 0; + /*! * \brief createSweepUnmixableTransaction creates transaction with unmixable outputs. * \return PendingTransaction object. caller is responsible to check PendingTransaction::status()