mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 21:47:07 +02:00
Fixes missing zaps on the first connection to a NWC wallet with a split payment.
This commit is contained in:
@@ -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() },
|
||||||
)
|
)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user