mirror of
https://codeberg.org/anoncontributorxmr/mysu.git
synced 2025-07-07 18:38:25 +00:00
fix: prevent app from crashing when attempting to create a transaction before wallet is opened
This commit is contained in:
parent
d9957c4214
commit
c45793e689
2 changed files with 13 additions and 3 deletions
|
@ -128,7 +128,16 @@ class SendActivity : MoneroActivity() {
|
||||||
}
|
}
|
||||||
sendMaxButton.setOnClickListener { viewModel.setSendingMax(!isSendAll) }
|
sendMaxButton.setOnClickListener { viewModel.setSendingMax(!isSendAll) }
|
||||||
createButton.setOnClickListener {
|
createButton.setOnClickListener {
|
||||||
val outputsValid = checkDestsValidity(isSendAll)
|
val wallet = walletService?.getWallet()
|
||||||
|
if (wallet == null) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
getString(R.string.cannot_create_transaction_no_wallet),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
val outputsValid = checkDestsValidity(wallet, isSendAll)
|
||||||
if (outputsValid) {
|
if (outputsValid) {
|
||||||
Toast.makeText(this, getString(R.string.creating_tx), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, getString(R.string.creating_tx), Toast.LENGTH_SHORT).show()
|
||||||
createButton.isEnabled = false
|
createButton.isEnabled = false
|
||||||
|
@ -237,7 +246,7 @@ class SendActivity : MoneroActivity() {
|
||||||
sendTx(pendingTx)
|
sendTx(pendingTx)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDestsValidity(sendAll: Boolean): Boolean {
|
private fun checkDestsValidity(wallet: Wallet, sendAll: Boolean): Boolean {
|
||||||
val dests = rawDests
|
val dests = rawDests
|
||||||
for (dest in dests) {
|
for (dest in dests) {
|
||||||
val address = dest.component1()
|
val address = dest.component1()
|
||||||
|
@ -252,7 +261,7 @@ class SendActivity : MoneroActivity() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
val amountRaw = Wallet.getAmountFromString(amount)
|
val amountRaw = Wallet.getAmountFromString(amount)
|
||||||
val balance = walletService!!.getWalletOrThrow().unlockedBalance
|
val balance = wallet.unlockedBalance
|
||||||
if (amountRaw >= balance || amountRaw <= 0) {
|
if (amountRaw >= balance || amountRaw <= 0) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
<string name="receive">Receive</string>
|
<string name="receive">Receive</string>
|
||||||
<string name="creating_tx">Creating transaction…</string>
|
<string name="creating_tx">Creating transaction…</string>
|
||||||
<string name="creating_tx_failed_invalid_outputs">Invalid destination combination</string>
|
<string name="creating_tx_failed_invalid_outputs">Invalid destination combination</string>
|
||||||
|
<string name="cannot_create_transaction_no_wallet">Cannot create transaction - wallet is not opened yet</string>
|
||||||
<string name="sending_tx">Sending transaction…</string>
|
<string name="sending_tx">Sending transaction…</string>
|
||||||
<string name="sent_tx">Sent transaction!</string>
|
<string name="sent_tx">Sent transaction!</string>
|
||||||
<string name="no_camera_permission">No camera permission</string>
|
<string name="no_camera_permission">No camera permission</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue