mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add jade multisig export to wallet export dialog
This commit is contained in:
parent
68cd3673af
commit
e7ed82699c
4 changed files with 59 additions and 4 deletions
|
@ -28,12 +28,14 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
||||||
private final Wallet wallet;
|
private final Wallet wallet;
|
||||||
private final WalletExport exporter;
|
private final WalletExport exporter;
|
||||||
private final boolean scannable;
|
private final boolean scannable;
|
||||||
|
private final boolean file;
|
||||||
|
|
||||||
public FileWalletExportPane(Wallet wallet, WalletExport exporter) {
|
public FileWalletExportPane(Wallet wallet, WalletExport exporter) {
|
||||||
super(exporter.getName(), "Wallet file export", exporter.getWalletExportDescription(), "image/" + exporter.getWalletModel().getType() + ".png");
|
super(exporter.getName(), "Wallet export", exporter.getWalletExportDescription(), "image/" + exporter.getWalletModel().getType() + ".png");
|
||||||
this.wallet = wallet;
|
this.wallet = wallet;
|
||||||
this.exporter = exporter;
|
this.exporter = exporter;
|
||||||
this.scannable = exporter.isWalletExportScannable();
|
this.scannable = exporter.isWalletExportScannable();
|
||||||
|
this.file = exporter.isWalletExportFile();
|
||||||
|
|
||||||
buttonBox.getChildren().clear();
|
buttonBox.getChildren().clear();
|
||||||
buttonBox.getChildren().add(createButton());
|
buttonBox.getChildren().add(createButton());
|
||||||
|
@ -41,7 +43,7 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Control createButton() {
|
protected Control createButton() {
|
||||||
if(scannable) {
|
if(scannable && file) {
|
||||||
ToggleButton showButton = new ToggleButton("Show...");
|
ToggleButton showButton = new ToggleButton("Show...");
|
||||||
Glyph cameraGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CAMERA);
|
Glyph cameraGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CAMERA);
|
||||||
cameraGlyph.setFontSize(12);
|
cameraGlyph.setFontSize(12);
|
||||||
|
@ -61,6 +63,15 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
||||||
SegmentedButton segmentedButton = new SegmentedButton();
|
SegmentedButton segmentedButton = new SegmentedButton();
|
||||||
segmentedButton.getButtons().addAll(showButton, fileButton);
|
segmentedButton.getButtons().addAll(showButton, fileButton);
|
||||||
return segmentedButton;
|
return segmentedButton;
|
||||||
|
} else if(scannable) {
|
||||||
|
Button showButton = new Button("Show...");
|
||||||
|
Glyph cameraGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CAMERA);
|
||||||
|
cameraGlyph.setFontSize(12);
|
||||||
|
showButton.setGraphic(cameraGlyph);
|
||||||
|
showButton.setOnAction(event -> {
|
||||||
|
exportQR();
|
||||||
|
});
|
||||||
|
return showButton;
|
||||||
} else {
|
} else {
|
||||||
Button exportButton = new Button("Export File...");
|
Button exportButton = new Button("Export File...");
|
||||||
exportButton.setAlignment(Pos.CENTER_RIGHT);
|
exportButton.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
@ -137,7 +148,7 @@ public class FileWalletExportPane extends TitledDescriptionPane {
|
||||||
QRDisplayDialog qrDisplayDialog;
|
QRDisplayDialog qrDisplayDialog;
|
||||||
if(exporter instanceof CoboVaultMultisig) {
|
if(exporter instanceof CoboVaultMultisig) {
|
||||||
qrDisplayDialog = new QRDisplayDialog(RegistryType.BYTES.toString(), outputStream.toByteArray(), true);
|
qrDisplayDialog = new QRDisplayDialog(RegistryType.BYTES.toString(), outputStream.toByteArray(), true);
|
||||||
} else if(exporter instanceof PassportMultisig || exporter instanceof KeystoneMultisig) {
|
} else if(exporter instanceof PassportMultisig || exporter instanceof KeystoneMultisig || exporter instanceof JadeMultisig) {
|
||||||
qrDisplayDialog = new QRDisplayDialog(RegistryType.BYTES.toString(), outputStream.toByteArray(), false);
|
qrDisplayDialog = new QRDisplayDialog(RegistryType.BYTES.toString(), outputStream.toByteArray(), false);
|
||||||
} else {
|
} else {
|
||||||
qrDisplayDialog = new QRDisplayDialog(outputStream.toString(StandardCharsets.UTF_8));
|
qrDisplayDialog = new QRDisplayDialog(outputStream.toString(StandardCharsets.UTF_8));
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class WalletExportDialog extends Dialog<Wallet> {
|
||||||
if(wallet.getPolicyType() == PolicyType.SINGLE) {
|
if(wallet.getPolicyType() == PolicyType.SINGLE) {
|
||||||
exporters = List.of(new Electrum(), new ElectrumPersonalServer(), new Descriptor(), new SpecterDesktop(), new Sparrow());
|
exporters = List.of(new Electrum(), new ElectrumPersonalServer(), new Descriptor(), new SpecterDesktop(), new Sparrow());
|
||||||
} else if(wallet.getPolicyType() == PolicyType.MULTI) {
|
} else if(wallet.getPolicyType() == PolicyType.MULTI) {
|
||||||
exporters = List.of(new CaravanMultisig(), new ColdcardMultisig(), new CoboVaultMultisig(), new Electrum(), new ElectrumPersonalServer(), new KeystoneMultisig(), new Descriptor(), new PassportMultisig(), new SpecterDesktop(), new BlueWalletMultisig(), new SpecterDIY(), new Sparrow());
|
exporters = List.of(new CaravanMultisig(), new ColdcardMultisig(), new CoboVaultMultisig(), new Electrum(), new ElectrumPersonalServer(), new KeystoneMultisig(), new Descriptor(), new JadeMultisig(), new PassportMultisig(), new SpecterDesktop(), new BlueWalletMultisig(), new SpecterDIY(), new Sparrow());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("Cannot export wallet with policy type " + wallet.getPolicyType());
|
throw new UnsupportedOperationException("Cannot export wallet with policy type " + wallet.getPolicyType());
|
||||||
}
|
}
|
||||||
|
|
41
src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java
Normal file
41
src/main/java/com/sparrowwallet/sparrow/io/JadeMultisig.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package com.sparrowwallet.sparrow.io;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.wallet.Wallet;
|
||||||
|
import com.sparrowwallet.drongo.wallet.WalletModel;
|
||||||
|
|
||||||
|
public class JadeMultisig extends ColdcardMultisig {
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Jade Multisig";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WalletModel getWalletModel() {
|
||||||
|
return WalletModel.JADE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWalletExportDescription() {
|
||||||
|
return "Export a QR that allows Jade to import a multisig wallet using the Scan feature.";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExportFileExtension(Wallet wallet) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWalletExportScannable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWalletExportFile() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean walletExportRequiresDecryption() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ public interface WalletExport extends ImportExport {
|
||||||
String getExportFileExtension(Wallet wallet);
|
String getExportFileExtension(Wallet wallet);
|
||||||
boolean isWalletExportScannable();
|
boolean isWalletExportScannable();
|
||||||
boolean walletExportRequiresDecryption();
|
boolean walletExportRequiresDecryption();
|
||||||
|
default boolean isWalletExportFile() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default boolean exportsAllWallets() {
|
default boolean exportsAllWallets() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue