Skip to content

Commit

Permalink
Merge pull request #470 from KeystoneHQ/fix-dot-large-transaction
Browse files Browse the repository at this point in the history
fix(substrate): large transaction
  • Loading branch information
NanYeZhuYu authored Jul 26, 2023
2 parents dd6fb8f + ecd9886 commit f3be538
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.keystone.coinlib.coins.polkadot.AddressCodec;
import com.keystone.coinlib.interfaces.SignCallback;
import com.keystone.coinlib.interfaces.Signer;
import com.keystone.coinlib.utils.Coins;
Expand All @@ -26,6 +27,7 @@

import org.json.JSONException;
import org.json.JSONObject;
import org.spongycastle.util.encoders.Hex;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -170,7 +172,14 @@ public void handleSignContent(String signContent) {
callback.onFail();
}
Signer signer = new ChipSigner(addressEntity.getPath(), authToken);
String signedHex = signer.sign(signContent);

byte[] content = Hex.decode(signContent);
String dataToSign = signContent;
if (content.length > 256) {
byte[] hash = AddressCodec.blake2b(content, 256);
dataToSign = Hex.toHexString(hash);
}
String signedHex = signer.sign(dataToSign);
String txId = signedHex.substring(0, 32);
if (!TextUtils.isEmpty(signedHex)) {
callback.onSuccess(txId, signedHex);
Expand Down

0 comments on commit f3be538

Please sign in to comment.