use of org.thoughtcrime.securesms.payments.MobileCoinLedgerWrapper in project Signal-Android by signalapp.
the class PaymentLedgerUpdateJob method onRun.
@Override
protected void onRun() throws IOException, RetryLaterException {
if (!SignalStore.paymentsValues().mobileCoinPaymentsEnabled()) {
Log.w(TAG, "Payments are not enabled");
return;
}
Long minimumBlockIndex = null;
if (paymentUuid != null) {
PaymentDatabase.PaymentTransaction payment = SignalDatabase.payments().getPayment(paymentUuid);
if (payment != null) {
minimumBlockIndex = payment.getBlockIndex();
Log.i(TAG, "Fetching for a payment " + paymentUuid + " " + (minimumBlockIndex > 0 ? "non-zero" : "zero"));
} else {
Log.w(TAG, "Payment not found " + paymentUuid);
}
}
MobileCoinLedgerWrapper ledger = ApplicationDependencies.getPayments().getWallet().tryGetFullLedger(minimumBlockIndex);
if (ledger == null) {
Log.i(TAG, "Ledger not updated yet, waiting for a minimum block index");
throw new RetryLaterException();
}
Log.i(TAG, "Ledger fetched successfully");
SignalStore.paymentsValues().setMobileCoinFullLedger(ledger);
}
Aggregations