From c3a466c3927d1071626b235e9cee967696797ded Mon Sep 17 00:00:00 2001 From: m2049r Date: Sun, 24 Nov 2019 17:17:25 +0100 Subject: [PATCH] remove payment id everywhere (#646) --- .../m2049r/xmrwallet/data/BarcodeData.java | 38 +++------ .../com/m2049r/xmrwallet/data/TxData.java | 18 +--- .../send/SendAddressWizardFragment.java | 83 +------------------ .../send/SendBtcSuccessWizardFragment.java | 6 -- .../send/SendConfirmWizardFragment.java | 8 -- .../send/SendSuccessWizardFragment.java | 6 -- .../com/m2049r/xmrwallet/model/Wallet.java | 7 +- .../main/res/layout/fragment_send_address.xml | 44 ---------- .../main/res/layout/fragment_send_amount.xml | 1 - .../res/layout/fragment_send_btc_success.xml | 21 ----- .../main/res/layout/fragment_send_confirm.xml | 23 ----- .../main/res/layout/fragment_send_success.xml | 26 +----- 12 files changed, 20 insertions(+), 261 deletions(-) diff --git a/app/src/main/java/com/m2049r/xmrwallet/data/BarcodeData.java b/app/src/main/java/com/m2049r/xmrwallet/data/BarcodeData.java index 7cf5a10e..ae826414 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/data/BarcodeData.java +++ b/app/src/main/java/com/m2049r/xmrwallet/data/BarcodeData.java @@ -59,42 +59,36 @@ public class BarcodeData { final public Asset asset; final public String address; final public String addressName; - final public String paymentId; final public String amount; final public String description; final public Security security; final public String bip70; public BarcodeData(Asset asset, String address) { - this(asset, address, null, null, null, null, Security.NORMAL); + this(asset, address, null, null, null, Security.NORMAL); } public BarcodeData(Asset asset, String address, String amount) { - this(asset, address, null, null, null, amount, Security.NORMAL); + this(asset, address, null, null, amount, Security.NORMAL); } public BarcodeData(Asset asset, String address, String amount, String description, Security security) { - this(asset, address, null, null, description, amount, security); - } - - public BarcodeData(Asset asset, String address, String paymentId, String amount) { - this(asset, address, null, paymentId, null, amount, Security.NORMAL); + this(asset, address, null, description, amount, security); } public BarcodeData(Asset asset, String address, String paymentId, String description, String amount) { - this(asset, address, null, paymentId, description, amount, Security.NORMAL); + this(asset, address, null, description, amount, Security.NORMAL); } - public BarcodeData(Asset asset, String address, String addressName, String paymentId, String description, String amount, Security security) { - this(asset, address, addressName, null, paymentId, description, amount, security); + public BarcodeData(Asset asset, String address, String addressName, String description, String amount, Security security) { + this(asset, address, addressName, null, description, amount, security); } - public BarcodeData(Asset asset, String address, String addressName, String bip70, String paymentId, String description, String amount, Security security) { + public BarcodeData(Asset asset, String address, String addressName, String bip70, String description, String amount, Security security) { this.asset = asset; this.address = address; this.bip70 = bip70; this.addressName = addressName; - this.paymentId = paymentId; this.description = description; this.amount = amount; this.security = security; @@ -110,11 +104,6 @@ public class BarcodeData { StringBuilder sb = new StringBuilder(); sb.append(BarcodeData.XMR_SCHEME).append(address); boolean first = true; - if ((paymentId != null) && !paymentId.isEmpty()) { - sb.append("?"); - first = false; - sb.append(BarcodeData.XMR_PAYMENTID).append('=').append(paymentId); - } if ((description != null) && !description.isEmpty()) { sb.append(first ? "?" : "&"); first = false; @@ -185,8 +174,11 @@ public class BarcodeData { String address = monero.getPath(); String paymentId = parms.get(XMR_PAYMENTID); - // deal with empty payment_id created by non-spec-conforming apps - if ((paymentId != null) && paymentId.isEmpty()) paymentId = null; + // no support for payment ids! + if (paymentId != null) { + Timber.e("no support for payment ids!"); + return null; + } String description = parms.get(XMR_DESCRIPTION); String amount = parms.get(XMR_AMOUNT); @@ -198,10 +190,6 @@ public class BarcodeData { return null; // we have an amount but its not a number! } } - if ((paymentId != null) && !Wallet.isPaymentIdValid(paymentId)) { - Timber.d("paymentId invalid"); - return null; - } if (!Wallet.isAddressValid(address)) { Timber.d("address invalid"); @@ -267,7 +255,7 @@ public class BarcodeData { Timber.d("[%s] is not http url", bip70); return null; } - return new BarcodeData(BarcodeData.Asset.BTC, null, null, bip70, null, description, null, Security.NORMAL); + return new BarcodeData(BarcodeData.Asset.BTC, null, null, bip70, description, null, Security.NORMAL); } if (!BitcoinAddressValidator.validate(address)) { Timber.d("BTC address (%s) invalid", address); diff --git a/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java b/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java index 3391c3af..6e0c3a2e 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java +++ b/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java @@ -29,19 +29,16 @@ public class TxData implements Parcelable { public TxData(TxData txData) { this.dstAddr = txData.dstAddr; - this.paymentId = txData.paymentId; this.amount = txData.amount; this.mixin = txData.mixin; this.priority = txData.priority; } public TxData(String dstAddr, - String paymentId, long amount, int mixin, PendingTransaction.Priority priority) { this.dstAddr = dstAddr; - this.paymentId = paymentId; this.amount = amount; this.mixin = mixin; this.priority = priority; @@ -51,10 +48,6 @@ public class TxData implements Parcelable { return dstAddr; } - public String getPaymentId() { - return paymentId; - } - public long getAmount() { return amount; } @@ -71,10 +64,6 @@ public class TxData implements Parcelable { this.dstAddr = dstAddr; } - public void setPaymentId(String paymentId) { - this.paymentId = paymentId; - } - public void setAmount(long amount) { this.amount = amount; } @@ -96,7 +85,6 @@ public class TxData implements Parcelable { } private String dstAddr; - private String paymentId; private long amount; private int mixin; private PendingTransaction.Priority priority; @@ -106,7 +94,6 @@ public class TxData implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeString(dstAddr); - out.writeString(paymentId); out.writeLong(amount); out.writeInt(mixin); out.writeInt(priority.getValue()); @@ -125,7 +112,6 @@ public class TxData implements Parcelable { protected TxData(Parcel in) { dstAddr = in.readString(); - paymentId = in.readString(); amount = in.readLong(); mixin = in.readInt(); priority = PendingTransaction.Priority.fromInteger(in.readInt()); @@ -142,14 +128,12 @@ public class TxData implements Parcelable { StringBuffer sb = new StringBuffer(); sb.append("dstAddr:"); sb.append(dstAddr); - sb.append(",paymentId:"); - sb.append(paymentId); sb.append(",amount:"); sb.append(amount); sb.append(",mixin:"); sb.append(mixin); sb.append(",priority:"); - sb.append(String.valueOf(priority)); + sb.append(priority); return sb.toString(); } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java index 98edc0a9..65165891 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAddressWizardFragment.java @@ -31,7 +31,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; -import android.widget.Button; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; @@ -86,12 +85,9 @@ public class SendAddressWizardFragment extends SendWizardFragment { private EditText etDummy; private TextInputLayout etAddress; - private TextInputLayout etPaymentId; private TextInputLayout etNotes; - private Button bPaymentId; private CardView cvScan; private View tvPaymentIdIntegrated; - private View llPaymentId; private TextView tvXmrTo; private View llXmrTo; private ImageButton bPasteAddress; @@ -114,7 +110,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { View view = inflater.inflate(R.layout.fragment_send_address, container, false); tvPaymentIdIntegrated = view.findViewById(R.id.tvPaymentIdIntegrated); - llPaymentId = view.findViewById(R.id.llPaymentId); llXmrTo = view.findViewById(R.id.llXmrTo); tvXmrTo = view.findViewById(R.id.tvXmrTo); tvXmrTo.setText(Html.fromHtml(getString(R.string.info_xmrto))); @@ -158,8 +153,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { etAddress.setError(null); if (isIntegratedAddress()) { Timber.d("isIntegratedAddress"); - etPaymentId.getEditText().getText().clear(); - llPaymentId.setVisibility(View.INVISIBLE); etAddress.setError(getString(R.string.info_paymentid_integrated)); tvPaymentIdIntegrated.setVisibility(View.VISIBLE); llXmrTo.setVisibility(View.INVISIBLE); @@ -169,7 +162,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { setBtcMode(); } else { Timber.d("isStandardAddress or other"); - llPaymentId.setVisibility(View.VISIBLE); tvPaymentIdIntegrated.setVisibility(View.INVISIBLE); llXmrTo.setVisibility(View.INVISIBLE); sendListener.setMode(SendFragment.Mode.XMR); @@ -211,46 +203,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { } }); - etPaymentId = view.findViewById(R.id.etPaymentId); - etPaymentId.getEditText().setRawInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - etPaymentId.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && (event.getAction() == KeyEvent.ACTION_DOWN)) - || (actionId == EditorInfo.IME_ACTION_NEXT)) { - if (checkPaymentId()) { - etNotes.requestFocus(); - } - return true; - } - return false; - } - }); - etPaymentId.getEditText().addTextChangedListener(new TextWatcher() { - @Override - public void afterTextChanged(Editable editable) { - etPaymentId.setError(null); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - }); - - bPaymentId = view.findViewById(R.id.bPaymentId); - bPaymentId.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final EditText et = etPaymentId.getEditText(); - et.setText((Wallet.generatePaymentId())); - et.setSelection(et.getText().length()); - etPaymentId.requestFocus(); - } - }); - etNotes = view.findViewById(R.id.etNotes); etNotes.getEditText().setRawInputType(InputType.TYPE_CLASS_TEXT); etNotes.getEditText().setOnEditorActionListener(new TextView.OnEditorActionListener() { @@ -286,8 +238,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { private void setBtcMode() { Timber.d("setBtcMode"); - etPaymentId.getEditText().getText().clear(); - llPaymentId.setVisibility(View.INVISIBLE); tvPaymentIdIntegrated.setVisibility(View.INVISIBLE); llXmrTo.setVisibility(View.VISIBLE); sendListener.setMode(SendFragment.Mode.BTC); @@ -342,7 +292,7 @@ public class SendAddressWizardFragment extends SendWizardFragment { final BarcodeData barcodeData = new BarcodeData(BarcodeData.Asset.BTC, address, null, - resolvedBip70, null, null, String.valueOf(amount), + resolvedBip70, null, String.valueOf(amount), BarcodeData.Security.BIP70); etNotes.post(new Runnable() { @Override @@ -403,22 +353,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { return BitcoinAddressValidator.validate(address); } - private boolean checkPaymentId() { - String paymentId = etPaymentId.getEditText().getText().toString(); - boolean ok = paymentId.isEmpty() || Wallet.isPaymentIdValid(paymentId); - if (!ok) { - etPaymentId.setError(getString(R.string.receive_paymentid_invalid)); - } else { - if (!paymentId.isEmpty() && isIntegratedAddress()) { - ok = false; - etPaymentId.setError(getString(R.string.receive_integrated_paymentid_invalid)); - } else { - etPaymentId.setError(null); - } - } - return ok; - } - private void shakeAddress() { etAddress.startAnimation(Helper.getShakeAnimation(getContext())); } @@ -441,11 +375,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { return false; } - if (!checkPaymentId()) { - etPaymentId.startAnimation(Helper.getShakeAnimation(getContext())); - return false; - } - if (sendListener != null) { TxData txData = sendListener.getTxData(); if (txData instanceof TxDataBtc) { @@ -459,10 +388,8 @@ public class SendAddressWizardFragment extends SendWizardFragment { ((TxDataBtc) txData).setBip70(null); } txData.setDestinationAddress(null); - txData.setPaymentId(""); } else { txData.setDestinationAddress(etAddress.getEditText().getText().toString()); - txData.setPaymentId(etPaymentId.getEditText().getText().toString()); } txData.setUserNotes(new UserNotes(etNotes.getEditText().getText().toString())); txData.setPriority(PendingTransaction.Priority.Priority_Default); @@ -525,14 +452,6 @@ public class SendAddressWizardFragment extends SendWizardFragment { etAddress.setError(null); } - String scannedPaymentId = barcodeData.paymentId; - if (scannedPaymentId != null) { - etPaymentId.getEditText().setText(scannedPaymentId); - checkPaymentId(); - } else { - etPaymentId.getEditText().getText().clear(); - etPaymentId.setError(null); - } String scannedNotes = barcodeData.description; if (scannedNotes != null) { etNotes.getEditText().setText(scannedNotes); diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcSuccessWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcSuccessWizardFragment.java index fc698b42..af4bc081 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcSuccessWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcSuccessWizardFragment.java @@ -138,12 +138,6 @@ public class SendBtcSuccessWizardFragment extends SendWizardFragment { btcData = (TxDataBtc) sendListener.getTxData(); tvTxAddress.setText(btcData.getDestinationAddress()); - String paymentId = btcData.getPaymentId(); - if ((paymentId != null) && (!paymentId.isEmpty())) { - tvTxPaymentId.setText(btcData.getPaymentId()); - } else { - tvTxPaymentId.setText("-"); - } final PendingTx committedTx = sendListener.getCommittedTx(); if (committedTx != null) { diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendConfirmWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendConfirmWizardFragment.java index cd0b1e16..e92cf25f 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendConfirmWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendConfirmWizardFragment.java @@ -70,7 +70,6 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen } private TextView tvTxAddress; - private TextView tvTxPaymentId; private TextView tvTxNotes; private TextView tvTxAmount; private TextView tvTxFee; @@ -90,7 +89,6 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen R.layout.fragment_send_confirm, container, false); tvTxAddress = view.findViewById(R.id.tvTxAddress); - tvTxPaymentId = view.findViewById(R.id.tvTxPaymentId); tvTxNotes = view.findViewById(R.id.tvTxNotes); tvTxAmount = view.findViewById(R.id.tvTxAmount); tvTxFee = view.findViewById(R.id.tvTxFee); @@ -192,12 +190,6 @@ public class SendConfirmWizardFragment extends SendWizardFragment implements Sen final TxData txData = sendListener.getTxData(); tvTxAddress.setText(txData.getDestinationAddress()); - String paymentId = txData.getPaymentId(); - if ((paymentId != null) && (!paymentId.isEmpty())) { - tvTxPaymentId.setText(txData.getPaymentId()); - } else { - tvTxPaymentId.setText("-"); - } UserNotes notes = sendListener.getTxData().getUserNotes(); if ((notes != null) && (!notes.note.isEmpty())) { tvTxNotes.setText(notes.note); diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendSuccessWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendSuccessWizardFragment.java index 1c34e086..f5c8fb6e 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendSuccessWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendSuccessWizardFragment.java @@ -111,12 +111,6 @@ public class SendSuccessWizardFragment extends SendWizardFragment { final TxData txData = sendListener.getTxData(); tvTxAddress.setText(txData.getDestinationAddress()); - String paymentId = txData.getPaymentId(); - if ((paymentId != null) && (!paymentId.isEmpty())) { - tvTxPaymentId.setText(txData.getPaymentId()); - } else { - tvTxPaymentId.setText("-"); - } final PendingTx committedTx = sendListener.getCommittedTx(); if (committedTx != null) { diff --git a/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java b/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java index 78126058..ec9f80e9 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java +++ b/app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java @@ -298,22 +298,21 @@ public class Wallet { public PendingTransaction createTransaction(TxData txData) { return createTransaction( txData.getDestinationAddress(), - txData.getPaymentId(), txData.getAmount(), txData.getMixin(), txData.getPriority()); } - public PendingTransaction createTransaction(String dst_addr, String payment_id, + public PendingTransaction createTransaction(String dst_addr, long amount, int mixin_count, PendingTransaction.Priority priority) { disposePendingTransaction(); int _priority = priority.getValue(); long txHandle = (amount == SWEEP_ALL ? - createSweepTransaction(dst_addr, payment_id, mixin_count, _priority, + createSweepTransaction(dst_addr, "", mixin_count, _priority, accountIndex) : - createTransactionJ(dst_addr, payment_id, amount, mixin_count, _priority, + createTransactionJ(dst_addr, "", amount, mixin_count, _priority, accountIndex)); pendingTransaction = new PendingTransaction(txHandle); return pendingTransaction; diff --git a/app/src/main/res/layout/fragment_send_address.xml b/app/src/main/res/layout/fragment_send_address.xml index 5f9bd56c..554ffcec 100644 --- a/app/src/main/res/layout/fragment_send_address.xml +++ b/app/src/main/res/layout/fragment_send_address.xml @@ -108,50 +108,6 @@ android:textSize="18sp" tools:text="@string/info_xmrto" /> - - - - - - - - -