mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 10:46:54 +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>
|
||||
<groupId>com.google</groupId>
|
||||
<artifactId>bitcoinj</artifactId>
|
||||
<version>0.11</version>
|
||||
<version>0.11.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -60,6 +60,9 @@ public class BitSquareWalletAppKit extends WalletAppKit
|
|||
}
|
||||
vChain = new BlockChain(params, vStore);
|
||||
vPeerGroup = createPeerGroup();
|
||||
|
||||
vPeerGroup.setBloomFilterFalsePositiveRate(0.001); // 0,1% instead of default 0,05%
|
||||
|
||||
if (this.userAgent != null)
|
||||
vPeerGroup.setUserAgent(userAgent, version);
|
||||
if (vWalletFile.exists())
|
||||
|
|
|
@ -42,6 +42,7 @@ public class WalletFacade
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
|
||||
|
||||
private String saveAddressEntryListId;
|
||||
private NetworkParameters params;
|
||||
private BitSquareWalletAppKit walletAppKit;
|
||||
private FeePolicy feePolicy;
|
||||
|
@ -163,7 +164,8 @@ public class WalletFacade
|
|||
};
|
||||
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)
|
||||
{
|
||||
addressEntryList = savedAddressEntryList;
|
||||
|
@ -195,7 +197,7 @@ public class WalletFacade
|
|||
private void saveAddressInfoList()
|
||||
{
|
||||
// use wallet extension?
|
||||
storage.write("addressInfoList", addressEntryList);
|
||||
storage.write(saveAddressEntryListId, addressEntryList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,13 +215,16 @@ public class WalletFacade
|
|||
downloadListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void addConfidenceListener(ConfidenceListener listener)
|
||||
public ConfidenceListener addConfidenceListener(ConfidenceListener listener)
|
||||
{
|
||||
log.debug("addConfidenceListener " + listener.getAddress().toString());
|
||||
confidenceListeners.add(listener);
|
||||
return listener;
|
||||
}
|
||||
|
||||
public void removeConfidenceListener(ConfidenceListener listener)
|
||||
{
|
||||
log.debug("removeConfidenceListener " + listener.getAddress().toString());
|
||||
confidenceListeners.remove(listener);
|
||||
}
|
||||
|
||||
|
@ -302,8 +307,6 @@ public class WalletFacade
|
|||
}
|
||||
|
||||
public AddressEntry getUnusedTradeAddressInfo()
|
||||
{
|
||||
if (addressEntryList != null)
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
||||
{
|
||||
|
@ -319,12 +322,8 @@ public class WalletFacade
|
|||
else
|
||||
return getNewTradeAddressInfo();
|
||||
}
|
||||
return getNewTradeAddressInfo();
|
||||
}
|
||||
|
||||
private AddressEntry getAddressInfoByAddressContext(AddressEntry.AddressContext addressContext)
|
||||
{
|
||||
if (addressEntryList != null)
|
||||
{
|
||||
List<AddressEntry> filteredList = Lists.newArrayList(Collections2.filter(addressEntryList, new Predicate<AddressEntry>()
|
||||
{
|
||||
|
@ -340,8 +339,6 @@ public class WalletFacade
|
|||
else
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AddressEntry getAddressInfoByTradeID(String tradeId)
|
||||
{
|
||||
|
@ -370,6 +367,7 @@ public class WalletFacade
|
|||
{
|
||||
ECKey key = new ECKey();
|
||||
wallet.addKey(key);
|
||||
wallet.addWatchedAddress(key.toAddress(params));
|
||||
AddressEntry addressEntry = new AddressEntry(key, params, addressContext);
|
||||
addressEntryList.add(addressEntry);
|
||||
saveAddressInfoList();
|
||||
|
|
|
@ -1,20 +1,112 @@
|
|||
package io.bitsquare.gui.funds;
|
||||
|
||||
import com.google.bitcoin.core.Address;
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
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.StringProperty;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tooltip;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class AddressListItem
|
||||
{
|
||||
private final StringProperty addressString = new SimpleStringProperty();
|
||||
private final BalanceListener balanceListener;
|
||||
private final Label balanceLabel;
|
||||
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.walletFacade = walletFacade;
|
||||
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()
|
||||
|
@ -49,4 +141,29 @@ public class AddressListItem
|
|||
{
|
||||
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;
|
||||
|
||||
import com.google.bitcoin.core.TransactionConfidence;
|
||||
import com.google.inject.Inject;
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
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.ChildController;
|
||||
import io.bitsquare.gui.NavigationController;
|
||||
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
|
||||
import io.bitsquare.gui.util.ConfidenceDisplay;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.collections.FXCollections;
|
||||
|
@ -27,7 +22,6 @@ import javafx.util.Callback;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
@ -68,21 +62,19 @@ public class FundsController implements Initializable, ChildController
|
|||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb)
|
||||
{
|
||||
setLabelColumnCellFactory();
|
||||
setBalanceColumnCellFactory();
|
||||
setCopyColumnCellFactory();
|
||||
setConfidenceColumnCellFactory();
|
||||
|
||||
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
|
||||
|
||||
for (int i = 0; i < addressEntryList.size(); i++)
|
||||
{
|
||||
AddressEntry addressEntry = addressEntryList.get(i);
|
||||
addressList.add(new AddressListItem(addressEntry));
|
||||
addressList.add(new AddressListItem(addressEntryList.get(i), walletFacade));
|
||||
}
|
||||
|
||||
addressesTable.setItems(addressList);
|
||||
addressesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
|
||||
|
||||
setLabelColumnCellFactory();
|
||||
setBalanceColumnCellFactory();
|
||||
setCopyColumnCellFactory();
|
||||
setConfidenceColumnCellFactory();
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,6 +90,10 @@ public class FundsController implements Initializable, ChildController
|
|||
@Override
|
||||
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
|
||||
public void onAddNewTradeAddress(ActionEvent actionEvent)
|
||||
{
|
||||
AddressEntry addressEntry = walletFacade.getNewTradeAddressInfo();
|
||||
addressList.add(new AddressListItem(addressEntry));
|
||||
addressList.add(new AddressListItem(walletFacade.getNewTradeAddressInfo(), walletFacade));
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,7 +129,7 @@ public class FundsController implements Initializable, ChildController
|
|||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null)
|
||||
if (item != null && !empty)
|
||||
{
|
||||
hyperlink = new Hyperlink(item.getLabel());
|
||||
hyperlink.setId("id-link");
|
||||
|
@ -175,35 +170,17 @@ public class FundsController implements Initializable, ChildController
|
|||
{
|
||||
return new TableCell<String, AddressListItem>()
|
||||
{
|
||||
Label balanceLabel;
|
||||
BalanceListener balanceListener;
|
||||
|
||||
@Override
|
||||
public void updateItem(final AddressListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null)
|
||||
if (item != null && !empty)
|
||||
{
|
||||
balanceListener = new BalanceListener(item.getAddress());
|
||||
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);
|
||||
setGraphic(item.getBalanceLabel());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (balanceListener != null)
|
||||
walletFacade.removeBalanceListener(balanceListener);
|
||||
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
|
@ -225,9 +202,7 @@ public class FundsController implements Initializable, ChildController
|
|||
Label copyIcon = new Label();
|
||||
|
||||
{
|
||||
//setId("hyperlink");
|
||||
copyIcon.getStyleClass().add("copy-icon");
|
||||
//copyIcon.getStyleClass().setAll("copy-icon");
|
||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||
Tooltip.install(copyIcon, new Tooltip("Copy address to clipboard"));
|
||||
}
|
||||
|
@ -237,7 +212,7 @@ public class FundsController implements Initializable, ChildController
|
|||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null)
|
||||
if (item != null && !empty)
|
||||
{
|
||||
setGraphic(copyIcon);
|
||||
copyIcon.setOnMouseClicked(e -> {
|
||||
|
@ -268,42 +243,18 @@ public class FundsController implements Initializable, ChildController
|
|||
{
|
||||
return new TableCell<String, AddressListItem>()
|
||||
{
|
||||
ConfidenceListener confidenceListener;
|
||||
ConfidenceProgressIndicator progressIndicator;
|
||||
|
||||
@Override
|
||||
public void updateItem(final AddressListItem item, boolean empty)
|
||||
{
|
||||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null)
|
||||
if (item != null && !empty)
|
||||
{
|
||||
progressIndicator = new ConfidenceProgressIndicator();
|
||||
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);
|
||||
setGraphic(item.getProgressIndicator());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (confidenceListener != null)
|
||||
walletFacade.removeConfidenceListener(confidenceListener);
|
||||
|
||||
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 boolean isRegistered()
|
||||
{
|
||||
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
|
||||
{
|
||||
trading.removeOffer(offer);
|
||||
trading.removeOffer(offerListItem.getOffer());
|
||||
|
||||
} 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
|
||||
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);
|
||||
}
|
||||
|
@ -192,7 +190,7 @@ public class OfferController implements Initializable, ChildController
|
|||
|
||||
if (offerListItem != null)
|
||||
{
|
||||
button.setOnAction(event -> removeOffer(offerListItem.getOffer()));
|
||||
button.setOnAction(event -> removeOffer(offerListItem));
|
||||
setGraphic(button);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue