mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
show taproot specific sighash default in sighash dropdown, and select if appropriate
This commit is contained in:
parent
15da62777e
commit
62e7c34eb5
2 changed files with 20 additions and 8 deletions
2
drongo
2
drongo
|
@ -1 +1 @@
|
||||||
Subproject commit 7535c876bad20a82b0ef4635e97d1528d58c4ba7
|
Subproject commit 7f2c5a5a59c046816b9809fc629305c7d4cfe932
|
|
@ -484,16 +484,28 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
noWalletsWarningLink.managedProperty().bind(noWalletsWarningLink.visibleProperty());
|
noWalletsWarningLink.managedProperty().bind(noWalletsWarningLink.visibleProperty());
|
||||||
noWalletsWarningLink.visibleProperty().bind(noWalletsWarning.visibleProperty());
|
noWalletsWarningLink.visibleProperty().bind(noWalletsWarning.visibleProperty());
|
||||||
|
|
||||||
SigHash psbtSigHash = SigHash.ALL;
|
boolean taprootInput = psbt.getPsbtInputs().stream().anyMatch(PSBTInput::isTaproot);
|
||||||
for(PSBTInput psbtInput : psbt.getPsbtInputs()) {
|
SigHash psbtSigHash = psbt.getPsbtInputs().stream().map(PSBTInput::getSigHash).filter(Objects::nonNull).findFirst().orElse(taprootInput ? SigHash.DEFAULT : SigHash.ALL);
|
||||||
if(psbtInput.getSigHash() != null) {
|
sigHash.setItems(FXCollections.observableList(taprootInput ? SigHash.TAPROOT_SIGNING_TYPES : SigHash.LEGACY_SIGNING_TYPES));
|
||||||
psbtSigHash = psbtInput.getSigHash();
|
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) -> {
|
sigHash.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
for(PSBTInput psbtInput : psbt.getPsbtInputs()) {
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue