mirror of https://github.com/m2049r/xmrwallet.git
tweaks + sweep
This commit is contained in:
parent
408b1a68d0
commit
a37ca4c0e5
|
@ -773,7 +773,12 @@ Java_com_m2049r_xmrwallet_model_Wallet_createTransactionJ(JNIEnv *env, jobject i
|
||||||
return reinterpret_cast<jlong>(tx);
|
return reinterpret_cast<jlong>(tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//virtual PendingTransaction * createSweepUnmixableTransaction() = 0;
|
JNIEXPORT jlong JNICALL
|
||||||
|
Java_com_m2049r_xmrwallet_model_Wallet_createSweepUnmixableTransactionJ(JNIEnv *env, jobject instance) {
|
||||||
|
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
|
||||||
|
Bitmonero::PendingTransaction *tx = wallet->createSweepUnmixableTransaction();
|
||||||
|
return reinterpret_cast<jlong>(tx);
|
||||||
|
}
|
||||||
|
|
||||||
//virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) = 0;
|
//virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) = 0;
|
||||||
//virtual bool submitTransaction(const std::string &fileName) = 0;
|
//virtual bool submitTransaction(const std::string &fileName) = 0;
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class SendFragment extends Fragment {
|
||||||
Spinner sMixin;
|
Spinner sMixin;
|
||||||
Spinner sPriority;
|
Spinner sPriority;
|
||||||
Button bPrepareSend;
|
Button bPrepareSend;
|
||||||
|
Button bPaymentId;
|
||||||
LinearLayout llConfirmSend;
|
LinearLayout llConfirmSend;
|
||||||
TextView tvTxAmount;
|
TextView tvTxAmount;
|
||||||
TextView tvTxFee;
|
TextView tvTxFee;
|
||||||
|
@ -77,6 +78,7 @@ public class SendFragment extends Fragment {
|
||||||
etAmount = (EditText) view.findViewById(R.id.etAmount);
|
etAmount = (EditText) view.findViewById(R.id.etAmount);
|
||||||
bSweep = (Button) view.findViewById(R.id.bSweep);
|
bSweep = (Button) view.findViewById(R.id.bSweep);
|
||||||
bPrepareSend = (Button) view.findViewById(R.id.bPrepareSend);
|
bPrepareSend = (Button) view.findViewById(R.id.bPrepareSend);
|
||||||
|
bPaymentId = (Button) view.findViewById(R.id.bPaymentId);
|
||||||
|
|
||||||
llConfirmSend = (LinearLayout) view.findViewById(R.id.llConfirmSend);
|
llConfirmSend = (LinearLayout) view.findViewById(R.id.llConfirmSend);
|
||||||
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
|
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
|
||||||
|
@ -177,6 +179,22 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bPaymentId.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
etPaymentId.setText((activityCallback.generatePaymentId()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bSweep.setOnClickListener(new View.OnClickListener()
|
||||||
|
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Helper.hideKeyboard(getActivity());
|
||||||
|
prepareSweep();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bSend.setOnClickListener(new View.OnClickListener()
|
bSend.setOnClickListener(new View.OnClickListener()
|
||||||
|
|
||||||
|
@ -212,8 +230,8 @@ public class SendFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean paymentIdOk() {
|
private boolean paymentIdOk() {
|
||||||
String spendKey = etPaymentId.getText().toString();
|
String paymentId = etPaymentId.getText().toString();
|
||||||
return ((spendKey.length() == 0) || ((spendKey.length() == 64) && (spendKey.matches("^[0-9a-fA-F]+$"))));
|
return paymentId.isEmpty() || activityCallback.isPaymentIdValid(paymentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareSend() {
|
private void prepareSend() {
|
||||||
|
@ -236,12 +254,22 @@ public class SendFragment extends Fragment {
|
||||||
activityCallback.onPrepareSend(txData);
|
activityCallback.onPrepareSend(txData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void prepareSweep() {
|
||||||
|
etAddress.setText(activityCallback.getWalletAddress());
|
||||||
|
etPaymentId.setText("");
|
||||||
|
etAmount.setText("");
|
||||||
|
disableEdit();
|
||||||
|
showProgress();
|
||||||
|
activityCallback.onPrepareSweep();
|
||||||
|
}
|
||||||
|
|
||||||
private void disableEdit() {
|
private void disableEdit() {
|
||||||
sMixin.setEnabled(false);
|
sMixin.setEnabled(false);
|
||||||
sPriority.setEnabled(false);
|
sPriority.setEnabled(false);
|
||||||
etAddress.setEnabled(false);
|
etAddress.setEnabled(false);
|
||||||
etPaymentId.setEnabled(false);
|
etPaymentId.setEnabled(false);
|
||||||
etAmount.setEnabled(false);
|
etAmount.setEnabled(false);
|
||||||
|
bPaymentId.setEnabled(false);
|
||||||
bSweep.setEnabled(false);
|
bSweep.setEnabled(false);
|
||||||
bPrepareSend.setEnabled(false);
|
bPrepareSend.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -252,11 +280,13 @@ public class SendFragment extends Fragment {
|
||||||
etAddress.setEnabled(true);
|
etAddress.setEnabled(true);
|
||||||
etPaymentId.setEnabled(true);
|
etPaymentId.setEnabled(true);
|
||||||
etAmount.setEnabled(true);
|
etAmount.setEnabled(true);
|
||||||
|
bPaymentId.setEnabled(true);
|
||||||
bSweep.setEnabled(true);
|
bSweep.setEnabled(true);
|
||||||
bPrepareSend.setEnabled(true);
|
bPrepareSend.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send() {
|
private void send() {
|
||||||
|
disableEdit(); // prevent this being sent more than once
|
||||||
activityCallback.onSend();
|
activityCallback.onSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +295,16 @@ public class SendFragment extends Fragment {
|
||||||
public interface Listener {
|
public interface Listener {
|
||||||
void onPrepareSend(TxData data);
|
void onPrepareSend(TxData data);
|
||||||
|
|
||||||
|
void onPrepareSweep();
|
||||||
|
|
||||||
void onSend();
|
void onSend();
|
||||||
|
|
||||||
|
String generatePaymentId();
|
||||||
|
|
||||||
|
boolean isPaymentIdValid(String paymentId);
|
||||||
|
|
||||||
|
String getWalletAddress();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,7 +66,6 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
Log.d(TAG, "onStart()");
|
Log.d(TAG, "onStart()");
|
||||||
this.synced = false; // init syncing logic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startWalletService() {
|
private void startWalletService() {
|
||||||
|
@ -137,6 +136,13 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
||||||
mBoundService = ((WalletService.WalletServiceBinder) service).getService();
|
mBoundService = ((WalletService.WalletServiceBinder) service).getService();
|
||||||
//Log.d(TAG, "setting observer of " + mBoundService);
|
//Log.d(TAG, "setting observer of " + mBoundService);
|
||||||
mBoundService.setObserver(WalletActivity.this);
|
mBoundService.setObserver(WalletActivity.this);
|
||||||
|
Bundle extras = getIntent().getExtras();
|
||||||
|
if (extras != null) {
|
||||||
|
String walletId = extras.getString(REQUEST_ID);
|
||||||
|
if (walletId != null) {
|
||||||
|
setTitle(walletId);
|
||||||
|
}
|
||||||
|
}
|
||||||
updateProgress();
|
updateProgress();
|
||||||
//TODO show current pbProgress (eg. if the service is already busy saving last wallet)
|
//TODO show current pbProgress (eg. if the service is already busy saving last wallet)
|
||||||
Log.d(TAG, "CONNECTED");
|
Log.d(TAG, "CONNECTED");
|
||||||
|
@ -421,6 +427,33 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrepareSweep() {
|
||||||
|
if (mIsBound) { // no point in talking to unbound service
|
||||||
|
Intent intent = new Intent(getApplicationContext(), WalletService.class);
|
||||||
|
intent.putExtra(WalletService.REQUEST, WalletService.REQUEST_CMD_SWEEP);
|
||||||
|
startService(intent);
|
||||||
|
Log.d(TAG, "SWEEP TX request sent");
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Service not bound");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generatePaymentId() {
|
||||||
|
return getWallet().generatePaymentId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPaymentIdValid(String paymentId) {
|
||||||
|
return getWallet().isPaymentIdValid(paymentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWalletAddress() {
|
||||||
|
return getWallet().getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
void popFragmentStack(String name) {
|
void popFragmentStack(String name) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
getFragmentManager().popBackStack();
|
getFragmentManager().popBackStack();
|
||||||
|
|
|
@ -106,7 +106,9 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
builder.setTitle("Transaction details");
|
builder.setTitle("Transaction details");
|
||||||
|
|
||||||
|
if (infoItem.txKey == null) {
|
||||||
infoItem.txKey = activityCallback.getTxKey(infoItem.hash);
|
infoItem.txKey = activityCallback.getTxKey(infoItem.hash);
|
||||||
|
}
|
||||||
|
|
||||||
builder.setPositiveButton("Copy TX ID", new DialogInterface.OnClickListener() {
|
builder.setPositiveButton("Copy TX ID", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class TransactionInfo {
|
||||||
public long confirmations;
|
public long confirmations;
|
||||||
public List<Transfer> transfers;
|
public List<Transfer> transfers;
|
||||||
|
|
||||||
public String txKey;
|
public String txKey = null;
|
||||||
|
|
||||||
public TransactionInfo(
|
public TransactionInfo(
|
||||||
int direction,
|
int direction,
|
||||||
|
|
|
@ -188,7 +188,15 @@ public class Wallet {
|
||||||
long mount, int mixin_count,
|
long mount, int mixin_count,
|
||||||
PendingTransaction.Priority priority);
|
PendingTransaction.Priority priority);
|
||||||
|
|
||||||
//virtual PendingTransaction * createSweepUnmixableTransaction() = 0;
|
|
||||||
|
public PendingTransaction createSweepUnmixableTransaction() {
|
||||||
|
disposePendingTransaction();
|
||||||
|
long txHandle = createSweepUnmixableTransactionJ();
|
||||||
|
pendingTransaction = new PendingTransaction(txHandle);
|
||||||
|
return pendingTransaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private native long createSweepUnmixableTransactionJ();
|
||||||
|
|
||||||
//virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) = 0;
|
//virtual UnsignedTransaction * loadUnsignedTx(const std::string &unsigned_filename) = 0;
|
||||||
//virtual bool submitTransaction(const std::string &fileName) = 0;
|
//virtual bool submitTransaction(const std::string &fileName) = 0;
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class WalletService extends Service {
|
||||||
public static final String REQUEST_CMD_TX = "createTX";
|
public static final String REQUEST_CMD_TX = "createTX";
|
||||||
public static final String REQUEST_CMD_TX_DATA = "data";
|
public static final String REQUEST_CMD_TX_DATA = "data";
|
||||||
|
|
||||||
|
public static final String REQUEST_CMD_SWEEP = "sweepTX";
|
||||||
|
|
||||||
public static final String REQUEST_CMD_SEND = "send";
|
public static final String REQUEST_CMD_SEND = "send";
|
||||||
|
|
||||||
public static final int START_SERVICE = 1;
|
public static final int START_SERVICE = 1;
|
||||||
|
@ -295,6 +297,20 @@ public class WalletService extends Service {
|
||||||
} else {
|
} else {
|
||||||
myWallet.disposePendingTransaction();
|
myWallet.disposePendingTransaction();
|
||||||
}
|
}
|
||||||
|
} else if (cmd.equals(REQUEST_CMD_SWEEP)) {
|
||||||
|
Wallet myWallet = getWallet();
|
||||||
|
Log.d(TAG, "SWEEP TX for wallet: " + myWallet.getName());
|
||||||
|
PendingTransaction pendingTransaction = myWallet.createSweepUnmixableTransaction();
|
||||||
|
PendingTransaction.Status status = pendingTransaction.getStatus();
|
||||||
|
Log.d(TAG, "transaction status " + status);
|
||||||
|
if (status != PendingTransaction.Status.Status_Ok) {
|
||||||
|
Log.d(TAG, "Create Transaction failed: " + pendingTransaction.getErrorString());
|
||||||
|
}
|
||||||
|
if (observer != null) {
|
||||||
|
observer.onCreatedTransaction(pendingTransaction);
|
||||||
|
} else {
|
||||||
|
myWallet.disposePendingTransaction();
|
||||||
|
}
|
||||||
} else if (cmd.equals(REQUEST_CMD_SEND)) {
|
} else if (cmd.equals(REQUEST_CMD_SEND)) {
|
||||||
Wallet myWallet = getWallet();
|
Wallet myWallet = getWallet();
|
||||||
Log.d(TAG, "SEND TX for wallet: " + myWallet.getName());
|
Log.d(TAG, "SEND TX for wallet: " + myWallet.getName());
|
||||||
|
|
|
@ -158,4 +158,42 @@
|
||||||
android:text="@string/generate_button_accept"
|
android:text="@string/generate_button_accept"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/llFunctions"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:background="@color/colorPrimary" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bBackup"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:background="@color/colorPrimaryDark"
|
||||||
|
android:text="@string/generate_button_backup" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bExport"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:background="@color/colorPrimaryDark"
|
||||||
|
android:text="@string/generate_button_export" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bDelete"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:background="@color/colorAccent"
|
||||||
|
android:text="@string/generate_button_delete" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -63,7 +63,8 @@
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:enabled="false"
|
android:enabled="true"
|
||||||
|
android:textSize="12sp"
|
||||||
android:text="@string/send_generate_paymentid_hint" />
|
android:text="@string/send_generate_paymentid_hint" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_weight="2"
|
android:layout_weight="2"
|
||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:enabled="false"
|
android:enabled="true"
|
||||||
android:text="@string/send_sweep_hint" />
|
android:text="@string/send_sweep_hint" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@
|
||||||
<string name="generate_seed">Mnemonic Seed</string>
|
<string name="generate_seed">Mnemonic Seed</string>
|
||||||
<string name="generate_button_accept">I have noted the above\nNow, I want to loose all my money!</string>
|
<string name="generate_button_accept">I have noted the above\nNow, I want to loose all my money!</string>
|
||||||
|
|
||||||
|
<string name="generate_button_backup">Backup</string>
|
||||||
|
<string name="generate_button_export">Export Keys</string>
|
||||||
|
<string name="generate_button_delete">DELETE</string>
|
||||||
|
|
||||||
<string name="generate_wallet_watchonly"><Watch Only Wallet></string>
|
<string name="generate_wallet_watchonly"><Watch Only Wallet></string>
|
||||||
|
|
||||||
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
||||||
|
|
Loading…
Reference in New Issue