Null exception can be thrown when signing a multisig transaction
from a Sparrow wallet reconstructed from a Bitcoin descriptor.
This happens when the user did not configure any keystore
with the corresponding Satochip card ('import' button).
In this case, the 'fullpath' derivation path remains undefined,
leading to the exception.
This commit is contained in:
Toporin 2025-01-14 13:00:52 +01:00
parent ee5015f0d5
commit 22ad1cc5d1

View file

@ -164,19 +164,12 @@ public class SatoCardApi extends CardApi {
for(PSBTInput psbtInput : psbt.getPsbtInputs()) { for(PSBTInput psbtInput : psbt.getPsbtInputs()) {
if(!psbtInput.isSigned()) { if(!psbtInput.isSigned()) {
WalletNode signingNode = signingNodes.get(psbtInput); WalletNode signingNode = signingNodes.get(psbtInput);
String fullPath = null;
List<Keystore> keystores = wallet.getKeystores(); List<Keystore> keystores = wallet.getKeystores();
for(int i = 0; i < keystores.size(); i++) { // recover full derivation path
Keystore keystore = keystores.get(i); Keystore keystore = keystores.get(0);
WalletModel walletModel = keystore.getWalletModel();
if(walletModel == WalletModel.SATOCHIP) {
String basePath = keystore.getKeyDerivation().getDerivationPath(); String basePath = keystore.getKeyDerivation().getDerivationPath();
String extendedPath = signingNode.getDerivationPath().substring(1); String extendedPath = signingNode.getDerivationPath().substring(1);
fullPath = basePath + extendedPath; String fullPath = basePath + extendedPath;
keystore.getPubKey(signingNode);
break;
}
}
psbtInput.sign(new CardPSBTInputSigner(signingNode, fullPath)); psbtInput.sign(new CardPSBTInputSigner(signingNode, fullPath));
} }