channeldb: make payhash on InvoiceRef optional
Currently we support queries by payHash or payHash+payAddr. For handling of AMP HTLCs, we only need to support querying by payAddr.
This commit is contained in:
4 files changed
+93
-35
No files matched your search
@@ -377,7 +377,8 @@ func (i *InvoiceRegistry) invoiceEventLoop() {
|
||||
func (i *InvoiceRegistry) dispatchToSingleClients(event *invoiceEvent) {
|
||||
// Dispatch to single invoice subscribers.
|
||||
for _, client := range i.singleNotificationClients {
|
||||
if client.invoiceRef.PayHash() != event.hash {
|
||||
payHash := client.invoiceRef.PayHash()
|
||||
if payHash == nil || *payHash != event.hash {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -524,8 +525,13 @@ func (i *InvoiceRegistry) deliverSingleBacklogEvents(
|
||||
return err
|
||||
}
|
||||
|
||||
payHash := client.invoiceRef.PayHash()
|
||||
if payHash == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = client.notify(&invoiceEvent{
|
||||
hash: client.invoiceRef.PayHash(),
|
||||
hash: *payHash,
|
||||
invoice: &invoice,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -29,9 +29,7 @@ func TestSettleInvoice(t *testing.T) {
|
||||
}
|
||||
defer subscription.Cancel()
|
||||
|
||||
if subscription.invoiceRef.PayHash() != testInvoicePaymentHash {
|
||||
t.Fatalf("expected subscription for provided hash")
|
||||
}
|
||||
require.Equal(t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash)
|
||||
|
||||
// Add the invoice.
|
||||
addIdx, err := ctx.registry.AddInvoice(testInvoice, testInvoicePaymentHash)
|
||||
@@ -244,9 +242,7 @@ func testCancelInvoice(t *testing.T, gc bool) {
|
||||
}
|
||||
defer subscription.Cancel()
|
||||
|
||||
if subscription.invoiceRef.PayHash() != testInvoicePaymentHash {
|
||||
t.Fatalf("expected subscription for provided hash")
|
||||
}
|
||||
require.Equal(t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash)
|
||||
|
||||
// Add the invoice.
|
||||
amt := lnwire.MilliSatoshi(100000)
|
||||
@@ -404,9 +400,7 @@ func TestSettleHoldInvoice(t *testing.T) {
|
||||
}
|
||||
defer subscription.Cancel()
|
||||
|
||||
if subscription.invoiceRef.PayHash() != testInvoicePaymentHash {
|
||||
t.Fatalf("expected subscription for provided hash")
|
||||
}
|
||||
require.Equal(t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash)
|
||||
|
||||
// Add the invoice.
|
||||
_, err = registry.AddInvoice(testHodlInvoice, testInvoicePaymentHash)
|
||||
@@ -1211,7 +1205,7 @@ func TestSettleInvoicePaymentAddrRequired(t *testing.T) {
|
||||
defer subscription.Cancel()
|
||||
|
||||
require.Equal(
|
||||
t, subscription.invoiceRef.PayHash(), testInvoicePaymentHash,
|
||||
t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash,
|
||||
)
|
||||
|
||||
// Add the invoice, which requires the MPP payload to always be
|
||||
@@ -1287,7 +1281,7 @@ func TestSettleInvoicePaymentAddrRequiredOptionalGrace(t *testing.T) {
|
||||
defer subscription.Cancel()
|
||||
|
||||
require.Equal(
|
||||
t, subscription.invoiceRef.PayHash(), testInvoicePaymentHash,
|
||||
t, subscription.invoiceRef.PayHash(), &testInvoicePaymentHash,
|
||||
)
|
||||
|
||||
// Add the invoice, which requires the MPP payload to always be
|
||||
|
||||
Reference in new issue
Block a user