mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 23:06:39 +01:00
Rename XmrProofResult to AutoConfirmResult
This commit is contained in:
parent
ac10d71f78
commit
967e0538d6
9 changed files with 84 additions and 76 deletions
|
@ -15,7 +15,7 @@
|
|||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.core.trade.asset.xmr;
|
||||
package bisq.core.trade;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
@Slf4j
|
||||
@Value
|
||||
public class XmrProofResult {
|
||||
public class AutoConfirmResult {
|
||||
public enum State {
|
||||
FEATURE_DISABLED,
|
||||
TX_NOT_FOUND,
|
||||
|
@ -48,14 +48,14 @@ public class XmrProofResult {
|
|||
private final int confirmsRequired;
|
||||
private final State state;
|
||||
|
||||
public XmrProofResult(int confirmCount, int confirmsRequired, State state) {
|
||||
public AutoConfirmResult(int confirmCount, int confirmsRequired, State state) {
|
||||
this.confirmCount = confirmCount;
|
||||
this.confirmsRequired = confirmsRequired;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
// alternate constructor for error scenarios
|
||||
public XmrProofResult(State state, @Nullable String errorMsg) {
|
||||
public AutoConfirmResult(State state, @Nullable String errorMsg) {
|
||||
this.confirmCount = 0;
|
||||
this.confirmsRequired = 0;
|
||||
this.state = state;
|
|
@ -23,10 +23,10 @@ import bisq.core.offer.Offer;
|
|||
import bisq.core.payment.payload.AssetsAccountPayload;
|
||||
import bisq.core.payment.payload.PaymentAccountPayload;
|
||||
import bisq.core.trade.asset.xmr.XmrProofInfo;
|
||||
import bisq.core.trade.asset.xmr.XmrProofResult;
|
||||
import bisq.core.trade.asset.xmr.XmrTransferProofService;
|
||||
import bisq.core.trade.closed.ClosedTradableManager;
|
||||
import bisq.core.trade.failed.FailedTradesManager;
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.btc.setup.WalletsSetup;
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class AutoConfirmationManager {
|
|||
if (alreadyUsed) {
|
||||
String message = "Peer used the XMR tx key already at another trade with trade ID " +
|
||||
t.getId() + ". This might be a scam attempt.";
|
||||
trade.setXmrProofResult(new XmrProofResult(XmrProofResult.State.TX_KEY_REUSED, message));
|
||||
trade.setAutoConfirmResult(new AutoConfirmResult(AutoConfirmResult.State.TX_KEY_REUSED, message));
|
||||
}
|
||||
return alreadyUsed;
|
||||
});
|
||||
|
@ -164,7 +164,7 @@ public class AutoConfirmationManager {
|
|||
}
|
||||
|
||||
if (!preferences.getAutoConfirmSettings().enabled || this.isAutoConfDisabledByFilter()) {
|
||||
trade.setXmrProofResult(new XmrProofResult(XmrProofResult.State.FEATURE_DISABLED, null));
|
||||
trade.setAutoConfirmResult(new AutoConfirmResult(AutoConfirmResult.State.FEATURE_DISABLED, null));
|
||||
return;
|
||||
}
|
||||
Coin tradeAmount = trade.getTradeAmount();
|
||||
|
@ -172,7 +172,7 @@ public class AutoConfirmationManager {
|
|||
if (tradeAmount.isGreaterThan(tradeLimit)) {
|
||||
log.warn("Trade amount {} is higher than settings limit {}, will not attempt auto-confirm",
|
||||
tradeAmount.toFriendlyString(), tradeLimit.toFriendlyString());
|
||||
trade.setXmrProofResult(new XmrProofResult(XmrProofResult.State.TRADE_LIMIT_EXCEEDED, null));
|
||||
trade.setAutoConfirmResult(new AutoConfirmResult(AutoConfirmResult.State.TRADE_LIMIT_EXCEEDED, null));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class AutoConfirmationManager {
|
|||
// XMR satoshis have 12 decimal places vs. bitcoin's 8
|
||||
long amountXmr = offer.getVolumeByAmount(tradeAmount).getValue() * 10000L;
|
||||
int confirmsRequired = preferences.getAutoConfirmSettings().requiredConfirmations;
|
||||
trade.setXmrProofResult(new XmrProofResult(0, confirmsRequired, XmrProofResult.State.TX_NOT_FOUND));
|
||||
trade.setAutoConfirmResult(new AutoConfirmResult(0, confirmsRequired, AutoConfirmResult.State.TX_NOT_FOUND));
|
||||
List<String> serviceAddresses = preferences.getAutoConfirmSettings().serviceAddresses;
|
||||
txProofResultsPending.put(trade.getId(), serviceAddresses.size()); // need result from each service address
|
||||
for (String serviceAddress : serviceAddresses) {
|
||||
|
@ -205,7 +205,7 @@ public class AutoConfirmationManager {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean handleProofResult(XmrProofResult result, Trade trade) {
|
||||
private boolean handleProofResult(AutoConfirmResult result, Trade trade) {
|
||||
boolean success = true;
|
||||
boolean failure = false;
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class AutoConfirmationManager {
|
|||
if (result.isPendingState()) {
|
||||
log.info("Auto confirm received a {} message for tradeId {}, retry will happen automatically",
|
||||
result.getState(), trade.getShortId());
|
||||
trade.setXmrProofResult(result); // this updates the GUI with the status..
|
||||
trade.setAutoConfirmResult(result); // this updates the GUI with the status..
|
||||
// Repeating the requests is handled in XmrTransferProofRequester
|
||||
return success;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class AutoConfirmationManager {
|
|||
}
|
||||
// we've received the final PROOF_OK, all good here.
|
||||
txProofResultsPending.remove(trade.getId());
|
||||
trade.setXmrProofResult(result); // this updates the GUI with the status..
|
||||
trade.setAutoConfirmResult(result); // this updates the GUI with the status..
|
||||
log.info("Auto confirm was successful, transitioning trade {} to next step...", trade.getShortId());
|
||||
if (!trade.isPayoutPublished()) {
|
||||
// note that this state can also be triggered by auto confirmation feature
|
||||
|
@ -262,7 +262,7 @@ public class AutoConfirmationManager {
|
|||
// TX_KEY_INVALID, ADDRESS_INVALID, AMOUNT_NOT_MATCHING, TRADE_DATE_NOT_MATCHING
|
||||
log.warn("Tx Proof Failure {}, shutting down all open API requests for this trade {}",
|
||||
result.getState(), trade.getShortId());
|
||||
trade.setXmrProofResult(result); // this updates the GUI with the status..
|
||||
trade.setAutoConfirmResult(result); // this updates the GUI with the status..
|
||||
resultsCountdown = -1; // signal all API requestors to cease
|
||||
txProofResultsPending.put(trade.getId(), resultsCountdown); // track proof result count
|
||||
return failure;
|
||||
|
|
|
@ -38,7 +38,7 @@ import bisq.core.support.dispute.mediation.mediator.MediatorManager;
|
|||
import bisq.core.support.dispute.refund.RefundResultState;
|
||||
import bisq.core.support.dispute.refund.refundagent.RefundAgentManager;
|
||||
import bisq.core.support.messages.ChatMessage;
|
||||
import bisq.core.trade.asset.xmr.XmrProofResult;
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
import bisq.core.trade.protocol.ProcessModel;
|
||||
import bisq.core.trade.protocol.TradeProtocol;
|
||||
import bisq.core.trade.statistics.ReferralIdService;
|
||||
|
@ -436,18 +436,18 @@ public abstract class Trade implements Tradable, Model {
|
|||
@Setter
|
||||
private String counterCurrencyExtraData;
|
||||
|
||||
// xmrProofResult is not persisted yet
|
||||
// autoConfirmResult is not persisted yet
|
||||
@Getter
|
||||
@Nullable
|
||||
private transient XmrProofResult xmrProofResult;
|
||||
private transient AutoConfirmResult autoConfirmResult;
|
||||
|
||||
public void setXmrProofResult(XmrProofResult xmrProofResult) {
|
||||
this.xmrProofResult = xmrProofResult;
|
||||
xmrProofResultProperty.setValue(xmrProofResult);
|
||||
public void setAutoConfirmResult(AutoConfirmResult autoConfirmResult) {
|
||||
this.autoConfirmResult = autoConfirmResult;
|
||||
autoConfirmResultProperty.setValue(autoConfirmResult);
|
||||
}
|
||||
@Getter
|
||||
// This observable property can be used for UI to show a notification to user of the XMR proof status
|
||||
transient final private ObjectProperty<XmrProofResult> xmrProofResultProperty = new SimpleObjectProperty<>();
|
||||
transient final private ObjectProperty<AutoConfirmResult> autoConfirmResultProperty = new SimpleObjectProperty<>();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, initialization
|
||||
|
@ -1187,7 +1187,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
",\n errorMessage='" + errorMessage + '\'' +
|
||||
",\n counterCurrencyTxId='" + counterCurrencyTxId + '\'' +
|
||||
",\n counterCurrencyExtraData='" + counterCurrencyExtraData + '\'' +
|
||||
",\n xmrProofResult='" + xmrProofResult + '\'' +
|
||||
",\n autoConfirmResult='" + autoConfirmResult + '\'' +
|
||||
",\n chatMessages=" + chatMessages +
|
||||
",\n txFee=" + txFee +
|
||||
",\n takerFee=" + takerFee +
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.core.trade.asset.xmr;
|
||||
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
|
||||
import bisq.asset.CryptoNoteAddressValidator;
|
||||
|
||||
import bisq.common.app.DevEnv;
|
||||
|
@ -65,55 +67,55 @@ public class XmrProofInfo {
|
|||
return txHash + "|" + serviceAddress;
|
||||
}
|
||||
|
||||
public XmrProofResult checkApiResponse(String jsonTxt) {
|
||||
public AutoConfirmResult checkApiResponse(String jsonTxt) {
|
||||
try {
|
||||
JsonObject json = new Gson().fromJson(jsonTxt, JsonObject.class);
|
||||
if (json == null)
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Empty json");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Empty json");
|
||||
// there should always be "data" and "status" at the top level
|
||||
if (json.get("data") == null || !json.get("data").isJsonObject() || json.get("status") == null)
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing data / status fields");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing data / status fields");
|
||||
JsonObject jsonData = json.get("data").getAsJsonObject();
|
||||
String jsonStatus = json.get("status").getAsString();
|
||||
if (jsonStatus.matches("fail")) {
|
||||
// the API returns "fail" until the transaction has successfully reached the mempool.
|
||||
// we return TX_NOT_FOUND which will cause a retry later
|
||||
return new XmrProofResult(XmrProofResult.State.TX_NOT_FOUND, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.TX_NOT_FOUND, null);
|
||||
} else if (!jsonStatus.matches("success")) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_FAILURE, "Unhandled status value");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_FAILURE, "Unhandled status value");
|
||||
}
|
||||
|
||||
// validate that the address matches
|
||||
JsonElement jsonAddress = jsonData.get("address");
|
||||
if (jsonAddress == null) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing address field");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing address field");
|
||||
} else {
|
||||
String expectedAddressHex = CryptoNoteAddressValidator.convertToRawHex(this.recipientAddress);
|
||||
if (!jsonAddress.getAsString().equalsIgnoreCase(expectedAddressHex)) {
|
||||
log.warn("address {}, expected: {}", jsonAddress.getAsString(), expectedAddressHex);
|
||||
return new XmrProofResult(XmrProofResult.State.ADDRESS_INVALID, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.ADDRESS_INVALID, null);
|
||||
}
|
||||
}
|
||||
|
||||
// validate that the txhash matches
|
||||
JsonElement jsonTxHash = jsonData.get("tx_hash");
|
||||
if (jsonTxHash == null) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing tx_hash field");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing tx_hash field");
|
||||
} else {
|
||||
if (!jsonTxHash.getAsString().equalsIgnoreCase(txHash)) {
|
||||
log.warn("txHash {}, expected: {}", jsonTxHash.getAsString(), txHash);
|
||||
return new XmrProofResult(XmrProofResult.State.TX_HASH_INVALID, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.TX_HASH_INVALID, null);
|
||||
}
|
||||
}
|
||||
|
||||
// validate that the txkey matches
|
||||
JsonElement jsonViewkey = jsonData.get("viewkey");
|
||||
if (jsonViewkey == null) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing viewkey field");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing viewkey field");
|
||||
} else {
|
||||
if (!jsonViewkey.getAsString().equalsIgnoreCase(this.txKey)) {
|
||||
log.warn("viewkey {}, expected: {}", jsonViewkey.getAsString(), txKey);
|
||||
return new XmrProofResult(XmrProofResult.State.TX_KEY_INVALID, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.TX_KEY_INVALID, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,14 +123,14 @@ public class XmrProofInfo {
|
|||
// (except that in dev mode we let this check pass anyway)
|
||||
JsonElement jsonTimestamp = jsonData.get("tx_timestamp");
|
||||
if (jsonTimestamp == null) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing tx_timestamp field");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing tx_timestamp field");
|
||||
} else {
|
||||
long tradeDateSeconds = tradeDate.getTime() / 1000;
|
||||
long difference = tradeDateSeconds - jsonTimestamp.getAsLong();
|
||||
if (difference > 60 * 60 * 24 && !DevEnv.isDevMode()) { // accept up to 1 day difference
|
||||
log.warn("tx_timestamp {}, tradeDate: {}, difference {}",
|
||||
jsonTimestamp.getAsLong(), tradeDateSeconds, difference);
|
||||
return new XmrProofResult(XmrProofResult.State.TRADE_DATE_NOT_MATCHING, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.TRADE_DATE_NOT_MATCHING, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +138,7 @@ public class XmrProofInfo {
|
|||
int confirmations = 0;
|
||||
JsonElement jsonConfs = jsonData.get("tx_confirmations");
|
||||
if (jsonConfs == null) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, "Missing tx_confirmations field");
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, "Missing tx_confirmations field");
|
||||
} else {
|
||||
confirmations = jsonConfs.getAsInt();
|
||||
log.info("Confirmations: {}, xmr txid: {}", confirmations, txHash);
|
||||
|
@ -153,18 +155,18 @@ public class XmrProofInfo {
|
|||
if (jsonAmount == amount || DevEnv.isDevMode()) { // any amount ok in dev mode
|
||||
if (confirmations < confirmsRequired)
|
||||
// we return TX_NOT_CONFIRMED which will cause a retry later
|
||||
return new XmrProofResult(confirmations, confirmsRequired, XmrProofResult.State.TX_NOT_CONFIRMED);
|
||||
return new AutoConfirmResult(confirmations, confirmsRequired, AutoConfirmResult.State.TX_NOT_CONFIRMED);
|
||||
else
|
||||
return new XmrProofResult(confirmations, confirmsRequired, XmrProofResult.State.PROOF_OK);
|
||||
return new AutoConfirmResult(confirmations, confirmsRequired, AutoConfirmResult.State.PROOF_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reaching this point means there was no matching amount
|
||||
return new XmrProofResult(XmrProofResult.State.AMOUNT_NOT_MATCHING, null);
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.AMOUNT_NOT_MATCHING, null);
|
||||
|
||||
} catch (JsonParseException | NullPointerException e) {
|
||||
return new XmrProofResult(XmrProofResult.State.API_INVALID, e.toString());
|
||||
return new AutoConfirmResult(AutoConfirmResult.State.API_INVALID, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.core.trade.asset.xmr;
|
||||
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
|
||||
import bisq.network.Socks5ProxyProvider;
|
||||
|
||||
import bisq.common.UserThread;
|
||||
|
@ -43,7 +45,7 @@ public class XmrTransferProofRequester {
|
|||
"XmrTransferProofRequester", 3, 5, 10 * 60);
|
||||
private final XmrTxProofHttpClient httpClient;
|
||||
private final XmrProofInfo xmrProofInfo;
|
||||
private final Consumer<XmrProofResult> resultHandler;
|
||||
private final Consumer<AutoConfirmResult> resultHandler;
|
||||
private final FaultHandler faultHandler;
|
||||
private boolean terminated;
|
||||
private long firstRequest;
|
||||
|
@ -58,7 +60,7 @@ public class XmrTransferProofRequester {
|
|||
|
||||
XmrTransferProofRequester(Socks5ProxyProvider socks5ProxyProvider,
|
||||
XmrProofInfo xmrProofInfo,
|
||||
Consumer<XmrProofResult> resultHandler,
|
||||
Consumer<AutoConfirmResult> resultHandler,
|
||||
FaultHandler faultHandler) {
|
||||
this.httpClient = new XmrTxProofHttpClient(socks5ProxyProvider);
|
||||
this.httpClient.setBaseUrl("http://" + xmrProofInfo.getServiceAddress());
|
||||
|
@ -89,7 +91,7 @@ public class XmrTransferProofRequester {
|
|||
log.info("Request() aborted, this object has been terminated: {}", httpClient.toString());
|
||||
return;
|
||||
}
|
||||
ListenableFuture<XmrProofResult> future = executorService.submit(() -> {
|
||||
ListenableFuture<AutoConfirmResult> future = executorService.submit(() -> {
|
||||
Thread.currentThread().setName("XmrTransferProofRequest-" + xmrProofInfo.getKey());
|
||||
String param = "/api/outputs?txhash=" + xmrProofInfo.getTxHash() +
|
||||
"&address=" + xmrProofInfo.getRecipientAddress() +
|
||||
|
@ -103,7 +105,7 @@ public class XmrTransferProofRequester {
|
|||
});
|
||||
|
||||
Futures.addCallback(future, new FutureCallback<>() {
|
||||
public void onSuccess(XmrProofResult result) {
|
||||
public void onSuccess(AutoConfirmResult result) {
|
||||
if (terminated) {
|
||||
log.info("API terminated from higher level: {}", httpClient.toString());
|
||||
return;
|
||||
|
@ -122,7 +124,7 @@ public class XmrTransferProofRequester {
|
|||
String errorMessage = "Request to " + httpClient.getBaseUrl() + " failed";
|
||||
faultHandler.handleFault(errorMessage, throwable);
|
||||
UserThread.execute(() -> resultHandler.accept(
|
||||
new XmrProofResult(XmrProofResult.State.CONNECTION_FAIL, errorMessage)));
|
||||
new AutoConfirmResult(AutoConfirmResult.State.CONNECTION_FAIL, errorMessage)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.core.trade.asset.xmr;
|
||||
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
|
||||
import bisq.network.Socks5ProxyProvider;
|
||||
|
||||
import bisq.common.handlers.FaultHandler;
|
||||
|
@ -45,7 +47,7 @@ public class XmrTransferProofService {
|
|||
}
|
||||
|
||||
public void requestProof(XmrProofInfo xmrProofInfo,
|
||||
Consumer<XmrProofResult> resultHandler,
|
||||
Consumer<AutoConfirmResult> resultHandler,
|
||||
FaultHandler faultHandler) {
|
||||
String key = xmrProofInfo.getKey();
|
||||
if (map.containsKey(key)) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package bisq.core.trade.asset.xmr;
|
||||
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -46,13 +48,13 @@ public class XmrProofInfoTest {
|
|||
public void testJsonRoot() {
|
||||
// checking what happens when bad input is provided
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"invalid json data").getState() == XmrProofResult.State.API_INVALID);
|
||||
"invalid json data").getState() == AutoConfirmResult.State.API_INVALID);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"").getState() == XmrProofResult.State.API_INVALID);
|
||||
"").getState() == AutoConfirmResult.State.API_INVALID);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"[]").getState() == XmrProofResult.State.API_INVALID);
|
||||
"[]").getState() == AutoConfirmResult.State.API_INVALID);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{}").getState() == XmrProofResult.State.API_INVALID);
|
||||
"{}").getState() == AutoConfirmResult.State.API_INVALID);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,34 +62,34 @@ public class XmrProofInfoTest {
|
|||
// testing the top level fields: data and status
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{'data':{'title':''},'status':'fail'}" )
|
||||
.getState() == XmrProofResult.State.TX_NOT_FOUND);
|
||||
.getState() == AutoConfirmResult.State.TX_NOT_FOUND);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{'data':{'title':''},'missingstatus':'success'}" )
|
||||
.getState() == XmrProofResult.State.API_INVALID);
|
||||
.getState() == AutoConfirmResult.State.API_INVALID);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{'missingdata':{'title':''},'status':'success'}" )
|
||||
.getState() == XmrProofResult.State.API_INVALID);
|
||||
.getState() == AutoConfirmResult.State.API_INVALID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonAddress() {
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{'data':{'missingaddress':'irrelevant'},'status':'success'}" )
|
||||
.getState() == XmrProofResult.State.API_INVALID);
|
||||
.getState() == AutoConfirmResult.State.API_INVALID);
|
||||
assertTrue(xmrProofInfo.checkApiResponse(
|
||||
"{'data':{'address':'e957dac7'},'status':'success'}" )
|
||||
.getState() == XmrProofResult.State.ADDRESS_INVALID);
|
||||
.getState() == AutoConfirmResult.State.ADDRESS_INVALID);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonTxHash() {
|
||||
String missing_tx_hash = "{'data':{'address':'" + recipientAddressHex + "'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(missing_tx_hash).getState()
|
||||
== XmrProofResult.State.API_INVALID);
|
||||
== AutoConfirmResult.State.API_INVALID);
|
||||
|
||||
String invalid_tx_hash = "{'data':{'address':'" + recipientAddressHex + "', 'tx_hash':'488e48'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(invalid_tx_hash).getState()
|
||||
== XmrProofResult.State.TX_HASH_INVALID);
|
||||
== AutoConfirmResult.State.TX_HASH_INVALID);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,13 +97,13 @@ public class XmrProofInfoTest {
|
|||
String missing_tx_key = "{'data':{'address':'" + recipientAddressHex + "', " +
|
||||
"'tx_hash':'" + txHash + "'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(missing_tx_key).getState()
|
||||
== XmrProofResult.State.API_INVALID);
|
||||
== AutoConfirmResult.State.API_INVALID);
|
||||
|
||||
String invalid_tx_key = "{'data':{'address':'" + recipientAddressHex + "', " +
|
||||
"'tx_hash':'" + txHash + "', " +
|
||||
"'viewkey':'cdce04'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(invalid_tx_key).getState()
|
||||
== XmrProofResult.State.TX_KEY_INVALID);
|
||||
== AutoConfirmResult.State.TX_KEY_INVALID);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -110,14 +112,14 @@ public class XmrProofInfoTest {
|
|||
"'tx_hash':'" + txHash + "'," +
|
||||
"'viewkey':'" + txKey + "'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(missing_tx_timestamp).getState()
|
||||
== XmrProofResult.State.API_INVALID);
|
||||
== AutoConfirmResult.State.API_INVALID);
|
||||
|
||||
String invalid_tx_timestamp = "{'data':{'address':'" + recipientAddressHex + "', " +
|
||||
"'tx_hash':'" + txHash + "', " +
|
||||
"'viewkey':'" + txKey + "'," +
|
||||
"'tx_timestamp':'12345'}, 'status':'success'}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(invalid_tx_timestamp).getState()
|
||||
== XmrProofResult.State.TRADE_DATE_NOT_MATCHING);
|
||||
== AutoConfirmResult.State.TRADE_DATE_NOT_MATCHING);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -135,19 +137,19 @@ public class XmrProofInfoTest {
|
|||
"'tx_timestamp':'" + Long.toString(epochDate) + "'}" +
|
||||
"}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(json).getState()
|
||||
== XmrProofResult.State.PROOF_OK);
|
||||
== AutoConfirmResult.State.PROOF_OK);
|
||||
json = json.replaceFirst("777", "0");
|
||||
assertTrue(xmrProofInfo.checkApiResponse(json).getState()
|
||||
== XmrProofResult.State.TX_NOT_CONFIRMED);
|
||||
== AutoConfirmResult.State.TX_NOT_CONFIRMED);
|
||||
json = json.replaceFirst("100000000000", "100000000001");
|
||||
assertTrue(xmrProofInfo.checkApiResponse(json).getState()
|
||||
== XmrProofResult.State.AMOUNT_NOT_MATCHING);
|
||||
== AutoConfirmResult.State.AMOUNT_NOT_MATCHING);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonFail() {
|
||||
String failedJson = "{\"data\":null,\"message\":\"Cant parse tx hash: a\",\"status\":\"error\"}";
|
||||
assertTrue(xmrProofInfo.checkApiResponse(failedJson).getState()
|
||||
== XmrProofResult.State.API_INVALID);
|
||||
== AutoConfirmResult.State.API_INVALID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ public class BuyerStep4View extends TradeStepView {
|
|||
GridPane.setMargin(hBox2, new Insets(18, -10, -12, -10));
|
||||
gridPane.getChildren().add(hBox2);
|
||||
GridPane.setRowSpan(hBox2, 5);
|
||||
if (trade.getXmrProofResult() == null || !trade.getXmrProofResult().isSuccessState()) {
|
||||
if (trade.getAutoConfirmResult() == null || !trade.getAutoConfirmResult().isSuccessState()) {
|
||||
autoConfBadge.setVisible(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import bisq.core.payment.payload.USPostalMoneyOrderAccountPayload;
|
|||
import bisq.core.payment.payload.WesternUnionAccountPayload;
|
||||
import bisq.core.trade.Contract;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.asset.xmr.XmrProofResult;
|
||||
import bisq.core.trade.AutoConfirmResult;
|
||||
import bisq.core.user.DontShowAgainLookup;
|
||||
|
||||
import bisq.common.Timer;
|
||||
|
@ -77,7 +77,7 @@ public class SellerStep3View extends TradeStepView {
|
|||
private Subscription tradeStatePropertySubscription;
|
||||
private Timer timeoutTimer;
|
||||
private TextFieldWithCopyIcon autoConfirmStatusField;
|
||||
private final ChangeListener<XmrProofResult> xmrProofResultListener;
|
||||
private final ChangeListener<AutoConfirmResult> autoConfirmResultListener;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, Initialisation
|
||||
|
@ -86,8 +86,8 @@ public class SellerStep3View extends TradeStepView {
|
|||
public SellerStep3View(PendingTradesViewModel model) {
|
||||
super(model);
|
||||
|
||||
// we listen for updates on the trade xmrProofResult field
|
||||
xmrProofResultListener = (observable, oldValue, newValue) -> {
|
||||
// we listen for updates on the trade autoConfirmResult field
|
||||
autoConfirmResultListener = (observable, oldValue, newValue) -> {
|
||||
autoConfirmStatusField.setText(newValue.getTextStatus());
|
||||
};
|
||||
}
|
||||
|
@ -150,14 +150,14 @@ public class SellerStep3View extends TradeStepView {
|
|||
}
|
||||
});
|
||||
|
||||
// we listen for updates on the trade xmrProofResult field
|
||||
// we listen for updates on the trade autoConfirmResult field
|
||||
if (autoConfirmStatusField != null) {
|
||||
trade.getXmrProofResultProperty().addListener(xmrProofResultListener);
|
||||
trade.getAutoConfirmResultProperty().addListener(autoConfirmResultListener);
|
||||
// display the initial value, or FEATURE_DISABLED if there is none
|
||||
XmrProofResult xmrProofResult = trade.getXmrProofResult();
|
||||
if (xmrProofResult == null)
|
||||
xmrProofResult = new XmrProofResult(0, 0, XmrProofResult.State.FEATURE_DISABLED);
|
||||
autoConfirmStatusField.setText(xmrProofResult.getTextStatus());
|
||||
AutoConfirmResult autoConfirmResult = trade.getAutoConfirmResult();
|
||||
if (autoConfirmResult == null)
|
||||
autoConfirmResult = new AutoConfirmResult(0, 0, AutoConfirmResult.State.FEATURE_DISABLED);
|
||||
autoConfirmStatusField.setText(autoConfirmResult.getTextStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class SellerStep3View extends TradeStepView {
|
|||
if (timeoutTimer != null)
|
||||
timeoutTimer.stop();
|
||||
|
||||
trade.getXmrProofResultProperty().removeListener(xmrProofResultListener);
|
||||
trade.getAutoConfirmResultProperty().removeListener(autoConfirmResultListener);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue