mirror of
https://codeberg.org/r4v3r23/mysu.git
synced 2024-11-10 05:03:44 +01:00
Add UI option for "occasional donations". Disabled by default.
This commit is contained in:
parent
676fe9367b
commit
c46ce609c6
@ -48,7 +48,6 @@ public class SubaddressAdapter extends RecyclerView.Adapter<SubaddressAdapter.Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void submitList(List<Subaddress> dataSet) {
|
public void submitList(List<Subaddress> dataSet) {
|
||||||
System.out.println("ADDRESSES: " + dataSet);
|
|
||||||
this.localDataSet = dataSet;
|
this.localDataSet = dataSet;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||||||
SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch);
|
SwitchCompat nightModeSwitch = view.findViewById(R.id.day_night_switch);
|
||||||
SwitchCompat streetModeSwitch = view.findViewById(R.id.street_mode_switch);
|
SwitchCompat streetModeSwitch = view.findViewById(R.id.street_mode_switch);
|
||||||
SwitchCompat monerochanSwitch = view.findViewById(R.id.monerochan_switch);
|
SwitchCompat monerochanSwitch = view.findViewById(R.id.monerochan_switch);
|
||||||
|
SwitchCompat donationSwitch = view.findViewById(R.id.donate_per_tx_switch);
|
||||||
SwitchCompat torSwitch = view.findViewById(R.id.tor_switch);
|
SwitchCompat torSwitch = view.findViewById(R.id.tor_switch);
|
||||||
ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
|
ConstraintLayout proxySettingsLayout = view.findViewById(R.id.wallet_proxy_settings_layout);
|
||||||
walletProxyAddressEditText = view.findViewById(R.id.wallet_proxy_address_edittext);
|
walletProxyAddressEditText = view.findViewById(R.id.wallet_proxy_address_edittext);
|
||||||
@ -127,6 +128,9 @@ public class SettingsFragment extends Fragment implements PasswordBottomSheetDia
|
|||||||
HistoryService.getInstance().refreshHistory();
|
HistoryService.getInstance().refreshHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
donationSwitch.setChecked(PrefService.getInstance().getBoolean(Constants.PREF_DONATE_PER_TX, false));
|
||||||
|
donationSwitch.setOnCheckedChangeListener((compoundButton, b) -> PrefService.getInstance().edit().putBoolean(Constants.PREF_DONATE_PER_TX, b).apply());
|
||||||
|
|
||||||
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
boolean usesProxy = PrefService.getInstance().getBoolean(Constants.PREF_USES_TOR, false);
|
||||||
String proxy = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
String proxy = PrefService.getInstance().getString(Constants.PREF_PROXY, "");
|
||||||
if (proxy.contains(":")) {
|
if (proxy.contains(":")) {
|
||||||
|
@ -132,7 +132,6 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||||||
|
|
||||||
public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception {
|
public PendingTransaction createTx(String address, String amountStr, boolean sendAll, PendingTransaction.Priority feePriority, ArrayList<String> selectedUtxos) throws Exception {
|
||||||
long amount = Wallet.getAmountFromString(amountStr);
|
long amount = Wallet.getAmountFromString(amountStr);
|
||||||
System.out.println("AMOUNT:: " + amount);
|
|
||||||
ArrayList<String> preferredInputs;
|
ArrayList<String> preferredInputs;
|
||||||
if (selectedUtxos.isEmpty()) {
|
if (selectedUtxos.isEmpty()) {
|
||||||
// no inputs manually selected, we are sending from home screen most likely, or user somehow broke the app
|
// no inputs manually selected, we are sending from home screen most likely, or user somehow broke the app
|
||||||
@ -153,24 +152,21 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TransactionOutput> maybeAddDonationOutputs(long amount, List<TransactionOutput> outputs, List<String> preferredInputs) throws Exception {
|
private List<TransactionOutput> maybeAddDonationOutputs(long amount, List<TransactionOutput> outputs, List<String> preferredInputs) throws Exception {
|
||||||
TransactionOutput mainDestination = outputs.get(0); // at this point, for now, we should only have one item in the list
|
TransactionOutput mainDestination = outputs.get(0); // at this point, for now, we should only have one item in the list. TODO: add multi-dest/pay-to-many feature in the UI
|
||||||
String paymentId = Wallet.getPaymentIdFromAddress(mainDestination.getDestination(), WalletManager.getInstance().getNetworkType().getValue());
|
String paymentId = Wallet.getPaymentIdFromAddress(mainDestination.getDestination(), WalletManager.getInstance().getNetworkType().getValue());
|
||||||
System.out.println("PAYMENT ID:: " + paymentId + ".");
|
|
||||||
ArrayList<TransactionOutput> newOutputs = new ArrayList<>(outputs);
|
ArrayList<TransactionOutput> newOutputs = new ArrayList<>(outputs);
|
||||||
boolean donatePerTx = true;
|
boolean donatePerTx = PrefService.getInstance().getBoolean(Constants.PREF_DONATE_PER_TX, false);
|
||||||
if(donatePerTx && paymentId.isEmpty()) {
|
if(donatePerTx && paymentId.isEmpty()) { // only attach donation when no payment id is needed (i.e. integrated address)
|
||||||
float randomDonatePct = getRandomDonateAmount(0.0075f, 0.015f); // occasionally attaches a 0.75% to 1.5% fee. 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 consistent 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 2 outputs instead of 1.
|
||||||
*/
|
*/
|
||||||
System.out.println("RANDOM DONATE PCT:: " + randomDonatePct);
|
|
||||||
int attachDonationRoll = new SecureRandom().nextInt(100);
|
int attachDonationRoll = new SecureRandom().nextInt(100);
|
||||||
if(attachDonationRoll > 1) {
|
if(attachDonationRoll > 75) { // 25% 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);
|
||||||
System.out.println("DONATE AMOUNT:: " + donateAmount);
|
if(splitDonationRoll > 50) { // 50% chance of being split
|
||||||
if(splitDonationRoll > 50) {
|
|
||||||
// split
|
// split
|
||||||
long splitAmount = donateAmount / 2;
|
long splitAmount = donateAmount / 2;
|
||||||
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, splitAmount));
|
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, splitAmount));
|
||||||
@ -179,7 +175,6 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||||||
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, donateAmount));
|
newOutputs.add(new TransactionOutput(Constants.DONATE_ADDRESS, donateAmount));
|
||||||
}
|
}
|
||||||
long total = amount + donateAmount;
|
long total = amount + donateAmount;
|
||||||
System.out.println("TOTAL:: " + total);
|
|
||||||
checkSelectedAmounts(preferredInputs, total, false); // check that the selected UTXOs satisfy the new amount total
|
checkSelectedAmounts(preferredInputs, total, false); // check that the selected UTXOs satisfy the new amount total
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,9 +192,6 @@ public class MoneroHandlerThread extends Thread implements WalletListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (amountSelected <= amount) {
|
if (amountSelected <= amount) {
|
||||||
System.out.println("/////// CHECK");
|
|
||||||
System.out.println("AMOUNT SELECTED:: " + amountSelected);
|
|
||||||
System.out.println("AMOUNT:: " + amount);
|
|
||||||
throw new Exception("insufficient wallet balance");
|
throw new Exception("insufficient wallet balance");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,6 @@ public class UTXOService extends ServiceBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("AMOUNT WITH BASIC FEE:: " + amountWithBasicFee);
|
|
||||||
System.out.println("AMOUNT SELECTED:: " + amountSelected);
|
|
||||||
if (amountSelected < amountWithBasicFee && !sendAll) {
|
if (amountSelected < amountWithBasicFee && !sendAll) {
|
||||||
throw new Exception("insufficient wallet balance");
|
throw new Exception("insufficient wallet balance");
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,54 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/display_seed_button" />
|
app:layout_constraintTop_toBottomOf="@id/display_seed_button" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/transaction_settings_textview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:text="@string/transactions"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/display_utxos_button" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/donate_per_tx_label_textview"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/option_donate_per_tx"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/donate_per_tx_switch"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/donate_per_tx_switch"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/donate_per_tx_switch" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/donate_per_tx_desc_textview"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/option_donate_per_tx_desc"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/oled_addressListColor"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/donate_per_tx_switch" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/donate_per_tx_switch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="24dp"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/transaction_settings_textview" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/appearance_settings_textview"
|
android:id="@+id/appearance_settings_textview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -88,7 +136,7 @@
|
|||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/display_utxos_button" />
|
app:layout_constraintTop_toBottomOf="@id/donate_per_tx_desc_textview" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/day_night_textview"
|
android:id="@+id/day_night_textview"
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
<string name="night_mode">Night mode</string>
|
<string name="night_mode">Night mode</string>
|
||||||
<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_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="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>
|
||||||
@ -121,4 +123,5 @@
|
|||||||
<string name="subbaddress_info_subtitle" translatable="false">#%1$d: %2$s</string>
|
<string name="subbaddress_info_subtitle" translatable="false">#%1$d: %2$s</string>
|
||||||
<string name="previous_addresses">Previous addresses</string>
|
<string name="previous_addresses">Previous addresses</string>
|
||||||
<string name="donate_label">Donate to MyNero</string>
|
<string name="donate_label">Donate to MyNero</string>
|
||||||
|
<string name="transactions">Transactions</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user