diff options
author | Torsten Grote <t@grobox.de> | 2022-09-13 14:41:22 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2022-09-13 14:41:55 -0300 |
commit | ac64720eecda411934b75c75417f6d69a4a2f365 (patch) | |
tree | f9a283272c206b6109b0c0569ced095fb87148ef | |
parent | ad053447d57b6e791369f5574f2a4253ba523467 (diff) | |
download | taler-android-ac64720eecda411934b75c75417f6d69a4a2f365.tar.gz taler-android-ac64720eecda411934b75c75417f6d69a4a2f365.tar.bz2 taler-android-ac64720eecda411934b75c75417f6d69a4a2f365.zip |
[wallet] Don't crash when there's no subject in the payto:// URI for manual withdrawals
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt index b597237..f21fd8c 100644 --- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt +++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt @@ -70,8 +70,7 @@ sealed class WithdrawStatus { val subject: String, val amountRaw: Amount, override val transactionId: String?, - ) : ManualTransferRequired() { - } + ) : ManualTransferRequired() data class ManualTransferRequiredBitcoin( val exchangeBaseUrl: String, @@ -287,10 +286,10 @@ fun createManualTransferRequired( uriStr: String, transactionId: String? = null, ): WithdrawStatus.ManualTransferRequired { - val uri = Uri.parse(uriStr) + val uri = Uri.parse(uriStr.replace("receiver-name=", "receiver_name=")) if ("bitcoin".equals(uri.authority, true)) { - val msg = uri.getQueryParameter("message") - val reg = "\\b([A-Z0-9]{52})\\b".toRegex().find(msg.orEmpty()) + val msg = uri.getQueryParameter("message").orEmpty() + val reg = "\\b([A-Z0-9]{52})\\b".toRegex().find(msg) val reserve = reg?.value ?: uri.getQueryParameter("subject")!! val segwitAddrs = Bech32.generateFakeSegwitAddress(reserve, uri.pathSegments.first()) return WithdrawStatus.ManualTransferRequiredBitcoin( @@ -307,7 +306,7 @@ fun createManualTransferRequired( exchangeBaseUrl = exchangeBaseUrl, uri = uri, iban = uri.lastPathSegment!!, - subject = uri.getQueryParameter("message")!!, + subject = uri.getQueryParameter("subject") ?: "Error: No subject in URI", amountRaw = amount, transactionId = transactionId, ) |