Add basic churning feature with warning

not tested yet
This commit is contained in:
pokkst 2022-10-04 03:40:20 -05:00
parent 7268b07c6c
commit 67000bafa0
No known key found for this signature in database
GPG Key ID: 90C2ED85E67A50FF
5 changed files with 56 additions and 12 deletions

View File

@ -55,6 +55,7 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
}); });
public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction; public LiveData<PendingTransaction> pendingTransaction = _pendingTransaction;
public UriData uriData = null; public UriData uriData = null;
public boolean isChurning = false;
public PendingTransaction.Priority priority; public PendingTransaction.Priority priority;
private EditText addressEditText; private EditText addressEditText;
private EditText amountEditText; private EditText amountEditText;
@ -118,7 +119,11 @@ public class SendBottomSheetDialog extends BottomSheetDialogFragment {
String valueString = Wallet.getDisplayAmount(selectedValue); String valueString = Wallet.getDisplayAmount(selectedValue);
selectedUtxosValueTextView.setVisibility(View.VISIBLE); selectedUtxosValueTextView.setVisibility(View.VISIBLE);
selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value, valueString)); if(isChurning) {
selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value_churning, valueString));
} else {
selectedUtxosValueTextView.setText(getResources().getString(R.string.selected_utxos_value, valueString));
}
} else { } else {
selectedUtxosValueTextView.setVisibility(View.GONE); selectedUtxosValueTextView.setVisibility(View.GONE);
} }

View File

@ -17,7 +17,9 @@ import net.mynero.wallet.R;
import net.mynero.wallet.adapter.CoinsInfoAdapter; import net.mynero.wallet.adapter.CoinsInfoAdapter;
import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog; import net.mynero.wallet.fragment.dialog.SendBottomSheetDialog;
import net.mynero.wallet.model.CoinsInfo; import net.mynero.wallet.model.CoinsInfo;
import net.mynero.wallet.service.AddressService;
import net.mynero.wallet.service.UTXOService; import net.mynero.wallet.service.UTXOService;
import net.mynero.wallet.util.UriData;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -28,6 +30,7 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
private final ArrayList<String> selectedUtxos = new ArrayList<>(); private final ArrayList<String> selectedUtxos = new ArrayList<>();
private final CoinsInfoAdapter adapter = new CoinsInfoAdapter(this); private final CoinsInfoAdapter adapter = new CoinsInfoAdapter(this);
private Button sendUtxosButton; private Button sendUtxosButton;
private Button churnUtxosButton;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@ -45,12 +48,21 @@ public class UtxosFragment extends Fragment implements CoinsInfoAdapter.CoinsInf
private void bindListeners(View view) { private void bindListeners(View view) {
sendUtxosButton = view.findViewById(R.id.send_utxos_button); sendUtxosButton = view.findViewById(R.id.send_utxos_button);
churnUtxosButton = view.findViewById(R.id.churn_utxos_button);
sendUtxosButton.setVisibility(View.GONE); sendUtxosButton.setVisibility(View.GONE);
churnUtxosButton.setVisibility(View.GONE);
sendUtxosButton.setOnClickListener(view1 -> { sendUtxosButton.setOnClickListener(view1 -> {
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog(); SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
sendDialog.selectedUtxos = selectedUtxos; sendDialog.selectedUtxos = selectedUtxos;
sendDialog.show(getActivity().getSupportFragmentManager(), null); sendDialog.show(getActivity().getSupportFragmentManager(), null);
}); });
churnUtxosButton.setOnClickListener(view1 -> {
SendBottomSheetDialog sendDialog = new SendBottomSheetDialog();
sendDialog.isChurning = true;
sendDialog.uriData = UriData.parse(AddressService.getInstance().getLatestSubaddress().getAddress());
sendDialog.selectedUtxos = selectedUtxos;
sendDialog.show(getActivity().getSupportFragmentManager(), null);
});
} }
private void bindObservers(View view) { private void bindObservers(View view) {

View File

@ -110,7 +110,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/button_bg_left" android:background="@drawable/button_bg_left"
android:text="@string/receive" android:text="@string/receive"
android:layout_marginBottom="16dp" android:layout_marginBottom="24dp"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/send_button" app:layout_constraintEnd_toStartOf="@id/send_button"
@ -122,7 +122,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/button_bg_right" android:background="@drawable/button_bg_right"
android:text="@string/send" android:text="@string/send"
android:layout_marginBottom="16dp" android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"

View File

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="24dp"
tools:context="net.mynero.wallet.fragment.home.HomeFragment"> tools:context="net.mynero.wallet.fragment.home.HomeFragment">
<TextView <TextView
@ -14,6 +13,9 @@
android:text="@string/view_utxos" android:text="@string/view_utxos"
android:textSize="32sp" android:textSize="32sp"
android:textStyle="bold" android:textStyle="bold"
android:layout_marginTop="24dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@ -25,20 +27,43 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:clipToPadding="false" android:clipToPadding="false"
android:paddingBottom="128dp" android:paddingBottom="128dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
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/view_utxos_textview" app:layout_constraintTop_toBottomOf="@id/view_utxos_textview"
app:layout_constraintVertical_bias="0.0" /> app:layout_constraintVertical_bias="0.0" />
<Button <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/send_utxos_button" android:id="@+id/utxos_options_layout"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/button_bg" android:layout_marginStart="24dp"
android:visibility="gone" android:layout_marginEnd="24dp"
android:text="@string/send" android:layout_marginBottom="24dp"
tools:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:id="@+id/churn_utxos_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button_bg_left"
android:text="@string/churn"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/send_utxos_button"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/send_utxos_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/button_bg_right"
android:text="@string/send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/churn_utxos_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -94,7 +94,9 @@
<string name="high">High</string> <string name="high">High</string>
<string name="view_utxos">View UTXOs</string> <string name="view_utxos">View UTXOs</string>
<string name="selected_utxos_value">Selected value: %1$s XMR</string> <string name="selected_utxos_value">Selected value: %1$s XMR</string>
<string name="selected_utxos_value_churning">Selected value: %1$s XMR\n\nThe anonymity benefits of churning are still being researched. Only proceed if you know what you are doing.</string>
<string name="global_index_text">Global Idx: %1$d</string> <string name="global_index_text">Global Idx: %1$d</string>
<string name="outpoint_text">Outpoint: %1$s</string> <string name="outpoint_text">Outpoint: %1$s</string>
<string name="create_wallet_failed">Create wallet failed: %1$s</string> <string name="create_wallet_failed">Create wallet failed: %1$s</string>
<string name="churn">Churn</string>
</resources> </resources>