mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2025-01-27 10:51:09 +00:00
First try to recover derivation path from satochip keystore, otherwise from first keystore as default value.
This commit is contained in:
parent
f4b3b3d55a
commit
91ad82a21c
1 changed files with 19 additions and 6 deletions
|
@ -165,12 +165,25 @@ public class SatoCardApi extends CardApi {
|
||||||
if(!psbtInput.isSigned()) {
|
if(!psbtInput.isSigned()) {
|
||||||
WalletNode signingNode = signingNodes.get(psbtInput);
|
WalletNode signingNode = signingNodes.get(psbtInput);
|
||||||
List<Keystore> keystores = wallet.getKeystores();
|
List<Keystore> keystores = wallet.getKeystores();
|
||||||
// recover full derivation path
|
// recover derivation path from Satochip keystore
|
||||||
Keystore keystore = keystores.get(0);
|
String fullPath = null;
|
||||||
String basePath = keystore.getKeyDerivation().getDerivationPath();
|
for(int i = 0; i < keystores.size(); i++) {
|
||||||
String extendedPath = signingNode.getDerivationPath().substring(1);
|
Keystore keystore = keystores.get(i);
|
||||||
String fullPath = basePath + extendedPath;
|
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));
|
psbtInput.sign(new CardPSBTInputSigner(signingNode, fullPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue