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,
relayTemplate =
RelaySetupInfoToConnect(
nip47.relayUri,
shouldUseTorForTrustedRelays(), // this is trusted.
true,
true,
wcListener.feedTypes,
url = nip47.relayUri,
forceProxy = shouldUseTorForTrustedRelays(), // this is trusted.
read = true,
write = true,
feedTypes = wcListener.feedTypes,
),
onDone = { wcListener.destroy() },
)

View File

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

View File

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

View File

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