diff --git a/staticaddr/loopin/interface.go b/staticaddr/loopin/interface.go index 45310152..b54949f6 100644 --- a/staticaddr/loopin/interface.go +++ b/staticaddr/loopin/interface.go @@ -64,6 +64,10 @@ type StaticAddressLoopInStore interface { // IsStored checks if the loop-in is already stored in the database. IsStored(ctx context.Context, swapHash lntypes.Hash) (bool, error) + + // GetLoopInByHash returns the loop-in swap with the given hash. + GetLoopInByHash(ctx context.Context, swapHash lntypes.Hash) ( + *StaticAddressLoopIn, error) } type QuoteGetter interface { diff --git a/staticaddr/loopin/sql_store.go b/staticaddr/loopin/sql_store.go index 06caae63..e6ba5aad 100644 --- a/staticaddr/loopin/sql_store.go +++ b/staticaddr/loopin/sql_store.go @@ -100,6 +100,30 @@ func NewSqlStore(db BaseDB, clock clock.Clock, } } +// GetLoopInByHash returns the loop-in swap with the given hash. +func (s *SqlStore) GetLoopInByHash(ctx context.Context, + swapHash lntypes.Hash) (*StaticAddressLoopIn, error) { + + var ( + err error + row sqlc.GetStaticAddressLoopInSwapRow + updates []sqlc.StaticAddressSwapUpdate + ) + row, err = s.baseDB.GetStaticAddressLoopInSwap(ctx, swapHash[:]) + if err != nil { + return nil, err + } + + updates, err = s.baseDB.GetLoopInSwapUpdates(ctx, swapHash[:]) + if err != nil { + return nil, err + } + + return toStaticAddressLoopIn( + ctx, s.network, row, updates, + ) +} + // GetStaticAddressLoopInSwapsByStates returns all static address loop-ins from // the db that are in the given states. func (s *SqlStore) GetStaticAddressLoopInSwapsByStates(ctx context.Context,