diff --git a/drongo b/drongo index 7535c876..7f2c5a5a 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 7535c876bad20a82b0ef4635e97d1528d58c4ba7 +Subproject commit 7f2c5a5a59c046816b9809fc629305c7d4cfe932 diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 7bc62043..f0d1aad2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -484,16 +484,28 @@ public class HeadersController extends TransactionFormController implements Init noWalletsWarningLink.managedProperty().bind(noWalletsWarningLink.visibleProperty()); noWalletsWarningLink.visibleProperty().bind(noWalletsWarning.visibleProperty()); - SigHash psbtSigHash = SigHash.ALL; - for(PSBTInput psbtInput : psbt.getPsbtInputs()) { - if(psbtInput.getSigHash() != null) { - psbtSigHash = psbtInput.getSigHash(); + boolean taprootInput = psbt.getPsbtInputs().stream().anyMatch(PSBTInput::isTaproot); + SigHash psbtSigHash = psbt.getPsbtInputs().stream().map(PSBTInput::getSigHash).filter(Objects::nonNull).findFirst().orElse(taprootInput ? SigHash.DEFAULT : SigHash.ALL); + sigHash.setItems(FXCollections.observableList(taprootInput ? SigHash.TAPROOT_SIGNING_TYPES : SigHash.LEGACY_SIGNING_TYPES)); + sigHash.setValue(psbtSigHash); + sigHash.setConverter(new StringConverter<>() { + @Override + public String toString(SigHash sigHash) { + if(sigHash == null) { + return ""; + } + + return sigHash.getName() + ((taprootInput && sigHash == SigHash.DEFAULT) || (!taprootInput && sigHash == SigHash.ALL) ? " (Recommended)" : ""); } - } - sigHash.setValue(psbtSigHash == SigHash.ALL_TAPROOT ? SigHash.ALL : psbtSigHash); + + @Override + public SigHash fromString(String string) { + return null; + } + }); sigHash.valueProperty().addListener((observable, oldValue, newValue) -> { for(PSBTInput psbtInput : psbt.getPsbtInputs()) { - psbtInput.setSigHash(psbtInput.isTaproot() && newValue == SigHash.ALL ? SigHash.ALL_TAPROOT : newValue); + psbtInput.setSigHash(newValue == SigHash.DEFAULT && !psbtInput.isTaproot() ? SigHash.ALL : newValue); } });