mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 18:56:59 +01:00
funds table update, lib update 11.3 (bloomfilter bug in 11.0)
This commit is contained in:
parent
a91346252e
commit
3d6c2a8c62
7 changed files with 180 additions and 150 deletions
2
pom.xml
2
pom.xml
|
@ -105,7 +105,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google</groupId>
|
<groupId>com.google</groupId>
|
||||||
<artifactId>bitcoinj</artifactId>
|
<artifactId>bitcoinj</artifactId>
|
||||||
<version>0.11</version>
|
<version>0.11.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -60,6 +60,9 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
||||||
}
|
}
|
||||||
vChain = new BlockChain(params, vStore);
|
vChain = new BlockChain(params, vStore);
|
||||||
vPeerGroup = createPeerGroup();
|
vPeerGroup = createPeerGroup();
|
||||||
|
|
||||||
|
vPeerGroup.setBloomFilterFalsePositiveRate(0.001); // 0,1% instead of default 0,05%
|
||||||
|
|
||||||
if (this.userAgent != null)
|
if (this.userAgent != null)
|
||||||
vPeerGroup.setUserAgent(userAgent, version);
|
vPeerGroup.setUserAgent(userAgent, version);
|
||||||
if (vWalletFile.exists())
|
if (vWalletFile.exists())
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class WalletFacade
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
||||||
|
|
||||||
|
private String saveAddressEntryListId;
|
||||||
private NetworkParameters params;
|
private NetworkParameters params;
|
||||||
private BitSquareWalletAppKit walletAppKit;
|
private BitSquareWalletAppKit walletAppKit;
|
||||||
private FeePolicy feePolicy;
|
private FeePolicy feePolicy;
|
||||||
|
@ -163,7 +164,8 @@ public class WalletFacade
|
||||||
};
|
};
|
||||||
wallet.addEventListener(walletEventListener);
|
wallet.addEventListener(walletEventListener);
|
||||||
|
|
||||||
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) storage.read("addressInfoList");
|
saveAddressEntryListId = this.getClass().getName() + ".addressEntryList";
|
||||||
|
List<AddressEntry> savedAddressEntryList = (List<AddressEntry>) storage.read(saveAddressEntryListId);
|
||||||
if (savedAddressEntryList != null)
|
if (savedAddressEntryList != null)
|
||||||
{
|
{
|
||||||
addressEntryList = savedAddressEntryList;
|
addressEntryList = savedAddressEntryList;
|
||||||
|
@ -195,7 +197,7 @@ public class WalletFacade
|
||||||
private void saveAddressInfoList()
|
private void saveAddressInfoList()
|
||||||
{
|
{
|
||||||
// use wallet extension?
|
// use wallet extension?
|
||||||
storage.write("addressInfoList", addressEntryList);
|
storage.write(saveAddressEntryListId, addressEntryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -213,13 +215,16 @@ public class WalletFacade
|
||||||
downloadListeners.remove(listener);
|
downloadListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addConfidenceListener(ConfidenceListener listener)
|
public ConfidenceListener addConfidenceListener(ConfidenceListener listener)
|
||||||
{
|
{
|
||||||
|
log.debug("addConfidenceListener " + listener.getAddress().toString());
|
||||||
confidenceListeners.add(listener);
|
confidenceListeners.add(listener);
|
||||||
|
return listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeConfidenceListener(ConfidenceListener listener)
|
public void removeConfidenceListener(ConfidenceListener listener)
|
||||||
{
|
{
|
||||||
|
log.debug("removeConfidenceListener " + listener.getAddress().toString());
|
||||||
confidenceListeners.remove(listener);
|
confidenceListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,44 +308,36 @@ public class WalletFacade
|
||||||
|
|
||||||
public AddressEntry getUnusedTradeAddressInfo()
|
public AddressEntry getUnusedTradeAddressInfo()
|
||||||
{
|
{
|
||||||
if (addressEntryList != null)
|
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
||||||
{
|
{
|
||||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
@Override
|
||||||
|
public boolean apply(@Nullable AddressEntry addressInfo)
|
||||||
{
|
{
|
||||||
@Override
|
return (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null);
|
||||||
public boolean apply(@Nullable AddressEntry addressInfo)
|
}
|
||||||
{
|
}));
|
||||||
return (addressInfo != null && addressInfo.getAddressContext().equals(AddressEntry.AddressContext.TRADE) && addressInfo.getTradeId() == null);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (filteredList != null && filteredList.size() > 0)
|
if (filteredList != null && filteredList.size() > 0)
|
||||||
return filteredList.get(0);
|
return filteredList.get(0);
|
||||||
else
|
else
|
||||||
return getNewTradeAddressInfo();
|
return getNewTradeAddressInfo();
|
||||||
}
|
|
||||||
return getNewTradeAddressInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
||||||
{
|
{
|
||||||
if (addressEntryList != null)
|
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
||||||
{
|
{
|
||||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
@Override
|
||||||
|
public boolean apply(@Nullable AddressEntry addressInfo)
|
||||||
{
|
{
|
||||||
@Override
|
return (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext));
|
||||||
public boolean apply(@Nullable AddressEntry addressInfo)
|
}
|
||||||
{
|
}));
|
||||||
return (addressInfo != null && addressContext != null && addressInfo.getAddressContext() != null && addressInfo.getAddressContext().equals(addressContext));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (filteredList != null && filteredList.size() > 0)
|
if (filteredList != null && filteredList.size() > 0)
|
||||||
return filteredList.get(0);
|
return filteredList.get(0);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddressEntry getAddressInfoByTradeID(String tradeId)
|
public AddressEntry getAddressInfoByTradeID(String tradeId)
|
||||||
|
@ -370,6 +367,7 @@ public class WalletFacade
|
||||||
{
|
{
|
||||||
ECKey key = new ECKey();
|
ECKey key = new ECKey();
|
||||||
wallet.addKey(key);
|
wallet.addKey(key);
|
||||||
|
wallet.addWatchedAddress(key.toAddress(params));
|
||||||
AddressEntry addressEntry = new AddressEntry(key, params, addressContext);
|
AddressEntry addressEntry = new AddressEntry(key, params, addressContext);
|
||||||
addressEntryList.add(addressEntry);
|
addressEntryList.add(addressEntry);
|
||||||
saveAddressInfoList();
|
saveAddressInfoList();
|
||||||
|
|
|
@ -1,20 +1,112 @@
|
||||||
package io.bitsquare.gui.funds;
|
package io.bitsquare.gui.funds;
|
||||||
|
|
||||||
import com.google.bitcoin.core.Address;
|
import com.google.bitcoin.core.Address;
|
||||||
|
import com.google.bitcoin.core.TransactionConfidence;
|
||||||
import io.bitsquare.btc.AddressEntry;
|
import io.bitsquare.btc.AddressEntry;
|
||||||
|
import io.bitsquare.btc.BtcFormatter;
|
||||||
|
import io.bitsquare.btc.WalletFacade;
|
||||||
|
import io.bitsquare.btc.listeners.BalanceListener;
|
||||||
|
import io.bitsquare.btc.listeners.ConfidenceListener;
|
||||||
|
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
public class AddressListItem
|
public class AddressListItem
|
||||||
{
|
{
|
||||||
private final StringProperty addressString = new SimpleStringProperty();
|
private final StringProperty addressString = new SimpleStringProperty();
|
||||||
|
private final BalanceListener balanceListener;
|
||||||
|
private final Label balanceLabel;
|
||||||
private AddressEntry addressEntry;
|
private AddressEntry addressEntry;
|
||||||
|
private WalletFacade walletFacade;
|
||||||
|
private ConfidenceListener confidenceListener;
|
||||||
|
private ConfidenceProgressIndicator progressIndicator;
|
||||||
|
private Tooltip tooltip;
|
||||||
|
|
||||||
public AddressListItem(AddressEntry addressEntry)
|
public AddressListItem(AddressEntry addressEntry, WalletFacade walletFacade)
|
||||||
{
|
{
|
||||||
this.addressEntry = addressEntry;
|
this.addressEntry = addressEntry;
|
||||||
|
this.walletFacade = walletFacade;
|
||||||
this.addressString.set(getAddress().toString());
|
this.addressString.set(getAddress().toString());
|
||||||
|
|
||||||
|
progressIndicator = new ConfidenceProgressIndicator();
|
||||||
|
progressIndicator.setId("funds-confidence");
|
||||||
|
tooltip = new Tooltip("Not used yet");
|
||||||
|
progressIndicator.setProgress(0);
|
||||||
|
progressIndicator.setPrefHeight(30);
|
||||||
|
progressIndicator.setPrefWidth(30);
|
||||||
|
Tooltip.install(progressIndicator, tooltip);
|
||||||
|
|
||||||
|
confidenceListener = walletFacade.addConfidenceListener(new ConfidenceListener(getAddress())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onTransactionConfidenceChanged(TransactionConfidence confidence)
|
||||||
|
{
|
||||||
|
updateConfidence(confidence);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateConfidence(walletFacade.getConfidenceForAddress(getAddress()));
|
||||||
|
|
||||||
|
|
||||||
|
balanceListener = new BalanceListener(getAddress());
|
||||||
|
balanceLabel = new Label();
|
||||||
|
walletFacade.addBalanceListener(new BalanceListener(getAddress())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onBalanceChanged(BigInteger balance)
|
||||||
|
{
|
||||||
|
updateBalance(balance);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateBalance(walletFacade.getBalanceForAddress(getAddress()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanup()
|
||||||
|
{
|
||||||
|
walletFacade.removeConfidenceListener(confidenceListener);
|
||||||
|
walletFacade.removeBalanceListener(balanceListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBalance(BigInteger balance)
|
||||||
|
{
|
||||||
|
if (balance != null)
|
||||||
|
{
|
||||||
|
balanceLabel.setText(BtcFormatter.btcToString(balance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConfidence(TransactionConfidence confidence)
|
||||||
|
{
|
||||||
|
if (confidence != null)
|
||||||
|
{
|
||||||
|
//log.debug("Type numBroadcastPeers getDepthInBlocks " + confidence.getConfidenceType() + " / " + confidence.numBroadcastPeers() + " / " + confidence.getDepthInBlocks());
|
||||||
|
switch (confidence.getConfidenceType())
|
||||||
|
{
|
||||||
|
case UNKNOWN:
|
||||||
|
tooltip.setText("Unknown transaction status");
|
||||||
|
progressIndicator.setProgress(0);
|
||||||
|
break;
|
||||||
|
case PENDING:
|
||||||
|
tooltip.setText("Seen by " + confidence.numBroadcastPeers() + " peer(s) / 0 confirmations");
|
||||||
|
progressIndicator.setProgress(-1.0);
|
||||||
|
break;
|
||||||
|
case BUILDING:
|
||||||
|
tooltip.setText("Confirmed in " + confidence.getDepthInBlocks() + " block(s)");
|
||||||
|
progressIndicator.setProgress(Math.min(1, (double) confidence.getDepthInBlocks() / 6.0));
|
||||||
|
break;
|
||||||
|
case DEAD:
|
||||||
|
tooltip.setText("Transaction is invalid.");
|
||||||
|
progressIndicator.setProgress(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
progressIndicator.setPrefSize(24, 24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getLabel()
|
public final String getLabel()
|
||||||
|
@ -49,4 +141,29 @@ public class AddressListItem
|
||||||
{
|
{
|
||||||
return addressEntry;
|
return addressEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfidenceListener getConfidenceListener()
|
||||||
|
{
|
||||||
|
return confidenceListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfidenceProgressIndicator getProgressIndicator()
|
||||||
|
{
|
||||||
|
return progressIndicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tooltip getTooltip()
|
||||||
|
{
|
||||||
|
return tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BalanceListener getBalanceListener()
|
||||||
|
{
|
||||||
|
return balanceListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Label getBalanceLabel()
|
||||||
|
{
|
||||||
|
return balanceLabel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
package io.bitsquare.gui.funds;
|
package io.bitsquare.gui.funds;
|
||||||
|
|
||||||
import com.google.bitcoin.core.TransactionConfidence;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||||
import io.bitsquare.btc.AddressEntry;
|
import io.bitsquare.btc.AddressEntry;
|
||||||
import io.bitsquare.btc.BtcFormatter;
|
|
||||||
import io.bitsquare.btc.WalletFacade;
|
import io.bitsquare.btc.WalletFacade;
|
||||||
import io.bitsquare.btc.listeners.BalanceListener;
|
|
||||||
import io.bitsquare.btc.listeners.ConfidenceListener;
|
|
||||||
import io.bitsquare.gui.ChildController;
|
import io.bitsquare.gui.ChildController;
|
||||||
import io.bitsquare.gui.NavigationController;
|
import io.bitsquare.gui.NavigationController;
|
||||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
|
||||||
import io.bitsquare.gui.util.ConfidenceDisplay;
|
import io.bitsquare.gui.util.ConfidenceDisplay;
|
||||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
|
@ -27,7 +22,6 @@ import javafx.util.Callback;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
@ -68,21 +62,19 @@ public class FundsController implements Initializable, ChildController
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb)
|
public void initialize(URL url, ResourceBundle rb)
|
||||||
{
|
{
|
||||||
setLabelColumnCellFactory();
|
|
||||||
setBalanceColumnCellFactory();
|
|
||||||
setCopyColumnCellFactory();
|
|
||||||
setConfidenceColumnCellFactory();
|
|
||||||
|
|
||||||
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
|
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
|
||||||
|
|
||||||
for (int i = 0; i < addressEntryList.size(); i++)
|
for (int i = 0; i < addressEntryList.size(); i++)
|
||||||
{
|
{
|
||||||
AddressEntry addressEntry = addressEntryList.get(i);
|
addressList.add(new AddressListItem(addressEntryList.get(i), walletFacade));
|
||||||
addressList.add(new AddressListItem(addressEntry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addressesTable.setItems(addressList);
|
addressesTable.setItems(addressList);
|
||||||
addressesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
addressesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||||
|
|
||||||
|
setLabelColumnCellFactory();
|
||||||
|
setBalanceColumnCellFactory();
|
||||||
|
setCopyColumnCellFactory();
|
||||||
|
setConfidenceColumnCellFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +90,10 @@ public class FundsController implements Initializable, ChildController
|
||||||
@Override
|
@Override
|
||||||
public void cleanup()
|
public void cleanup()
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < addressList.size(); i++)
|
||||||
|
{
|
||||||
|
addressList.get(i).cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +104,7 @@ public class FundsController implements Initializable, ChildController
|
||||||
@FXML
|
@FXML
|
||||||
public void onAddNewTradeAddress(ActionEvent actionEvent)
|
public void onAddNewTradeAddress(ActionEvent actionEvent)
|
||||||
{
|
{
|
||||||
AddressEntry addressEntry = walletFacade.getNewTradeAddressInfo();
|
addressList.add(new AddressListItem(walletFacade.getNewTradeAddressInfo(), walletFacade));
|
||||||
addressList.add(new AddressListItem(addressEntry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +129,7 @@ public class FundsController implements Initializable, ChildController
|
||||||
{
|
{
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null && !empty)
|
||||||
{
|
{
|
||||||
hyperlink = new Hyperlink(item.getLabel());
|
hyperlink = new Hyperlink(item.getLabel());
|
||||||
hyperlink.setId("id-link");
|
hyperlink.setId("id-link");
|
||||||
|
@ -175,35 +170,17 @@ public class FundsController implements Initializable, ChildController
|
||||||
{
|
{
|
||||||
return new TableCell<String, AddressListItem>()
|
return new TableCell<String, AddressListItem>()
|
||||||
{
|
{
|
||||||
Label balanceLabel;
|
|
||||||
BalanceListener balanceListener;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(final AddressListItem item, boolean empty)
|
public void updateItem(final AddressListItem item, boolean empty)
|
||||||
{
|
{
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null && !empty)
|
||||||
{
|
{
|
||||||
balanceListener = new BalanceListener(item.getAddress());
|
setGraphic(item.getBalanceLabel());
|
||||||
balanceLabel = new Label();
|
|
||||||
walletFacade.addBalanceListener(new BalanceListener(item.getAddress())
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onBalanceChanged(BigInteger balance)
|
|
||||||
{
|
|
||||||
updateBalance(balance, balanceLabel);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updateBalance(walletFacade.getBalanceForAddress(item.getAddress()), balanceLabel);
|
|
||||||
setGraphic(balanceLabel);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (balanceListener != null)
|
|
||||||
walletFacade.removeBalanceListener(balanceListener);
|
|
||||||
|
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,9 +202,7 @@ public class FundsController implements Initializable, ChildController
|
||||||
Label copyIcon = new Label();
|
Label copyIcon = new Label();
|
||||||
|
|
||||||
{
|
{
|
||||||
//setId("hyperlink");
|
|
||||||
copyIcon.getStyleClass().add("copy-icon");
|
copyIcon.getStyleClass().add("copy-icon");
|
||||||
//copyIcon.getStyleClass().setAll("copy-icon");
|
|
||||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||||
Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard"));
|
Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard"));
|
||||||
}
|
}
|
||||||
|
@ -237,7 +212,7 @@ public class FundsController implements Initializable, ChildController
|
||||||
{
|
{
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null && !empty)
|
||||||
{
|
{
|
||||||
setGraphic(copyIcon);
|
setGraphic(copyIcon);
|
||||||
copyIcon.setOnMouseClicked(e -> {
|
copyIcon.setOnMouseClicked(e -> {
|
||||||
|
@ -268,42 +243,18 @@ public class FundsController implements Initializable, ChildController
|
||||||
{
|
{
|
||||||
return new TableCell<String, AddressListItem>()
|
return new TableCell<String, AddressListItem>()
|
||||||
{
|
{
|
||||||
ConfidenceListener confidenceListener;
|
|
||||||
ConfidenceProgressIndicator progressIndicator;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateItem(final AddressListItem item, boolean empty)
|
public void updateItem(final AddressListItem item, boolean empty)
|
||||||
{
|
{
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null && !empty)
|
||||||
{
|
{
|
||||||
progressIndicator = new ConfidenceProgressIndicator();
|
setGraphic(item.getProgressIndicator());
|
||||||
progressIndicator.setId("funds-confidence");
|
|
||||||
Tooltip tooltip = new Tooltip("Not used yet");
|
|
||||||
progressIndicator.setProgress(0);
|
|
||||||
progressIndicator.setPrefHeight(30);
|
|
||||||
progressIndicator.setPrefWidth(30);
|
|
||||||
Tooltip.install(progressIndicator, tooltip);
|
|
||||||
|
|
||||||
confidenceListener = new ConfidenceListener(item.getAddress());
|
|
||||||
walletFacade.addConfidenceListener(new ConfidenceListener(item.getAddress())
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onTransactionConfidenceChanged(TransactionConfidence confidence)
|
|
||||||
{
|
|
||||||
updateConfidence(confidence, progressIndicator, tooltip);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updateConfidence(walletFacade.getConfidenceForAddress(item.getAddress()), progressIndicator, tooltip);
|
|
||||||
setGraphic(progressIndicator);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (confidenceListener != null)
|
|
||||||
walletFacade.removeConfidenceListener(confidenceListener);
|
|
||||||
|
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,41 +263,5 @@ public class FundsController implements Initializable, ChildController
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBalance(BigInteger balance, Label balanceLabel)
|
|
||||||
{
|
|
||||||
if (balance != null)
|
|
||||||
{
|
|
||||||
balanceLabel.setText(BtcFormatter.btcToString(balance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateConfidence(TransactionConfidence confidence, ConfidenceProgressIndicator progressIndicator, Tooltip tooltip)
|
|
||||||
{
|
|
||||||
if (confidence != null)
|
|
||||||
{
|
|
||||||
//log.debug("Type numBroadcastPeers getDepthInBlocks " + confidence.getConfidenceType() + " / " + confidence.numBroadcastPeers() + " / " + confidence.getDepthInBlocks());
|
|
||||||
switch (confidence.getConfidenceType())
|
|
||||||
{
|
|
||||||
case UNKNOWN:
|
|
||||||
tooltip.setText("Unknown transaction status");
|
|
||||||
progressIndicator.setProgress(0);
|
|
||||||
break;
|
|
||||||
case PENDING:
|
|
||||||
tooltip.setText("Seen by " + confidence.numBroadcastPeers() + " peer(s) / 0 confirmations");
|
|
||||||
progressIndicator.setProgress(-1.0);
|
|
||||||
break;
|
|
||||||
case BUILDING:
|
|
||||||
tooltip.setText("Confirmed in " + confidence.getDepthInBlocks() + " block(s)");
|
|
||||||
progressIndicator.setProgress(Math.min(1, (double) confidence.getDepthInBlocks() / 6.0));
|
|
||||||
break;
|
|
||||||
case DEAD:
|
|
||||||
tooltip.setText("Transaction is invalid.");
|
|
||||||
progressIndicator.setProgress(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
progressIndicator.setPrefSize(24, 24);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,6 @@ public class OrderBookController implements Initializable, ChildController
|
||||||
// Private methods
|
// Private methods
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
private boolean isRegistered()
|
private boolean isRegistered()
|
||||||
{
|
{
|
||||||
return user.getAccountID() != null;
|
return user.getAccountID() != null;
|
||||||
|
|
|
@ -95,15 +95,22 @@ public class OfferController implements Initializable, ChildController
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
private void removeOffer(Offer offer)
|
private void removeOffer(OfferListItem offerListItem)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
trading.removeOffer(offer);
|
trading.removeOffer(offerListItem.getOffer());
|
||||||
|
|
||||||
} catch (IOException e)
|
} catch (IOException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
offerListItems.remove(offerListItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openOfferDetails(OfferListItem offerListItem)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -140,18 +147,9 @@ public class OfferController implements Initializable, ChildController
|
||||||
@Override
|
@Override
|
||||||
public void handle(ActionEvent event)
|
public void handle(ActionEvent event)
|
||||||
{
|
{
|
||||||
log.info("Show offer details " + item.getOfferId());
|
openOfferDetails(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* hyperlink.setOnMouseEntered(new EventHandler<MouseEvent>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(MouseEvent event)
|
|
||||||
{
|
|
||||||
log.info("Show offer details " + item.getOfferId());
|
|
||||||
}
|
|
||||||
}); */
|
|
||||||
}
|
}
|
||||||
setGraphic(hyperlink);
|
setGraphic(hyperlink);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +190,7 @@ public class OfferController implements Initializable, ChildController
|
||||||
|
|
||||||
if (offerListItem != null)
|
if (offerListItem != null)
|
||||||
{
|
{
|
||||||
button.setOnAction(event -> removeOffer(offerListItem.getOffer()));
|
button.setOnAction(event -> removeOffer(offerListItem));
|
||||||
setGraphic(button);
|
setGraphic(button);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue