From f6c22d25a8ad955097917c9192367e245232e28e Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Mon, 13 May 2024 12:59:37 +0800 Subject: [PATCH 1/7] fix: declare rusttool chain version --- cryptoCore/build.gradle | 3 +-- cryptoCore/rcc_android | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cryptoCore/build.gradle b/cryptoCore/build.gradle index 21f22ed5..1f141ca2 100644 --- a/cryptoCore/build.gradle +++ b/cryptoCore/build.gradle @@ -88,9 +88,8 @@ cargo { targets = ["arm"] // See bellow for a longer list of options profile = 'release' targetIncludes = ['librcc_android.so'] - rustupChannel="nightly" + rustupChannel="nightly-2023-10-16-aarch64-apple-darwin" } - tasks.whenTaskAdded { task -> if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) { task.dependsOn 'cargoBuild' diff --git a/cryptoCore/rcc_android b/cryptoCore/rcc_android index 751e1c36..76c99d57 160000 --- a/cryptoCore/rcc_android +++ b/cryptoCore/rcc_android @@ -1 +1 @@ -Subproject commit 751e1c36602f09653a4ce254993b5b61fa623a57 +Subproject commit 76c99d57fb4e292b6caf165cc53429f204eb12f7 From f37e08e1e25268d3cdb90f1a3f1b40b049d5fcc2 Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Mon, 13 May 2024 14:01:14 +0800 Subject: [PATCH 2/7] fix: remove keystone companion app --- app/src/main/res_remove_wallet_mode/values/string.xml | 6 +++--- cryptoCore/rcc_android | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res_remove_wallet_mode/values/string.xml b/app/src/main/res_remove_wallet_mode/values/string.xml index 6878bf1d..2b0dc0d2 100644 --- a/app/src/main/res_remove_wallet_mode/values/string.xml +++ b/app/src/main/res_remove_wallet_mode/values/string.xml @@ -11,7 +11,7 @@ Connect SoftWare Wallets - Keystone Companion App + MetaMask OKX Wallet Keplr @@ -36,7 +36,7 @@ SushiSwap - keystone + metamask okx keplr @@ -61,7 +61,7 @@ sushiswap - 9 main chains including BTC, ETH, etc + ETH, AVAX, BNB, and other EVM tokens ETH, AVAX, BNB, and other EVM tokens Cosmos Eco diff --git a/cryptoCore/rcc_android b/cryptoCore/rcc_android index 76c99d57..a8851066 160000 --- a/cryptoCore/rcc_android +++ b/cryptoCore/rcc_android @@ -1 +1 @@ -Subproject commit 76c99d57fb4e292b6caf165cc53429f204eb12f7 +Subproject commit a8851066ac0251712cc9113f8ef9623cbd73d502 From d763763d6d24cc12ddda56aac9be293fc044f5ef Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Mon, 13 May 2024 16:57:48 +0800 Subject: [PATCH 3/7] feat: add dash bch trx ltc supported networks for okxwallet --- .../fragment/connect_wallet/SyncFragment.java | 4 +++ .../connect_wallet/config/WalletConfig.java | 2 +- .../sync_viewmodel/OKXWalletViewModel.java | 34 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/SyncFragment.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/SyncFragment.java index 72049704..3e5086da 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/SyncFragment.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/SyncFragment.java @@ -180,6 +180,10 @@ public void setupWalletUI(Wallet wallet) { R.drawable.ic_coin_btc, R.drawable.ic_coin_eth, R.drawable.ic_coin_okb, + R.drawable.ic_coin_dash, + R.drawable.ic_coin_bch, + R.drawable.ic_coin_trx, + R.drawable.ic_coin_ltc, R.drawable.ic_coin_bnb, R.drawable.ic_coin_arb, R.drawable.ic_coin_avax, diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/config/WalletConfig.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/config/WalletConfig.java index a5429062..f5bb6dfc 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/config/WalletConfig.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/connect_wallet/config/WalletConfig.java @@ -28,7 +28,7 @@ public enum WalletConfig { BITKEEP_ONLY_BTC(Wallet.BITKEEP.getWalletId(), new String[]{Coins.BTC.coinId()}, false, false, true, false), KEYSTONE(Wallet.KEYSTONE.getWalletId(), new String[]{Coins.BTC.coinId(), Coins.ETH.coinId()}, false, false, true, true), ETERNL(Wallet.ETERNL.getWalletId(), new String[]{Coins.ADA.coinId()}, false, false, true, false), - OKX(Wallet.OKX.getWalletId(), new String[]{Coins.BTC.coinId(), Coins.ETH.coinId()}, false, false, true, true), + OKX(Wallet.OKX.getWalletId(), new String[]{Coins.BTC.coinId(), Coins.ETH.coinId(),Coins.DASH.coinId(),Coins.BCH.coinId(),Coins.TRON.coinId(),Coins.LTC.coinId()}, false, false, true, true), DEFAULT("default", new String[]{""}, false, false, true, true), ; diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java index 444c7338..20b1bfb7 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java @@ -26,6 +26,12 @@ public class OKXWalletViewModel extends AndroidViewModel { public static final String BTCNestedSegwitPath = "M/49'/0'/0'"; public static final String BTCNativeSegwitPath = "M/84'/0'/0'"; + + public static final String DashPath = "M/44'/5'/0'"; + public static final String BtcCashPath = "M/44'/145'/0'"; + public static final String TronPath = "M/44'/195'/0'"; + public static final String LitcoinPath = "M/44'/2'/0'"; + private final String[] btcPaths = {BTCLegacyPath, BTCNestedSegwitPath, BTCNativeSegwitPath}; private List openedCoins = new ArrayList<>(); @@ -52,6 +58,10 @@ public void setOpenedCoins(List openedCoins) { this.openedCoins.add(Coins.ETH.coinId()); this.openedCoins.add(Coins.BTC.coinId()); } + this.openedCoins.add(Coins.DASH.coinId()); + this.openedCoins.add(Coins.BCH.coinId()); + this.openedCoins.add(Coins.TRON.coinId()); + this.openedCoins.add(Coins.LTC.coinId()); } private CryptoMultiAccounts generateCryptoMultiAccounts() { @@ -63,6 +73,26 @@ private CryptoMultiAccounts generateCryptoMultiAccounts() { if (openedCoins.contains(Coins.BTC.coinId())) { cryptoHDKeyList.addAll(generateCryptoHDKeysForBitcoin()); } + + if (openedCoins.contains(Coins.DASH.coinId())) { + CryptoHDKey dash = generateCryptoHDKeyForOtherCoin(DashPath, 5); + cryptoHDKeyList.add(dash); + } + + if (openedCoins.contains(Coins.BCH.coinId())) { + CryptoHDKey bch = generateCryptoHDKeyForOtherCoin(BtcCashPath, 145); + cryptoHDKeyList.add(bch); + } + + if (openedCoins.contains(Coins.TRON.coinId())) { + CryptoHDKey tron = generateCryptoHDKeyForOtherCoin(TronPath,195); + cryptoHDKeyList.add(tron); + } + + if (openedCoins.contains(Coins.LTC.coinId())) { + CryptoHDKey litcoin = generateCryptoHDKeyForOtherCoin(LitcoinPath,2); + cryptoHDKeyList.add(litcoin); + } return new CryptoMultiAccounts(masterFingerprint, cryptoHDKeyList, DeviceInfoUtil.getDeviceType(), DeviceInfoUtil.getDeviceId()); } @@ -98,4 +128,8 @@ private List generateCryptoHDKeysForBitcoin() { private CryptoHDKey generateCryptoHDKeyForBitcoin(String path) { return URRegistryHelper.generateCryptoHDKey(path, 0); } + + private CryptoHDKey generateCryptoHDKeyForOtherCoin(String path, int type) { + return URRegistryHelper.generateCryptoHDKey(path, type); + } } \ No newline at end of file From 01a0dc0b7911b172162202770e3c20aa46cf2802 Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Tue, 14 May 2024 10:01:53 +0800 Subject: [PATCH 4/7] feat: bump version to 13.0 --- app/version.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/version.properties b/app/version.properties index 5a4f0151..4572cf62 100644 --- a/app/version.properties +++ b/app/version.properties @@ -17,5 +17,5 @@ #Fri Feb 21 13:33:46 CST 2020 major=3 -minor=12 -patch=6 +minor=13 +patch=0 From 5099d242ee305bd048fc181804c07d3af5b65e5e Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Fri, 17 May 2024 18:49:35 +0800 Subject: [PATCH 5/7] fix: fix bch dash ltc trx sign request for okxwallet --- .vscode/settings.json | 3 + app/build.gradle | 8 +- .../main/scanner/processor/URProcessor.java | 96 ++++++++++++++++++- .../KeystoneConfirmTransactionFragment.java | 2 +- .../sync_viewmodel/OKXWalletViewModel.java | 2 +- .../viewmodel/tx/KeystoneTxViewModel.java | 35 ++++++- .../cold/ui/fragment/main/AssetFragment.java | 2 + .../main/scan/scanner/ScanResultTypes.java | 12 ++- build.gradle | 5 + .../com/keystone/coinlib/coins/BTC/Btc.java | 48 +++++++--- .../com/keystone/coinlib/coins/DASH/Dash.java | 7 +- 11 files changed, 192 insertions(+), 28 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..4cd8c4fe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} diff --git a/app/build.gradle b/app/build.gradle index 34af53bf..1ce43277 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -185,7 +185,9 @@ dependencies { implementation 'androidx.core:core:1.6.0' compileOnly files('libs/cvos.jar') implementation 'co.nstant.in:cbor:0.9' - implementation 'com.github.KeystoneHQ:hummingbird:0.6.0' + // implementation 'com.github.KeystoneHQ:hummingbird:0.6.0' + // implementation 'com.github.KeystoneHQ:hummingbird:a90ea57' + implementation files('/Users/jianjianjianjian/hummingbird/build/libs/hummingbird-1.6.1.jar') implementation 'androidx.appcompat:appcompat:1.3.0-beta01' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.navigation:navigation-fragment:2.2.0-rc04' @@ -219,6 +221,10 @@ dependencies { } +configurations.all { + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' +} + preBuild { doLast { def imlFile = file(project.name + ".iml") diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/scanner/processor/URProcessor.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/scanner/processor/URProcessor.java index f6f9c255..11184b1d 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/scanner/processor/URProcessor.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/scanner/processor/URProcessor.java @@ -48,6 +48,8 @@ import com.sparrowwallet.hummingbird.registry.solana.SolNFTItem; import com.sparrowwallet.hummingbird.registry.solana.SolSignRequest; import com.sparrowwallet.hummingbird.registry.sui.SuiSignRequest; +import com.sparrowwallet.hummingbird.registry.KeystoneSignRequest; + import org.json.JSONException; import org.json.JSONObject; @@ -92,7 +94,9 @@ public Destination run(ScanResult r) throws BaseException { return new QRHardwareCallProcessor().run(r.resolve()); } else if (r.getType().equals(ScanResultTypes.UR_CARDANO_SIGN_REQUEST)) { return new CardanoSignRequestProcessor().run(r.resolve()); - } else { + } else if (r.getType().equals(ScanResultTypes.UR_KEYSTONE_SIGN_REQUEST)){ + return new KeystoneSignRequestProcessor().run(r.resolve()); + }else { throw UnimplementedException.newInstance(); } } @@ -101,8 +105,94 @@ interface URResolver { Destination run(Object object) throws BaseException; } - private static class ETHSignRequestProcessor implements URResolver { + private static class KeystoneSignRequestProcessor implements URResolver { + + + @Override + public Destination run(Object object) throws BaseException { + KeystoneSignRequest keystoneSignRequest = (KeystoneSignRequest) object; + String origin = keystoneSignRequest.getOrigin(); + String hexString = Hex.toHexString(keystoneSignRequest.getSignData()); + JSONObject json = tryDecodeAsJson(hexString); + if (json == null) { + json = tryDecodeAsProtobuf(hexString); + } + if (json != null) { + Destination destination = decodeAndProcess(json); + if (destination == null) { + throw UnknownQrCodeException.newInstance(); + } + return destination; + } else { + throw UnknownQrCodeException.newInstance(); + } + } + + + private JSONObject tryDecodeAsJson(String hex) { + try { + return new JSONObject(new String(Hex.decode(hex))); + } catch (Exception ignored) { + } + return null; + } + + private JSONObject tryDecodeAsProtobuf(String hex) { + JSONObject object; + hex = ZipUtil.unzip(hex); + object = new ProtoParser(Hex.decode(hex)).parseToJson(); + return object; + } + + private Destination decodeAndProcess(JSONObject object) throws BaseException { + Destination destination = checkWebAuth(object); + if (destination != null) return destination; + if (object.has("TransactionType")) { + Bundle bundle = new Bundle(); + bundle.putString(BundleKeys.SIGN_DATA_KEY, object.toString()); + return new Destination(R.id.action_to_rippleConfirmTransactionFragment, bundle); + } + if (object.optString("type").equals("TYPE_SIGN_TX")) { + return handleSign(object); + } + throw UnknownQrCodeException.newInstance(); + } + + private Destination checkWebAuth(JSONObject object) { + try { + JSONObject webAuth = object.optJSONObject("data"); + if (webAuth != null && webAuth.optString("type").equals("webAuth")) { + String data = webAuth.getString("data"); + Bundle bundle = new Bundle(); + bundle.putString(BundleKeys.WEB_AUTH_DATA_KEY, data); + return new Destination(R.id.action_to_webAuthResultFragment, bundle); + } + } catch (JSONException e) { + e.printStackTrace(); + } + return null; + } + + private Destination handleSign(JSONObject object) + throws BaseException { + String xfp = new GetMasterFingerprintCallable().call(); + if (!object.optString("xfp").toUpperCase().equals(xfp.toUpperCase())){ + throw XfpNotMatchException.newInstance(); + } + try { + Bundle bundle = new Bundle(); + bundle.putString(BundleKeys.SIGN_DATA_KEY, object.getJSONObject("signTx").toString()); + return new Destination(R.id.action_to_keystoneConfirmTransactionFragment, bundle); + } catch (JSONException e) { + e.printStackTrace(); + return null; + } + } + } + + + private static class ETHSignRequestProcessor implements URResolver { @Override public Destination run(Object object) throws BaseException { EthSignRequest ethSignRequest = (EthSignRequest) object; @@ -548,7 +638,7 @@ private Destination checkWebAuth(JSONObject object) { private Destination handleSign(JSONObject object) throws BaseException { String xfp = new GetMasterFingerprintCallable().call(); - if (!object.optString("xfp").equals(xfp)) { + if (!object.optString("xfp").toUpperCase().equals(xfp.toUpperCase())) { throw XfpNotMatchException.newInstance(); } try { diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/tx/keystone/KeystoneConfirmTransactionFragment.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/tx/keystone/KeystoneConfirmTransactionFragment.java index cd225cc0..d17c7f87 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/tx/keystone/KeystoneConfirmTransactionFragment.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/ui/fragment/main/tx/keystone/KeystoneConfirmTransactionFragment.java @@ -64,7 +64,7 @@ protected void setupView() { @Override protected void onSignSuccess() { - String signatureURString = viewModel.getSignatureUR(); + String signatureURString = viewModel.getSignatureUR(); Bundle data = new Bundle(); data.putString(BundleKeys.SIGNATURE_UR_KEY, signatureURString); data.putString(BundleKeys.COIN_CODE_KEY, viewModel.getCoinCode()); diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java index 20b1bfb7..b92da1d4 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/sync_viewmodel/OKXWalletViewModel.java @@ -30,7 +30,7 @@ public class OKXWalletViewModel extends AndroidViewModel { public static final String DashPath = "M/44'/5'/0'"; public static final String BtcCashPath = "M/44'/145'/0'"; public static final String TronPath = "M/44'/195'/0'"; - public static final String LitcoinPath = "M/44'/2'/0'"; + public static final String LitcoinPath = "M/49'/2'/0'"; private final String[] btcPaths = {BTCLegacyPath, BTCNestedSegwitPath, BTCNativeSegwitPath}; diff --git a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/tx/KeystoneTxViewModel.java b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/tx/KeystoneTxViewModel.java index 8519082c..aebcd3a3 100644 --- a/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/tx/KeystoneTxViewModel.java +++ b/app/src/main/java/com/keystone/cold/remove_wallet_mode/viewmodel/tx/KeystoneTxViewModel.java @@ -85,7 +85,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.stream.Stream; - +import com.sparrowwallet.hummingbird.registry.KeystoneSignature; +import java.nio.ByteBuffer; +import java.util.UUID; public class KeystoneTxViewModel extends BaseTxViewModel { private static final String TAG = "KeystoneTxViewModel"; private static final String BTC_SEGWIT_PATH = "M/49'/0'/0'/"; @@ -118,7 +120,6 @@ public void parseTxData(Bundle bundle) { try { String json = bundle.getString(BundleKeys.SIGN_DATA_KEY); JSONObject object = new JSONObject(json); - Log.i(TAG, "object = " + object.toString(4)); transaction = AbsTx.newInstance(object); if (transaction == null) { observableException.postValue(new InvalidTransactionException(MainApplication.getApplication().getString(R.string.incorrect_tx_data), "invalid transaction")); @@ -437,9 +438,37 @@ public void handleSignMessage() { } + + + private static byte[] hexToBytes(String s) { + int len = s.length(); + byte[] data = new byte[len / 2]; + for (int i = 0; i < len; i += 2) { + data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + + Character.digit(s.charAt(i+1), 16)); + } + return data; + } + @Override public String getSignatureUR() { - return observableTransaction.getValue().getSignResult(); + KeystoneSignature keystoneSignature; + String signatureStr = observableTransaction.getValue().getSignResult(); + String requestIdStr = observableTransaction.getValue().getSignId(); + byte[] signature = hexToBytes(signatureStr); + if (signatureStr == null) { + keystoneSignature = new KeystoneSignature(signature); + } else { + UUID uuid = UUID.fromString(requestIdStr); + ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); + byteBuffer.putLong(uuid.getMostSignificantBits()); + byteBuffer.putLong(uuid.getLeastSignificantBits()); + byte[] requestId = byteBuffer.array(); + keystoneSignature = new KeystoneSignature(signature); + } + String urString = keystoneSignature.toUR().toString(); + + return urString; } void signTransaction(Signer... signer) { diff --git a/app/src/main/java/com/keystone/cold/ui/fragment/main/AssetFragment.java b/app/src/main/java/com/keystone/cold/ui/fragment/main/AssetFragment.java index 6fca3fd3..72f6e64f 100644 --- a/app/src/main/java/com/keystone/cold/ui/fragment/main/AssetFragment.java +++ b/app/src/main/java/com/keystone/cold/ui/fragment/main/AssetFragment.java @@ -506,11 +506,13 @@ public void handleScanResult(ScanResult result) throws Exception { handleArweaveSignRequest(result); } else if (result.getType().equals(ScanResultTypes.UR_EVM_SIGN_REQUEST)) { handleEvmSignRequest(result); + } else { throw new UnknowQrCodeException("unknown transaction!"); } } + private void handleURBytes(ScanResult result) throws JSONException, UnExpectedQRException { JSONObject object = new JSONObject(new String((byte[]) result.resolve(), StandardCharsets.UTF_8)); JSONObject webAuth = object.optJSONObject("data"); diff --git a/app/src/main/java/com/keystone/cold/ui/fragment/main/scan/scanner/ScanResultTypes.java b/app/src/main/java/com/keystone/cold/ui/fragment/main/scan/scanner/ScanResultTypes.java index c607d1d8..9640124e 100644 --- a/app/src/main/java/com/keystone/cold/ui/fragment/main/scan/scanner/ScanResultTypes.java +++ b/app/src/main/java/com/keystone/cold/ui/fragment/main/scan/scanner/ScanResultTypes.java @@ -18,7 +18,7 @@ import com.sparrowwallet.hummingbird.registry.solana.SolNFTItem; import com.sparrowwallet.hummingbird.registry.solana.SolSignRequest; import com.sparrowwallet.hummingbird.registry.sui.SuiSignRequest; - +import com.sparrowwallet.hummingbird.registry.KeystoneSignRequest; import org.spongycastle.util.encoders.Hex; import java.util.List; @@ -46,7 +46,9 @@ public enum ScanResultTypes { UR_COSMOS_SIGN_REQUEST, UR_QR_HARDWARE_CALL, UR_CARDANO_SIGN_REQUEST, - UR_EVM_SIGN_REQUEST; + UR_EVM_SIGN_REQUEST, + + UR_KEYSTONE_SIGN_REQUEST; public boolean isType(String text) { @@ -88,6 +90,8 @@ public boolean isType(UR ur) { return decodeResult instanceof QRHardwareCall; case UR_CARDANO_SIGN_REQUEST: return decodeResult instanceof CardanoSignRequest; + case UR_KEYSTONE_SIGN_REQUEST: + return decodeResult instanceof KeystoneSignRequest; default: return false; } @@ -138,6 +142,8 @@ public Object resolveURHex(String hex) { return QRHardwareCall.fromCbor(dataItem); case UR_CARDANO_SIGN_REQUEST: return CardanoSignRequest.fromCbor(dataItem); + case UR_KEYSTONE_SIGN_REQUEST: + return KeystoneSignRequest.fromCbor(dataItem); default: return null; } @@ -179,6 +185,8 @@ public static ScanResultTypes fromUR(UR ur) throws UnsupportedURException { return UR_QR_HARDWARE_CALL; case "cardano-sign-request": return UR_CARDANO_SIGN_REQUEST; + case "keystone-sign-request": + return UR_KEYSTONE_SIGN_REQUEST; default: throw new UnsupportedURException(MainApplication.getApplication().getString(R.string.invalid_qr_code_hint), "unsupported ur type: " + ur.getType()); } diff --git a/build.gradle b/build.gradle index 486bbb43..17cdd4cf 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,10 @@ allprojects { } +configurations.all { + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' +} + task clean(type: Delete) { delete rootProject.buildDir } @@ -66,3 +70,4 @@ ext { junit = '4.12' mockito = '1.10.19' } + diff --git a/coinlib/src/main/java/com/keystone/coinlib/coins/BTC/Btc.java b/coinlib/src/main/java/com/keystone/coinlib/coins/BTC/Btc.java index 5beae0a1..11444fcb 100644 --- a/coinlib/src/main/java/com/keystone/coinlib/coins/BTC/Btc.java +++ b/coinlib/src/main/java/com/keystone/coinlib/coins/BTC/Btc.java @@ -159,22 +159,40 @@ private void parseOutPut() throws JSONException { JSONObject output = outputs.getJSONObject(i); String address = output.getString("address"); String newAddress = convertAddress(address); - outputAmount += output.getLong("value"); - if (output.optBoolean("isChange") && output.has("changeAddressPath")) { - changeAmount += output.getLong("value"); - changeAddressInfoList.add(new ChangeAddressInfo( - newAddress, - output.getString("changeAddressPath"), - output.getLong("value"))); - outputsClone.remove(i); - continue; + try { + outputAmount += output.getLong("value"); + if (output.optBoolean("isChange") && output.has("changeAddressPath")) { + changeAmount += output.getLong("value"); + changeAddressInfoList.add(new ChangeAddressInfo( + newAddress, + output.getString("changeAddressPath"), + output.getLong("value"))); + outputsClone.remove(i); + continue; + } + + NumberFormat nf = NumberFormat.getInstance(); + nf.setMaximumFractionDigits(20); + String amount = nf.format(satoshiToBtc(output.getLong("value"))); + outputsClone.getJSONObject(i).put("value", amount + " " + coinCode); + destinations.append(address).append(SEPARATOR); + } catch (Exception e) { + if (output.optBoolean("isChange") && output.has("changeAddressPath")) { + changeAmount += 0; + changeAddressInfoList.add(new ChangeAddressInfo( + newAddress, + output.getString("changeAddressPath"), + 0)); + outputsClone.remove(i); + continue; + } + + NumberFormat nf = NumberFormat.getInstance(); + nf.setMaximumFractionDigits(20); + String amount = nf.format(satoshiToBtc(0)); + outputsClone.getJSONObject(i).put("value", amount + " " + coinCode); + destinations.append(address).append(SEPARATOR); } - - NumberFormat nf = NumberFormat.getInstance(); - nf.setMaximumFractionDigits(20); - String amount = nf.format(satoshiToBtc(output.getLong("value"))); - outputsClone.getJSONObject(i).put("value", amount + " " + coinCode); - destinations.append(address).append(SEPARATOR); } if (outputsClone.length() == 1) { to = destinations.deleteCharAt(destinations.length() - 1).toString(); diff --git a/coinlib/src/main/java/com/keystone/coinlib/coins/DASH/Dash.java b/coinlib/src/main/java/com/keystone/coinlib/coins/DASH/Dash.java index 64973375..8152448d 100644 --- a/coinlib/src/main/java/com/keystone/coinlib/coins/DASH/Dash.java +++ b/coinlib/src/main/java/com/keystone/coinlib/coins/DASH/Dash.java @@ -28,7 +28,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; - +import java.text.NumberFormat; public class Dash extends Btc { public Dash(Coin impl) { super(impl); @@ -62,7 +62,10 @@ protected void parseInput() throws JSONException, InvalidTransactionException { } hdPath = paths.deleteCharAt(paths.length() - 1).toString(); } - } + + + +} public static class Deriver extends AbsDeriver { From 2186c674985d4b6eeebe40b9a9d6e9deab16dec9 Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Mon, 20 May 2024 15:44:58 +0800 Subject: [PATCH 6/7] fix: modify okx wallet desc --- app/src/main/res_remove_wallet_mode/values/string.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res_remove_wallet_mode/values/string.xml b/app/src/main/res_remove_wallet_mode/values/string.xml index 2b0dc0d2..2bac1dee 100644 --- a/app/src/main/res_remove_wallet_mode/values/string.xml +++ b/app/src/main/res_remove_wallet_mode/values/string.xml @@ -63,7 +63,7 @@ ETH, AVAX, BNB, and other EVM tokens - ETH, AVAX, BNB, and other EVM tokens + BTC, ETH, TRX, BCH, LTC, DASH and EVM Cosmos Eco ETH, AVAX, BNB, and other EVM tokens ETH, AVAX, BNB, and other EVM tokens From 852e03f6602a5efd0d343df955911aae4be28450 Mon Sep 17 00:00:00 2001 From: ZhenQian Date: Thu, 23 May 2024 10:14:31 +0800 Subject: [PATCH 7/7] fix: update hummingbird dependecy --- app/build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1ce43277..24f2df20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -185,9 +185,7 @@ dependencies { implementation 'androidx.core:core:1.6.0' compileOnly files('libs/cvos.jar') implementation 'co.nstant.in:cbor:0.9' - // implementation 'com.github.KeystoneHQ:hummingbird:0.6.0' - // implementation 'com.github.KeystoneHQ:hummingbird:a90ea57' - implementation files('/Users/jianjianjianjian/hummingbird/build/libs/hummingbird-1.6.1.jar') + implementation 'com.github.KeystoneHQ:hummingbird:0.6.2' implementation 'androidx.appcompat:appcompat:1.3.0-beta01' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.navigation:navigation-fragment:2.2.0-rc04'