Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions android/app/src/main/java/org/bitcoinppl/cove/QrCodeScanView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.google.mlkit.vision.barcode.common.Barcode
import com.google.mlkit.vision.common.InputImage
import org.bitcoinppl.cove_core.AppAlertState
import org.bitcoinppl.cove_core.MultiFormat
import org.bitcoinppl.cove_core.MultiQrException
import org.bitcoinppl.cove_core.QrScanner
import org.bitcoinppl.cove_core.ScanProgress
import org.bitcoinppl.cove_core.ScanResult
Expand Down Expand Up @@ -249,14 +250,14 @@ private fun QrScannerContent(
scannedData = data
if (!isDisposed) scanner.reset()
},
onError = { error ->
onError = { title, message ->
if (!isDisposed) scanner.reset()
onDismiss()
app.alertState =
TaggedItem(
AppAlertState.General(
title = "QR Scan Error",
message = error,
title = title,
message = message,
),
)
},
Expand Down Expand Up @@ -465,7 +466,7 @@ private fun handleQrCode(
scanner: QrScanner,
onProgress: (ScanProgress) -> Unit,
onComplete: (MultiFormat) -> Unit,
onError: (String) -> Unit,
onError: (title: String, message: String) -> Unit,
) {
try {
// convert barcode to StringOrData (prioritize text, fall back to binary)
Expand All @@ -490,7 +491,15 @@ private fun handleQrCode(
} catch (e: IllegalStateException) {
// scanner was destroyed during async callback, ignore
Log.d("QrCodeScanView", "Scanner already destroyed, ignoring: ${e.message}")
} catch (e: MultiQrException.SilentPaymentNotSupported) {
onError(
"Unsupported Address",
"Sending to silent payment addresses (sp1...) is not yet supported. Support is coming soon.",
)
} catch (e: Exception) {
onError("Unable to scan QR code: ${e.message ?: "Unknown scanning error"}")
onError(
"QR Scan Error",
"Unable to scan QR code: ${e.message ?: "Unknown scanning error"}",
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class SendFlowPresenter(
is SendFlowException.WrongNetwork,
-> "Invalid Address"

is SendFlowException.SilentPaymentNotSupported,
-> "Unsupported Address"

is SendFlowException.InvalidNumber,
is SendFlowException.ZeroAmount,
-> "Invalid Amount"
Expand Down Expand Up @@ -152,6 +155,9 @@ class SendFlowPresenter(

is SendFlowException.UnableToSaveUnsignedTransaction ->
error.v1

is SendFlowException.SilentPaymentNotSupported ->
"Sending to silent payment addresses (sp1...) is not yet supported. Support is coming soon."
}

/**
Expand All @@ -171,6 +177,7 @@ class SendFlowPresenter(
is SendFlowException.EmptyAddress,
is SendFlowException.WrongNetwork,
is SendFlowException.InvalidAddress,
is SendFlowException.SilentPaymentNotSupported,
-> {
{
alertState = null
Expand Down
81 changes: 63 additions & 18 deletions android/app/src/main/java/org/bitcoinppl/cove_core/cove.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39997,6 +39997,12 @@ sealed class MultiFormatException: kotlin.Exception() {
get() = ""
}

class SilentPaymentNotSupported(
) : MultiFormatException() {
override val message
get() = ""
}

class UnrecognizedFormat(
) : MultiFormatException() {
override val message
Expand Down Expand Up @@ -40055,12 +40061,13 @@ public object FfiConverterTypeMultiFormatError : FfiConverterRustBuffer<MultiFor
FfiConverterTypeSeedQrError.read(buf),
)
2 -> MultiFormatException.UnsupportedNetworkAddress()
3 -> MultiFormatException.UnrecognizedFormat()
4 -> MultiFormatException.InvalidTapSigner(
3 -> MultiFormatException.SilentPaymentNotSupported()
4 -> MultiFormatException.UnrecognizedFormat()
5 -> MultiFormatException.InvalidTapSigner(
FfiConverterTypeTapCardParseError.read(buf),
)
5 -> MultiFormatException.TaprootNotSupported()
6 -> MultiFormatException.PsbtNotSigned()
6 -> MultiFormatException.TaprootNotSupported()
7 -> MultiFormatException.PsbtNotSigned()
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
}
}
Expand All @@ -40076,6 +40083,10 @@ public object FfiConverterTypeMultiFormatError : FfiConverterRustBuffer<MultiFor
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
is MultiFormatException.SilentPaymentNotSupported -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
is MultiFormatException.UnrecognizedFormat -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
Expand Down Expand Up @@ -40107,21 +40118,25 @@ public object FfiConverterTypeMultiFormatError : FfiConverterRustBuffer<MultiFor
buf.putInt(2)
Unit
}
is MultiFormatException.UnrecognizedFormat -> {
is MultiFormatException.SilentPaymentNotSupported -> {
buf.putInt(3)
Unit
}
is MultiFormatException.InvalidTapSigner -> {
is MultiFormatException.UnrecognizedFormat -> {
buf.putInt(4)
Unit
}
is MultiFormatException.InvalidTapSigner -> {
buf.putInt(5)
FfiConverterTypeTapCardParseError.write(value.v1, buf)
Unit
}
is MultiFormatException.TaprootNotSupported -> {
buf.putInt(5)
buf.putInt(6)
Unit
}
is MultiFormatException.PsbtNotSigned -> {
buf.putInt(6)
buf.putInt(7)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
Expand All @@ -40143,6 +40158,12 @@ sealed class MultiQrException: kotlin.Exception() {
get() = "v1=${ v1 }"
}

class SilentPaymentNotSupported(
) : MultiQrException() {
override val message
get() = ""
}

class InvalidUtf8(
) : MultiQrException() {
override val message
Expand Down Expand Up @@ -40208,15 +40229,16 @@ public object FfiConverterTypeMultiQrError : FfiConverterRustBuffer<MultiQrExcep
1 -> MultiQrException.ParseException(
FfiConverterString.read(buf),
)
2 -> MultiQrException.InvalidUtf8()
3 -> MultiQrException.RequiresStringData()
4 -> MultiQrException.InvalidSeedQr(
2 -> MultiQrException.SilentPaymentNotSupported()
3 -> MultiQrException.InvalidUtf8()
4 -> MultiQrException.RequiresStringData()
5 -> MultiQrException.InvalidSeedQr(
FfiConverterTypeSeedQrError.read(buf),
)
5 -> MultiQrException.Ur(
6 -> MultiQrException.Ur(
FfiConverterTypeUrError.read(buf),
)
6 -> MultiQrException.BbqrCborNotSupported()
7 -> MultiQrException.BbqrCborNotSupported()
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
}
}
Expand All @@ -40228,6 +40250,10 @@ public object FfiConverterTypeMultiQrError : FfiConverterRustBuffer<MultiQrExcep
4UL
+ FfiConverterString.allocationSize(value.v1)
)
is MultiQrException.SilentPaymentNotSupported -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
is MultiQrException.InvalidUtf8 -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
Expand Down Expand Up @@ -40260,26 +40286,30 @@ public object FfiConverterTypeMultiQrError : FfiConverterRustBuffer<MultiQrExcep
FfiConverterString.write(value.v1, buf)
Unit
}
is MultiQrException.InvalidUtf8 -> {
is MultiQrException.SilentPaymentNotSupported -> {
buf.putInt(2)
Unit
}
is MultiQrException.RequiresStringData -> {
is MultiQrException.InvalidUtf8 -> {
buf.putInt(3)
Unit
}
is MultiQrException.InvalidSeedQr -> {
is MultiQrException.RequiresStringData -> {
buf.putInt(4)
Unit
}
is MultiQrException.InvalidSeedQr -> {
buf.putInt(5)
FfiConverterTypeSeedQrError.write(value.v1, buf)
Unit
}
is MultiQrException.Ur -> {
buf.putInt(5)
buf.putInt(6)
FfiConverterTypeUrError.write(value.v1, buf)
Unit
}
is MultiQrException.BbqrCborNotSupported -> {
buf.putInt(6)
buf.putInt(7)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
Expand Down Expand Up @@ -43638,6 +43668,12 @@ sealed class SendFlowException: kotlin.Exception() {
get() = "v1=${ v1 }"
}

class SilentPaymentNotSupported(
) : SendFlowException() {
override val message
get() = ""
}




Expand Down Expand Up @@ -43696,6 +43732,7 @@ public object FfiConverterTypeSendFlowError : FfiConverterRustBuffer<SendFlowExc
14 -> SendFlowException.UnableToGetFeeDetails(
FfiConverterString.read(buf),
)
15 -> SendFlowException.SilentPaymentNotSupported()
Comment thread
guptapratykshh marked this conversation as resolved.
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
}
}
Expand Down Expand Up @@ -43767,6 +43804,10 @@ public object FfiConverterTypeSendFlowError : FfiConverterRustBuffer<SendFlowExc
4UL
+ FfiConverterString.allocationSize(value.v1)
)
is SendFlowException.SilentPaymentNotSupported -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
}
}

Expand Down Expand Up @@ -43837,6 +43878,10 @@ public object FfiConverterTypeSendFlowError : FfiConverterRustBuffer<SendFlowExc
FfiConverterString.write(value.v1, buf)
Unit
}
is SendFlowException.SilentPaymentNotSupported -> {
buf.putInt(15)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9537,6 +9537,12 @@ sealed class AddressException: kotlin.Exception() {
get() = ""
}

class SilentPaymentNotSupported(
) : AddressException() {
override val message
get() = ""
}




Expand Down Expand Up @@ -9567,6 +9573,7 @@ public object FfiConverterTypeAddressError : FfiConverterRustBuffer<AddressExcep
FfiConverterTypeNetwork.read(buf),
)
6 -> AddressException.EmptyAddress()
7 -> AddressException.SilentPaymentNotSupported()
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
}
}
Expand Down Expand Up @@ -9600,6 +9607,10 @@ public object FfiConverterTypeAddressError : FfiConverterRustBuffer<AddressExcep
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
is AddressException.SilentPaymentNotSupported -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4UL
)
}
}

Expand Down Expand Up @@ -9632,6 +9643,10 @@ public object FfiConverterTypeAddressError : FfiConverterRustBuffer<AddressExcep
buf.putInt(6)
Unit
}
is AddressException.SilentPaymentNotSupported -> {
buf.putInt(7)
Unit
}
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
}

Expand Down
6 changes: 5 additions & 1 deletion ios/Cove/Flows/SendFlow/SendFlowPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ import SwiftUI
switch error {
case .EmptyAddress, .InvalidAddress, .WrongNetwork:
"Invalid Address"
case .SilentPaymentNotSupported:
"Unsupported Address"
case .InvalidNumber, .ZeroAmount: "Invalid Amount"
case .InsufficientFunds, .NoBalance: "Insufficient Funds"
case .SendAmountToLow: "Send Amount Too Low"
Expand Down Expand Up @@ -129,6 +131,8 @@ import SwiftUI
msg
case let .UnableToSaveUnsignedTransaction(msg):
msg
case .SilentPaymentNotSupported:
"Sending to silent payment addresses (sp1...) is not yet supported. Support is coming soon."
}
}

Expand All @@ -145,7 +149,7 @@ import SwiftUI
@ViewBuilder
private func errorAlertButtons(_ error: SendFlowError) -> some View {
switch error {
case .EmptyAddress, .WrongNetwork, .InvalidAddress:
case .EmptyAddress, .WrongNetwork, .InvalidAddress, .SilentPaymentNotSupported:
Button("OK") {
self.alertState = .none
self.focusField = .address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ struct QrCodeAddressView: View {
haptic.trigger()
progress = prog
}
} catch MultiQrError.SilentPaymentNotSupported {
scanner.reset()
dismiss()
app.alertState = TaggedItem(
.general(
title: "Unsupported Address",
message: "Sending to silent payment addresses (sp1...) is not yet supported. Support is coming soon."
)
)
} catch {
scanner.reset()
dismiss()
Expand Down
Loading
Loading