channeldb: split settleHodlInvoice logic in the UpdateInvoice method

This commit is contained in:
positiveblue
2023-02-01 06:15:32 -08:00
parent a3f6d5c97e
commit cbaec4382a
2 changed files with 86 additions and 3 deletions

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,