/*
 * This file is part of Bisq.
 *
 * Bisq is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 *
 * Bisq is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Bisq. If not, see <http://www.gnu.org/licenses/>.
 */

package bisq.core.trade.txproof;

import lombok.Getter;

public enum AssetTxProofResult {
    UNDEFINED,

    FEATURE_DISABLED,
    TRADE_LIMIT_EXCEEDED,
    INVALID_DATA,  // Peer provided invalid data. Might be a scam attempt (e.g. txKey reused)
    PAYOUT_TX_ALREADY_PUBLISHED,
    DISPUTE_OPENED,

    REQUESTS_STARTED(false),
    PENDING(false),

    // All services completed with a success state
    COMPLETED,

    // Any service had an error (network, API service)
    ERROR,

    // Any service failed. Might be that the tx is invalid.
    FAILED;

    @Getter
    private int numSuccessResults;
    @Getter
    private int numRequiredSuccessResults;
    @Getter
    private int numConfirmations;
    @Getter
    private int numRequiredConfirmations;
    @Getter
    private String details = "";
    // If isTerminal is set it means that we stop the service
    @Getter
    private final boolean isTerminal;

    AssetTxProofResult() {
        this(true);
    }

    AssetTxProofResult(boolean isTerminal) {
        this.isTerminal = isTerminal;
    }


    public AssetTxProofResult numSuccessResults(int numSuccessResults) {
        this.numSuccessResults = numSuccessResults;
        return this;
    }

    public AssetTxProofResult numRequiredSuccessResults(int numRequiredSuccessResults) {
        this.numRequiredSuccessResults = numRequiredSuccessResults;
        return this;
    }

    public AssetTxProofResult numConfirmations(int numConfirmations) {
        this.numConfirmations = numConfirmations;
        return this;
    }

    public AssetTxProofResult numRequiredConfirmations(int numRequiredConfirmations) {
        this.numRequiredConfirmations = numRequiredConfirmations;
        return this;
    }

    public AssetTxProofResult details(String details) {
        this.details = details;
        return this;
    }

    @Override
    public String toString() {
        return "AssetTxProofResult{" +
                "\n     numSuccessResults=" + numSuccessResults +
                ",\n     requiredSuccessResults=" + numRequiredSuccessResults +
                ",\n     numConfirmations=" + numConfirmations +
                ",\n     numRequiredConfirmations=" + numRequiredConfirmations +
                ",\n     details='" + details + '\'' +
                "\n} " + super.toString();
    }
}

@@ -1234,16 +1234,173 @@
 AILED;%0A%0A
+    // If isTerminal is set it means that we stop the service%0A    @Getter%0A    private final boolean isTerminal;%0A    @Getter%0A    private String details = %22%22;%0A
     @Get
@@ -1597,164 +1597,8 @@
 ns;%0A
-    @Getter%0A    private String details = %22%22;%0A    // If isTerminal is set it means that we stop the service%0A    @Getter%0A    private final boolean isTerminal;
 %0A%0A  
@@ -2632,16 +2632,124 @@
 %22%5Cn     
+details='%22 + details + '%5C'' +%0A                %22,%5Cn     isTerminal=%22 + isTerminal +%0A                %22,%5Cn     
 numSucce
@@ -2807,17 +2807,20 @@
 ,%5Cn     
-r
+numR
 equiredS
@@ -3015,63 +3015,8 @@
 s +%0A
-                %22,%5Cn     details='%22 + details + '%5C'' +%0A
     

Rearrange fields and improve toString method