mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 06:21:40 +01:00
htlcswitch: fix mockInvoiceRegistry implementation of SettleInvoice
In this commit we fix the implementation of SettleInvoice by ensuring the lock is held for the duration of the method.
This commit is contained in:
parent
a702aace9c
commit
849abde253
1 changed files with 5 additions and 5 deletions
|
@ -419,15 +419,15 @@ func (i *mockInvoiceRegistry) LookupInvoice(rHash chainhash.Hash) (*channeldb.In
|
|||
}
|
||||
|
||||
func (i *mockInvoiceRegistry) SettleInvoice(rhash chainhash.Hash) error {
|
||||
i.Lock()
|
||||
defer i.Unlock()
|
||||
|
||||
invoice, err := i.LookupInvoice(rhash)
|
||||
if err != nil {
|
||||
return err
|
||||
invoice, ok := i.invoices[rhash]
|
||||
if !ok {
|
||||
return errors.New("can't find mock invoice")
|
||||
}
|
||||
|
||||
i.Lock()
|
||||
invoice.Terms.Settled = true
|
||||
i.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue