mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
Update LND, Aperture, and Taproot Assets to revisions using the btcd v2 modules, and update lndclient to v0.21.0-3. Migrate Loop chain, transaction, and address types to their corresponding v2 packages. The lndclient release includes the migration from: https://github.com/lightninglabs/lndclient/pull/280 Taproot Assets is temporarily replaced with its btcd v2 revision because the v0.8 release branch has not adopted the new modules. This raises the minimum Go version to 1.26 and changes exported address types.
47 lines
1.2 KiB
Go
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()
|
|
}
|
|
}
|