Skip to content

Commit

Permalink
Add a signing nonce in settings so users can increase or decrease its…
Browse files Browse the repository at this point in the history
… value if signing takes too long.

the sweet value seems to be 51, you can change it if your device takes too long to sign a transaction.
  • Loading branch information
hispeedimagins committed Aug 3, 2018
1 parent 94dc623 commit a56d663
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.SharedPreferences
import android.opengl.Visibility
import android.os.AsyncTask
import android.preference.PreferenceManager
import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.text.format.DateUtils
Expand Down Expand Up @@ -74,6 +75,7 @@ class GetDynamicAndBlock(context: Context, adapter: arvdinterface?, position : I
val sharedpref : SharedPreferences = applicationContext.getSharedPreferences(CentralConstants.sharedprefname,0)
//var username = sharedpref.getString(CentralConstants.username,null)
var key = sharedpref.getString(CentralConstants.key,null)
var signingnonce = PreferenceManager.getDefaultSharedPreferences(context).getString("signing_nonce","51").toInt()
//var accountrep = if(CentralConstantsOfSteem.getInstance() != null && CentralConstantsOfSteem.getInstance().profile != null) CentralConstantsOfSteem.getInstance()?.profile?.reputation else sharedpref.getString(CentralConstants.accountrep,null)
/*val listner = listner*/
val toastString = toastString
Expand Down Expand Up @@ -458,6 +460,7 @@ class GetDynamicAndBlock(context: Context, adapter: arvdinterface?, position : I
key = sharedpref.getString(CentralConstants.key,null)
}
Log.i("startingsignmaasy", "mainasync pre")
Log.d("startsigningback","nonce is $signingnonce")
//useIfOne++;
}

Expand All @@ -467,7 +470,7 @@ class GetDynamicAndBlock(context: Context, adapter: arvdinterface?, position : I
try {

//params[0].signedtra.sign(ImmutablePair(PrivateKeyType.POSTING,key))
params[0].signedtra.signMy(SteemJConfig.getInstance().getChainId(), ImmutablePair(PrivateKeyType.POSTING,params[0].key))
params[0].signedtra.signMy(SteemJConfig.getInstance().getChainId(), ImmutablePair(PrivateKeyType.POSTING,params[0].key),signingnonce)
} catch (e: InterruptedException) {


Expand Down
Expand Up @@ -195,7 +195,7 @@ public void sign(String chainId,ImmutablePair<PrivateKeyType, String> keys) {



public void signMy(String chainId,ImmutablePair<PrivateKeyType, String> keys) {
public void signMy(String chainId,ImmutablePair<PrivateKeyType, String> keys,int signingnonce) {
/*if (!SteemJConfig.getInstance().getValidationLevel().equals(ValidationType.SKIP_VALIDATION)) {
this.validate();
}*///getRequiredSignatureKeys()
Expand All @@ -222,7 +222,7 @@ public void signMy(String chainId,ImmutablePair<PrivateKeyType, String> keys) {

if (isCanonical(signatureAsByteArray)) {
nonce++;
this.getExpirationDate().setDateTime(this.getExpirationDate().getDateTimeAsTimestamp() + 31);
this.getExpirationDate().setDateTime(this.getExpirationDate().getDateTimeAsTimestamp() + signingnonce);
Log.d("nonce",String.valueOf(nonce));
//nonce++;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Expand Up @@ -44,7 +44,7 @@
<string name="pref_Notifications_description">Deliver notifications to your device
</string>

<string name="pref_title_display_name">Display name</string>
<string name="pref_title_display_name">Signing nonce</string>
<string name="pref_default_display_name">John Smith</string>

<string name="pref_theme_title">Theme</string>
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/res/xml/pref_general.xml
Expand Up @@ -9,15 +9,14 @@

<!-- NOTE: EditTextPreference accepts EditText attributes. -->
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
<!-- <EditTextPreference
android:capitalize="words"
android:defaultValue="@string/pref_default_display_name"
android:inputType="textCapWords"
android:key="example_text"
<EditTextPreference
android:defaultValue="51"
android:inputType="number"
android:key="signing_nonce"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/pref_title_display_name" />-->
android:title="@string/pref_title_display_name" />

<!-- NOTE: Hide buttons to simplify the UI. Users can touch outside the dialog to
dismiss it. -->
Expand Down

0 comments on commit a56d663

Please sign in to comment.