mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
broadcast fixes
This commit is contained in:
parent
39e5031a78
commit
e5327b3d3d
9 changed files with 86 additions and 13 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 4c5166a6ea886622d57254444e95efa043ba302f
|
Subproject commit 72a2a8bd1becaa77371d1e644c3b9e76b757a8ed
|
|
@ -404,6 +404,8 @@ public class AppController implements Initializable {
|
||||||
return onlineProperty.get();
|
return onlineProperty.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BooleanProperty onlineProperty() { return onlineProperty; }
|
||||||
|
|
||||||
public static Integer getCurrentBlockHeight() {
|
public static Integer getCurrentBlockHeight() {
|
||||||
return currentBlockHeight;
|
return currentBlockHeight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ConfirmationProgressIndicator extends StackPane {
|
||||||
|
|
||||||
Timeline arcLengthTimeline = new Timeline();
|
Timeline arcLengthTimeline = new Timeline();
|
||||||
KeyValue arcLengthValue = new KeyValue(arc.lengthProperty(), getDegrees(newValue.intValue()));
|
KeyValue arcLengthValue = new KeyValue(arc.lengthProperty(), getDegrees(newValue.intValue()));
|
||||||
KeyFrame arcLengthFrame = new KeyFrame(Duration.millis(1000), arcLengthValue);
|
KeyFrame arcLengthFrame = new KeyFrame(Duration.millis(3000), arcLengthValue);
|
||||||
arcLengthTimeline.getKeyFrames().add(arcLengthFrame);
|
arcLengthTimeline.getKeyFrames().add(arcLengthFrame);
|
||||||
sequence.getChildren().add(arcLengthTimeline);
|
sequence.getChildren().add(arcLengthTimeline);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class ConfirmationProgressIndicator extends StackPane {
|
||||||
upTickLineTimeline.getKeyFrames().add(upTickLineFrame);
|
upTickLineTimeline.getKeyFrames().add(upTickLineFrame);
|
||||||
sequence.getChildren().add(upTickLineTimeline);
|
sequence.getChildren().add(upTickLineTimeline);
|
||||||
|
|
||||||
FadeTransition groupFadeOut = new FadeTransition(Duration.minutes(1), confirmationGroup);
|
FadeTransition groupFadeOut = new FadeTransition(Duration.minutes(10), confirmationGroup);
|
||||||
groupFadeOut.setFromValue(1);
|
groupFadeOut.setFromValue(1);
|
||||||
groupFadeOut.setToValue(0);
|
groupFadeOut.setToValue(0);
|
||||||
sequence.getChildren().add(groupFadeOut);
|
sequence.getChildren().add(groupFadeOut);
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class FontAwesome5 extends GlyphFont {
|
||||||
* The individual glyphs offered by the FontAwesome5 font.
|
* The individual glyphs offered by the FontAwesome5 font.
|
||||||
*/
|
*/
|
||||||
public static enum Glyph implements INamedCharacter {
|
public static enum Glyph implements INamedCharacter {
|
||||||
|
ARROW_DOWN('\uf063'),
|
||||||
ARROW_UP('\uf062'),
|
ARROW_UP('\uf062'),
|
||||||
CAMERA('\uf030'),
|
CAMERA('\uf030'),
|
||||||
CHECK_CIRCLE('\uf058'),
|
CHECK_CIRCLE('\uf058'),
|
||||||
|
|
|
@ -246,8 +246,7 @@ public class ElectrumServer {
|
||||||
for(WalletNode node : nodes) {
|
for(WalletNode node : nodes) {
|
||||||
if(node.getIndex() >= startIndex) {
|
if(node.getIndex() >= startIndex) {
|
||||||
String scriptHash = getScriptHash(wallet, node);
|
String scriptHash = getScriptHash(wallet, node);
|
||||||
if(!subscribedScriptHashes.containsKey(scriptHash)) {
|
if(!subscribedScriptHashes.containsKey(scriptHash) && scriptHashes.add(scriptHash)) {
|
||||||
scriptHashes.add(scriptHash);
|
|
||||||
batchRequest.add(node.getDerivationPath(), "blockchain.scripthash.subscribe", scriptHash);
|
batchRequest.add(node.getDerivationPath(), "blockchain.scripthash.subscribe", scriptHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.sparrowwallet.sparrow.transaction;
|
package com.sparrowwallet.sparrow.transaction;
|
||||||
|
|
||||||
import com.sparrowwallet.drongo.SecureString;
|
import com.sparrowwallet.drongo.SecureString;
|
||||||
|
import com.sparrowwallet.drongo.Utils;
|
||||||
import com.sparrowwallet.drongo.protocol.*;
|
import com.sparrowwallet.drongo.protocol.*;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBT;
|
import com.sparrowwallet.drongo.psbt.PSBT;
|
||||||
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
import com.sparrowwallet.drongo.psbt.PSBTInput;
|
||||||
|
@ -12,6 +13,7 @@ import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
|
||||||
import com.sparrowwallet.sparrow.io.ElectrumServer;
|
import com.sparrowwallet.sparrow.io.ElectrumServer;
|
||||||
import com.sparrowwallet.sparrow.io.Storage;
|
import com.sparrowwallet.sparrow.io.Storage;
|
||||||
|
import com.sparrowwallet.sparrow.wallet.TransactionEntry;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -105,7 +107,7 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
private Form blockchainForm;
|
private Form blockchainForm;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CopyableLabel blockStatus;
|
private Label blockStatus;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Field blockHeightField;
|
private Field blockHeightField;
|
||||||
|
@ -173,6 +175,9 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
@FXML
|
@FXML
|
||||||
private Button broadcastButton;
|
private Button broadcastButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button saveFinalButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
EventManager.get().register(this);
|
EventManager.get().register(this);
|
||||||
|
@ -308,6 +313,11 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
broadcastProgressBar.managedProperty().bind(broadcastProgressBar.visibleProperty());
|
broadcastProgressBar.managedProperty().bind(broadcastProgressBar.visibleProperty());
|
||||||
broadcastProgressBar.visibleProperty().bind(signaturesProgressBar.visibleProperty().not());
|
broadcastProgressBar.visibleProperty().bind(signaturesProgressBar.visibleProperty().not());
|
||||||
|
|
||||||
|
broadcastButton.managedProperty().bind(broadcastButton.visibleProperty());
|
||||||
|
saveFinalButton.managedProperty().bind(saveFinalButton.visibleProperty());
|
||||||
|
saveFinalButton.visibleProperty().bind(broadcastButton.visibleProperty().not());
|
||||||
|
broadcastButton.visibleProperty().bind(AppController.onlineProperty());
|
||||||
|
|
||||||
blockchainForm.setVisible(false);
|
blockchainForm.setVisible(false);
|
||||||
signingWalletForm.setVisible(false);
|
signingWalletForm.setVisible(false);
|
||||||
sigHashForm.setVisible(false);
|
sigHashForm.setVisible(false);
|
||||||
|
@ -433,6 +443,17 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
} else {
|
} else {
|
||||||
blockStatus.setText(confirmations + " Confirmations");
|
blockStatus.setText(confirmations + " Confirmations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(confirmations <= TransactionEntry.BLOCKS_TO_CONFIRM) {
|
||||||
|
ConfirmationProgressIndicator indicator;
|
||||||
|
if(blockStatus.getGraphic() == null) {
|
||||||
|
indicator = new ConfirmationProgressIndicator(confirmations);
|
||||||
|
blockStatus.setGraphic(indicator);
|
||||||
|
} else {
|
||||||
|
indicator = (ConfirmationProgressIndicator)blockStatus.getGraphic();
|
||||||
|
indicator.setConfirmations(confirmations);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blockHeightField.managedProperty().bind(blockHeightField.visibleProperty());
|
blockHeightField.managedProperty().bind(blockHeightField.visibleProperty());
|
||||||
|
@ -644,6 +665,12 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
broadcastButton.setDisable(true);
|
broadcastButton.setDisable(true);
|
||||||
extractTransaction(event);
|
extractTransaction(event);
|
||||||
|
|
||||||
|
if(headersForm.getSigningWallet() instanceof FinalizingPSBTWallet) {
|
||||||
|
//Ensure the script hashes of the UTXOs in FinalizingPSBTWallet are subscribed to
|
||||||
|
ElectrumServer.TransactionHistoryService historyService = new ElectrumServer.TransactionHistoryService(headersForm.getSigningWallet());
|
||||||
|
historyService.start();
|
||||||
|
}
|
||||||
|
|
||||||
ElectrumServer.BroadcastTransactionService broadcastTransactionService = new ElectrumServer.BroadcastTransactionService(headersForm.getTransaction());
|
ElectrumServer.BroadcastTransactionService broadcastTransactionService = new ElectrumServer.BroadcastTransactionService(headersForm.getTransaction());
|
||||||
broadcastTransactionService.setOnSucceeded(workerStateEvent -> {
|
broadcastTransactionService.setOnSucceeded(workerStateEvent -> {
|
||||||
//Do nothing and wait for WalletNodeHistoryChangedEvent to indicate tx is in mempool
|
//Do nothing and wait for WalletNodeHistoryChangedEvent to indicate tx is in mempool
|
||||||
|
@ -659,6 +686,29 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
broadcastTransactionService.start();
|
broadcastTransactionService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveFinalTransaction(ActionEvent event) {
|
||||||
|
Stage window = new Stage();
|
||||||
|
|
||||||
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
fileChooser.setTitle("Save Final Transaction");
|
||||||
|
|
||||||
|
if(headersForm.getName() != null && !headersForm.getName().isEmpty()) {
|
||||||
|
fileChooser.setInitialFileName(headersForm.getName().replace(".psbt", "") + ".txn");
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = fileChooser.showSaveDialog(window);
|
||||||
|
if(file != null) {
|
||||||
|
try {
|
||||||
|
try(PrintWriter writer = new PrintWriter(file, StandardCharsets.UTF_8)) {
|
||||||
|
Transaction finalTx = headersForm.getPsbt().extractTransaction();
|
||||||
|
writer.print(Utils.bytesToHex(finalTx.bitcoinSerialize()));
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
AppController.showErrorDialog("Error saving transaction", "Cannot write to " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void transactionChanged(TransactionChangedEvent event) {
|
public void transactionChanged(TransactionChangedEvent event) {
|
||||||
if(headersForm.getTransaction().equals(event.getTransaction())) {
|
if(headersForm.getTransaction().equals(event.getTransaction())) {
|
||||||
|
@ -830,9 +880,9 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void walletBlockHeightChanged(WalletBlockHeightChangedEvent event) {
|
public void newBlock(NewBlockEvent event) {
|
||||||
if(headersForm.getSigningWallet() != null && event.getWallet() == headersForm.getSigningWallet() && headersForm.getBlockTransaction() != null) {
|
if(headersForm.getBlockTransaction() != null) {
|
||||||
updateBlockchainForm(headersForm.getBlockTransaction(), event.getBlockHeight());
|
updateBlockchainForm(headersForm.getBlockTransaction(), event.getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -79,14 +79,18 @@ public class WalletController extends WalletFormController implements Initializa
|
||||||
configure(walletForm.getWallet().isValid());
|
configure(walletForm.getWallet().isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configure(boolean isWalletValid) {
|
public void configure(boolean validWallet) {
|
||||||
for(Toggle toggle : walletMenu.getToggles()) {
|
for(Toggle toggle : walletMenu.getToggles()) {
|
||||||
if(toggle.getUserData().equals(Function.SETTINGS)) {
|
if(toggle.getUserData().equals(Function.SETTINGS)) {
|
||||||
if(!isWalletValid) {
|
if(!validWallet) {
|
||||||
toggle.setSelected(true);
|
toggle.setSelected(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
((ToggleButton)toggle).setDisable(!isWalletValid);
|
if(toggle.getUserData().equals(Function.TRANSACTIONS) && validWallet && walletMenu.getSelectedToggle() == null) {
|
||||||
|
toggle.setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
((ToggleButton)toggle).setDisable(!validWallet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,18 @@
|
||||||
-fx-text-fill: #a0a1a7;
|
-fx-text-fill: #a0a1a7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#blockchainForm .input-container {
|
||||||
|
-fx-alignment: center-left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirmation-progress-circle, .confirmation-progress-tick {
|
||||||
|
-fx-stroke: -fx-text-base-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirmation-progress-arc {
|
||||||
|
-fx-fill: -fx-text-base-color;
|
||||||
|
}
|
||||||
|
|
||||||
#signingWalletForm .input-container {
|
#signingWalletForm .input-container {
|
||||||
-fx-alignment: center-left;
|
-fx-alignment: center-left;
|
||||||
-fx-pref-height: 30;
|
-fx-pref-height: 30;
|
||||||
|
|
|
@ -116,7 +116,7 @@
|
||||||
<Form fx:id="blockchainForm" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="6">
|
<Form fx:id="blockchainForm" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="6">
|
||||||
<Fieldset text="Blockchain" inputGrow="SOMETIMES">
|
<Fieldset text="Blockchain" inputGrow="SOMETIMES">
|
||||||
<Field text="Status:">
|
<Field text="Status:">
|
||||||
<CopyableLabel fx:id="blockStatus" />
|
<Label fx:id="blockStatus" contentDisplay="RIGHT" graphicTextGap="5" />
|
||||||
</Field>
|
</Field>
|
||||||
<Field fx:id="blockHeightField" text="Block Height:">
|
<Field fx:id="blockHeightField" text="Block Height:">
|
||||||
<CopyableLabel fx:id="blockHeight" />
|
<CopyableLabel fx:id="blockHeight" />
|
||||||
|
@ -224,6 +224,11 @@
|
||||||
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="20" icon="SATELLITE_DISH" />
|
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="20" icon="SATELLITE_DISH" />
|
||||||
</graphic>
|
</graphic>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button fx:id="saveFinalButton" defaultButton="true" HBox.hgrow="ALWAYS" text="Save Final Transaction" contentDisplay="TOP" wrapText="true" textAlignment="CENTER" onAction="#saveFinalTransaction">
|
||||||
|
<graphic>
|
||||||
|
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="20" icon="ARROW_DOWN" />
|
||||||
|
</graphic>
|
||||||
|
</Button>
|
||||||
</HBox>
|
</HBox>
|
||||||
</VBox>
|
</VBox>
|
||||||
</Fieldset>
|
</Fieldset>
|
||||||
|
|
Loading…
Reference in a new issue