From 8d7308bc37fbf957c32fd9756086b35d9585740e Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 16 Sep 2024 08:27:29 +0200 Subject: [PATCH] add warning when sighash none is selected --- .../sparrow/transaction/HeadersController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index bb719c2a..cb3bed45 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -522,6 +522,16 @@ public class HeadersController extends TransactionFormController implements Init } }); sigHash.valueProperty().addListener((observable, oldValue, newValue) -> { + if(newValue == SigHash.NONE || newValue == SigHash.ANYONECANPAY_NONE) { + Optional optType = AppServices.showWarningDialog("Confirm Sighash None", + "A sighash value of none means the signature does not commit to any of the outputs, and can be reused on a transaction with different outputs.\n\nAre you sure?", + ButtonType.NO, ButtonType.YES); + if(optType.isPresent() && optType.get() == ButtonType.NO) { + Platform.runLater(() -> sigHash.getSelectionModel().select(oldValue)); + return; + } + } + for(PSBTInput psbtInput : psbt.getPsbtInputs()) { psbtInput.setSigHash(newValue == SigHash.DEFAULT && !psbtInput.isTaproot() ? SigHash.ALL : newValue); }