mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
add show transaction/psbt as qr from file menu
This commit is contained in:
parent
b5301c4556
commit
25dd0440f6
2 changed files with 43 additions and 0 deletions
|
@ -17,6 +17,9 @@ import com.sparrowwallet.drongo.psbt.PSBTInput;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTParseException;
|
import com.sparrowwallet.drongo.psbt.PSBTParseException;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTSignatureException;
|
import com.sparrowwallet.drongo.psbt.PSBTSignatureException;
|
||||||
import com.sparrowwallet.drongo.wallet.*;
|
import com.sparrowwallet.drongo.wallet.*;
|
||||||
|
import com.sparrowwallet.hummingbird.UR;
|
||||||
|
import com.sparrowwallet.hummingbird.registry.CryptoPSBT;
|
||||||
|
import com.sparrowwallet.hummingbird.registry.RegistryType;
|
||||||
import com.sparrowwallet.sparrow.control.*;
|
import com.sparrowwallet.sparrow.control.*;
|
||||||
import com.sparrowwallet.sparrow.event.*;
|
import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
|
@ -90,12 +93,18 @@ public class AppController implements Initializable {
|
||||||
@FXML
|
@FXML
|
||||||
private MenuItem saveTransaction;
|
private MenuItem saveTransaction;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem showTransaction;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Menu savePSBT;
|
private Menu savePSBT;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private MenuItem savePSBTBinary;
|
private MenuItem savePSBTBinary;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private MenuItem showPSBT;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private MenuItem exportWallet;
|
private MenuItem exportWallet;
|
||||||
|
|
||||||
|
@ -306,8 +315,11 @@ public class AppController implements Initializable {
|
||||||
preventSleep.selectedProperty().bindBidirectional(preventSleepProperty);
|
preventSleep.selectedProperty().bindBidirectional(preventSleepProperty);
|
||||||
|
|
||||||
saveTransaction.setDisable(true);
|
saveTransaction.setDisable(true);
|
||||||
|
showTransaction.visibleProperty().bind(Bindings.and(saveTransaction.visibleProperty(), saveTransaction.disableProperty().not()));
|
||||||
|
showTransaction.disableProperty().bind(saveTransaction.disableProperty());
|
||||||
savePSBT.visibleProperty().bind(saveTransaction.visibleProperty().not());
|
savePSBT.visibleProperty().bind(saveTransaction.visibleProperty().not());
|
||||||
savePSBTBinary.disableProperty().bind(saveTransaction.visibleProperty());
|
savePSBTBinary.disableProperty().bind(saveTransaction.visibleProperty());
|
||||||
|
showPSBT.visibleProperty().bind(saveTransaction.visibleProperty().not());
|
||||||
exportWallet.setDisable(true);
|
exportWallet.setDisable(true);
|
||||||
lockWallet.setDisable(true);
|
lockWallet.setDisable(true);
|
||||||
refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
|
refreshWallet.disableProperty().bind(Bindings.or(exportWallet.disableProperty(), Bindings.or(serverToggle.disableProperty(), AppServices.onlineProperty().not())));
|
||||||
|
@ -588,6 +600,23 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showTransaction(ActionEvent event) {
|
||||||
|
Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
|
||||||
|
TabData tabData = (TabData)selectedTab.getUserData();
|
||||||
|
if(tabData.getType() == TabData.TabType.TRANSACTION) {
|
||||||
|
TransactionTabData transactionTabData = (TransactionTabData) tabData;
|
||||||
|
Transaction transaction = transactionTabData.getTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
UR ur = UR.fromBytes(transaction.bitcoinSerialize());
|
||||||
|
QRDisplayDialog qrDisplayDialog = new QRDisplayDialog(ur);
|
||||||
|
qrDisplayDialog.showAndWait();
|
||||||
|
} catch(Exception e) {
|
||||||
|
log.error("Error creating UR", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void savePSBTBinary(ActionEvent event) {
|
public void savePSBTBinary(ActionEvent event) {
|
||||||
savePSBT(false, true);
|
savePSBT(false, true);
|
||||||
}
|
}
|
||||||
|
@ -671,6 +700,18 @@ public class AppController implements Initializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void showPSBT(ActionEvent event) {
|
||||||
|
Tab selectedTab = tabs.getSelectionModel().getSelectedItem();
|
||||||
|
TabData tabData = (TabData)selectedTab.getUserData();
|
||||||
|
if(tabData.getType() == TabData.TabType.TRANSACTION) {
|
||||||
|
TransactionTabData transactionTabData = (TransactionTabData)tabData;
|
||||||
|
|
||||||
|
CryptoPSBT cryptoPSBT = new CryptoPSBT(transactionTabData.getPsbt().serialize());
|
||||||
|
QRDisplayDialog qrDisplayDialog = new QRDisplayDialog(cryptoPSBT.toUR());
|
||||||
|
qrDisplayDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<WalletTabData> getOpenWalletTabData() {
|
public List<WalletTabData> getOpenWalletTabData() {
|
||||||
List<WalletTabData> openWalletTabData = new ArrayList<>();
|
List<WalletTabData> openWalletTabData = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<MenuItem fx:id="saveTransaction" mnemonicParsing="false" text="Save Transaction..." accelerator="Shortcut+S" onAction="#saveTransaction"/>
|
<MenuItem fx:id="saveTransaction" mnemonicParsing="false" text="Save Transaction..." accelerator="Shortcut+S" onAction="#saveTransaction"/>
|
||||||
|
<MenuItem fx:id="showTransaction" mnemonicParsing="false" text="Show Transaction as QR..." onAction="#showTransaction"/>
|
||||||
<Menu fx:id="savePSBT" mnemonicParsing="false" text="Save PSBT">
|
<Menu fx:id="savePSBT" mnemonicParsing="false" text="Save PSBT">
|
||||||
<MenuItem fx:id="savePSBTBinary" text="As Binary..." onAction="#savePSBTBinary" accelerator="Shortcut+S"/>
|
<MenuItem fx:id="savePSBTBinary" text="As Binary..." onAction="#savePSBTBinary" accelerator="Shortcut+S"/>
|
||||||
<MenuItem text="As Base64..." onAction="#savePSBTText"/>
|
<MenuItem text="As Base64..." onAction="#savePSBTText"/>
|
||||||
|
@ -40,6 +41,7 @@
|
||||||
<MenuItem text="As Base64..." onAction="#savePSBTTextNoXpubs"/>
|
<MenuItem text="As Base64..." onAction="#savePSBTTextNoXpubs"/>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
<MenuItem fx:id="showPSBT" mnemonicParsing="false" text="Show PSBT as QR..." onAction="#showPSBT"/>
|
||||||
<SeparatorMenuItem />
|
<SeparatorMenuItem />
|
||||||
<MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/>
|
<MenuItem mnemonicParsing="false" text="Import Wallet..." onAction="#importWallet"/>
|
||||||
<MenuItem fx:id="exportWallet" mnemonicParsing="false" text="Export Wallet..." onAction="#exportWallet"/>
|
<MenuItem fx:id="exportWallet" mnemonicParsing="false" text="Export Wallet..." onAction="#exportWallet"/>
|
||||||
|
|
Loading…
Reference in a new issue