Update text in UI, add code comments, cleanup code

This commit is contained in:
pokkst 2022-12-04 01:45:59 -06:00
parent c46ce609c6
commit 5030ce5640
No known key found for this signature in database
GPG key ID: 90C2ED85E67A50FF
4 changed files with 26 additions and 30 deletions

View file

@ -280,14 +280,6 @@ public class Wallet {
private native long estimateTransactionFee(List<Pair<String, Long>> 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<String> 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<String> 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<TransactionOutput> outputs, PendingTransaction.Priority priority, ArrayList<String> key_images) {
disposePendingTransaction();
int _priority = priority.getValue();

View file

@ -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 {

View file

@ -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";
}

View file

@ -43,7 +43,7 @@
<string name="street_mode">Street mode (hide balances)</string>
<string name="option_hide_xmrchan">Show Monerochan</string>
<string name="option_donate_per_tx">Add occasional donation</string>
<string name="option_donate_per_tx_desc">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.</string>
<string name="option_donate_per_tx_desc">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.</string>
<string name="display_recovery_phrase">Display wallet keys</string>
<string name="tor_switch_label">Connect to proxy</string>
<string name="connection_failed">Connection failed</string>