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 d3080b4..446cc4e 100644 --- a/app/src/main/java/net/mynero/wallet/model/Wallet.java +++ b/app/src/main/java/net/mynero/wallet/model/Wallet.java @@ -280,14 +280,6 @@ public class Wallet { private native long estimateTransactionFee(List> destinations, int priority); - public PendingTransaction createTransaction(TxData txData) { - return createTransaction( - txData.getDestinationAddress(), - txData.getAmount(), - txData.getPriority(), - txData.getPreferredInputs()); - } - public PendingTransaction createSweepTransaction(String dst_addr, PendingTransaction.Priority priority, ArrayList key_images) { disposePendingTransaction(); int _priority = priority.getValue(); @@ -296,20 +288,6 @@ public class Wallet { return pendingTransaction; } - public PendingTransaction createTransaction(String dst_addr, - long amount, PendingTransaction.Priority priority, ArrayList key_images) { - disposePendingTransaction(); - int _priority = priority.getValue(); - long txHandle = - (amount == SWEEP_ALL ? - createSweepTransaction(dst_addr, "", 0, _priority, - accountIndex, key_images) : - createTransactionJ(dst_addr, "", amount, 0, _priority, - accountIndex, key_images)); - pendingTransaction = new PendingTransaction(txHandle); - return pendingTransaction; - } - public PendingTransaction createTransactionMultDest(List outputs, PendingTransaction.Priority priority, ArrayList key_images) { disposePendingTransaction(); int _priority = priority.getValue(); diff --git a/app/src/main/java/net/mynero/wallet/service/MoneroHandlerThread.java b/app/src/main/java/net/mynero/wallet/service/MoneroHandlerThread.java index cef8f6f..7a21bc7 100644 --- a/app/src/main/java/net/mynero/wallet/service/MoneroHandlerThread.java +++ b/app/src/main/java/net/mynero/wallet/service/MoneroHandlerThread.java @@ -30,6 +30,7 @@ import net.mynero.wallet.util.Constants; import java.security.SecureRandom; import java.util.ArrayList; +import java.util.Collections; import java.util.List; @@ -159,19 +160,26 @@ public class MoneroHandlerThread extends Thread implements WalletListener { if(donatePerTx && paymentId.isEmpty()) { // only attach donation when no payment id is needed (i.e. integrated address) float randomDonatePct = getRandomDonateAmount(0.005f, 0.015f); // occasionally attaches a 0.5% to 1.5% donation. It is random so that not even I know how much exactly you are sending. /* - It's also not entirely "per tx". It won't always attach it so as to not have a consistent fingerprint on-chain. When it does attach a donation, - it will periodically split it up into 2 outputs instead of 1. + It's also not entirely "per tx". It won't always attach it so as to not have a consistently uncommon fingerprint on-chain. When it does attach a donation, + it will periodically split it up into multiple outputs instead of one. */ int attachDonationRoll = new SecureRandom().nextInt(100); - if(attachDonationRoll > 75) { // 25% chance of being added + if(attachDonationRoll > 90) { // 10% chance of being added int splitDonationRoll = new SecureRandom().nextInt(100); long donateAmount = (long) (amount*randomDonatePct); if(splitDonationRoll > 50) { // 50% chance of being split // split - long splitAmount = donateAmount / 2; - newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, splitAmount)); - newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS_2, splitAmount)); + int split = genRandomDonationSplit(1, 4); // splits into at most 4 outputs, for a total of 6 outputs in the transaction (real dest + change. we don't add donations to send-all/sweep transactions) + long splitAmount = donateAmount / split; + for(int i = 0; i < split; i++) { + // TODO this can be expanded upon into the future to perform an auto-splitting/auto-churning for the user if their wallet is fresh and has few utxos. + // randomly split between multiple wallets + int randomDonationAddress = new SecureRandom().nextInt(Constants.DONATION_ADDRESSES.length); + String donationAddress = Constants.DONATION_ADDRESSES[randomDonationAddress]; + newOutputs.add(new TransactionOutput(donationAddress, splitAmount)); + } } else { + // just add one output, for a total of 3 (real dest + change) newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, donateAmount)); } long total = amount + donateAmount; @@ -179,6 +187,8 @@ public class MoneroHandlerThread extends Thread implements WalletListener { } } + Collections.shuffle(newOutputs); // shuffle the outputs just in case. i think the monero library handles this for us anyway + return newOutputs; } @@ -208,7 +218,11 @@ public class MoneroHandlerThread extends Thread implements WalletListener { private float getRandomDonateAmount(float min, float max) { SecureRandom rand = new SecureRandom(); return rand.nextFloat() * (max - min) + min; + } + private int genRandomDonationSplit(int min, int max) { + SecureRandom rand = new SecureRandom(); + return rand.nextInt() * (max - min) + min; } public interface Listener { diff --git a/app/src/main/java/net/mynero/wallet/util/Constants.java b/app/src/main/java/net/mynero/wallet/util/Constants.java index 47494bf..6320e73 100644 --- a/app/src/main/java/net/mynero/wallet/util/Constants.java +++ b/app/src/main/java/net/mynero/wallet/util/Constants.java @@ -20,6 +20,10 @@ public class Constants { public static final String NAV_ARG_TXINFO = "nav_arg_txinfo"; public static final String STREET_MODE_BALANCE = "#.############"; - public static final String DONATE_ADDRESS_2 = "89Yym1JTqiM7PMgra3XP1oMtGkiAQHBrFE7VJFAVYU1DTpAqviTsNewM2KoBw5fLLufaNMfJZq9bNhyPmfWq62hy4T9jzQF"; // secondary wallet + public static final String[] DONATION_ADDRESSES = new String[] { + "87MRtZPrWUCVUgcFHdsVb5MoZUcLtqfD3FvQVGwftFb8eSdMnE39JhAJcbuSW8X2vRaRsB9RQfuCpFciybJFHaz3QYPhCLw", // primary MyNero Donation address + "89Yym1JTqiM7PMgra3XP1oMtGkiAQHBrFE7VJFAVYU1DTpAqviTsNewM2KoBw5fLLufaNMfJZq9bNhyPmfWq62hy4T9jzQF", // second MyNero Donation address + "8Bv91cxyDjaTdzW6186iwPGrQ2ZNDFVXL4bSw7mnSZ26Pii3cRNniY9K6r5yvg1yDsLtbt9pmiYcKUDTgWB2pmGJ4Fi2jK1" // third MyNero Donation address + }; public static final String DONATE_ADDRESS = "87MRtZPrWUCVUgcFHdsVb5MoZUcLtqfD3FvQVGwftFb8eSdMnE39JhAJcbuSW8X2vRaRsB9RQfuCpFciybJFHaz3QYPhCLw"; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6fca38a..0d2186e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -43,7 +43,7 @@ Street mode (hide balances) Show Monerochan Add occasional donation - Randomly adds a 0.75%-1.5% MyNero donation to Txns. It\'s random so Txns don\'t have a consistent fingerprint, and the % is random so I don\'t know the exact Txn amount. + Randomly adds a 0.5%-1.5% MyNero donation to Txns. It\'s random so Txns don\'t have a consistently uncommon fingerprint, and the % is random so MyNero doesn\'t know the exact Txn amount. Display wallet keys Connect to proxy Connection failed