finalize psbt once signing animation is complete

This commit is contained in:
Craig Raw 2020-07-28 08:31:11 +02:00
parent 62618e5da5
commit 658ab2f81c
8 changed files with 72 additions and 2 deletions

2
drongo

@ -1 +1 @@
Subproject commit 15beeefcb687c77adddbfe5e2b74c75b2c6f2196
Subproject commit 3ce2394813749be99e79f4f0253f2636fab9df91

View file

@ -1,6 +1,8 @@
package com.sparrowwallet.sparrow.control;
import com.sparrowwallet.drongo.wallet.Keystore;
import com.sparrowwallet.sparrow.EventManager;
import com.sparrowwallet.sparrow.event.KeystoreSignedEvent;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
@ -100,6 +102,10 @@ public class SignaturesProgressBar extends SegmentedBar<SignaturesProgressBar.Si
public void setKeystore(Keystore keystore) {
keystoreProperty.set(keystore);
}
public void signatureCompleted() {
EventManager.get().post(new KeystoreSignedEvent(getKeystore()));
}
}
public static class SignatureProgressSegmentView extends StackPane {
@ -126,7 +132,9 @@ public class SignaturesProgressBar extends SegmentedBar<SignaturesProgressBar.Si
if(oldValue == null && newValue != null) {
Timeline timeline = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(progressBar.progressProperty(), 0)),
new KeyFrame(Duration.millis(800), new KeyValue(progressBar.progressProperty(), 1))
new KeyFrame(Duration.millis(800), e -> {
segment.signatureCompleted();
}, new KeyValue(progressBar.progressProperty(), 1))
);
timeline.setCycleCount(1);
timeline.play();

View file

@ -0,0 +1,18 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.wallet.Keystore;
/**
* This event is used to indicate the animation for signing a keystore is complete
*/
public class KeystoreSignedEvent {
private final Keystore keystore;
public KeystoreSignedEvent(Keystore keystore) {
this.keystore = keystore;
}
public Keystore getKeystore() {
return keystore;
}
}

View file

@ -0,0 +1,13 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.psbt.PSBT;
/**
* This event is fired once the signing animation has finished and the PSBT has been finalized
*
*/
public class PSBTFinalizedEvent extends PSBTEvent {
public PSBTFinalizedEvent(PSBT psbt) {
super(psbt);
}
}

View file

@ -2,6 +2,10 @@ package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.drongo.psbt.PSBT;
/**
* This event is used by the DeviceSignDialog to indicate that a USB device has signed a PSBT
*
*/
public class PSBTSignedEvent extends PSBTEvent {
private final PSBT signedPsbt;

View file

@ -646,4 +646,14 @@ public class HeadersController extends TransactionFormController implements Init
updateSignedKeystores(headersForm.getSigningWallet());
}
}
@Subscribe
public void keystoreSigned(KeystoreSignedEvent event) {
if(headersForm.getSignedKeystores().contains(event.getKeystore()) && headersForm.getPsbt() != null) {
if(headersForm.getPsbt().isSigned()) {
headersForm.getSigningWallet().finalise(headersForm.getPsbt());
EventManager.get().post(new PSBTFinalizedEvent(headersForm.getPsbt()));
}
}
}
}

View file

@ -526,4 +526,13 @@ public class InputController extends TransactionFormController implements Initia
updateSignatures(inputForm.getPsbtInput());
}
}
@Subscribe
public void psbtFinalized(PSBTFinalizedEvent event) {
if(event.getPsbt().equals(inputForm.getPsbt())) {
updateSpends(inputForm.getPsbtInput().getUtxo());
updateScriptFields(inputForm.getTransactionInput(), inputForm.getPsbtInput());
updateSignatures(inputForm.getPsbtInput());
}
}
}

View file

@ -12,6 +12,7 @@ import com.sparrowwallet.sparrow.control.CopyableLabel;
import com.sparrowwallet.sparrow.event.BitcoinUnitChangedEvent;
import com.sparrowwallet.sparrow.event.BlockTransactionFetchedEvent;
import com.sparrowwallet.sparrow.event.PSBTCombinedEvent;
import com.sparrowwallet.sparrow.event.PSBTFinalizedEvent;
import javafx.collections.ListChangeListener;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
@ -180,4 +181,11 @@ public class InputsController extends TransactionFormController implements Initi
updatePSBTInputs(inputsForm.getPsbt());
}
}
@Subscribe
public void psbtFinalized(PSBTFinalizedEvent event) {
if(event.getPsbt().equals(inputsForm.getPsbt())) {
updatePSBTInputs(inputsForm.getPsbt());
}
}
}