Search in sources :

Example 1 with PaymentMetaData

use of org.thoughtcrime.securesms.payments.proto.PaymentMetaData in project Signal-Android by WhisperSystems.

the class LedgerReconcileTest method payment.

private static Payment payment(String note, Money.MobileCoin valueAndDirection, Set<ByteString> keyImages, Set<ByteString> publicKeys) {
    UUID uuid = UUID.randomUUID();
    PaymentMetaData.MobileCoinTxoIdentification.Builder builderForValue = PaymentMetaData.MobileCoinTxoIdentification.newBuilder();
    builderForValue.addAllKeyImages(keyImages);
    builderForValue.addAllPublicKey(publicKeys);
    PaymentMetaData paymentMetaData = PaymentMetaData.newBuilder().setMobileCoinTxoIdentification(builderForValue).build();
    return new Payment() {

        @Override
        @NonNull
        public UUID getUuid() {
            return uuid;
        }

        @Override
        @NonNull
        public Payee getPayee() {
            return new Payee(RecipientId.from(1));
        }

        @Override
        public long getBlockIndex() {
            return 0;
        }

        @Override
        public long getBlockTimestamp() {
            return 0;
        }

        @Override
        public long getTimestamp() {
            return 0;
        }

        @Override
        @NonNull
        public Direction getDirection() {
            return valueAndDirection.isNegative() ? Direction.SENT : Direction.RECEIVED;
        }

        @Override
        @NonNull
        public State getState() {
            return State.SUCCESSFUL;
        }

        @Override
        @Nullable
        public FailureReason getFailureReason() {
            return null;
        }

        @Override
        @NonNull
        public String getNote() {
            return note;
        }

        @Override
        @NonNull
        public Money getAmount() {
            return valueAndDirection.abs();
        }

        @Override
        @NonNull
        public Money getFee() {
            return getAmount().toZero();
        }

        @Override
        @NonNull
        public PaymentMetaData getPaymentMetaData() {
            return paymentMetaData;
        }

        @Override
        public boolean isSeen() {
            return true;
        }
    };
}
Also used : Payment(org.thoughtcrime.securesms.payments.Payment) PaymentMetaData(org.thoughtcrime.securesms.payments.proto.PaymentMetaData) UUID(java.util.UUID) Payee(org.thoughtcrime.securesms.payments.Payee)

Aggregations

UUID (java.util.UUID)1 Payee (org.thoughtcrime.securesms.payments.Payee)1 Payment (org.thoughtcrime.securesms.payments.Payment)1 PaymentMetaData (org.thoughtcrime.securesms.payments.proto.PaymentMetaData)1