mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2025-01-03 18:48:07 +00:00
Update text in UI, add code comments, cleanup code
This commit is contained in:
parent
c46ce609c6
commit
5030ce5640
4 changed files with 26 additions and 30 deletions
|
@ -280,14 +280,6 @@ public class Wallet {
|
||||||
|
|
||||||
private native long estimateTransactionFee(List<Pair<String, Long>> destinations, int priority);
|
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) {
|
public PendingTransaction createSweepTransaction(String dst_addr, PendingTransaction.Priority priority, ArrayList<String> key_images) {
|
||||||
disposePendingTransaction();
|
disposePendingTransaction();
|
||||||
int _priority = priority.getValue();
|
int _priority = priority.getValue();
|
||||||
|
@ -296,20 +288,6 @@ public class Wallet {
|
||||||
return pendingTransaction;
|
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) {
|
public PendingTransaction createTransactionMultDest(List<TransactionOutput> outputs, PendingTransaction.Priority priority, ArrayList<String> key_images) {
|
||||||
disposePendingTransaction();
|
disposePendingTransaction();
|
||||||
int _priority = priority.getValue();
|
int _priority = priority.getValue();
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.mynero.wallet.util.Constants;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
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)
|
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.
|
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'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 2 outputs instead of 1.
|
it will periodically split it up into multiple outputs instead of one.
|
||||||
*/
|
*/
|
||||||
int attachDonationRoll = new SecureRandom().nextInt(100);
|
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);
|
int splitDonationRoll = new SecureRandom().nextInt(100);
|
||||||
long donateAmount = (long) (amount*randomDonatePct);
|
long donateAmount = (long) (amount*randomDonatePct);
|
||||||
if(splitDonationRoll > 50) { // 50% chance of being split
|
if(splitDonationRoll > 50) { // 50% chance of being split
|
||||||
// split
|
// split
|
||||||
long splitAmount = donateAmount / 2;
|
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)
|
||||||
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, splitAmount));
|
long splitAmount = donateAmount / split;
|
||||||
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS_2, splitAmount));
|
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 {
|
} else {
|
||||||
|
// just add one output, for a total of 3 (real dest + change)
|
||||||
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, donateAmount));
|
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, donateAmount));
|
||||||
}
|
}
|
||||||
long total = amount + 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;
|
return newOutputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +218,11 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
||||||
private float getRandomDonateAmount(float min, float max) {
|
private float getRandomDonateAmount(float min, float max) {
|
||||||
SecureRandom rand = new SecureRandom();
|
SecureRandom rand = new SecureRandom();
|
||||||
return rand.nextFloat() * (max - min) + min;
|
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 {
|
public interface Listener {
|
||||||
|
|
|
@ -20,6 +20,10 @@ public class Constants {
|
||||||
public static final String NAV_ARG_TXINFO = "nav_arg_txinfo";
|
public static final String NAV_ARG_TXINFO = "nav_arg_txinfo";
|
||||||
|
|
||||||
public static final String STREET_MODE_BALANCE = "#.############";
|
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";
|
public static final String DONATE_ADDRESS = "87MRtZPrWUCVUgcFHdsVb5MoZUcLtqfD3FvQVGwftFb8eSdMnE39JhAJcbuSW8X2vRaRsB9RQfuCpFciybJFHaz3QYPhCLw";
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
<string name="street_mode">Street mode (hide balances)</string>
|
<string name="street_mode">Street mode (hide balances)</string>
|
||||||
<string name="option_hide_xmrchan">Show Monerochan</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">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="display_recovery_phrase">Display wallet keys</string>
|
||||||
<string name="tor_switch_label">Connect to proxy</string>
|
<string name="tor_switch_label">Connect to proxy</string>
|
||||||
<string name="connection_failed">Connection failed</string>
|
<string name="connection_failed">Connection failed</string>
|
||||||
|
|
Loading…
Reference in a new issue