@@ -11,6 +11,7 @@ import (
1111 "github.com/btcsuite/btcd/wire"
1212 "github.com/btcsuite/btcutil"
1313 "github.com/lightninglabs/loop/lndclient"
14+ "github.com/lightningnetwork/lnd/channeldb"
1415 "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
1516 "github.com/lightningnetwork/lnd/lntypes"
1617 "github.com/lightningnetwork/lnd/zpay32"
@@ -125,9 +126,38 @@ func (h *mockLightningClient) AddInvoice(ctx context.Context,
125126 return lntypes.Hash {}, "" , err
126127 }
127128
129+ // Add the invoice we have created to our mock's set of invoices.
130+ h .lnd .Invoices [hash ] = & lndclient.Invoice {
131+ Preimage : nil ,
132+ Hash : hash ,
133+ PaymentRequest : payReqString ,
134+ Amount : in .Value ,
135+ CreationDate : creationDate ,
136+ State : channeldb .ContractOpen ,
137+ IsKeysend : false ,
138+ }
139+
128140 return hash , payReqString , nil
129141}
130142
143+ // LookupInvoice looks up an invoice in the mock's set of stored invoices.
144+ // If it is not found, this call will fail. Note that these invoices should
145+ // be settled using settleInvoice to have a preimage, settled state and settled
146+ // date set.
147+ func (h * mockLightningClient ) LookupInvoice (_ context.Context ,
148+ hash lntypes.Hash ) (* lndclient.Invoice , error ) {
149+
150+ h .lnd .lock .Lock ()
151+ defer h .lnd .lock .Unlock ()
152+
153+ inv , ok := h .lnd .Invoices [hash ]
154+ if ! ok {
155+ return nil , fmt .Errorf ("invoice: %x not found" , hash )
156+ }
157+
158+ return inv , nil
159+ }
160+
131161// ListTransactions returns all known transactions of the backing lnd node.
132162func (h * mockLightningClient ) ListTransactions (
133163 ctx context.Context ) ([]* wire.MsgTx , error ) {
0 commit comments