Skip to content

Commit

Permalink
LNPay Core Alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
tkthundr committed Nov 26, 2023
0 parents commit 9e72224
Show file tree
Hide file tree
Showing 535 changed files with 48,503 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "vendor/bower-asset"
}
64 changes: 64 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
############## SAMPLE ENVIRONMENT DEFAULTS

INSTANCE_ID=lnpay-1

# Used for generating URLs via console
BASE_URL=https://lnpay.local:8111

# Endpoint to receive lightning node events
LN_NODE_INGESTION_ENDPOINT=http://192.168.69.11

# Yii Settings (IF DEVELOPMENT)
YII_DEBUG=true
YII_ENV=dev

# LNPay version
LNPAY_FLAVOR=OPEN

# Database
DB_HOST=192.168.69.22
DB_USER=root
DB_PASS=example
DB_DB=lnpay_db

# Mongo database
MONGO_HOST=
MONGO_USER=
MONGO_PASS=
MONGO_DB=

#PHP bin path
PHP_BIN_PATH=/usr/local/bin/php

# cookie auth key, generate this randomly
YII_COOKIE_VALIDATION_KEY=yii-cookie-validation-key

# general encryption key for sensitive info
GENERAL_ENCRYPTION_KEY=general-encryption-key

#Supervisor Server, this is for monitoring RPC listeners
SUPERVISOR_RPC_HOST=192.168.69.11
SUPERVISOR_RPC_PORT=9001
SUPERVISOR_CONF_PATH=/app/docker/supervisor/conf.d/
SUPERVISOR_SERVER_APP_PATH=/app/

# Email - if DEV emails are sent to files in /runtime/mail
DEFAULT_EMAIL_FROM=
DEFAULT_EMAIL_HOST=
DEFAULT_EMAIL_PORT=
DEFAULT_EMAIL_USERNAME=
DEFAULT_EMAIL_PASSWORD=

######## Scale environment vars

# Redis
# REDIS_HOST=192.168.69.44
# REDIS_CACHE_DB=1
# REDIS_MUTEX_DB=2

# Papertrail logging (OPTIONAL)
# PAPERTRAIL_HOST=
# PAPERTRAIL_PORT=

# Server side tracking help
# AMPLITUDE_API_KEY=
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore all test and documentation for archive
/.github export-ignore
/.gitattributes export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/docs export-ignore
7 changes: 7 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Contributing to Yii2
====================

- [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md)
- [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md)
- [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/)
- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md)
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### What steps will reproduce the problem?

### What's expected?

### What do you get instead?


### Additional info

