Skip to content

Commit

Permalink
Merge pull request #378 from KeystoneHQ/rwm-ar
Browse files Browse the repository at this point in the history
fix: eth errors caused by core wallet integration
  • Loading branch information
NanYeZhuYu authored Feb 17, 2023
2 parents 76e1b5a + 0ac4c19 commit f0a58d7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private void calculateDisplayEIP1559Fee(JSONObject ethTx, EthereumTransaction tx
public String getFromAddress(String path) {
try {
ensureAddressExist(path);
return mRepository.loadAddressBypath(path).getAddressString();
return mRepository.loadAddressByPathAndCoinId(path, Coins.ETH.coinId()).getAddressString();
} catch (InvalidTransactionException | InvalidETHAccountException e) {
parseTxException.postValue(e);
e.printStackTrace();
Expand All @@ -460,7 +460,7 @@ private void ensureAddressExist(String path) throws InvalidETHAccountException,
if (target == null) {
throw new InvalidTransactionException(context.getString(R.string.incorrect_tx_data), "unknown hd path");
}
AddressEntity address = mRepository.loadAddressBypath(path);
AddressEntity address = mRepository.loadAddressByPathAndCoinId(path, Coins.ETH.coinId());
if (address == null) {
updateAccountDb(getAddressIndex(account, path));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void addEthAccountAddress(AccountEntity accountEntity, DataReposit
addressEntity.setIndex(index);
addressEntity.setName("ETH-" + index);
addressEntity.setBelongTo(coinEntity.getBelongTo());
if (repository.loadAddressBypath(addressEntity.getPath()) != null) {
if (repository.loadAddressByPathAndCoinId(addressEntity.getPath(), Coins.ETH.coinId()) != null) {
continue;
}
addressEntities.add(addressEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private String getFromAddress() {

return Stream.of(externalPath)
.distinct()
.map(path -> mRepository.loadAddressBypath(path).getAddressString())
.map(path -> mRepository.loadAddressByPathAndCoinId(path, Coins.coinIdFromCoinCode(coinCode)).getAddressString())
.reduce((s1, s2) -> s1 + AbsTx.SEPARATOR + s2)
.orElse("");
}
Expand Down Expand Up @@ -315,7 +315,7 @@ private void ensureAddressExist(String[] paths) {
}
}
}
AddressEntity address = mRepository.loadAddressBypath(maxIndexHdPath);
AddressEntity address = mRepository.loadAddressByPathAndCoinId(maxIndexHdPath, Coins.coinIdFromCoinCode(coinCode));
if (address == null) {
addAddress(getAddressIndex(maxIndexHdPath));
}
Expand Down
7 changes: 4 additions & 3 deletions coinlib/src/main/java/com/keystone/coinlib/coins/AbsTx.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ protected void checkHdPath(String hdPath, boolean allHardend) throws InvalidTran
}

CoinType coinType = account.getParent();
if ((coinType.getValue()!=0 && coinType.getValue() != 1) && !coinCode.equals(Coins.coinCodeOfIndex(coinType.getValue()))) {
throw new InvalidTransactionException("invalid hdPath, error coinIndex");
}

// if ((coinType.getValue()!=0 && coinType.getValue() != 1) && !coinCode.equals(Coins.coinCodeOfIndex(coinType.getValue()))) {
// throw new InvalidTransactionException("invalid hdPath, error coinIndex");
// }

if(coinType.getValue() == 0 && !Coins.isBTCMainnet(coinCode)) {
throw new InvalidTransactionException("invalid hdPath, error coinIndex");
Expand Down

0 comments on commit f0a58d7

Please sign in to comment.