Example #1
0
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
{
    AssertLockHeld(cs_main);
    if (!IsFinalTx(wtx, chainActive.Height() + 1)) {
        if (wtx.nLockTime < LOCKTIME_THRESHOLD)
            return tr("Open for %n more block(s)", "", wtx.nLockTime - chainActive.Height());
        else
            return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime));
    } else {
        int signatures = wtx.GetTransactionLockSignatures();
        QString strUsingIX = "";
        if (signatures >= 0) {
            if (signatures >= QUICKTX_SIGNATURES_REQUIRED) {
                int nDepth = wtx.GetDepthInMainChain();
                if (nDepth < 0)
                    return tr("conflicted");
                else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
                    return tr("%1/offline (verified via quicktx)").arg(nDepth);
                else if (nDepth < 6)
                    return tr("%1/confirmed (verified via quicktx)").arg(nDepth);
                else
                    return tr("%1 confirmations (verified via quicktx)").arg(nDepth);
            } else {
                if (!wtx.IsTransactionLockTimedOut()) {
                    int nDepth = wtx.GetDepthInMainChain();
                    if (nDepth < 0)
                        return tr("conflicted");
                    else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
                        return tr("%1/offline (quickTX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(QUICKTX_SIGNATURES_TOTAL);
                    else if (nDepth < 6)
                        return tr("%1/confirmed (quickTX verification in progress - %2 of %3 signatures )").arg(nDepth).arg(signatures).arg(QUICKTX_SIGNATURES_TOTAL);
                    else
                        return tr("%1 confirmations (quickTX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(QUICKTX_SIGNATURES_TOTAL);
                } else {
                    int nDepth = wtx.GetDepthInMainChain();
                    if (nDepth < 0)
                        return tr("conflicted");
                    else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
                        return tr("%1/offline (quickTX verification failed)").arg(nDepth);
                    else if (nDepth < 6)
                        return tr("%1/confirmed (quickTX verification failed)").arg(nDepth);
                    else
                        return tr("%1 confirmations").arg(nDepth);
                }
            }
        } else {
            int nDepth = wtx.GetDepthInMainChain();
            if (nDepth < 0)
                return tr("conflicted");
            else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
                return tr("%1/offline").arg(nDepth);
            else if (nDepth < 6)
                return tr("%1/unconfirmed").arg(nDepth);
            else
                return tr("%1 confirmations").arg(nDepth);
        }
    }
}