channeldb: split settleHodlInvoice logic in the UpdateInvoice method

This commit is contained in:
positiveblue committed 2023-03-14 19:01:52 -07:00
1 parent a3f6d5c97e
commit cbaec4382a
2 files changed
+86 -3

No files matched your search

+2 -3
View File
@@ -1231,9 +1231,7 @@ func (i *InvoiceRegistry) SettleHodlInvoice(preimage lntypes.Preimage) error {
i.Lock()
defer i.Unlock()
updateInvoice := func(invoice *Invoice) (
*InvoiceUpdateDesc, error) {
updateInvoice := func(invoice *Invoice) (*InvoiceUpdateDesc, error) {
switch invoice.State {
case ContractOpen:
return nil, ErrInvoiceStillOpen
@@ -1246,6 +1244,7 @@ func (i *InvoiceRegistry) SettleHodlInvoice(preimage lntypes.Preimage) error {
}
return &InvoiceUpdateDesc{
UpdateType: SettleHodlInvoiceUpdate,
State: &InvoiceStateUpdateDesc{
NewState: ContractSettled,
Preimage: &preimage,