mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 23:56:30 -04:00
Fix missing tx confidence update
This commit is contained in:
parent
689d60b854
commit
0ddd025b93
@ -113,8 +113,8 @@ public class BitsquareApp extends Application {
|
||||
|
||||
primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMinWidth(75);
|
||||
primaryStage.setMinHeight(50);
|
||||
primaryStage.setMinWidth(750);
|
||||
primaryStage.setMinHeight(500);
|
||||
|
||||
// on windows the title icon is also used as task bar icon in a larger size
|
||||
// on Linux no title icon is supported but also a large task bar icon is derived form that title icon
|
||||
|
@ -398,13 +398,13 @@ public class TradeWalletService {
|
||||
Futures.addCallback(broadcastComplete, callback);
|
||||
}
|
||||
|
||||
// Returns local transaction which has a different state as the serialized publishedOffererDepositTx we get from the offerer
|
||||
public Transaction takerCommitsDepositTx(Transaction publishedOffererDepositTx) throws VerificationException {
|
||||
// Returns local transaction which has a different state as the serialized publishedDepositTx we get from the offerer
|
||||
public Transaction commitsDepositTx(Transaction publishedDepositTx) throws VerificationException {
|
||||
log.trace("takerCommitsDepositTx called");
|
||||
log.trace("publishedOffererDepositTx " + publishedOffererDepositTx.toString());
|
||||
log.trace("publishedDepositTx " + publishedDepositTx.toString());
|
||||
|
||||
// We need to recreate the tx we get a null pointer otherwise
|
||||
Transaction depositTx = new Transaction(params, publishedOffererDepositTx.bitcoinSerialize());
|
||||
Transaction depositTx = new Transaction(params, publishedDepositTx.bitcoinSerialize());
|
||||
log.trace("depositTx " + depositTx.toString());
|
||||
|
||||
wallet.receivePending(depositTx, null, true);
|
||||
|
@ -20,7 +20,6 @@ package io.bitsquare.trade;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.protocol.trade.offerer.OffererAsBuyerProtocol;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
@ -58,11 +57,11 @@ public class OffererTrade extends Trade implements Serializable {
|
||||
public enum OffererProcessState implements ProcessState {
|
||||
DEPOSIT_PUBLISHED,
|
||||
DEPOSIT_CONFIRMED,
|
||||
|
||||
|
||||
FIAT_PAYMENT_STARTED,
|
||||
|
||||
|
||||
PAYOUT_PUBLISHED,
|
||||
|
||||
|
||||
MESSAGE_SENDING_FAILED,
|
||||
EXCEPTION
|
||||
}
|
||||
@ -124,10 +123,6 @@ public class OffererTrade extends Trade implements Serializable {
|
||||
lifeCycleStateProperty.set(lifeCycleState);
|
||||
}
|
||||
|
||||
public void setDepositTx(Transaction tx) {
|
||||
this.depositTx = tx;
|
||||
setConfidenceListener();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -155,6 +150,7 @@ public class OffererTrade extends Trade implements Serializable {
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void setConfidenceListener() {
|
||||
TransactionConfidence transactionConfidence = depositTx.getConfidence();
|
||||
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
|
||||
|
@ -20,7 +20,6 @@ package io.bitsquare.trade;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.trade.protocol.trade.taker.TakerAsSellerProtocol;
|
||||
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
@ -58,15 +57,15 @@ public class TakerTrade extends Trade implements Serializable {
|
||||
TAKE_OFFER_FEE_TX_CREATED,
|
||||
TAKE_OFFER_FEE_PUBLISHED,
|
||||
TAKE_OFFER_FEE_PUBLISH_FAILED,
|
||||
|
||||
|
||||
DEPOSIT_PUBLISHED,
|
||||
DEPOSIT_CONFIRMED,
|
||||
|
||||
|
||||
FIAT_PAYMENT_STARTED,
|
||||
|
||||
|
||||
FIAT_PAYMENT_RECEIVED,
|
||||
PAYOUT_PUBLISHED,
|
||||
|
||||
|
||||
MESSAGE_SENDING_FAILED,
|
||||
EXCEPTION
|
||||
}
|
||||
@ -118,17 +117,12 @@ public class TakerTrade extends Trade implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDepositTx(Transaction tx) {
|
||||
this.depositTx = tx;
|
||||
setConfidenceListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThrowable(Throwable throwable) {
|
||||
super.setThrowable(throwable);
|
||||
setProcessState(TakerTrade.TakerProcessState.EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getters
|
||||
@ -146,7 +140,8 @@ public class TakerTrade extends Trade implements Serializable {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Override
|
||||
protected void setConfidenceListener() {
|
||||
TransactionConfidence transactionConfidence = depositTx.getConfidence();
|
||||
ListenableFuture<TransactionConfidence> future = transactionConfidence.getDepthFuture(1);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.p2p.MailboxMessage;
|
||||
import io.bitsquare.p2p.Peer;
|
||||
@ -44,7 +45,6 @@ abstract public class Trade implements Serializable {
|
||||
|
||||
transient protected static final Logger log = LoggerFactory.getLogger(Trade.class);
|
||||
|
||||
|
||||
public interface ProcessState {
|
||||
}
|
||||
|
||||
@ -92,6 +92,18 @@ abstract public class Trade implements Serializable {
|
||||
tradeVolumeProperty = new SimpleObjectProperty<>(getTradeVolume());
|
||||
}
|
||||
|
||||
// The deserialized tx has not actual confidence data, so we need to get the fresh one from the wallet.
|
||||
public void updateTxFromWallet(TradeWalletService tradeWalletService) {
|
||||
if (depositTx != null) {
|
||||
depositTx = tradeWalletService.commitsDepositTx(depositTx);
|
||||
setConfidenceListener();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDepositTx(Transaction tx) {
|
||||
this.depositTx = tx;
|
||||
setConfidenceListener();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Protocol
|
||||
@ -235,10 +247,11 @@ abstract public class Trade implements Serializable {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
abstract public ReadOnlyObjectProperty<? extends ProcessState> processStateProperty();
|
||||
public abstract ReadOnlyObjectProperty<? extends ProcessState> processStateProperty();
|
||||
|
||||
abstract public ReadOnlyObjectProperty<? extends LifeCycleState> lifeCycleStateProperty();
|
||||
public abstract ReadOnlyObjectProperty<? extends LifeCycleState> lifeCycleStateProperty();
|
||||
|
||||
protected abstract void setConfidenceListener();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -20,6 +20,7 @@ package io.bitsquare.trade;
|
||||
import io.bitsquare.arbitration.ArbitrationRepository;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
import io.bitsquare.btc.BlockChainService;
|
||||
import io.bitsquare.btc.TradeWalletService;
|
||||
import io.bitsquare.btc.WalletService;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.FaultHandler;
|
||||
@ -84,6 +85,7 @@ public class TradeManager {
|
||||
private final AddressService addressService;
|
||||
private final BlockChainService blockChainService;
|
||||
private final WalletService walletService;
|
||||
private TradeWalletService tradeWalletService;
|
||||
private final SignatureService signatureService;
|
||||
private final EncryptionService<MailboxMessage> encryptionService;
|
||||
private final OfferBookService offerBookService;
|
||||
@ -105,7 +107,8 @@ public class TradeManager {
|
||||
@Inject
|
||||
public TradeManager(User user, AccountSettings accountSettings,
|
||||
MessageService messageService, MailboxService mailboxService, AddressService addressService, BlockChainService blockChainService,
|
||||
WalletService walletService, SignatureService signatureService, EncryptionService<MailboxMessage> encryptionService,
|
||||
WalletService walletService, TradeWalletService tradeWalletService, SignatureService signatureService,
|
||||
EncryptionService<MailboxMessage> encryptionService,
|
||||
OfferBookService offerBookService, ArbitrationRepository arbitrationRepository, @Named("storage.dir") File storageDir) {
|
||||
this.user = user;
|
||||
this.accountSettings = accountSettings;
|
||||
@ -114,6 +117,7 @@ public class TradeManager {
|
||||
this.addressService = addressService;
|
||||
this.blockChainService = blockChainService;
|
||||
this.walletService = walletService;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
this.signatureService = signatureService;
|
||||
this.encryptionService = encryptionService;
|
||||
this.offerBookService = offerBookService;
|
||||
@ -169,6 +173,7 @@ public class TradeManager {
|
||||
OffererTrade offererTrade = (OffererTrade) trade;
|
||||
OffererAsBuyerProtocol protocol = createOffererAsBuyerProtocol(offererTrade);
|
||||
offererTrade.setProtocol(protocol);
|
||||
offererTrade.updateTxFromWallet(tradeWalletService);
|
||||
}
|
||||
else if (trade instanceof TakerTrade) {
|
||||
TakerTrade takerTrade = (TakerTrade) trade;
|
||||
|
@ -37,7 +37,7 @@ public class TakerCommitDepositTx extends Task<TakerAsSellerModel> {
|
||||
protected void doRun() {
|
||||
try {
|
||||
// To access tx confidence we need to add that tx into our wallet.
|
||||
Transaction depositTx = model.tradeWalletService.takerCommitsDepositTx(model.trade.getDepositTx());
|
||||
Transaction depositTx = model.tradeWalletService.commitsDepositTx(model.trade.getDepositTx());
|
||||
|
||||
model.trade.setDepositTx(depositTx);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user