mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
support scanning crypto-account and crypto-output through both qr scans on settings tab
This commit is contained in:
parent
22957e9d88
commit
b530ced9ed
4 changed files with 23 additions and 2 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 60e989b946cbfa86f7121671a986788c17fbaa34
|
Subproject commit 6ac593f161f7d17bf1f99658a92d7d65d25997be
|
|
@ -10,6 +10,8 @@ import com.sparrowwallet.drongo.address.P2PKHAddress;
|
||||||
import com.sparrowwallet.drongo.address.P2SHAddress;
|
import com.sparrowwallet.drongo.address.P2SHAddress;
|
||||||
import com.sparrowwallet.drongo.address.P2WPKHAddress;
|
import com.sparrowwallet.drongo.address.P2WPKHAddress;
|
||||||
import com.sparrowwallet.drongo.crypto.*;
|
import com.sparrowwallet.drongo.crypto.*;
|
||||||
|
import com.sparrowwallet.drongo.policy.Policy;
|
||||||
|
import com.sparrowwallet.drongo.policy.PolicyType;
|
||||||
import com.sparrowwallet.drongo.protocol.Base43;
|
import com.sparrowwallet.drongo.protocol.Base43;
|
||||||
import com.sparrowwallet.drongo.protocol.ScriptType;
|
import com.sparrowwallet.drongo.protocol.ScriptType;
|
||||||
import com.sparrowwallet.drongo.protocol.Transaction;
|
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||||
|
@ -491,6 +493,7 @@ public class QRScanDialog extends Dialog<QRScanDialog.Result> {
|
||||||
keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, KeyDerivation.writePath(outputDescriptor.getKeyDerivation(extendedKey).getDerivation())));
|
keystore.setKeyDerivation(new KeyDerivation(masterFingerprint, KeyDerivation.writePath(outputDescriptor.getKeyDerivation(extendedKey).getDerivation())));
|
||||||
keystore.setExtendedPublicKey(extendedKey);
|
keystore.setExtendedPublicKey(extendedKey);
|
||||||
wallet.getKeystores().add(keystore);
|
wallet.getKeystores().add(keystore);
|
||||||
|
wallet.setDefaultPolicy(Policy.getPolicy(outputDescriptor.isCosigner() ? PolicyType.MULTI : PolicyType.SINGLE, wallet.getScriptType(), wallet.getKeystores(), 1));
|
||||||
wallets.add(wallet);
|
wallets.add(wallet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,6 +394,24 @@ public class KeystoreController extends WalletFormController implements Initiali
|
||||||
QRScanDialog.Result result = optionalResult.get();
|
QRScanDialog.Result result = optionalResult.get();
|
||||||
if(result.extendedKey != null && result.extendedKey.getKey().isPubKeyOnly()) {
|
if(result.extendedKey != null && result.extendedKey.getKey().isPubKeyOnly()) {
|
||||||
xpub.setText(result.extendedKey.getExtendedKey());
|
xpub.setText(result.extendedKey.getExtendedKey());
|
||||||
|
} else if(result.outputDescriptor != null && !result.outputDescriptor.getExtendedPublicKeys().isEmpty()) {
|
||||||
|
ExtendedKey extendedKey = result.outputDescriptor.getExtendedPublicKeys().iterator().next();
|
||||||
|
KeyDerivation keyDerivation = result.outputDescriptor.getKeyDerivation(extendedKey);
|
||||||
|
fingerprint.setText(keyDerivation.getMasterFingerprint());
|
||||||
|
derivation.setText(keyDerivation.getDerivationPath());
|
||||||
|
xpub.setText(extendedKey.toString());
|
||||||
|
} else if(result.wallets != null) {
|
||||||
|
for(Wallet wallet : result.wallets) {
|
||||||
|
if(getWalletForm().getWallet().getScriptType().equals(wallet.getScriptType()) && !wallet.getKeystores().isEmpty()) {
|
||||||
|
Keystore keystore = wallet.getKeystores().get(0);
|
||||||
|
fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint());
|
||||||
|
derivation.setText(keystore.getKeyDerivation().getDerivationPath());
|
||||||
|
xpub.setText(keystore.getExtendedPublicKey().toString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AppServices.showErrorDialog("Missing Script Type", "QR Code did not contain any information for the " + getWalletForm().getWallet().getScriptType().getDescription() + " script type.");
|
||||||
} else if(result.exception != null) {
|
} else if(result.exception != null) {
|
||||||
log.error("Error scanning QR", result.exception);
|
log.error("Error scanning QR", result.exception);
|
||||||
AppServices.showErrorDialog("Error scanning QR", result.exception.getMessage());
|
AppServices.showErrorDialog("Error scanning QR", result.exception.getMessage());
|
||||||
|
|
|
@ -304,7 +304,7 @@ public class SettingsController extends WalletFormController implements Initiali
|
||||||
} else if(result.wallets != null) {
|
} else if(result.wallets != null) {
|
||||||
for(Wallet wallet : result.wallets) {
|
for(Wallet wallet : result.wallets) {
|
||||||
if(scriptType.getValue().equals(wallet.getScriptType()) && !wallet.getKeystores().isEmpty()) {
|
if(scriptType.getValue().equals(wallet.getScriptType()) && !wallet.getKeystores().isEmpty()) {
|
||||||
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor(walletForm.getWallet());
|
OutputDescriptor outputDescriptor = OutputDescriptor.getOutputDescriptor(wallet);
|
||||||
setDescriptorText(outputDescriptor.toString());
|
setDescriptorText(outputDescriptor.toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue