Search in sources :

Example 6 with AttestationException

use of com.mobilecoin.lib.exceptions.AttestationException in project Signal-Android by WhisperSystems.

the class Wallet method getSentTransactionStatus.

@WorkerThread
@NonNull
public TransactionStatusResult getSentTransactionStatus(@NonNull PaymentTransactionId transactionId) throws IOException {
    try {
        PaymentTransactionId.MobileCoin mobcoinTransaction = (PaymentTransactionId.MobileCoin) transactionId;
        Transaction transaction = Transaction.fromBytes(mobcoinTransaction.getTransaction());
        Transaction.Status status = mobileCoinClient.getAccountSnapshot().getTransactionStatus(transaction);
        switch(status) {
            case UNKNOWN:
                Log.w(TAG, "Unknown sent Transaction Status");
                return TransactionStatusResult.inProgress();
            case FAILED:
                return TransactionStatusResult.failed();
            case ACCEPTED:
                return TransactionStatusResult.complete(status.getBlockIndex().longValue());
            default:
                throw new IllegalStateException("Unknown Transaction Status: " + status);
        }
    } catch (SerializationException | InvalidFogResponse e) {
        Log.w(TAG, e);
        return TransactionStatusResult.failed();
    } catch (NetworkException | AttestationException e) {
        Log.w(TAG, e);
        throw new IOException(e);
    }
}
Also used : SerializationException(com.mobilecoin.lib.exceptions.SerializationException) AttestationException(com.mobilecoin.lib.exceptions.AttestationException) IOException(java.io.IOException) InvalidFogResponse(com.mobilecoin.lib.exceptions.InvalidFogResponse) PendingTransaction(com.mobilecoin.lib.PendingTransaction) Transaction(com.mobilecoin.lib.Transaction) NetworkException(com.mobilecoin.lib.exceptions.NetworkException) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Aggregations

AttestationException (com.mobilecoin.lib.exceptions.AttestationException)6 NonNull (androidx.annotation.NonNull)4 WorkerThread (androidx.annotation.WorkerThread)4 InvalidFogResponse (com.mobilecoin.lib.exceptions.InvalidFogResponse)4 NetworkException (com.mobilecoin.lib.exceptions.NetworkException)4 SerializationException (com.mobilecoin.lib.exceptions.SerializationException)3 IOException (java.io.IOException)3 BigInteger (java.math.BigInteger)3 ClientConfig (com.mobilecoin.lib.ClientConfig)2 PendingTransaction (com.mobilecoin.lib.PendingTransaction)2 Verifier (com.mobilecoin.lib.Verifier)2 X509Certificate (java.security.cert.X509Certificate)2 Nullable (androidx.annotation.Nullable)1 AccountSnapshot (com.mobilecoin.lib.AccountSnapshot)1 OwnedTxOut (com.mobilecoin.lib.OwnedTxOut)1 Receipt (com.mobilecoin.lib.Receipt)1 Transaction (com.mobilecoin.lib.Transaction)1 UnsignedLong (com.mobilecoin.lib.UnsignedLong)1 AmountDecoderException (com.mobilecoin.lib.exceptions.AmountDecoderException)1 FeeRejectedException (com.mobilecoin.lib.exceptions.FeeRejectedException)1