mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2024-12-22 21:17:47 +00:00
Testing safe-guard against integrated addresses inside of pay-to-many txs. It should fail anyway right now but this is a sanity check.
This commit is contained in:
parent
099e3c7281
commit
d4e871ede5
4 changed files with 47 additions and 18 deletions
|
@ -137,7 +137,6 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
sendMaxButton.setOnClickListener(view1 -> {
|
sendMaxButton.setOnClickListener(view1 -> {
|
||||||
addOutputImageView.setVisibility(View.INVISIBLE);
|
|
||||||
boolean currentValue = mViewModel.sendingMax.getValue() != null ? mViewModel.sendingMax.getValue() : false;
|
boolean currentValue = mViewModel.sendingMax.getValue() != null ? mViewModel.sendingMax.getValue() : false;
|
||||||
mViewModel.setSendingMax(!currentValue);
|
mViewModel.setSendingMax(!currentValue);
|
||||||
});
|
});
|
||||||
|
@ -192,17 +191,19 @@ public class SendFragment extends Fragment {
|
||||||
mViewModel.sendingMax.observe(getViewLifecycleOwner(), sendingMax -> {
|
mViewModel.sendingMax.observe(getViewLifecycleOwner(), sendingMax -> {
|
||||||
if (mViewModel.pendingTransaction.getValue() == null) {
|
if (mViewModel.pendingTransaction.getValue() == null) {
|
||||||
if (sendingMax) {
|
if (sendingMax) {
|
||||||
addOutputImageView.setVisibility(View.GONE);
|
|
||||||
prepareOutputsForMaxSend();
|
prepareOutputsForMaxSend();
|
||||||
sendMaxButton.setText(getText(R.string.undo));
|
sendMaxButton.setText(getText(R.string.undo));
|
||||||
} else {
|
} else {
|
||||||
addOutputImageView.setVisibility(View.VISIBLE);
|
|
||||||
unprepareMaxSend();
|
unprepareMaxSend();
|
||||||
sendMaxButton.setText(getText(R.string.send_max));
|
sendMaxButton.setText(getText(R.string.send_max));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mViewModel.showAddOutputButton.observe(getViewLifecycleOwner(), show -> {
|
||||||
|
setAddOutputButtonVisibility(show ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
});
|
||||||
|
|
||||||
mViewModel.pendingTransaction.observe(getViewLifecycleOwner(), pendingTx -> {
|
mViewModel.pendingTransaction.observe(getViewLifecycleOwner(), pendingTx -> {
|
||||||
showConfirmationLayout(pendingTx != null);
|
showConfirmationLayout(pendingTx != null);
|
||||||
|
|
||||||
|
@ -322,31 +323,41 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pasteAddress(ConstraintLayout entryView, String clipboard, boolean pastingAmount) {
|
private void pasteAddress(ConstraintLayout entryView, String clipboard, boolean pastingAmount) {
|
||||||
|
if(pastingAmount) {
|
||||||
|
try {
|
||||||
|
Double.parseDouble(clipboard);
|
||||||
|
setAmount(entryView, clipboard);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UriData uriData = UriData.parse(clipboard);
|
UriData uriData = UriData.parse(clipboard);
|
||||||
if (uriData != null) {
|
if (uriData != null) {
|
||||||
|
int currentOutputs = getDestCount();
|
||||||
|
if(currentOutputs > 1 && uriData.hasPaymentId()) {
|
||||||
|
Toast.makeText(getActivity(), getString(R.string.paymentid_paytomany), Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
} else if(currentOutputs == 1 && uriData.hasPaymentId()) {
|
||||||
|
mViewModel.setShowAddOutputButton(false);
|
||||||
|
}
|
||||||
EditText addressField = entryView.findViewById(R.id.address_edittext);
|
EditText addressField = entryView.findViewById(R.id.address_edittext);
|
||||||
addressField.setText(uriData.getAddress());
|
addressField.setText(uriData.getAddress());
|
||||||
if (uriData.hasAmount()) {
|
if (uriData.hasAmount()) {
|
||||||
sendMaxButton.setEnabled(false);
|
setAmount(entryView, uriData.getAmount());
|
||||||
EditText amountField = entryView.findViewById(R.id.amount_edittext);
|
|
||||||
amountField.setText(uriData.getAmount());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(pastingAmount) {
|
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
||||||
try {
|
|
||||||
Double.parseDouble(clipboard);
|
|
||||||
sendMaxButton.setEnabled(false);
|
|
||||||
EditText amountField = entryView.findViewById(R.id.amount_edittext);
|
|
||||||
amountField.setText(clipboard);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(getActivity(), getString(R.string.send_amount_invalid), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(getActivity(), getString(R.string.send_address_invalid), Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAmount(ConstraintLayout entryView, String amount) {
|
||||||
|
sendMaxButton.setEnabled(false);
|
||||||
|
EditText amountField = entryView.findViewById(R.id.amount_edittext);
|
||||||
|
amountField.setText(amount);
|
||||||
|
}
|
||||||
|
|
||||||
private void createTx(List<Pair<String, String>> dests, boolean sendAll, PendingTransaction.Priority feePriority) {
|
private void createTx(List<Pair<String, String>> dests, boolean sendAll, PendingTransaction.Priority feePriority) {
|
||||||
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
((MoneroApplication)getActivity().getApplication()).getExecutor().execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
@ -393,4 +404,8 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setAddOutputButtonVisibility(int visibility) {
|
||||||
|
addOutputImageView.setVisibility(visibility);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,11 +9,18 @@ import net.mynero.wallet.model.PendingTransaction;
|
||||||
public class SendViewModel extends ViewModel {
|
public class SendViewModel extends ViewModel {
|
||||||
private final MutableLiveData<Boolean> _sendingMax = new MutableLiveData<>(false);
|
private final MutableLiveData<Boolean> _sendingMax = new MutableLiveData<>(false);
|
||||||
public LiveData<Boolean> sendingMax = _sendingMax;
|
public LiveData<Boolean> sendingMax = _sendingMax;
|
||||||
|
private final MutableLiveData<Boolean> _showAddOutputButton = new MutableLiveData<>(true);
|
||||||
|
public LiveData<Boolean> showAddOutputButton = _showAddOutputButton;
|
||||||
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
private final MutableLiveData<PendingTransaction> _pendingTransaction = new MutableLiveData<>(null);
|
||||||
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
|
||||||
|
|
||||||
public void setSendingMax(boolean value) {
|
public void setSendingMax(boolean value) {
|
||||||
_sendingMax.setValue(value);
|
_sendingMax.setValue(value);
|
||||||
|
setShowAddOutputButton(!value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowAddOutputButton(boolean value) {
|
||||||
|
_showAddOutputButton.setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPendingTransaction(PendingTransaction pendingTx) {
|
public void setPendingTransaction(PendingTransaction pendingTx) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.mynero.wallet.util;
|
package net.mynero.wallet.util;
|
||||||
|
|
||||||
import net.mynero.wallet.model.Wallet;
|
import net.mynero.wallet.model.Wallet;
|
||||||
|
import net.mynero.wallet.model.WalletManager;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@ -46,6 +47,10 @@ public class UriData {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPaymentId() {
|
||||||
|
return !Wallet.getPaymentIdFromAddress(this.address, WalletManager.getInstance().getWallet().nettype()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public String getAmount() {
|
public String getAmount() {
|
||||||
String txAmount = params.get(Constants.URI_ARG_AMOUNT);
|
String txAmount = params.get(Constants.URI_ARG_AMOUNT);
|
||||||
if (txAmount == null) {
|
if (txAmount == null) {
|
||||||
|
|
|
@ -125,4 +125,6 @@
|
||||||
<string name="auth">[ auth ]</string>
|
<string name="auth">[ auth ]</string>
|
||||||
<string name="to">To</string>
|
<string name="to">To</string>
|
||||||
<string name="max_outputs_allowed">Maximum allowed outputs</string>
|
<string name="max_outputs_allowed">Maximum allowed outputs</string>
|
||||||
|
<string name="paymentid_paytomany">Cannot send to integrated addresses in a pay-to-many transaction</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue