From 7d8774c94cba6804cb113358294170a8ed99548d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 10 Aug 2020 08:34:47 +0200 Subject: [PATCH] better handling of showing blocktransaction details --- .../sparrowwallet/sparrow/io/ElectrumServer.java | 1 + .../sparrow/transaction/HeadersController.java | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java index 76301895..793d0676 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/ElectrumServer.java @@ -111,6 +111,7 @@ public class ElectrumServer { public List getServerVersion() throws ServerException { JsonRpcClient client = new JsonRpcClient(getTransport()); + //return client.createRequest().returnAsList(String.class).method("server.version").id(1).params("Sparrow", "1.4").execute(); return client.createRequest().returnAsList(String.class).method("server.version").id(1).param("client_name", "Sparrow").param("protocol_version", SUPPORTED_VERSIONS).execute(); } diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 6e425462..86d6e171 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -464,20 +464,28 @@ public class HeadersController extends TransactionFormController implements Init blockHeightField.managedProperty().bind(blockHeightField.visibleProperty()); blockTimestampField.managedProperty().bind(blockTimestampField.visibleProperty()); blockHashField.managedProperty().bind(blockHashField.visibleProperty()); - blockTimestampField.visibleProperty().bind(blockHeightField.visibleProperty()); - blockHashField.visibleProperty().bind(blockHeightField.visibleProperty()); - if(blockTransaction.getBlockHash() != null) { + if(blockTransaction.getHeight() > 0) { blockHeightField.setVisible(true); blockHeight.setText(Integer.toString(blockTransaction.getHeight())); + } else { + blockHeightField.setVisible(false); + } + if(blockTransaction.getDate() != null) { + blockTimestampField.setVisible(true); SimpleDateFormat dateFormat = new SimpleDateFormat(BLOCK_TIMESTAMP_DATE_FORMAT); blockTimestamp.setText(dateFormat.format(blockTransaction.getDate())); + } else { + blockTimestampField.setVisible(false); + } + if(blockTransaction.getBlockHash() != null) { + blockHashField.setVisible(true); blockHash.setText(blockTransaction.getBlockHash().toString()); blockHash.setContextMenu(new BlockHeightContextMenu(blockTransaction.getBlockHash())); } else { - blockHeightField.setVisible(false); + blockHashField.setVisible(false); } }