| Q | A
| ---------------- | ---
| Yii vesion |
| PHP version |
| Operating system |
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| Q | A
| ------------- | ---
| Is bugfix? | yes/no
| New feature? | yes/no
| Breaks BC? | yes/no
| Tests pass? | yes/no
| Fixed issues | comma-separated list of tickets # fixed by the PR, if any
15 changes: 15 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: lnpay-build-test-workflow
on: [push,pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the stack
run: bash docker.sh build
- name: Build codecept
run: docker exec lnpay-php vendor/bin/codecept build
- name: Run API Tests
run: docker exec lnpay-php vendor/bin/codecept run -g base_api -vvv
- name: Run unit,functional Tests
run: docker exec lnpay-php vendor/bin/codecept run unit,functional
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# phpstorm project files
.idea

# netbeans project files
nbproject

# zend studio for eclipse project files
.buildpath
.project
.settings

# windows thumbnail cache
Thumbs.db

# composer vendor dir
/vendor

# composer itself is not needed
composer.phar

# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml

tests/_output/*
tests/_support/_generated

#vagrant folder
/.vagrant

# Ignore environment files
.env
prod.env

lnrpc/

cluster/ssh
Empty file added .gitmodules
Empty file.
45 changes: 45 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
# - hhvm

# faster builds on new travis setup not using sudo
sudo: false

# cache vendor dirs
cache:
directories:
- $HOME/.composer/cache

services:
- mysql

before_install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS yii2_basic_tests;'

install:
- travis_retry composer self-update && composer --version
- travis_retry composer update --dev --prefer-dist --no-interaction
# install php extensions
- |
if (php --version | grep -i HipHop > /dev/null); then
echo "Skipping imagick and gmagick tests on HHVM"
else
pear config-set preferred_state beta
printf "\n" | pecl install imagick
# gmagick is not installed on travis currently
#printf "\n" | pecl install gmagick
fi
# setup application:
- |
sed -i "s/'cookieValidationKey' => ''/'cookieValidationKey' => 'testkey'/" config/web.php
script:
- |
php -S localhost:8080 -t web > /dev/null 2>&1 &
vendor/bin/codecept run
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 LNPAY

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
163 changes: 163 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<a href="https://docs.lnpay.co/" rel="noopener" target="_blank"><img width="247" height="60" src="https://lnpay.co/frontend-resources/assets/logo_full.svg" alt="LNPAY"></a>

[![License](https://img.shields.io/badge/license-ELv2-yellow)](https://www.elastic.co/licensing/elastic-license)
![Build Status](https://github.com/lnpay/lnpay-core/actions/workflows/main.yml/badge.svg)
![Latest Stable Version](https://img.shields.io/github/tag/lnpay/lnpay-core.svg?label=stable)


#### LNPAY CORE is an enterprise toolkit / API for building Lightning Network applications on the web. Built with Yii2/PHP.


REQUIREMENTS
------------

Docker Engine is suggested for development environment.
Since this is PHP, it's pretty easy to run on a base Ubuntu image with apache/nginx.


DEV ENVIRONMENT
------------

### Install with Docker

Clone repo

$ git clone https://github.com/lnpay/lnpay-core

Run the build script

$ cd lnpay-core
$ bash docker.sh build

# Wait for build process, then start the queue workers

$ bash docker.sh start

Add the following line to your `/etc/hosts` file

127.0.0.1 lnpay.local

You can then access the application through the following URL:

http://lnpay.local:8111

CONFIGURATION
-------------

### .env file

There is a `.env.example` file that is automatically copied over as `.env` on first build.
This file contains the environment specific config vars. Here is an example

```
############## SAMPLE ENVIRONMENT DEFAULTS
INSTANCE_ID=lnpay-1
BASE_URL=https://lnpay.local:8111
# Yii Settings (IF DEVELOPMENT)
YII_DEBUG=true
YII_ENV=dev
# Database
DB_HOST=192.168.69.22
DB_USER=root
DB_PASS=example
DB_DB=lnpay_db
#PHP bin path
PHP_BIN_PATH=/usr/local/bin/php
# Redis
REDIS_HOST=192.168.69.44
REDIS_CACHE_DB=1
REDIS_MUTEX_DB=2
# Papertrail logging (OPTIONAL)
PAPERTRAIL_HOST=
PAPERTRAIL_PORT=
# cookie auth key, generate this randomly
YII_COOKIE_VALIDATION_KEY=609F45AEgenerateNEWinPRODEA480D3B68
#Supervisor Server, this is for monitoring RPC listeners
SUPERVISOR_RPC_HOST=192.168.69.11
SUPERVISOR_RPC_PORT=9001
SUPERVISOR_CONF_PATH=/app/docker/supervisor/conf.d/
SUPERVISOR_SERVER_APP_PATH=/app/
# Email - if DEV emails are sent to files in /runtime/mail
DEFAULT_EMAIL_FROM=
DEFAULT_EMAIL_HOST=
DEFAULT_EMAIL_PORT=
DEFAULT_EMAIL_USERNAME=
DEFAULT_EMAIL_PASSWORD=
# Helps track aggregate sat movement for an idea of what's going on (OPTIONAL)
AMPLITUDE_API_KEY=
```

# Operating the environment

### Starting / Stopping / Destroying Docker containers
$ bash docker.sh start # Start docker container
$ bash docker.sh stop # Stop docker container
$ bash docker.sh destroy # Destroy docker containers

### Accessing docker containers
$ docker exec -it lnpay-php bash
$ docker exec -it lnpay-db bash

### Accessing local mysql database
`lnpay.local:8222` with user/pass `root/example`

### Accessing local mysql database

Database migrations should be run often to pull in database changes from other devs.

$ docker exec lnpay-php php yii migrate

**NOTES:**
- The default configuration uses a host-volume in your home directory `.docker-composer` for composer caches

WORKERS
-------------

`php yii queue/listen --verbose` to start a listener, and `php yii queue/run --verbose` can be used to run the queue and then exit.

The queue currently pulls from the `queue` table in the database.

http://lnpay.local:8111/monitor is a lightweight interface to see what is going on.



SUPERVISOR
----------
Supervisor is used to make sure workers stay up and keep RPC subscribes going

`$ supervisord`

Configuration files supervisor are mapped to the service inside the container for easy editing: `docker/dev/supervisor/`


TESTING
-------

Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](http://codeception.com/).
By default there are 4 test suites:

- `unit`
- `api`
- `functional`
- `acceptance`

Tests can be executed by running

```
docker exec lnpay-php vendor/bin/codecept run
```

The command above will execute unit and functional tests. Unit tests are testing the system components, while functional
tests are for testing user interaction. Acceptance tests are disabled by default as they require additional setup since
they perform testing in real browser.
Loading

0 comments on commit 9e72224

Please sign in to comment.