loop/loopd/static_loopin_status_updater.go
Boris Nagaev 0ee07198f6
build: update lndclient (btcd v2)
Include https://github.com/lightninglabs/lndclient/pull/280
multi: migrate to btcd v2 modules + add WalletKit.SubmitPackage

Migrate Loop imports and update Aperture and Taproot Assets to compatible
revisions so this commit remains green on its own.
2026-08-11 13:36:02 -05:00

47 lines
1.2 KiB
Go

package loopd
import (
"context"
"fmt"
"github.com/btcsuite/btcd/chaincfg/v2"
"github.com/lightninglabs/loop"
"github.com/lightninglabs/loop/staticaddr/loopin"
)
// staticLoopInStatusUpdater publishes static-address loop-in status updates to
// the client-facing swap stream.
type staticLoopInStatusUpdater struct {
// statusChan sends updates to the client-facing swap stream.
statusChan chan<- loop.SwapInfo
// mainCtx is canceled when loopd is shutting down.
mainCtx context.Context
// chainParams are used to reconstruct the static loop-in HTLC address.
chainParams *chaincfg.Params
}
// sendUpdate converts the persisted static-address loop-in into swap info and
// forwards it to the status stream unless either context is canceled.
func (u *staticLoopInStatusUpdater) sendUpdate(ctx context.Context,
swp *loopin.StaticAddressLoopIn) error {
info, err := staticAddressLoopInSwapInfoWithChainParams(
swp, u.chainParams,
)
if err != nil {
return fmt.Errorf("unable to notify static loop-in update: %w", err)
}
select {
case u.statusChan <- *info:
return nil
case <-ctx.Done():
return ctx.Err()
case <-u.mainCtx.Done():
return u.mainCtx.Err()
}
}