refactor: clear two name clashes ahead of the AccountViewModel move

- The app's ui/dal DefaultFeedOrder repeated commons' feeds
  DefaultFeedOrder verbatim; the copy is gone, callers use commons', and
  the file keeps the app-only orders as FeedOrders.kt.
- The app's LNURL-pay resolver becomes LightningInvoiceResolver, so it
  no longer shares a simple name with commons' plain
  LightningAddressResolver (the Desktop/CLI one) once both sit in the
  same package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S7FuNBSKiyVecARSoE4B9P
This commit is contained in:
Claude
2026-09-28 14:39:15 +00:00
parent 0980c9b5d2
commit 4906843e43
8 changed files with 24 additions and 27 deletions
@@ -36,7 +36,7 @@ import com.vitorpamplona.amethyst.commons.resources.podcast_value_no_recipients
import com.vitorpamplona.amethyst.commons.service.lnurl.LnurlHttpTransport
import com.vitorpamplona.amethyst.commons.tor.MoneyOpRelayRouting
import com.vitorpamplona.amethyst.commons.ui.loadStringRes
import com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver
import com.vitorpamplona.amethyst.service.lnurl.LightningInvoiceResolver
import com.vitorpamplona.amethyst.ui.nwc.nwcFailureDetail
import com.vitorpamplona.amethyst.ui.nwc.nwcTimeoutMessage
import com.vitorpamplona.quartz.nip01Core.core.toHexKey
@@ -245,7 +245,7 @@ class V4VPaymentHandler(
}
val invoice =
LightningAddressResolver(lnurl).lnAddressInvoice(
LightningInvoiceResolver(lnurl).lnAddressInvoice(
lnAddress = lnAddress,
milliSats = share.amountMilliSats,
message = message,
@@ -255,7 +255,7 @@ class V4VPaymentHandler(
progress += 1f / shares.size
onProgress(progress)
InvoicePayable(share, invoice)
} catch (e: LightningAddressResolver.LightningAddressError) {
} catch (e: LightningInvoiceResolver.LightningAddressError) {
onError(e.title, e.msg)
null
} catch (e: Exception) {
@@ -44,7 +44,7 @@ import com.vitorpamplona.amethyst.commons.resources.wallet_connect_pay_invoice_e
import com.vitorpamplona.amethyst.commons.service.lnurl.LnurlHttpTransport
import com.vitorpamplona.amethyst.commons.tor.MoneyOpRelayRouting
import com.vitorpamplona.amethyst.commons.ui.loadStringRes
import com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver
import com.vitorpamplona.amethyst.service.lnurl.LightningInvoiceResolver
import com.vitorpamplona.amethyst.ui.nwc.nwcFailureDetail
import com.vitorpamplona.amethyst.ui.nwc.nwcTimeoutMessage
import com.vitorpamplona.quartz.experimental.clink.pointers.NDebit
@@ -434,7 +434,7 @@ class ZapPaymentHandler(
onProgress(progressAllPayments)
},
)
} catch (e: LightningAddressResolver.LightningAddressError) {
} catch (e: LightningInvoiceResolver.LightningAddressError) {
onError(e.title, e.msg, splitZapRequestPair.inputSetup.user)
null
} catch (e: Exception) {
@@ -681,7 +681,7 @@ class ZapPaymentHandler(
var sentZapRequest: ZapRequestEvent? = null
val invoice =
LightningAddressResolver(lnurl).lnAddressInvoice(
LightningInvoiceResolver(lnurl).lnAddressInvoice(
lnAddress = lud16,
milliSats = zapValue,
message = message,
@@ -28,7 +28,7 @@ import com.vitorpamplona.amethyst.commons.resources.cashu_unsafe_mint_url
import com.vitorpamplona.amethyst.commons.resources.cashu_unsafe_mint_url_explainer
import com.vitorpamplona.amethyst.commons.service.lnurl.LnurlHttpTransport
import com.vitorpamplona.amethyst.commons.ui.loadStringRes
import com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver
import com.vitorpamplona.amethyst.service.lnurl.LightningInvoiceResolver
import com.vitorpamplona.quartz.nip60Cashu.mintApi.CashuMintOperations
import com.vitorpamplona.quartz.nip60Cashu.mintApi.MintHttpClient
import com.vitorpamplona.quartz.nip60Cashu.mintApi.MintHttpTransport
@@ -75,7 +75,7 @@ class MeltProcessor {
// the LN fee_reserve, then add the NUT-02 input fee the mint
// charges on these proofs.
val probeInvoice =
LightningAddressResolver(lnurl).lnAddressInvoice(
LightningInvoiceResolver(lnurl).lnAddressInvoice(
lnAddress = lud16,
milliSats = token.totalAmount * 1000,
message = "Calculate Fees for Cashu",
@@ -86,7 +86,7 @@ class MeltProcessor {
val sendable = token.totalAmount - fees
if (sendable <= 0) {
throw LightningAddressResolver.LightningAddressError(
throw LightningInvoiceResolver.LightningAddressError(
loadStringRes(Res.string.cashu_failed_redemption),
loadStringRes(
Res.string.cashu_failed_redemption_explainer_error_msg,
@@ -99,7 +99,7 @@ class MeltProcessor {
// requesting change — there is no wallet to hold leftover proofs,
// so the unused fee_reserve stays with the mint.
val invoice =
LightningAddressResolver(lnurl).lnAddressInvoice(
LightningInvoiceResolver(lnurl).lnAddressInvoice(
lnAddress = lud16,
milliSats = sendable * 1000,
message = "Redeem Cashu",
@@ -115,16 +115,16 @@ class MeltProcessor {
)
} catch (e: Exception) {
if (e is CancellationException) throw e
if (e is LightningAddressResolver.LightningAddressError) throw e
if (e is LightningInvoiceResolver.LightningAddressError) throw e
// The mint URL was refused before any request went out: this is OUR
// message, not the mint's, so don't dress it up as "the mint said".
if (e is MintUrlException) {
throw LightningAddressResolver.LightningAddressError(
throw LightningInvoiceResolver.LightningAddressError(
loadStringRes(Res.string.cashu_unsafe_mint_url),
loadStringRes(Res.string.cashu_unsafe_mint_url_explainer, e.message),
)
}
throw LightningAddressResolver.LightningAddressError(
throw LightningInvoiceResolver.LightningAddressError(
loadStringRes(Res.string.cashu_failed_redemption),
loadStringRes(Res.string.cashu_failed_redemption_explainer_error_msg, e.message),
)
@@ -53,7 +53,7 @@ import kotlinx.serialization.json.longOrNull
import kotlin.coroutines.cancellation.CancellationException
/** LNURL-pay (LUD-06/16) for zaps and payments, over whatever [transport] the platform supplies. */
class LightningAddressResolver(
class LightningInvoiceResolver(
private val transport: LnurlHttpTransport,
) {
fun assembleUrl(lnAddress: String): String? {
@@ -166,7 +166,7 @@ class LightningAddressResolver(
}
if (errorMessage == null) {
Log.d("LightningAddressResolver") { "Error parsing LNResponse: $body" }
Log.d("LightningInvoiceResolver") { "Error parsing LNResponse: $body" }
}
return errorMessage
@@ -25,9 +25,6 @@ import com.vitorpamplona.amethyst.commons.model.Note
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.ChannelInviteCard
import com.vitorpamplona.quartz.nip01Core.core.Event
val DefaultFeedOrder: Comparator<Note> =
compareByDescending<Note> { it.createdAt() }.thenBy { it.idHex }
val DefaultFeedOrderEvent: Comparator<Event> =
compareByDescending<Event> { it.createdAt }.thenBy { it.id }
@@ -107,7 +107,7 @@ import com.vitorpamplona.amethyst.service.ClinkDebitPayer
import com.vitorpamplona.amethyst.service.V4VPaymentHandler
import com.vitorpamplona.amethyst.service.ZapPaymentHandler
import com.vitorpamplona.amethyst.service.cashu.melt.MeltProcessor
import com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver
import com.vitorpamplona.amethyst.service.lnurl.LightningInvoiceResolver
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.RelaySubscriptionsCoordinator
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.markRoomNoteAsRead
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.rowHasUnread
@@ -2683,7 +2683,7 @@ class AccountViewModel(
meltResult.fees.toString(),
),
)
} catch (e: LightningAddressResolver.LightningAddressError) {
} catch (e: LightningInvoiceResolver.LightningAddressError) {
onDone(e.title, e.msg)
} catch (e: Exception) {
if (e is kotlin.coroutines.cancellation.CancellationException) throw e
@@ -2915,7 +2915,7 @@ class AccountViewModel(
}
val invoice =
LightningAddressResolver(host.lnurlTransport).lnAddressInvoice(
LightningInvoiceResolver(host.lnurlTransport).lnAddressInvoice(
lnAddress = lnAddress,
milliSats = milliSats,
message = message,
@@ -2927,7 +2927,7 @@ class AccountViewModel(
// its message TextFieldState, which is UI-thread confined (see the KDoc on
// commons' `onUiThread`). This whole block runs on Dispatchers.IO.
withContext(Dispatchers.Main) { onNewInvoice(invoice) }
} catch (e: LightningAddressResolver.LightningAddressError) {
} catch (e: LightningInvoiceResolver.LightningAddressError) {
onError(e.title, e.msg)
} catch (e: Exception) {
if (e is CancellationException) throw e
@@ -28,11 +28,11 @@ import org.junit.Assert.assertEquals
import org.junit.Test
/**
* [LightningAddressResolver] over a scripted transport. The replies use the loose typing real
* [LightningInvoiceResolver] over a scripted transport. The replies use the loose typing real
* LNURL servers send (a boolean as text, a number for a flag), which the resolver was written to
* read through Jackson's lenient readers.
*/
class LightningAddressResolverTest {
class LightningInvoiceResolverTest {
// A 1 mBTC (100,000 sat) BOLT-11.
private val invoice100kSats = "lnbc1m1pjt9u0qsp553q90pj5mafzv20w45eqavned9tgwhl4q99n9s5ppcw24nzw3zeqpp5002kd3ktym67du86kj665fgaev7ka8ys7j5yz5fg686lr5e2gfkshp5dkk27nnuax05az3pk2r6ytxtvwn5j4xzsq9ajprhc7crjkmgvr3qxqyjw5qcqpjrzjqtzxvfsuxe4l92pf97tt4rcgpy2xalkmlwexh899wqxf83l8nwv4xzh0gvqq89qqqqqqqqlgqqqqq0gqvs9qxpqysgqx5mz04wd7kqu5zhhel9enr036hjrp4gga0nz084p2asjl36a0zmrk6mhqa249zsgqref2rlvhffm73u7rxgr47gden6rugup4ksvpzsqvds4pz"
@@ -51,7 +51,7 @@ class LightningAddressResolverTest {
private fun resolverFor(
lnurlp: String,
invoiceReply: String = """{"pr":"$invoice100kSats","routes":[]}""",
): Pair<LightningAddressResolver, ScriptedTransport> {
): Pair<LightningInvoiceResolver, ScriptedTransport> {
val transport =
ScriptedTransport(
mapOf(
@@ -59,7 +59,7 @@ class LightningAddressResolverTest {
"https://example.com/callback" to invoiceReply,
),
)
return LightningAddressResolver(transport) to transport
return LightningInvoiceResolver(transport) to transport
}
@Test
@@ -32,7 +32,7 @@ import kotlinx.coroutines.CompletableDeferred
* recipient's LNURL provider's `nostrPubkey` to validate the signer (NIP-57
* Appendix F). Without a cache, we'd re-fetch the same lnurlp endpoint for
* every zap from every popular author. Outbound zaps populate the cache as a
* side effect when [com.vitorpamplona.amethyst.service.lnurl.LightningAddressResolver]
* side effect when Amethyst's `LightningInvoiceResolver`
* fetches the recipient's metadata.
*
* Keys are URLs (not lud16 forms) so callers can convert lud16 / bech32 LNURL