diff --git a/database/chain.go b/database/chain.go index 9410eb68..e7b404dc 100644 --- a/database/chain.go +++ b/database/chain.go @@ -325,12 +325,11 @@ FROM chainSwaps swaps WHERE data.lockupTransactionId != '' AND data.transactionId == '' AND state != ? - AND data.timeoutBlockheight > ? ` -func (database *Database) QueryClaimableChainSwaps(tenantId *Id, currency boltz.Currency, currentBlockHeight uint32) ([]*ChainSwap, error) { +func (database *Database) QueryClaimableChainSwaps(tenantId *Id, currency boltz.Currency) ([]*ChainSwap, error) { query := claimableChainSwapsQuery - values := []any{currency, boltzrpc.SwapState_REFUNDED, currentBlockHeight} + values := []any{currency, boltzrpc.SwapState_REFUNDED} if tenantId != nil { query += " AND tenantId = ?" values = append(values, tenantId) diff --git a/database/database.go b/database/database.go index ec1886f7..070a3508 100644 --- a/database/database.go +++ b/database/database.go @@ -480,12 +480,12 @@ func (database *Database) QueryAllRefundableSwaps(tenantId *Id, currency boltz.C return swaps, chainSwaps, nil } -func (database *Database) QueryAllClaimableSwaps(tenantId *Id, currency boltz.Currency, currentHeight uint32) ([]*ReverseSwap, []*ChainSwap, error) { - reverseSwaps, err := database.QueryClaimableReverseSwaps(tenantId, currency, currentHeight) +func (database *Database) QueryAllClaimableSwaps(tenantId *Id, currency boltz.Currency) ([]*ReverseSwap, []*ChainSwap, error) { + reverseSwaps, err := database.QueryClaimableReverseSwaps(tenantId, currency) if err != nil { return nil, nil, err } - chainSwaps, err := database.QueryClaimableChainSwaps(tenantId, currency, currentHeight) + chainSwaps, err := database.QueryClaimableChainSwaps(tenantId, currency) if err != nil { return nil, nil, err } diff --git a/database/reverse.go b/database/reverse.go index 85fb27cc..08fd7954 100644 --- a/database/reverse.go +++ b/database/reverse.go @@ -270,12 +270,11 @@ SELECT * FROM reverseSwaps WHERE fromCurrency = ? AND reverseSwaps.lockupTransactionId != '' AND reverseSwaps.claimTransactionId == '' - AND reverseSwaps.timeoutBlockheight > ? ` -func (database *Database) QueryClaimableReverseSwaps(tenantId *Id, currency boltz.Currency, currentBlockHeight uint32) ([]*ReverseSwap, error) { +func (database *Database) QueryClaimableReverseSwaps(tenantId *Id, currency boltz.Currency) ([]*ReverseSwap, error) { query := claimableSwapsQuery - values := []any{currency, currentBlockHeight} + values := []any{currency} if tenantId != nil { query += " AND tenantId = ?" values = append(values, *tenantId) diff --git a/rpcserver/router.go b/rpcserver/router.go index 8bc2feaf..b4ff7796 100644 --- a/rpcserver/router.go +++ b/rpcserver/router.go @@ -168,24 +168,22 @@ func (server *routedBoltzServer) queryRefundableSwaps(ctx context.Context, heigh return } -func (server *routedBoltzServer) queryClaimableSwaps(ctx context.Context, heights *boltzrpc.BlockHeights) ( +func (server *routedBoltzServer) queryClaimableSwaps(ctx context.Context) ( reverseSwaps []*database.ReverseSwap, chainSwaps []*database.ChainSwap, err error, ) { tenantId := macaroons.TenantIdFromContext(ctx) - reverseSwaps, chainSwaps, err = server.database.QueryAllClaimableSwaps(tenantId, boltz.CurrencyBtc, heights.Btc) + reverseSwaps, chainSwaps, err = server.database.QueryAllClaimableSwaps(tenantId, boltz.CurrencyBtc) if err != nil { return } - if heights.Liquid != nil { - liquidReverseSwaps, liquidChainSwaps, liquidErr := server.database.QueryAllClaimableSwaps(tenantId, boltz.CurrencyLiquid, *heights.Liquid) - if liquidErr != nil { - err = liquidErr - return - } - reverseSwaps = append(reverseSwaps, liquidReverseSwaps...) - chainSwaps = append(chainSwaps, liquidChainSwaps...) + liquidReverseSwaps, liquidChainSwaps, liquidErr := server.database.QueryAllClaimableSwaps(tenantId, boltz.CurrencyLiquid) + if liquidErr != nil { + err = liquidErr + return } + reverseSwaps = append(reverseSwaps, liquidReverseSwaps...) + chainSwaps = append(chainSwaps, liquidChainSwaps...) return } @@ -226,7 +224,7 @@ func (server *routedBoltzServer) GetInfo(ctx context.Context, _ *boltzrpc.GetInf return nil, err } - claimableReverseSwaps, claimableChainSwaps, err := server.queryClaimableSwaps(ctx, blockHeights) + claimableReverseSwaps, claimableChainSwaps, err := server.queryClaimableSwaps(ctx) if err != nil { return nil, err } @@ -482,12 +480,7 @@ func (server *routedBoltzServer) ClaimSwaps(ctx context.Context, request *boltzr var chainSwaps []*database.ChainSwap var currency boltz.Currency - heights, err := server.queryHeights() - if err != nil { - return nil, err - } - - claimableReverseSwaps, claimableChainSwaps, err := server.queryClaimableSwaps(ctx, heights) + claimableReverseSwaps, claimableChainSwaps, err := server.queryClaimableSwaps(ctx) if err != nil { return nil, err }