mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 07:46:05 -04:00
Use bitcoinJ fork
This commit is contained in:
parent
a80733d771
commit
c4905baef3
12
core/pom.xml
12
core/pom.xml
@ -93,18 +93,6 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype-oss-snapshot</id>
|
||||
<snapshots/>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>repository.tomp2p.net</id>
|
||||
<url>http://tomp2p.net/dev/mvn</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
@ -112,7 +112,7 @@ public class TradeWalletService {
|
||||
}
|
||||
|
||||
public void broadcastCreateOfferFeeTx(Transaction createOfferFeeTx, FutureCallback<Transaction> callback) {
|
||||
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(createOfferFeeTx);
|
||||
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(createOfferFeeTx).future();
|
||||
Futures.addCallback(future, callback);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ public class TradeWalletService {
|
||||
}
|
||||
|
||||
public void broadcastTakeOfferFeeTx(Transaction takeOfferFeeTx, FutureCallback<Transaction> callback) throws InsufficientMoneyException {
|
||||
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(takeOfferFeeTx);
|
||||
ListenableFuture<Transaction> future = walletAppKit.peerGroup().broadcastTransaction(takeOfferFeeTx).future();
|
||||
Futures.addCallback(future, callback);
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ public class TradeWalletService {
|
||||
|
||||
// Broadcast depositTx
|
||||
printTxWithInputs("depositTx", depositTx);
|
||||
ListenableFuture<Transaction> broadcastComplete = walletAppKit.peerGroup().broadcastTransaction(depositTx);
|
||||
ListenableFuture<Transaction> broadcastComplete = walletAppKit.peerGroup().broadcastTransaction(depositTx).future();
|
||||
Futures.addCallback(broadcastComplete, callback);
|
||||
}
|
||||
|
||||
@ -488,7 +488,7 @@ public class TradeWalletService {
|
||||
|
||||
printTxWithInputs("payoutTx", payoutTx);
|
||||
|
||||
ListenableFuture<Transaction> broadcastComplete = walletAppKit.peerGroup().broadcastTransaction(payoutTx);
|
||||
ListenableFuture<Transaction> broadcastComplete = walletAppKit.peerGroup().broadcastTransaction(payoutTx).future();
|
||||
Futures.addCallback(broadcastComplete, callback);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.bitcoinj.core.AbstractWalletEventListener;
|
||||
import org.bitcoinj.core.Address;
|
||||
import org.bitcoinj.core.AddressFormatException;
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.DownloadListener;
|
||||
import org.bitcoinj.core.DownloadProgressTracker;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
@ -54,7 +54,6 @@ import java.io.Serializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -420,7 +419,7 @@ public class WalletService {
|
||||
return wallet != null ? getBalance(wallet.calculateAllSpendCandidates(true), address) : Coin.ZERO;
|
||||
}
|
||||
|
||||
private Coin getBalance(LinkedList<TransactionOutput> transactionOutputs, Address address) {
|
||||
private Coin getBalance(List<TransactionOutput> transactionOutputs, Address address) {
|
||||
Coin balance = Coin.ZERO;
|
||||
for (TransactionOutput transactionOutput : transactionOutputs) {
|
||||
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isPayToScriptHash()) {
|
||||
@ -560,7 +559,7 @@ public class WalletService {
|
||||
// Inner classes
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static class ObservableDownloadListener extends DownloadListener {
|
||||
private static class ObservableDownloadListener extends DownloadProgressTracker {
|
||||
|
||||
private final Subject<Double, Double> subject = BehaviorSubject.create(0d);
|
||||
|
||||
|
@ -40,6 +40,7 @@ import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
// TODO consider to use SealedObject
|
||||
public class EncryptionService<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(EncryptionService.class);
|
||||
private static final String ALGO_SYM = "AES";
|
||||
|
@ -324,8 +324,7 @@ public class ArbitratorRegistrationView extends ActivatableView<AnchorPane, Void
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScriptsAdded(Wallet wallet, List<Script> scripts) {
|
||||
|
||||
public void onScriptsChanged(Wallet var1, List<Script> scripts, boolean isAddingScripts) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,6 +108,11 @@ class PendingTradesDataModel implements Activatable, DataModel {
|
||||
|
||||
// we sort by date, earliest first
|
||||
list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate()));
|
||||
|
||||
if (list.size() > 0) {
|
||||
selectTrade(list.get(0));
|
||||
selectedIndex.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
void selectTrade(PendingTradesListItem item) {
|
||||
|
@ -280,7 +280,7 @@ public class PendingTradesView extends ActivatableViewAndModel<AnchorPane, Pendi
|
||||
private void applyOffererState(PendingTradesViewModel.State state) {
|
||||
setPaymentsControlsVisible(false);
|
||||
setSummaryControlsVisible(false);
|
||||
|
||||
log.debug("applyOffererState " + state);
|
||||
processBar.reset();
|
||||
|
||||
if (state != null) {
|
||||
@ -357,7 +357,7 @@ public class PendingTradesView extends ActivatableViewAndModel<AnchorPane, Pendi
|
||||
setSummaryControlsVisible(false);
|
||||
|
||||
processBar.reset();
|
||||
log.debug("applyTakerState "+state);
|
||||
log.debug("applyTakerState " + state);
|
||||
|
||||
if (state != null) {
|
||||
switch (state) {
|
||||
@ -506,7 +506,7 @@ public class PendingTradesView extends ActivatableViewAndModel<AnchorPane, Pendi
|
||||
if (visible)
|
||||
Platform.runLater(() -> {
|
||||
withdrawAddressTextField.requestFocus();
|
||||
|
||||
|
||||
// delay it once more as it does not get applied at first runLater
|
||||
Platform.runLater(() -> scrollPane.setVvalue(scrollPane.getVmax()));
|
||||
});
|
||||
|
@ -22,8 +22,15 @@ import io.bitsquare.p2p.Peer;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
@ -31,8 +38,12 @@ import java.util.Date;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Trade implements Serializable {
|
||||
private static final long serialVersionUID = -8275323072940974077L;
|
||||
private static final Logger log = LoggerFactory.getLogger(Trade.class);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -84,6 +95,7 @@ public class Trade implements Serializable {
|
||||
private Transaction depositTx;
|
||||
private Transaction payoutTx;
|
||||
private Peer tradingPeer;
|
||||
private int depthInBlocks = 0;
|
||||
|
||||
// For changing values we use properties to get binding support in the UI (table)
|
||||
// When serialized those transient properties are not instantiated, so we instantiate them in the getters at first
|
||||
@ -103,6 +115,43 @@ public class Trade implements Serializable {
|
||||
date = new Date();
|
||||
|
||||
setProcessState(ProcessState.INIT);
|
||||
log.debug("Trade ");
|
||||
}
|
||||
|
||||
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
|
||||
log.debug("Trade writeObject");
|
||||
out.defaultWriteObject();
|
||||
log.debug("Trade writeObject");
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
log.debug("Trade readObject");
|
||||
in.defaultReadObject();
|
||||
//TODO cannot call yet as persistence need to be refactored first. cann be called only after bitcoinJ is initialized as serialized tx objects throw
|
||||
// exceptions
|
||||
//setConfidenceListener();
|
||||
log.debug("Trade readObject");
|
||||
}
|
||||
|
||||
private void setConfidenceListener() {
|
||||
// log.debug("setConfidenceListener called. depthInBlocks=" + depthInBlocks + " / depositTx != null ? " + (depositTx.toString() != null));
|
||||
if (depositTx != null && depthInBlocks == 0) {
|
||||
TransactionConfidence transactionConfidence = depositTx.getConfidence();
|
||||
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
|
||||
Futures.addCallback(future, new FutureCallback<TransactionConfidence>() {
|
||||
@Override
|
||||
public void onSuccess(TransactionConfidence result) {
|
||||
setProcessState(Trade.ProcessState.DEPOSIT_CONFIRMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
log.error(t.getMessage());
|
||||
Throwables.propagate(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -146,6 +195,7 @@ public class Trade implements Serializable {
|
||||
|
||||
public void setDepositTx(Transaction tx) {
|
||||
this.depositTx = tx;
|
||||
setConfidenceListener();
|
||||
}
|
||||
|
||||
public void setPayoutTx(Transaction tx) {
|
||||
|
@ -378,7 +378,9 @@ public class TradeManager {
|
||||
persistPendingTrades();
|
||||
|
||||
TakerAsSellerProtocol sellerTakesOfferProtocol = createTakerAsSellerProtocol(trade);
|
||||
//trade.setProtocol(sellerTakesOfferProtocol);
|
||||
sellerTakesOfferProtocol.takeAvailableOffer();
|
||||
|
||||
return trade;
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,12 @@ import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.models.OffererAsBuyerModel;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -33,35 +35,28 @@ import org.slf4j.LoggerFactory;
|
||||
public class SetupListenerForBlockChainConfirmation extends Task<OffererAsBuyerModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetupListenerForBlockChainConfirmation.class);
|
||||
|
||||
private TransactionConfidence.Listener transactionConfidenceListener;
|
||||
private TransactionConfidence transactionConfidence;
|
||||
|
||||
public SetupListenerForBlockChainConfirmation(TaskRunner taskHandler, OffererAsBuyerModel model) {
|
||||
super(taskHandler, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
transactionConfidence = model.trade.getDepositTx().getConfidence();
|
||||
transactionConfidenceListener = new TransactionConfidence.Listener() {
|
||||
TransactionConfidence transactionConfidence = model.trade.getDepositTx().getConfidence();
|
||||
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
|
||||
Futures.addCallback(future, new FutureCallback<TransactionConfidence>() {
|
||||
@Override
|
||||
public void onConfidenceChanged(Transaction tx, ChangeReason reason) {
|
||||
log.trace("onConfidenceChanged " + tx.getConfidence());
|
||||
if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) {
|
||||
model.trade.setProcessState(Trade.ProcessState.DEPOSIT_CONFIRMED);
|
||||
|
||||
// transactionConfidence use CopyOnWriteArrayList as listeners, but be safe and delay remove a bit.
|
||||
Platform.runLater(() -> removeEventListener());
|
||||
}
|
||||
public void onSuccess(TransactionConfidence result) {
|
||||
model.trade.setProcessState(Trade.ProcessState.DEPOSIT_CONFIRMED);
|
||||
}
|
||||
};
|
||||
transactionConfidence.addEventListener(transactionConfidenceListener);
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
log.error(t.getMessage());
|
||||
Throwables.propagate(t);
|
||||
}
|
||||
});
|
||||
|
||||
complete();
|
||||
}
|
||||
|
||||
private void removeEventListener() {
|
||||
if (!transactionConfidence.removeEventListener(transactionConfidenceListener))
|
||||
log.error("Remove transactionConfidenceListener failed at SetupListenerForBlockChainConfirmation.");
|
||||
}
|
||||
}
|
||||
|
@ -22,10 +22,12 @@ import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.taker.models.TakerAsSellerModel;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -33,40 +35,28 @@ import org.slf4j.LoggerFactory;
|
||||
public class SetupListenerForBlockChainConfirmation extends Task<TakerAsSellerModel> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetupListenerForBlockChainConfirmation.class);
|
||||
|
||||
private TransactionConfidence.Listener transactionConfidenceListener;
|
||||
private TransactionConfidence transactionConfidence;
|
||||
|
||||
public SetupListenerForBlockChainConfirmation(TaskRunner taskHandler, TakerAsSellerModel model) {
|
||||
super(taskHandler, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doRun() {
|
||||
try {
|
||||
transactionConfidence = model.trade.getDepositTx().getConfidence();
|
||||
transactionConfidenceListener = new TransactionConfidence.Listener() {
|
||||
@Override
|
||||
public void onConfidenceChanged(Transaction tx, ChangeReason reason) {
|
||||
log.trace("onConfidenceChanged " + tx.getConfidence());
|
||||
if (reason == ChangeReason.TYPE && tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) {
|
||||
model.trade.setProcessState(Trade.ProcessState.DEPOSIT_CONFIRMED);
|
||||
TransactionConfidence transactionConfidence = model.trade.getDepositTx().getConfidence();
|
||||
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
|
||||
Futures.addCallback(future, new FutureCallback<TransactionConfidence>() {
|
||||
@Override
|
||||
public void onSuccess(TransactionConfidence result) {
|
||||
model.trade.setProcessState(Trade.ProcessState.DEPOSIT_CONFIRMED);
|
||||
}
|
||||
|
||||
// transactionConfidence use CopyOnWriteArrayList as listeners, but be safe and delay remove a bit.
|
||||
Platform.runLater(() -> removeEventListener());
|
||||
}
|
||||
}
|
||||
};
|
||||
transactionConfidence.addEventListener(transactionConfidenceListener);
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
t.printStackTrace();
|
||||
log.error(t.getMessage());
|
||||
Throwables.propagate(t);
|
||||
}
|
||||
});
|
||||
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
log.error(t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEventListener() {
|
||||
if (!transactionConfidence.removeEventListener(transactionConfidenceListener))
|
||||
log.error("Remove transactionConfidenceListener failed at SetupListenerForBlockChainConfirmation.");
|
||||
complete();
|
||||
}
|
||||
}
|
||||
|
0
doc/update_fork_tomp2p.sh
Executable file → Normal file
0
doc/update_fork_tomp2p.sh
Executable file → Normal file
6
pom.xml
6
pom.xml
@ -86,13 +86,17 @@
|
||||
<id>repository.tomp2p.net</id>
|
||||
<url>http://tomp2p.net/dev/mvn</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>partnerdemo.artifactoryonline.com</id>
|
||||
<url>http://partnerdemo.artifactoryonline.com/partnerdemo/libs-snapshots-local</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bitcoinj</groupId>
|
||||
<artifactId>bitcoinj-core</artifactId>
|
||||
<version>0.12.2</version>
|
||||
<version>0.13.d13665c-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user