diff --git a/drongo b/drongo index d2559136..3dbcdfcf 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit d255913654b29a33c772dead9b66721c70fe7950 +Subproject commit 3dbcdfcf4ebeb478d6da28f17f5dc74dba244fe1 diff --git a/src/main/java/com/sparrowwallet/sparrow/io/CardApi.java b/src/main/java/com/sparrowwallet/sparrow/io/CardApi.java index 1ea660c6..6d7dc298 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/CardApi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/CardApi.java @@ -62,7 +62,7 @@ public abstract class CardApi { } public static CardApi getCardApi(WalletModel walletModel, String pin) throws CardException { - if(walletModel == WalletModel.TAPSIGNER || walletModel == WalletModel.SATSCARD) { + if(walletModel == WalletModel.TAPSIGNER || walletModel == WalletModel.SATSCHIP || walletModel == WalletModel.SATSCARD) { return new CkCardApi(walletModel, pin); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CardStatus.java b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CardStatus.java index 7e471b01..1af96ffe 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CardStatus.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CardStatus.java @@ -15,6 +15,7 @@ public class CardStatus extends CardResponse { String ver; BigInteger birth; boolean tapsigner; + boolean satschip; List path; BigInteger num_backups; List slots; @@ -24,7 +25,7 @@ public class CardStatus extends CardResponse { boolean testnet; public boolean isInitialized() { - return (getCardType() == WalletModel.TAPSIGNER && path != null) || (getCardType() == WalletModel.SATSCARD && addr != null); + return ((getCardType() == WalletModel.TAPSIGNER || getCardType() == WalletModel.SATSCHIP) && path != null) || (getCardType() == WalletModel.SATSCARD && addr != null); } public String getIdentifier() { @@ -42,11 +43,11 @@ public class CardStatus extends CardResponse { } public boolean requiresBackup() { - return num_backups == null || num_backups.intValue() == 0; + return !satschip && (num_backups == null || num_backups.intValue() == 0); } public WalletModel getCardType() { - return tapsigner ? WalletModel.TAPSIGNER : WalletModel.SATSCARD; + return satschip ? WalletModel.SATSCHIP : (tapsigner ? WalletModel.TAPSIGNER : WalletModel.SATSCARD); } public int getCurrentSlot() { @@ -72,6 +73,7 @@ public class CardStatus extends CardResponse { ", ver='" + ver + '\'' + ", birth=" + birth + ", tapsigner=" + tapsigner + + ", satschip=" + satschip + ", path=" + path + ", num_backups=" + num_backups + ", slots=" + slots + diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CkCardApi.java b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CkCardApi.java index 653db879..6455bf4f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CkCardApi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/CkCardApi.java @@ -32,10 +32,6 @@ public class CkCardApi extends CardApi { private final CardProtocol cardProtocol; private String cvc; - public CkCardApi(String cvc) throws CardException { - this(WalletModel.TAPSIGNER, cvc); - } - public CkCardApi(WalletModel cardType, String cvc) throws CardException { this.cardType = cardType; this.cardProtocol = new CardProtocol(); @@ -137,6 +133,8 @@ public class CkCardApi extends CardApi { public Service getInitializationService(byte[] entropy, StringProperty messageProperty) { if(cardType == WalletModel.TAPSIGNER) { return new CardImportPane.CardInitializationService(new Tapsigner(), cvc, entropy, messageProperty); + } else if(cardType == WalletModel.SATSCHIP) { + return new CardImportPane.CardInitializationService(new Satschip(), cvc, entropy, messageProperty); } return new CardInitializationService(entropy, messageProperty); @@ -144,6 +142,10 @@ public class CkCardApi extends CardApi { @Override public Service getImportService(List derivation, StringProperty messageProperty) { + if(cardType == WalletModel.SATSCHIP) { + return new CardImportPane.CardImportService(new Satschip(), cvc, derivation, messageProperty); + } + return new CardImportPane.CardImportService(new Tapsigner(), cvc, derivation, messageProperty); } @@ -155,11 +157,11 @@ public class CkCardApi extends CardApi { ExtendedKey derivedXpubkey = ExtendedKey.fromDescriptor(Base58.encodeChecked(derivedXpub.xpub)); Keystore keystore = new Keystore(); - keystore.setLabel(WalletModel.TAPSIGNER.toDisplayString()); + keystore.setLabel(cardType.toDisplayString()); keystore.setKeyDerivation(keyDerivation); keystore.setSource(KeystoreSource.HW_AIRGAPPED); keystore.setExtendedPublicKey(derivedXpubkey); - keystore.setWalletModel(WalletModel.TAPSIGNER); + keystore.setWalletModel(cardType); return keystore; } @@ -404,7 +406,7 @@ public class CkCardApi extends CardApi { @Override protected PSBT call() throws Exception { CardStatus cardStatus = getStatus(); - if(cardStatus.getCardType() != WalletModel.TAPSIGNER) { + if(cardStatus.getCardType() != WalletModel.TAPSIGNER && cardStatus.getCardType() != WalletModel.SATSCHIP) { throw new IllegalStateException("Please use a " + WalletModel.TAPSIGNER.toDisplayString() + " to sign transactions."); } @@ -465,7 +467,7 @@ public class CkCardApi extends CardApi { @Override protected String call() throws Exception { CardStatus cardStatus = getStatus(); - if(cardStatus.getCardType() != WalletModel.TAPSIGNER) { + if(cardStatus.getCardType() != WalletModel.TAPSIGNER && cardStatus.getCardType() != WalletModel.SATSCHIP) { throw new IllegalStateException("Please use a " + WalletModel.TAPSIGNER.toDisplayString() + " to sign messages."); } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Satschip.java b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Satschip.java new file mode 100644 index 00000000..08dee12a --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Satschip.java @@ -0,0 +1,20 @@ +package com.sparrowwallet.sparrow.io.ckcard; + +import com.sparrowwallet.drongo.wallet.WalletModel; + +public class Satschip extends Tapsigner { + @Override + public String getKeystoreImportDescription(int account) { + return "Import the keystore from your Satschip by placing it on the card reader."; + } + + @Override + public String getName() { + return "Satschip"; + } + + @Override + public WalletModel getWalletModel() { + return WalletModel.SATSCHIP; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Tapsigner.java b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Tapsigner.java index a526506d..b85c0a82 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Tapsigner.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ckcard/Tapsigner.java @@ -16,7 +16,7 @@ public class Tapsigner implements KeystoreCardImport { public boolean isInitialized() throws CardException { CkCardApi cardApi = null; try { - cardApi = new CkCardApi(null); + cardApi = new CkCardApi(getWalletModel(), null); return cardApi.isInitialized(); } finally { if(cardApi != null) { @@ -37,7 +37,7 @@ public class Tapsigner implements KeystoreCardImport { CkCardApi cardApi = null; try { - cardApi = new CkCardApi(pin); + cardApi = new CkCardApi(getWalletModel(), pin); CardStatus cardStatus = cardApi.getStatus(); if(cardStatus.isInitialized()) { throw new IllegalStateException("Card is already initialized."); @@ -63,7 +63,7 @@ public class Tapsigner implements KeystoreCardImport { CkCardApi cardApi = null; try { - cardApi = new CkCardApi(pin); + cardApi = new CkCardApi(getWalletModel(), pin); CardStatus cardStatus = cardApi.getStatus(); if(!cardStatus.isInitialized()) { throw new IllegalStateException("Card is not initialized."); diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java index 1cb4b71b..8e4707e3 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/HwAirgappedController.java @@ -5,6 +5,7 @@ import com.sparrowwallet.sparrow.control.CardImportPane; import com.sparrowwallet.sparrow.control.FileKeystoreImportPane; import com.sparrowwallet.sparrow.control.TitledDescriptionPane; import com.sparrowwallet.sparrow.io.*; +import com.sparrowwallet.sparrow.io.ckcard.Satschip; import com.sparrowwallet.sparrow.io.ckcard.Tapsigner; import com.sparrowwallet.sparrow.io.satochip.Satochip; import javafx.fxml.FXML; @@ -39,7 +40,7 @@ public class HwAirgappedController extends KeystoreImportDetailController { } } - List cardImporters = List.of(new Tapsigner(), new Satochip()); + List cardImporters = List.of(new Tapsigner(), new Satochip(), new Satschip()); for(KeystoreCardImport importer : cardImporters) { if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) { CardImportPane importPane = new CardImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation()); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java index 9fe828ea..1f12ae02 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java @@ -493,7 +493,7 @@ public class KeystoreController extends WalletFormController implements Initiali log.error("Error communicating with card", e); AppServices.showErrorDialog("Error communicating with card", e.getMessage()); }); - ServiceProgressDialog serviceProgressDialog = new ServiceProgressDialog("Authentication Delay", "Waiting for authentication delay to clear...", "/image/tapsigner.png", authDelayService); + ServiceProgressDialog serviceProgressDialog = new ServiceProgressDialog("Authentication Delay", "Waiting for authentication delay to clear...", "/image/" + cardApi.getCardType().getType() + ".png", authDelayService); serviceProgressDialog.initOwner(cardServiceButtons.getScene().getWindow()); AppServices.moveToActiveWindowScreen(serviceProgressDialog); authDelayService.start(); diff --git a/src/main/resources/image/satschip-icon-invert.svg b/src/main/resources/image/satschip-icon-invert.svg new file mode 100644 index 00000000..af7147ce --- /dev/null +++ b/src/main/resources/image/satschip-icon-invert.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/main/resources/image/satschip-icon.svg b/src/main/resources/image/satschip-icon.svg new file mode 100644 index 00000000..fb59fa47 --- /dev/null +++ b/src/main/resources/image/satschip-icon.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/main/resources/image/satschip.png b/src/main/resources/image/satschip.png new file mode 100644 index 00000000..9bbd1270 Binary files /dev/null and b/src/main/resources/image/satschip.png differ diff --git a/src/main/resources/image/satschip@2x.png b/src/main/resources/image/satschip@2x.png new file mode 100644 index 00000000..ab3c53c4 Binary files /dev/null and b/src/main/resources/image/satschip@2x.png differ diff --git a/src/main/resources/image/satschip@3x.png b/src/main/resources/image/satschip@3x.png new file mode 100644 index 00000000..bed902a1 Binary files /dev/null and b/src/main/resources/image/satschip@3x.png differ