Verified Commit 942b825b authored by Sarath's avatar Sarath
Browse files

Save payload after blocking utxos

parent fdbdab86
......@@ -2,20 +2,35 @@ package com.samourai.wallet;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.samourai.wallet.access.AccessFactory;
import com.samourai.wallet.payload.PayloadUtil;
import com.samourai.wallet.send.BlockedUTXO;
import com.samourai.wallet.util.CharSequenceX;
import com.samourai.wallet.util.LogUtil;
import com.samourai.wallet.util.TimeOutUtil;
import com.samourai.wallet.whirlpool.WhirlpoolMeta;
import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
@SuppressLint("Registered")
public class SamouraiActivity extends AppCompatActivity {
protected int account = 0;
private boolean switchThemes = false;
private CompositeDisposable compositeDisposable = new CompositeDisposable();
private static final String TAG = "SamouraiActivity";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -34,6 +49,29 @@ public class SamouraiActivity extends AppCompatActivity {
}
}
protected void saveState() {
if(TimeOutUtil.getInstance().isTimedOut()){
return;
}
Disposable disposable = Observable.fromCallable(() -> {
PayloadUtil.getInstance(getApplicationContext()).saveWalletToJSON(new CharSequenceX(AccessFactory.getInstance(getApplicationContext()).getGUID() + AccessFactory.getInstance(getApplicationContext()).getPIN()));
return true;
}) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe((aBoolean) -> {
},throwable -> {
LogUtil.error(TAG,throwable);
});
compositeDisposable.add(disposable);
}
@Override
protected void onDestroy() {
compositeDisposable.dispose();
super.onDestroy();
}
public void setSwitchThemes(boolean switchThemes) {
this.switchThemes = switchThemes;
}
......
......@@ -282,7 +282,7 @@ public class BalanceActivity extends SamouraiActivity {
else {
BlockedUTXO.getInstance().add(hash, idx, amount);
}
saveState();
}
}).setNegativeButton(R.string.dusting_attempt_ignore, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
......
......@@ -38,6 +38,12 @@ public class LogUtil {
message.printStackTrace();
}
}
public static void error(final String tag, Throwable message) {
if (BuildConfig.DEBUG) {
android.util.Log.e(tag, Objects.requireNonNull(message.getMessage()));
message.printStackTrace();
}
}
public static void setLoggersDebug() {
// skip noisy logs
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment