Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First try to recover derivation path from satochip keystore, otherwise from first keystore as default value.
  • Loading branch information
Toporin committed Jan 14, 2025
1 parent f4b3b3d commit 91ad82a
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,25 @@ void sign(Wallet wallet, PSBT psbt) throws CardException {
if(!psbtInput.isSigned()) {
WalletNode signingNode = signingNodes.get(psbtInput);
List<Keystore> keystores = wallet.getKeystores();
// recover full derivation path
Keystore keystore = keystores.get(0);
String basePath = keystore.getKeyDerivation().getDerivationPath();
String extendedPath = signingNode.getDerivationPath().substring(1);
String fullPath = basePath + extendedPath;

// recover derivation path from Satochip keystore
String fullPath = null;
for(int i = 0; i < keystores.size(); i++) {
Keystore keystore = keystores.get(i);
WalletModel walletModel = keystore.getWalletModel();
if(walletModel == WalletModel.SATOCHIP) {
String basePath = keystore.getKeyDerivation().getDerivationPath();
String extendedPath = signingNode.getDerivationPath().substring(1);
fullPath = basePath + extendedPath;
break;
}
}
if (fullPath == null) {
// recover a default derivation path from first keystore
Keystore keystore = keystores.get(0);
String basePath = keystore.getKeyDerivation().getDerivationPath();
String extendedPath = signingNode.getDerivationPath().substring(1);
fullPath = basePath + extendedPath;
}
psbtInput.sign(new CardPSBTInputSigner(signingNode, fullPath));
}
}
Expand Down

0 comments on commit 91ad82a

Please sign in to comment.