Fixes missing zaps on the first connection to a NWC wallet with a split payment.

This commit is contained in:
Vitor Pamplona
2024-09-27 15:19:48 -04:00
parent 86e5dfa799
commit a028c2c3fc
4 changed files with 8 additions and 23 deletions

View File

@@ -1298,11 +1298,11 @@ class Account(
signedEvent = event, signedEvent = event,
relayTemplate = relayTemplate =
RelaySetupInfoToConnect( RelaySetupInfoToConnect(
nip47.relayUri, url = nip47.relayUri,
shouldUseTorForTrustedRelays(), // this is trusted. forceProxy = shouldUseTorForTrustedRelays(), // this is trusted.
true, read = true,
true, write = true,
wcListener.feedTypes, feedTypes = wcListener.feedTypes,
), ),
onDone = { wcListener.destroy() }, onDone = { wcListener.destroy() },
) )

View File

@@ -118,10 +118,6 @@ class ZapPaymentHandler(
onProgress(0.02f) onProgress(0.02f)
signAllZapRequests(note, pollOption, message, zapType, zapsToSend) { splitZapRequestPairs -> signAllZapRequests(note, pollOption, message, zapType, zapsToSend) { splitZapRequestPairs ->
splitZapRequestPairs.forEach {
println("AABBCC 1 ${it.key} ${it.value} $amountMilliSats")
}
if (splitZapRequestPairs.isEmpty()) { if (splitZapRequestPairs.isEmpty()) {
onProgress(0.00f) onProgress(0.00f)
return@signAllZapRequests return@signAllZapRequests
@@ -132,10 +128,6 @@ class ZapPaymentHandler(
assembleAllInvoices(splitZapRequestPairs.toList(), amountMilliSats, message, showErrorIfNoLnAddress, forceProxy, onError, onProgress = { assembleAllInvoices(splitZapRequestPairs.toList(), amountMilliSats, message, showErrorIfNoLnAddress, forceProxy, onError, onProgress = {
onProgress(it * 0.7f + 0.05f) // keeps within range. onProgress(it * 0.7f + 0.05f) // keeps within range.
}, context) { }, context) {
splitZapRequestPairs.forEach {
println("AABBCC 2 ${it.key} ${it.value} $amountMilliSats")
}
if (it.isEmpty()) { if (it.isEmpty()) {
onProgress(0.00f) onProgress(0.00f)
return@assembleAllInvoices return@assembleAllInvoices
@@ -225,7 +217,6 @@ class ZapPaymentHandler(
) + (authorRelayList ?: emptySet()) ) + (authorRelayList ?: emptySet())
prepareZapRequestIfNeeded(note, pollOption, message, zapType, user, userRelayList) { zapRequestJson -> prepareZapRequestIfNeeded(note, pollOption, message, zapType, user, userRelayList) { zapRequestJson ->
println("AABBCC middle ${user?.toBestDisplayName()} + $zapRequestJson")
onReady(SignAllZapRequestsReturn(zapRequestJson, user)) onReady(SignAllZapRequestsReturn(zapRequestJson, user))
} }
} }
@@ -284,20 +275,15 @@ class ZapPaymentHandler(
collectSuccessfulSigningOperations<String, Boolean>( collectSuccessfulSigningOperations<String, Boolean>(
operationsInput = invoices, operationsInput = invoices,
runRequestFor = { invoice: String, onReady -> runRequestFor = { invoice: String, onReady ->
println("AABBCC sending $invoice")
account.sendZapPaymentRequestFor( account.sendZapPaymentRequestFor(
bolt11 = invoice, bolt11 = invoice,
zappedNote = note, zappedNote = note,
onSent = { onSent = {
println("AABBCC sent $invoice")
progressAllPayments += 0.5f / invoices.size progressAllPayments += 0.5f / invoices.size
onProgress(progressAllPayments) onProgress(progressAllPayments)
onReady(true) onReady(true)
}, },
onResponse = { response -> onResponse = { response ->
println("AABBCC response $invoice")
if (response is PayInvoiceErrorResponse) { if (response is PayInvoiceErrorResponse) {
progressAllPayments += 0.5f / invoices.size progressAllPayments += 0.5f / invoices.size
onProgress(progressAllPayments) onProgress(progressAllPayments)

View File

@@ -99,7 +99,7 @@ class Relay(
} }
} }
private fun sendOutbox() { fun sendOutbox() {
synchronized(outboxCache) { synchronized(outboxCache) {
outboxCache.values.forEach { outboxCache.values.forEach {
send(it) send(it)

View File

@@ -96,9 +96,8 @@ object RelayPool : Relay.Listener {
addRelay(relay) addRelay(relay)
relay.connectAndRun { relay.connectAndRun {
Client.allSubscriptions().forEach { relay.renewFilters()
relay.sendFilter(it.key, it.value) relay.sendOutbox()
}
onConnected(relay) onConnected(relay)