mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
various fixes to signing
This commit is contained in:
parent
f2afd7cb69
commit
a8612da463
8 changed files with 82 additions and 20 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 1f7be6c7d5f1cdfda58617b212630575066e5496
|
Subproject commit d2582c041479704d609c20ed13195c3f92ced999
|
|
@ -168,19 +168,9 @@ public class AppController implements Initializable {
|
||||||
if(selectedTab != null) {
|
if(selectedTab != null) {
|
||||||
TabData tabData = (TabData)selectedTab.getUserData();
|
TabData tabData = (TabData)selectedTab.getUserData();
|
||||||
if(tabData.getType() == TabData.TabType.TRANSACTION) {
|
if(tabData.getType() == TabData.TabType.TRANSACTION) {
|
||||||
TransactionTabData transactionTabData = (TransactionTabData)tabData;
|
|
||||||
EventManager.get().post(new TransactionTabSelectedEvent(selectedTab));
|
EventManager.get().post(new TransactionTabSelectedEvent(selectedTab));
|
||||||
saveTransaction.setDisable(false);
|
|
||||||
saveTransaction.setText("Save " + (transactionTabData.getPsbt() == null || transactionTabData.getPsbt().isFinalized() ? "Transaction..." : "PSBT..."));
|
|
||||||
exportWallet.setDisable(true);
|
|
||||||
showTxHex.setDisable(false);
|
|
||||||
} else if(tabData.getType() == TabData.TabType.WALLET) {
|
} else if(tabData.getType() == TabData.TabType.WALLET) {
|
||||||
WalletTabData walletTabData = (WalletTabData)tabData;
|
|
||||||
EventManager.get().post(new WalletTabSelectedEvent(selectedTab));
|
EventManager.get().post(new WalletTabSelectedEvent(selectedTab));
|
||||||
saveTransaction.setDisable(true);
|
|
||||||
saveTransaction.setText("Save Transaction...");
|
|
||||||
exportWallet.setDisable(walletTabData.getWallet() == null || !walletTabData.getWallet().isValid());
|
|
||||||
showTxHex.setDisable(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -492,6 +482,12 @@ public class AppController implements Initializable {
|
||||||
|
|
||||||
String fileName = selectedTab.getText();
|
String fileName = selectedTab.getText();
|
||||||
if(fileName != null && !fileName.isEmpty()) {
|
if(fileName != null && !fileName.isEmpty()) {
|
||||||
|
if(transactionTabData.getPsbt() != null && !fileName.endsWith(".psbt")) {
|
||||||
|
fileName += ".psbt";
|
||||||
|
} else if(!fileName.endsWith(".txn")) {
|
||||||
|
fileName += ".txn";
|
||||||
|
}
|
||||||
|
|
||||||
if(saveTx && fileName.endsWith(".psbt")) {
|
if(saveTx && fileName.endsWith(".psbt")) {
|
||||||
fileName = fileName.replace(".psbt", "") + ".txn";
|
fileName = fileName.replace(".psbt", "") + ".txn";
|
||||||
}
|
}
|
||||||
|
@ -919,13 +915,40 @@ public class AppController implements Initializable {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void tabSelected(TabSelectedEvent event) {
|
public void tabSelected(TabSelectedEvent event) {
|
||||||
Tab selectedTab = event.getTab();
|
String tabName = event.getTabName();
|
||||||
|
|
||||||
String tabName = selectedTab.getText();
|
|
||||||
if(tabs.getScene() != null) {
|
if(tabs.getScene() != null) {
|
||||||
Stage tabStage = (Stage)tabs.getScene().getWindow();
|
Stage tabStage = (Stage)tabs.getScene().getWindow();
|
||||||
tabStage.setTitle("Sparrow - " + tabName);
|
tabStage.setTitle("Sparrow - " + tabName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(event instanceof TransactionTabSelectedEvent) {
|
||||||
|
TransactionTabSelectedEvent txTabEvent = (TransactionTabSelectedEvent)event;
|
||||||
|
TransactionTabData transactionTabData = txTabEvent.getTransactionTabData();
|
||||||
|
saveTransaction.setDisable(false);
|
||||||
|
saveTransaction.setText("Save " + (transactionTabData.getPsbt() == null || transactionTabData.getPsbt().isFinalized() ? "Transaction..." : "PSBT..."));
|
||||||
|
exportWallet.setDisable(true);
|
||||||
|
showTxHex.setDisable(false);
|
||||||
|
} else if(event instanceof WalletTabSelectedEvent) {
|
||||||
|
WalletTabSelectedEvent walletTabEvent = (WalletTabSelectedEvent)event;
|
||||||
|
WalletTabData walletTabData = walletTabEvent.getWalletTabData();
|
||||||
|
saveTransaction.setDisable(true);
|
||||||
|
saveTransaction.setText("Save Transaction...");
|
||||||
|
exportWallet.setDisable(walletTabData.getWallet() == null || !walletTabData.getWallet().isValid());
|
||||||
|
showTxHex.setDisable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void psbtFinalizedEvent(PSBTFinalizedEvent event) {
|
||||||
|
for(Tab tab : tabs.getTabs()) {
|
||||||
|
TabData tabData = (TabData) tab.getUserData();
|
||||||
|
if(tabData instanceof TransactionTabData) {
|
||||||
|
TransactionTabData transactionTabData = (TransactionTabData)tabData;
|
||||||
|
if(Arrays.equals(transactionTabData.getTransaction().bitcoinSerialize(), event.getPsbt().getTransaction().bitcoinSerialize())) {
|
||||||
|
saveTransaction.setText("Save Transaction...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -1113,6 +1136,8 @@ public class AppController implements Initializable {
|
||||||
if(!deviceEnumerateService.isRunning()) {
|
if(!deviceEnumerateService.isRunning()) {
|
||||||
deviceEnumerateService.start();
|
deviceEnumerateService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,7 +399,7 @@ public class DevicePane extends TitledDescriptionPane {
|
||||||
EventManager.get().post(new KeystoreImportEvent(keystore));
|
EventManager.get().post(new KeystoreImportEvent(keystore));
|
||||||
});
|
});
|
||||||
getXpubService.setOnFailed(workerStateEvent -> {
|
getXpubService.setOnFailed(workerStateEvent -> {
|
||||||
setError(getXpubService.getException().getMessage(), null);
|
setError("Could not retrieve xpub", getXpubService.getException().getMessage());
|
||||||
importButton.setDisable(false);
|
importButton.setDisable(false);
|
||||||
});
|
});
|
||||||
setDescription("Importing...");
|
setDescription("Importing...");
|
||||||
|
@ -414,7 +414,7 @@ public class DevicePane extends TitledDescriptionPane {
|
||||||
EventManager.get().post(new PSBTSignedEvent(psbt, signedPsbt));
|
EventManager.get().post(new PSBTSignedEvent(psbt, signedPsbt));
|
||||||
});
|
});
|
||||||
signPSBTService.setOnFailed(workerStateEvent -> {
|
signPSBTService.setOnFailed(workerStateEvent -> {
|
||||||
setError(signPSBTService.getException().getMessage(), null);
|
setError("Signing Error", signPSBTService.getException().getMessage());
|
||||||
signButton.setDisable(false);
|
signButton.setDisable(false);
|
||||||
});
|
});
|
||||||
setDescription("Signing...");
|
setDescription("Signing...");
|
||||||
|
@ -429,7 +429,7 @@ public class DevicePane extends TitledDescriptionPane {
|
||||||
EventManager.get().post(new AddressDisplayedEvent(address));
|
EventManager.get().post(new AddressDisplayedEvent(address));
|
||||||
});
|
});
|
||||||
displayAddressService.setOnFailed(failedEvent -> {
|
displayAddressService.setOnFailed(failedEvent -> {
|
||||||
setError(displayAddressService.getException().getMessage(), null);
|
setError("Could not display address", displayAddressService.getException().getMessage());
|
||||||
displayAddressButton.setDisable(false);
|
displayAddressButton.setDisable(false);
|
||||||
});
|
});
|
||||||
setDescription("Check device for address");
|
setDescription("Check device for address");
|
||||||
|
|
|
@ -12,6 +12,9 @@ import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Priority;
|
import javafx.scene.layout.Priority;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.OptionalDouble;
|
||||||
|
|
||||||
public class TitledDescriptionPane extends TitledPane {
|
public class TitledDescriptionPane extends TitledPane {
|
||||||
private Label descriptionLabel;
|
private Label descriptionLabel;
|
||||||
protected Hyperlink showHideLink;
|
protected Hyperlink showHideLink;
|
||||||
|
@ -123,6 +126,13 @@ public class TitledDescriptionPane extends TitledPane {
|
||||||
|
|
||||||
double width = TextUtils.computeTextWidth(details.getFont(), message, 0.0D);
|
double width = TextUtils.computeTextWidth(details.getFont(), message, 0.0D);
|
||||||
double numLines = Math.max(1, width / 400);
|
double numLines = Math.max(1, width / 400);
|
||||||
|
|
||||||
|
//Handle long words like txids
|
||||||
|
OptionalDouble maxWordLength = Arrays.stream(message.split(" ")).mapToDouble(word -> TextUtils.computeTextWidth(details.getFont(), message, 0.0D)).max();
|
||||||
|
if(maxWordLength.isPresent() && maxWordLength.getAsDouble() > 300.0) {
|
||||||
|
numLines += 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
double height = Math.max(60, numLines * 40);
|
double height = Math.max(60, numLines * 40);
|
||||||
contentBox.setPrefHeight(height);
|
contentBox.setPrefHeight(height);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package com.sparrowwallet.sparrow.event;
|
package com.sparrowwallet.sparrow.event;
|
||||||
|
|
||||||
|
import com.sparrowwallet.sparrow.TabData;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
|
|
||||||
public class TabEvent {
|
public class TabEvent {
|
||||||
private Tab tab;
|
private final Tab tab;
|
||||||
|
|
||||||
public TabEvent(Tab tab) {
|
public TabEvent(Tab tab) {
|
||||||
this.tab = tab;
|
this.tab = tab;
|
||||||
|
@ -12,4 +13,12 @@ public class TabEvent {
|
||||||
public Tab getTab() {
|
public Tab getTab() {
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTabName() {
|
||||||
|
return tab.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabData getTabData() {
|
||||||
|
return (TabData)tab.getUserData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package com.sparrowwallet.sparrow.event;
|
package com.sparrowwallet.sparrow.event;
|
||||||
|
|
||||||
|
import com.sparrowwallet.sparrow.TransactionTabData;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
|
|
||||||
public class TransactionTabSelectedEvent extends TabSelectedEvent {
|
public class TransactionTabSelectedEvent extends TabSelectedEvent {
|
||||||
public TransactionTabSelectedEvent(Tab tab) {
|
public TransactionTabSelectedEvent(Tab tab) {
|
||||||
super(tab);
|
super(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TransactionTabData getTransactionTabData() {
|
||||||
|
return (TransactionTabData)getTabData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package com.sparrowwallet.sparrow.event;
|
package com.sparrowwallet.sparrow.event;
|
||||||
|
|
||||||
|
import com.sparrowwallet.sparrow.WalletTabData;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
|
|
||||||
public class WalletTabSelectedEvent extends TabSelectedEvent {
|
public class WalletTabSelectedEvent extends TabSelectedEvent {
|
||||||
public WalletTabSelectedEvent(Tab tab) {
|
public WalletTabSelectedEvent(Tab tab) {
|
||||||
super(tab);
|
super(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WalletTabData getWalletTabData() {
|
||||||
|
return (WalletTabData)getTabData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,21 @@ public class InputForm extends IndexedTransactionForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransactionInput getTransactionInput() {
|
public TransactionInput getTransactionInput() {
|
||||||
|
if(txdata.getTransaction() != null) {
|
||||||
return txdata.getTransaction().getInputs().get(getIndex());
|
return txdata.getTransaction().getInputs().get(getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public PSBTInput getPsbtInput() {
|
public PSBTInput getPsbtInput() {
|
||||||
|
if(txdata.getPsbt() != null) {
|
||||||
return txdata.getPsbt().getPsbtInputs().get(getIndex());
|
return txdata.getPsbt().getPsbtInputs().get(getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public TransactionOutput getReferencedTransactionOutput() {
|
public TransactionOutput getReferencedTransactionOutput() {
|
||||||
if(getInputTransactions() != null) {
|
if(getInputTransactions() != null) {
|
||||||
BlockTransaction inputTransaction = getInputTransactions().get(getTransactionInput().getOutpoint().getHash());
|
BlockTransaction inputTransaction = getInputTransactions().get(getTransactionInput().getOutpoint().getHash());
|
||||||
|
|
Loading…
Reference in a new issue