use of com.mobilecoin.lib.Receipt in project Signal-Android by signalapp.
the class Wallet method getReceivedTransactionStatus.
@WorkerThread
@NonNull
public ReceivedTransactionStatus getReceivedTransactionStatus(@NonNull byte[] receiptBytes) throws IOException {
try {
Receipt receipt = Receipt.fromBytes(receiptBytes);
Receipt.Status status = mobileCoinClient.getReceiptStatus(receipt);
switch(status) {
case UNKNOWN:
Log.w(TAG, "Unknown received Transaction Status");
return ReceivedTransactionStatus.inProgress();
case FAILED:
return ReceivedTransactionStatus.failed();
case RECEIVED:
BigInteger amount = receipt.getAmount(account);
return ReceivedTransactionStatus.complete(Money.picoMobileCoin(amount), status.getBlockIndex().longValue());
default:
throw new IllegalStateException("Unknown Transaction Status: " + status);
}
} catch (SerializationException | InvalidFogResponse | InvalidReceiptException e) {
Log.w(TAG, e);
return ReceivedTransactionStatus.failed();
} catch (NetworkException | AttestationException e) {
throw new IOException(e);
} catch (AmountDecoderException e) {
Log.w(TAG, "Failed to decode amount", e);
return ReceivedTransactionStatus.failed();
}
}
use of com.mobilecoin.lib.Receipt in project Signal-Android by WhisperSystems.
the class Wallet method getReceivedTransactionStatus.
@WorkerThread
@NonNull
public ReceivedTransactionStatus getReceivedTransactionStatus(@NonNull byte[] receiptBytes) throws IOException {
try {
Receipt receipt = Receipt.fromBytes(receiptBytes);
Receipt.Status status = mobileCoinClient.getReceiptStatus(receipt);
switch(status) {
case UNKNOWN:
Log.w(TAG, "Unknown received Transaction Status");
return ReceivedTransactionStatus.inProgress();
case FAILED:
return ReceivedTransactionStatus.failed();
case RECEIVED:
BigInteger amount = receipt.getAmount(account);
return ReceivedTransactionStatus.complete(Money.picoMobileCoin(amount), status.getBlockIndex().longValue());
default:
throw new IllegalStateException("Unknown Transaction Status: " + status);
}
} catch (SerializationException | InvalidFogResponse | InvalidReceiptException e) {
Log.w(TAG, e);
return ReceivedTransactionStatus.failed();
} catch (NetworkException | AttestationException e) {
throw new IOException(e);
} catch (AmountDecoderException e) {
Log.w(TAG, "Failed to decode amount", e);
return ReceivedTransactionStatus.failed();
}
}
Aggregations