accept output descriptor fragments in pubkey qr scanner

This commit is contained in:
Craig Raw 2022-08-10 12:31:43 +02:00
parent ca782dfc69
commit 6534ccb07e

View file

@ -424,6 +424,17 @@ public class KeystoreController extends WalletFormController implements Initiali
} finally {
result.seed.clear();
}
} else if(result.payload != null) {
try {
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor("sh(" + result.payload + ")");
Wallet wallet = outputDescriptor.toWallet();
Keystore keystore = wallet.getKeystores().get(0);
fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint());
derivation.setText(keystore.getKeyDerivation().getDerivationPath());
xpub.setText(keystore.getExtendedPublicKey().toString());
} catch(Exception e) {
AppServices.showErrorDialog("Invalid QR Code", "QR Code did not contain a valid " + Network.get().getXpubHeader().getDisplayName());
}
} else if(result.exception != null) {
log.error("Error scanning QR", result.exception);
AppServices.showErrorDialog("Error scanning QR", result.exception.getMessage());