Skip to content

Commit

Permalink
UI fixes regarding unconfirmed/confirmed mined transaction updates. R…
Browse files Browse the repository at this point in the history
…estart transaction broadcast after successful transaction validation. More decimal places for the fee display in the transaction details screen. Bump build number.
  • Loading branch information
kukabi committed Feb 26, 2021
1 parent adae21d commit e5ec8e4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/cpp/jniWallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void txMinedUnconfirmedCallback(struct TariCompletedTransaction *pCompletedTrans
callbackHandler,
txMinedUnconfirmedCallbackMethodId,
jpCompletedTransaction,
confirmationCount);
bytes);
g_vm->DetachCurrentThread();
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/tari/android/wallet/ffi/FFIWallet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ internal class FFIWallet(
return BigInteger(1, bytes)
}

fun restartTxValidation(): BigInteger {
fun restartTxBroadcast(): BigInteger {
val error = FFIError()
val bytes = jniRestartTxBroadcast(error)
throwIf(error)
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/tari/android/wallet/service/WalletService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ internal class WalletService : Service(), FFIWalletListener, LifecycleObserver {

private lateinit var wallet: FFIWallet

private var txBroadcastRestarted = false

/**
* Pairs of <tx id, recipient public key hex>.
*/
Expand Down Expand Up @@ -596,6 +598,15 @@ internal class WalletService : Service(), FFIWalletListener, LifecycleObserver {

override fun onTxValidationComplete(responseId: BigInteger, result: BaseNodeValidationResult) {
checkValidationResult(BaseNodeValidationType.TX, responseId, result)
if (!txBroadcastRestarted && result == BaseNodeValidationResult.SUCCESS) {
try {
wallet.restartTxBroadcast()
txBroadcastRestarted = true
Logger.i("Transaction broadcast restarted.")
} catch (e: Exception) {
Logger.e("Error while restarting tx broadcast: " + e.message)
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ internal class TxDetailsActivity : AppCompatActivity(), ServiceConnection {
ui.feeLabelTextView.visible()
ui.txFeeTextView.text = string(
tx_details_fee_value,
WalletUtil.amountFormatter.format(fee.tariValue)
WalletUtil.feeFormatter.format(fee.tariValue)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ internal class TxListFragment : Fragment(),
EventBus.subscribe<Event.Wallet.OutboundTxBroadcast>(this) {
onOutboundTxBroadcast(it.tx)
}
EventBus.subscribe<Event.Wallet.TxMinedUnconfirmed>(this) {
onTxMinedUnconfirmed(it.tx, it.confirmationCount)
}
EventBus.subscribe<Event.Wallet.TxMined>(this) {
onTxMined(it.tx)
}
Expand Down Expand Up @@ -448,13 +451,21 @@ internal class TxListFragment : Fragment(),
pendingOutboundTxs.firstOrNull { it.id == tx.id }?.status = TxStatus.BROADCAST
}

private fun onTxMined(tx: CompletedTx) {
private fun onTxMinedUnconfirmed(tx: CompletedTx, confirmationCount: Int) {
val source = when (tx.direction) {
Tx.Direction.INBOUND -> pendingInboundTxs
Tx.Direction.OUTBOUND -> pendingOutboundTxs
}
source.find { it.id == tx.id }?.let { source.remove(it) }
completedTxs.add(tx)
if (completedTxs.find { it.id == tx.id } == null) {
completedTxs.add(tx)
}
// update tx list UI
lifecycleScope.launch(Dispatchers.Main) { updateTxListUI() }
}

private fun onTxMined(tx: CompletedTx) {
completedTxs.firstOrNull { it.id == tx.id }?.status = TxStatus.MINED_CONFIRMED
// update tx list UI
lifecycleScope.launch(Dispatchers.Main) { updateTxListUI() }
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
ext.kotlin_version = '1.4.21'

// build & version
ext.buildNumber = 152
ext.buildNumber = 153
ext.versionNumber = "0.6.0"

// JNI libs
Expand Down

0 comments on commit e5ec8e4

Please sign in to comment.