mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
channeldb/invoice: add InvoiceRefByAddr
This commit is contained in:
@@ -236,6 +236,14 @@ func InvoiceRefByHashAndAddr(payHash lntypes.Hash,
|
||||
}
|
||||
}
|
||||
|
||||
// InvoiceRefByAddr creates an InvoiceRef that queries the payment addr index
|
||||
// for an invoice with the provided payment address.
|
||||
func InvoiceRefByAddr(addr [32]byte) InvoiceRef {
|
||||
return InvoiceRef{
|
||||
payAddr: &addr,
|
||||
}
|
||||
}
|
||||
|
||||
// InvoiceRefBySetID creates an InvoiceRef that queries the set id index for an
|
||||
// invoice with the provided setID. If the invoice is not found, the query will
|
||||
// not fallback to payHash or payAddr.
|
||||
@@ -903,6 +911,10 @@ func fetchInvoiceNumByRef(invoiceIndex, payAddrIndex, setIDIndex kvdb.RBucket,
|
||||
|
||||
return invoiceNumByAddr, nil
|
||||
|
||||
// Return invoices by payment addr only.
|
||||
case invoiceNumByAddr != nil:
|
||||
return invoiceNumByAddr, nil
|
||||
|
||||
// If we were only able to reference the invoice by hash, return the
|
||||
// corresponding invoice number. This can happen when no payment address
|
||||
// was provided, or if it didn't match anything in our records.
|
||||
|
Reference in New Issue
Block a user