Search in sources :

Example 1 with Transaction

use of com.mobilecoin.lib.Transaction in project Signal-Android by signalapp.

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)

Example 2 with Transaction

use of com.mobilecoin.lib.Transaction 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)

Example 3 with Transaction

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

the class PaymentMetaDataUtil method addTransactionData.

private static void addTransactionData(@NonNull byte[] transactionBytes, PaymentMetaData.MobileCoinTxoIdentification.Builder builder) throws SerializationException {
    Transaction transaction = Transaction.fromBytes(transactionBytes);
    Set<KeyImage> keyImages = transaction.getKeyImages();
    for (KeyImage keyImage : keyImages) {
        builder.addKeyImages(ByteString.copyFrom(keyImage.getData()));
    }
    for (RistrettoPublic publicKey : transaction.getOutputPublicKeys()) {
        addPublicKey(builder, publicKey);
    }
}
Also used : RistrettoPublic(com.mobilecoin.lib.RistrettoPublic) KeyImage(com.mobilecoin.lib.KeyImage) Transaction(com.mobilecoin.lib.Transaction)

Example 4 with Transaction

use of com.mobilecoin.lib.Transaction in project Signal-Android by signalapp.

the class PaymentMetaDataUtil method addTransactionData.

private static void addTransactionData(@NonNull byte[] transactionBytes, PaymentMetaData.MobileCoinTxoIdentification.Builder builder) throws SerializationException {
    Transaction transaction = Transaction.fromBytes(transactionBytes);
    Set<KeyImage> keyImages = transaction.getKeyImages();
    for (KeyImage keyImage : keyImages) {
        builder.addKeyImages(ByteString.copyFrom(keyImage.getData()));
    }
    for (RistrettoPublic publicKey : transaction.getOutputPublicKeys()) {
        addPublicKey(builder, publicKey);
    }
}
Also used : RistrettoPublic(com.mobilecoin.lib.RistrettoPublic) KeyImage(com.mobilecoin.lib.KeyImage) Transaction(com.mobilecoin.lib.Transaction)

Aggregations

Transaction (com.mobilecoin.lib.Transaction)4 NonNull (androidx.annotation.NonNull)2 WorkerThread (androidx.annotation.WorkerThread)2 KeyImage (com.mobilecoin.lib.KeyImage)2 PendingTransaction (com.mobilecoin.lib.PendingTransaction)2 RistrettoPublic (com.mobilecoin.lib.RistrettoPublic)2 AttestationException (com.mobilecoin.lib.exceptions.AttestationException)2 InvalidFogResponse (com.mobilecoin.lib.exceptions.InvalidFogResponse)2 NetworkException (com.mobilecoin.lib.exceptions.NetworkException)2 SerializationException (com.mobilecoin.lib.exceptions.SerializationException)2 IOException (java.io.IOException)2