Skip to content

Commit

Permalink
Display the address used to receive funds in Transaction Details
Browse files Browse the repository at this point in the history
  • Loading branch information
angelix committed Jul 14, 2022
1 parent 3982ba7 commit 049d90e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crypto/src/main/java/com/blockstream/gdk/data/Transaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package com.blockstream.gdk.data

import android.os.Parcelable
import com.blockstream.gdk.BalancePair
import com.blockstream.gdk.GAJson
import com.blockstream.gdk.serializers.DateAsMicrosecondsSerializer
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.util.*
Expand Down Expand Up @@ -43,7 +45,8 @@ data class Transaction(
@SerialName("user_signed") val userSigned: Boolean,

@SerialName("satoshi") val satoshi: Map<String, Long>
) : Parcelable {
) : GAJson<Transaction>(),Parcelable {
override fun kSerializer() = serializer()

enum class SPVResult {
Disabled, InProgress, NotVerified, NotLongest, Unconfirmed, Verified;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class GreenModules {
ScreenCaptureToolboxModule(),
DividerModule(),
TextModule("Logs", TextModule.Type.SECTION_HEADER),
LogListModule(maxItemCount = 50),
LogListModule(maxItemCount = 25),
DividerModule(),
TextModule("Other", TextModule.Type.SECTION_HEADER),
DeviceInfoModule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.blockstream.green.ui.items
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import com.blockstream.gdk.data.Transaction
import com.blockstream.green.R
import com.blockstream.green.databinding.ListItemTransactionAmountBinding
import com.blockstream.green.ui.looks.AddreseeLookInterface
Expand All @@ -29,7 +28,7 @@ data class TransactionAmountListItem constructor(
override fun bindView(binding: ListItemTransactionAmountBinding, payloads: List<Any>) {
binding.isChange = look.isChange(index)
binding.type = look.txType
binding.address = if(look.txType == Transaction.Type.OUT) look.getAddress(index) else null
binding.address = look.getAddress(index)

if(withStroke){
binding.card.strokeWidth = binding.root.context.toPixels(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ abstract class TransactionLook constructor(open val session: GreenSession, inter
override fun getAssetId(index: Int): String = assets[index].first

// GDK returns non-confidential addresses for Liquid. Hide them for now
override fun getAddress(index: Int) = if(session.isLiquid) null else tx.addressees.getOrNull(index)
override fun getAddress(index: Int): String? = when {
session.isLiquid -> null
txType == Transaction.Type.OUT -> tx.addressees.getOrNull(index)
txType == Transaction.Type.IN -> tx.outputs.filter { it.isRelevant == true }.getOrNull(index)?.address
else -> null
}

// Cache amounts to avoid calling convert every time for performance reasons
private val cacheAmounts = hashMapOf<Int, String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import com.mikepenz.fastadapter.adapters.GenericFastItemAdapter
import com.mikepenz.fastadapter.binding.listeners.addClickListener
import com.mikepenz.fastadapter.diff.FastAdapterDiffUtil
import com.mikepenz.itemanimators.AlphaInAnimator
import com.pandulapeter.beagle.Beagle
import dagger.hilt.android.AndroidEntryPoint
import mu.KLogging
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -51,6 +53,9 @@ class TransactionDetailsFragment : WalletFragment<BaseRecyclerViewBinding>(

lateinit var noteListItem: GenericDetailListItem

@Inject
lateinit var beagle: Beagle

@Inject
lateinit var viewModelFactory: TransactionDetailsViewModel.AssistedFactory
val viewModel: TransactionDetailsViewModel by viewModels {
Expand All @@ -69,6 +74,13 @@ class TransactionDetailsFragment : WalletFragment<BaseRecyclerViewBinding>(
override fun onViewCreatedGuarded(view: View, savedInstanceState: Bundle?) {
binding.vm = viewModel

if(isDevelopmentOrDebug){
args.transaction.toJson().also {
logger.info { it }
beagle.log(it)
}
}

noteListItem = GenericDetailListItem(
title = StringHolder(R.string.id_my_notes),
liveContent = viewModel.editableNote,
Expand Down Expand Up @@ -246,4 +258,6 @@ class TransactionDetailsFragment : WalletFragment<BaseRecyclerViewBinding>(
}

override fun getWalletViewModel() = viewModel

companion object: KLogging()
}

0 comments on commit 049d90e

Please sign in to comment.