mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
* fix: intercept self hold payments based on invoice rather than payment hash * fix: generate test invoices with long expiry * fix: add timeout seconds for standard lnd payments
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package transactions
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/getAlby/hub/db"
|
|
"github.com/getAlby/hub/events"
|
|
)
|
|
|
|
type holdInvoiceUpdatedConsumer struct {
|
|
paymentRequest string
|
|
settledChannel chan<- *db.Transaction
|
|
canceledChannel chan<- *db.Transaction
|
|
}
|
|
|
|
func newHoldInvoiceUpdatedConsumer(paymentRequest string, settledChannel chan<- *db.Transaction, canceledChannel chan<- *db.Transaction) *holdInvoiceUpdatedConsumer {
|
|
return &holdInvoiceUpdatedConsumer{
|
|
paymentRequest: paymentRequest,
|
|
settledChannel: settledChannel,
|
|
canceledChannel: canceledChannel,
|
|
}
|
|
}
|
|
|
|
func (consumer *holdInvoiceUpdatedConsumer) ConsumeEvent(ctx context.Context, event *events.Event, globalProperties map[string]interface{}) {
|
|
if event.Event == "nwc_payment_received" && event.Properties.(*db.Transaction).PaymentRequest == consumer.paymentRequest {
|
|
consumer.settledChannel <- event.Properties.(*db.Transaction)
|
|
}
|
|
if event.Event == "nwc_hold_invoice_canceled" && event.Properties.(*db.Transaction).PaymentRequest == consumer.paymentRequest {
|
|
consumer.canceledChannel <- event.Properties.(*db.Transaction)
|
|
}
|
|
}
|