Fixes NWC with Auth
This commit is contained in:
@@ -217,7 +217,12 @@ class Account(
|
|||||||
zapPaymentRequest?.let { nip47 ->
|
zapPaymentRequest?.let { nip47 ->
|
||||||
val event = LnZapPaymentRequestEvent.create(bolt11, nip47.pubKeyHex, nip47.secret?.hexToByteArray() ?: loggedIn.privKey!!)
|
val event = LnZapPaymentRequestEvent.create(bolt11, nip47.pubKeyHex, nip47.secret?.hexToByteArray() ?: loggedIn.privKey!!)
|
||||||
|
|
||||||
val wcListener = NostrLnZapPaymentResponseDataSource(nip47.pubKeyHex, event.pubKey, event.id)
|
val wcListener = NostrLnZapPaymentResponseDataSource(
|
||||||
|
fromServiceHex = nip47.pubKeyHex,
|
||||||
|
toUserHex = event.pubKey,
|
||||||
|
replyingToHex = event.id,
|
||||||
|
authSigningKey = nip47.secret?.hexToByteArray() ?: loggedIn.privKey!!
|
||||||
|
)
|
||||||
wcListener.start()
|
wcListener.start()
|
||||||
|
|
||||||
LocalCache.consume(event, zappedNote) {
|
LocalCache.consume(event, zappedNote) {
|
||||||
|
|||||||
+17
-3
@@ -1,14 +1,18 @@
|
|||||||
package com.vitorpamplona.amethyst.service
|
package com.vitorpamplona.amethyst.service
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent
|
import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent
|
||||||
|
import com.vitorpamplona.amethyst.service.model.RelayAuthEvent
|
||||||
|
import com.vitorpamplona.amethyst.service.relays.Client
|
||||||
import com.vitorpamplona.amethyst.service.relays.FeedType
|
import com.vitorpamplona.amethyst.service.relays.FeedType
|
||||||
import com.vitorpamplona.amethyst.service.relays.JsonFilter
|
import com.vitorpamplona.amethyst.service.relays.JsonFilter
|
||||||
|
import com.vitorpamplona.amethyst.service.relays.Relay
|
||||||
import com.vitorpamplona.amethyst.service.relays.TypedFilter
|
import com.vitorpamplona.amethyst.service.relays.TypedFilter
|
||||||
|
|
||||||
class NostrLnZapPaymentResponseDataSource(
|
class NostrLnZapPaymentResponseDataSource(
|
||||||
private var fromServiceHex: String,
|
private val fromServiceHex: String,
|
||||||
private var toUserHex: String,
|
private val toUserHex: String,
|
||||||
private var replyingToHex: String
|
private val replyingToHex: String,
|
||||||
|
private val authSigningKey: ByteArray
|
||||||
) : NostrDataSource("LnZapPaymentResponseFeed") {
|
) : NostrDataSource("LnZapPaymentResponseFeed") {
|
||||||
|
|
||||||
val feedTypes = setOf(FeedType.WALLET_CONNECT)
|
val feedTypes = setOf(FeedType.WALLET_CONNECT)
|
||||||
@@ -36,4 +40,14 @@ class NostrLnZapPaymentResponseDataSource(
|
|||||||
|
|
||||||
channel.typedFilters = listOfNotNull(wc).ifEmpty { null }
|
channel.typedFilters = listOfNotNull(wc).ifEmpty { null }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun auth(relay: Relay, challenge: String) {
|
||||||
|
super.auth(relay, challenge)
|
||||||
|
|
||||||
|
val event = RelayAuthEvent.create(relay.url, challenge, authSigningKey)
|
||||||
|
Client.send(
|
||||||
|
event,
|
||||||
|
relay.url
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user