mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-24 23:09:36 -05:00
fetch maker and taker txs from wallet then daemon
This commit is contained in:
parent
8820a87286
commit
28c07e966b
@ -811,10 +811,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if wallet balance > dust
|
// check if wallet balance > dust
|
||||||
// TODO (monero-java): use getMakerDepositTx() but fee is not returned from daemon txs
|
BigInteger maxBalance = isDepositsPublished() ? getMakerDepositTx().getFee().min(getTakerDepositTx().getFee()) : BigInteger.ZERO;
|
||||||
BigInteger maxBalance = isDepositsPublished()
|
|
||||||
? getWallet().getTx(getMaker().getDepositTxHash()).getFee().min(getWallet().getTx(getTaker().getDepositTxHash()).getFee())
|
|
||||||
: BigInteger.ZERO;
|
|
||||||
if (getWallet().getBalance().compareTo(maxBalance) > 0) {
|
if (getWallet().getBalance().compareTo(maxBalance) > 0) {
|
||||||
throw new RuntimeException("Refusing to delete wallet for " + getClass().getSimpleName() + " " + getId() + " because its balance is more than dust");
|
throw new RuntimeException("Refusing to delete wallet for " + getClass().getSimpleName() + " " + getId() + " because its balance is more than dust");
|
||||||
}
|
}
|
||||||
@ -1051,28 +1048,37 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public MoneroTx getTakerDepositTx() {
|
public MoneroTx getTakerDepositTx() {
|
||||||
String depositTxHash = getProcessModel().getTaker().getDepositTxHash();
|
return getDepositTx(getTaker());
|
||||||
try {
|
|
||||||
if (getTaker().getDepositTx() == null || !getTaker().getDepositTx().isConfirmed()) getTaker().setDepositTx(depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash));
|
|
||||||
return getTaker().getDepositTx();
|
|
||||||
} catch (MoneroError e) {
|
|
||||||
log.error("Wallet is missing taker deposit tx " + depositTxHash);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public MoneroTx getMakerDepositTx() {
|
public MoneroTx getMakerDepositTx() {
|
||||||
String depositTxHash = getProcessModel().getMaker().getDepositTxHash();
|
return getDepositTx(getMaker());
|
||||||
|
}
|
||||||
|
|
||||||
|
private MoneroTx getDepositTx(TradePeer trader) {
|
||||||
|
String depositId = trader.getDepositTxHash();
|
||||||
try {
|
try {
|
||||||
if (getMaker().getDepositTx() == null || !getMaker().getDepositTx().isConfirmed()) getMaker().setDepositTx(depositTxHash == null ? null : getXmrWalletService().getTxWithCache(depositTxHash));
|
if (trader == null || !trader.getDepositTx().isConfirmed()) {
|
||||||
return getMaker().getDepositTx();
|
trader.setDepositTx(getTxFromWalletOrDaemon(depositId));
|
||||||
|
}
|
||||||
|
return trader.getDepositTx();
|
||||||
} catch (MoneroError e) {
|
} catch (MoneroError e) {
|
||||||
log.error("Wallet is missing maker deposit tx " + depositTxHash);
|
log.error("Error getting {} deposit tx {}: {}", getPeerRole(trader), depositId, e.getMessage()); // TODO: peer.getRole()
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MoneroTx getTxFromWalletOrDaemon(String txId) {
|
||||||
|
MoneroTx tx = null;
|
||||||
|
if (getWallet() != null) {
|
||||||
|
try { tx = getWallet().getTx(txId); } // TODO monero-java: return null if tx not found
|
||||||
|
catch (Exception e) { }
|
||||||
|
}
|
||||||
|
if (tx == null) tx = getXmrWalletService().getTxWithCache(txId);
|
||||||
|
return tx;
|
||||||
|
}
|
||||||
|
|
||||||
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
||||||
if (!chatMessages.contains(chatMessage)) {
|
if (!chatMessages.contains(chatMessage)) {
|
||||||
chatMessages.add(chatMessage);
|
chatMessages.add(chatMessage);
|
||||||
@ -1749,7 +1755,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (!isShutDown && getWallet() != null && isWalletConnected()) log.warn("Error polling trade wallet {}: {}", getId(), e.getMessage()); // TODO (monero-java): poller.isPolling()?
|
if (!isShutDown && getWallet() != null && isWalletConnected()) log.warn("Error polling trade wallet {}: {}", getId(), e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user