mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
fix locktime none and date
This commit is contained in:
parent
b25aa27375
commit
79e7b2440c
5 changed files with 24 additions and 9 deletions
|
@ -42,7 +42,7 @@ dependencies {
|
||||||
testImplementation('junit:junit:4.12')
|
testImplementation('junit:junit:4.12')
|
||||||
}
|
}
|
||||||
|
|
||||||
mainClassName = 'com.sparrowwallet.sparrow.MainApp'
|
mainClassName = 'com.sparrowwallet.sparrow/com.sparrowwallet.sparrow.MainApp'
|
||||||
|
|
||||||
run {
|
run {
|
||||||
applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png"]
|
applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png"]
|
||||||
|
|
|
@ -35,8 +35,10 @@ public class AppController implements Initializable {
|
||||||
void initializeView() {
|
void initializeView() {
|
||||||
tabs.getSelectionModel().selectedItemProperty().addListener((observable, old_val, new_val) -> {
|
tabs.getSelectionModel().selectedItemProperty().addListener((observable, old_val, new_val) -> {
|
||||||
String tabName = new_val.getText();
|
String tabName = new_val.getText();
|
||||||
|
if(tabs.getScene() != null) {
|
||||||
Stage tabStage = (Stage)tabs.getScene().getWindow();
|
Stage tabStage = (Stage)tabs.getScene().getWindow();
|
||||||
tabStage.setTitle("Sparrow - " + tabName);
|
tabStage.setTitle("Sparrow - " + tabName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addExampleTxTabs();
|
addExampleTxTabs();
|
||||||
|
|
|
@ -14,7 +14,6 @@ public class MainApp extends Application {
|
||||||
FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("app.fxml"));
|
FXMLLoader transactionLoader = new FXMLLoader(getClass().getResource("app.fxml"));
|
||||||
Parent root = transactionLoader.load();
|
Parent root = transactionLoader.load();
|
||||||
AppController appController = transactionLoader.getController();
|
AppController appController = transactionLoader.getController();
|
||||||
appController.initializeView();
|
|
||||||
|
|
||||||
Scene scene = new Scene(root);
|
Scene scene = new Scene(root);
|
||||||
scene.getStylesheets().add(getClass().getResource("app.css").toExternalForm());
|
scene.getStylesheets().add(getClass().getResource("app.css").toExternalForm());
|
||||||
|
@ -23,6 +22,8 @@ public class MainApp extends Application {
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.getIcons().add(new Image(MainApp.class.getResourceAsStream("/sparrow.png")));
|
stage.getIcons().add(new Image(MainApp.class.getResourceAsStream("/sparrow.png")));
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
|
appController.initializeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -42,12 +42,18 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
@FXML
|
@FXML
|
||||||
private Fieldset locktimeFieldset;
|
private Fieldset locktimeFieldset;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Field locktimeNoneField;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Field locktimeBlockField;
|
private Field locktimeBlockField;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Field locktimeDateField;
|
private Field locktimeDateField;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> locktimeNone;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Spinner<Integer> locktimeBlock;
|
private Spinner<Integer> locktimeBlock;
|
||||||
|
|
||||||
|
@ -102,16 +108,15 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
if(selection.equals("none")) {
|
if(selection.equals("none")) {
|
||||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||||
locktimeFieldset.getChildren().add(locktimeBlockField);
|
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||||
locktimeBlock.setDisable(true);
|
locktimeFieldset.getChildren().add(locktimeNoneField);
|
||||||
locktimeBlock.getValueFactory().setValue(0);
|
|
||||||
tx.setLockTime(0);
|
tx.setLockTime(0);
|
||||||
EventManager.get().notify(tx);
|
EventManager.get().notify(tx);
|
||||||
} else if(selection.equals("block")) {
|
} else if(selection.equals("block")) {
|
||||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||||
|
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||||
locktimeFieldset.getChildren().add(locktimeBlockField);
|
locktimeFieldset.getChildren().add(locktimeBlockField);
|
||||||
locktimeBlock.setDisable(false);
|
|
||||||
Integer block = locktimeBlock.getValue();
|
Integer block = locktimeBlock.getValue();
|
||||||
if(block != null) {
|
if(block != null) {
|
||||||
tx.setLockTime(block);
|
tx.setLockTime(block);
|
||||||
|
@ -120,9 +125,11 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
} else {
|
} else {
|
||||||
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
locktimeFieldset.getChildren().remove(locktimeBlockField);
|
||||||
locktimeFieldset.getChildren().remove(locktimeDateField);
|
locktimeFieldset.getChildren().remove(locktimeDateField);
|
||||||
|
locktimeFieldset.getChildren().remove(locktimeNoneField);
|
||||||
locktimeFieldset.getChildren().add(locktimeDateField);
|
locktimeFieldset.getChildren().add(locktimeDateField);
|
||||||
LocalDateTime date = locktimeDate.getDateTimeValue();
|
LocalDateTime date = locktimeDate.getDateTimeValue();
|
||||||
if(date != null) {
|
if(date != null) {
|
||||||
|
locktimeDate.setDateTimeValue(date);
|
||||||
tx.setLockTime(date.toEpochSecond(OffsetDateTime.now(ZoneId.systemDefault()).getOffset()));
|
tx.setLockTime(date.toEpochSecond(OffsetDateTime.now(ZoneId.systemDefault()).getOffset()));
|
||||||
EventManager.get().notify(tx);
|
EventManager.get().notify(tx);
|
||||||
}
|
}
|
||||||
|
@ -130,14 +137,16 @@ public class HeadersController extends TransactionFormController implements Init
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
locktimeNone.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1, 0));
|
||||||
if(tx.getLockTime() < MAX_BLOCK_LOCKTIME) {
|
if(tx.getLockTime() < MAX_BLOCK_LOCKTIME) {
|
||||||
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1, (int)tx.getLockTime()));
|
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1, (int)tx.getLockTime()));
|
||||||
if(tx.getLockTime() == 0) {
|
if(tx.getLockTime() == 0) {
|
||||||
locktimeToggleGroup.selectToggle(locktimeNoneType);
|
locktimeToggleGroup.selectToggle(locktimeNoneType);
|
||||||
locktimeBlock.setDisable(true);
|
|
||||||
} else {
|
} else {
|
||||||
locktimeToggleGroup.selectToggle(locktimeBlockType);
|
locktimeToggleGroup.selectToggle(locktimeBlockType);
|
||||||
}
|
}
|
||||||
|
LocalDateTime date = Instant.now().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||||
|
locktimeDate.setDateTimeValue(date);
|
||||||
} else {
|
} else {
|
||||||
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1));
|
locktimeBlock.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, (int)MAX_BLOCK_LOCKTIME-1));
|
||||||
LocalDateTime date = Instant.ofEpochSecond(tx.getLockTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
LocalDateTime date = Instant.ofEpochSecond(tx.getLockTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||||
|
|
|
@ -63,6 +63,9 @@
|
||||||
</buttons>
|
</buttons>
|
||||||
</SegmentedButton>
|
</SegmentedButton>
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field fx:id="locktimeNoneField" text="Block:">
|
||||||
|
<Spinner fx:id="locktimeNone" disable="true" prefWidth="120"/>
|
||||||
|
</Field>
|
||||||
<Field fx:id="locktimeBlockField" text="Block:">
|
<Field fx:id="locktimeBlockField" text="Block:">
|
||||||
<Spinner fx:id="locktimeBlock" prefWidth="120"/>
|
<Spinner fx:id="locktimeBlock" prefWidth="120"/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
Loading…
Reference in a new issue