Compare commits
39
Commits
v1.24.3
...
ci/ca-root-ye
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6658614db0 | ||
|
|
051e475b44 | ||
|
|
2ece12d44b | ||
|
|
79b6b914aa | ||
|
|
38231b15cb | ||
|
|
a950fd2ead | ||
|
|
7421d8574b | ||
|
|
92cca8a420 | ||
|
|
f94687788d | ||
|
|
fee63db19e | ||
|
|
4a866731f3 | ||
|
|
bf686e6f08 | ||
|
|
b5c330e311 | ||
|
|
eea05adea1 | ||
|
|
a3f4587d1e | ||
|
|
4e01e9809e | ||
|
|
e7a8dd9681 | ||
|
|
0ae8a9be0f | ||
|
|
647e1b96b1 | ||
|
|
ca239fbce4 | ||
|
|
963c80aaa0 | ||
|
|
be344b97f7 | ||
|
|
59d23a2dc7 | ||
|
|
8a91be6a15 | ||
|
|
8ff1bce889 | ||
|
|
5791328de4 | ||
|
|
566aa5a486 | ||
|
|
78db081b35 | ||
|
|
c592d3fb7a | ||
|
|
5cb1d6f099 | ||
|
|
ebff24a190 | ||
|
|
5a1f9def13 | ||
|
|
448cda9022 | ||
|
|
6784a98c8e | ||
|
|
d54669a8aa | ||
|
|
5b3a1ded6d | ||
|
|
144cdb8c40 | ||
|
|
9131b9d5c4 | ||
|
|
2fdb6e81d3 |
+7
-3
@@ -2,10 +2,14 @@
|
||||
LISTEN=127.0.0.1:8080
|
||||
|
||||
# 日志文件保存路径
|
||||
LOG=/var/log/bepusdt/
|
||||
LOG=/var/log/vupay/
|
||||
|
||||
# SQLite 数据库文件路径(如果使用 MySQL,此项可忽略)
|
||||
SQLITE=/var/lib/bepusdt/sqlite.db
|
||||
SQLITE=/var/lib/vupay/sqlite.db
|
||||
|
||||
# PostgreSQL 数据库
|
||||
# POSTGRESQL_DSN=postgres://user:password@localhost:5432/bepusdt?sslmode=disable&connect_timeout=3&timezone=Asia/Shanghai
|
||||
# POSTGRESQL_DSN=postgres://user:password@localhost:5432/vupay?sslmode=disable&connect_timeout=3&timezone=Asia/Shanghai
|
||||
|
||||
# MySQL 数据库(本仓库支持;DSN 里 charset=utf8mb4&parseTime=True&loc=Local 不能省)
|
||||
# 优先级:MYSQL_DSN > POSTGRESQL_DSN > SQLITE
|
||||
# MYSQL_DSN=user:password@tcp(127.0.0.1:3306)/vupay?charset=utf8mb4&parseTime=True&loc=Local&timeout=5s
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
name: Docker Build (Gitea)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'ci/**'
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: git.viaeon.com
|
||||
IMAGE: git.viaeon.com/admin/vupay
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: ubuntu
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
|
||||
steps:
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
if ! command -v docker &> /dev/null; then
|
||||
if command -v apk &> /dev/null; then
|
||||
apk add --no-cache docker-cli git
|
||||
elif command -v apt-get &> /dev/null; then
|
||||
apt-get update && apt-get install -y docker.io git
|
||||
else
|
||||
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | tar xz -C /tmp
|
||||
mv /tmp/docker/docker /usr/local/bin/
|
||||
chmod +x /usr/local/bin/docker
|
||||
fi
|
||||
fi
|
||||
docker --version
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Prepare version
|
||||
id: ver
|
||||
run: |
|
||||
SHORT_SHA=$(git rev-parse --short=7 HEAD)
|
||||
BASE=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
# 分支名可能带斜杠(ci/xxx),docker tag 不允许,统一换成短横线
|
||||
REF_SLUG=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
|
||||
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
|
||||
echo "ref_slug=${REF_SLUG}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${BASE}-${SHORT_SHA}" >> "$GITHUB_OUTPUT"
|
||||
echo "VERSION=${BASE}-${SHORT_SHA}"
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
run: |
|
||||
echo "${{ secrets.TOKEN }}" | docker login "${{ env.REGISTRY }}" -u "${{ github.actor }}" --password-stdin 2>&1
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
# latest 只给 main,特性分支别把 latest 顶掉
|
||||
TAGS="-t ${{ env.IMAGE }}:${{ steps.ver.outputs.short_sha }} -t ${{ env.IMAGE }}:${{ steps.ver.outputs.ref_slug }}"
|
||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then TAGS="$TAGS -t ${{ env.IMAGE }}:latest"; fi
|
||||
docker build \
|
||||
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
|
||||
--label "org.opencontainers.image.revision=${{ github.sha }}" \
|
||||
--build-arg "VERSION=${{ steps.ver.outputs.version }}" \
|
||||
$TAGS .
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push "${{ env.IMAGE }}:${{ steps.ver.outputs.short_sha }}" 2>&1
|
||||
docker push "${{ env.IMAGE }}:${{ steps.ver.outputs.ref_slug }}" 2>&1
|
||||
if [ "${GITHUB_REF_NAME}" = "main" ]; then docker push "${{ env.IMAGE }}:latest" 2>&1; fi
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
echo "镜像已推送:"
|
||||
echo " ${{ env.IMAGE }}:${{ steps.ver.outputs.short_sha }}"
|
||||
echo " ${{ env.IMAGE }}:${{ steps.ver.outputs.ref_slug }}"
|
||||
echo " ${{ env.IMAGE }}:latest"
|
||||
@@ -1,5 +1,5 @@
|
||||
name: BUG 反馈|使用异常|功能建议|其它问题
|
||||
description: "提交在使用 BEpusdt 过程中遇到的 BUG 反馈、使用异常、对接失败等问题"
|
||||
description: "提交在使用 VUPAY 过程中遇到的 BUG 反馈、使用异常、对接失败等问题"
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
@@ -45,7 +45,7 @@ body:
|
||||
attributes:
|
||||
value: |-
|
||||
## 日志信息
|
||||
默认的日志目录在 `/var/log/bepusdt/` 下,请将相关时间段的日志内容粘贴在下面的代码块中。
|
||||
默认的日志目录在 `/var/log/vupay/` 下,请将相关时间段的日志内容粘贴在下面的代码块中。
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 日志内容
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Telegram Group
|
||||
url: https://t.me/BEpusdtChat
|
||||
url: https://t.me/VUPAYChat
|
||||
about: Telegram 交流群组
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
days-before-issue-stale: 3
|
||||
days-before-issue-close: 7
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: "此议题由于30天内没有任何活动,现在标记为过时。"
|
||||
stale-issue-message: "此议题由于3天内没有任何活动,现在标记为过时。"
|
||||
close-issue-message: "此议题被标记为过时并且在7天内没有活动,因此已被关闭。请随时重新打开此议题以继续讨论。"
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
|
||||
@@ -7,8 +7,8 @@ on:
|
||||
tags:
|
||||
- v*
|
||||
env:
|
||||
APP_NAME: bepusdt
|
||||
DOCKERHUB_REPO: v03413/bepusdt
|
||||
APP_NAME: vupay
|
||||
DOCKERHUB_REPO: admin/vupay
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -4,9 +4,9 @@ on:
|
||||
- cron: '0 16 * * *'
|
||||
workflow_dispatch:
|
||||
env:
|
||||
APP_NAME: bepusdt
|
||||
APP_NAME: vupay
|
||||
DOCKER_HUB_USER: v03413
|
||||
DOCKER_HUB_REPO: v03413/bepusdt
|
||||
DOCKER_HUB_REPO: admin/vupay
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -14,7 +14,7 @@ concurrency:
|
||||
permissions:
|
||||
contents: read
|
||||
env:
|
||||
APP_NAME: bepusdt
|
||||
APP_NAME: vupay
|
||||
jobs:
|
||||
docker-build:
|
||||
name: Docker Build
|
||||
|
||||
+6
-1
@@ -9,4 +9,9 @@ dist/
|
||||
static/web
|
||||
static/secure
|
||||
*.log
|
||||
AGENTS.md
|
||||
AGENTS.md
|
||||
CLAUDE.md
|
||||
data/
|
||||
logs/
|
||||
mysqldata/
|
||||
pgdata/
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
version: 2
|
||||
project_name: BEpusdt
|
||||
project_name: VUPAY
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
main: ./main
|
||||
binary: bepusdt
|
||||
binary: vupay
|
||||
ldflags:
|
||||
- -X '{{ .ModulePath }}/app.Version={{ .Env.VERSION }}'
|
||||
- -s -w -buildid=
|
||||
@@ -25,7 +25,7 @@ archives:
|
||||
formats: [ zip ]
|
||||
files:
|
||||
- .env.example
|
||||
- src: docs/bepusdt.service
|
||||
- src: docs/vupay.service
|
||||
dst: .
|
||||
strip_parent: true
|
||||
changelog:
|
||||
|
||||
@@ -4,34 +4,33 @@
|
||||
|
||||
---
|
||||
|
||||
# BEpusdt (Better Easy Payment USDT)
|
||||
# VUPAY (Better Easy Payment USDT)
|
||||
|
||||
<p align="center">
|
||||
<img src="./static/checkout/official/assets/img/bepusdt.svg" width="15%" alt="tether">
|
||||
<img src="./static/checkout/official/assets/img/vupay.svg" width="15%" alt="tether">
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.html">
|
||||
<img src="https://img.shields.io/github/license/v03413/bepusdt" alt="license GPLV3">
|
||||
<img src="https://img.shields.io/github/license/admin/vupay" alt="license GPLV3">
|
||||
</a>
|
||||
<a href="https://github.com/v03413/bepusdt">
|
||||
<img src="https://img.shields.io/github/v/release/v03413/bepusdt" alt="GitHub Release">
|
||||
<a href="https://git.viaeon.com/admin/vupay">
|
||||
<img src="https://img.shields.io/github/v/release/admin/vupay" alt="GitHub Release">
|
||||
</a>
|
||||
<a href="https://github.com/v03413/bepusdt">
|
||||
<img src="https://img.shields.io/github/downloads/v03413/bepusdt/total" alt="GitHub Release">
|
||||
<a href="https://git.viaeon.com/admin/vupay">
|
||||
<img src="https://img.shields.io/github/downloads/admin/vupay/total" alt="GitHub Release">
|
||||
</a>
|
||||
<a href="https://hub.docker.com/r/v03413/bepusdt">
|
||||
<img src="https://img.shields.io/docker/pulls/v03413/bepusdt?style=flat-square&logo=docker" alt="Docker Pulls">
|
||||
<a href="https://hub.docker.com/r/admin/vupay">
|
||||
<img src="https://img.shields.io/docker/pulls/admin/vupay?style=flat-square&logo=docker" alt="Docker Pulls">
|
||||
</a>
|
||||
<a href="https://github.com/gin-gonic/gin">
|
||||
<img src="https://img.shields.io/github/stars/v03413/bepusdt?style=flat-square&logo=github" alt="GitHub Stars">
|
||||
<img src="https://img.shields.io/github/stars/admin/vupay?style=flat-square&logo=github" alt="GitHub Stars">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## 🪧 介绍
|
||||
|
||||
缘起于`Epusdt`,但不仅限于此,加入了一些新特性,致力于成为一款更好用的个人`加密货币`收款网关。
|
||||
VUPAY 是一款个人`加密货币`收款网关:多链收款、订单自动回调、后台可视化管理。
|
||||
|
||||
> 原始 EPusdt 项目已被转手,现与本项目再没任何联系、两个项目完全独立运营,[具体说明](./docs/faq/epusdt.md)。
|
||||
|
||||
## 🎉 新特性
|
||||
|
||||
@@ -40,7 +39,7 @@
|
||||
🔥 主流网络:TRON Ethereum BSC Polygon<br>
|
||||
⚡ 其他网络: X-Layer Solana Aptos Arbitrum-One Base [完整列表](./docs/trade-type.md)
|
||||
|
||||
- ✅ 完全兼容 `Epusdt` 插件无缝替换
|
||||
- ✅ 完全兼容 `Vupay` 插件无缝替换
|
||||
- ️✅ 支持主流区块网络 不仅限于`USDT`
|
||||
- ✅ 支持主流法定货币 汇率自动更新
|
||||
- ✅ 轻依赖 单体二进制文件 部署便捷
|
||||
@@ -55,13 +54,20 @@
|
||||
Docker 快速启动,执行完命令打开地址`http://服务器IP:8080`即可看到初始页面
|
||||
|
||||
```bash
|
||||
docker run -d --restart=unless-stopped -p 8080:8080 v03413/bepusdt:latest
|
||||
docker run -d --restart=unless-stopped -p 8080:8080 admin/vupay:latest
|
||||
```
|
||||
|
||||
> **本仓库(admin/VUPAY)额外提供:**
|
||||
> - CI 自动构建镜像并推到 `git.viaeon.com/admin/vupay`(`.gitea/workflows/docker.yaml`)
|
||||
> - 三份 compose 示例:`docker-compose.example.yml`(SQLite)、`docker-compose.postgres.example.yml`、
|
||||
> `docker-compose.mysql.example.yml`
|
||||
> - **新增 MySQL 支持**(`MYSQL_DSN`),上游只有 SQLite/PostgreSQL;用法见
|
||||
> [Docker 部署指南 · MySQL](docs/docker/docker.md)
|
||||
## 📃 技术文档
|
||||
|
||||
- 安装:[Docker](docs/docker/docker.md) [Linux](docs/linux/install.md) [1Panel](./docs/1panel/README.md) [宝塔](./docs/bt_panel/README.md)
|
||||
- 开发:[API对接](docs/api/api.md) [订单回调](docs/notify/readme.md) [Python](https://github.com/luoyanglang/bepusdt-python-sdk) [PHP](https://github.com/v03413/bepusdt-php-sdk)
|
||||
- 对接:[独角Next](docs/api/dujiao-next/dujiao-next.md) [彩虹易支付](https://github.com/v03413/Epay-BEpusdt) [whmcs](https://github.com/v03413/whmcs-gateway-epusdt) [其它](docs/api/other.md)
|
||||
- 开发:[API对接](docs/api/api.md) [订单回调](docs/notify/readme.md) [Python](https://github.com/luoyanglang/vupay-python-sdk) [PHP](https://git.viaeon.com/admin/vupay-php-sdk)
|
||||
- 对接:[独角Next](docs/api/dujiao-next/dujiao-next.md) [彩虹易支付](https://github.com/v03413/Epay-VUPAY) [whmcs](https://github.com/v03413/whmcs-gateway-vupay) [其它](docs/api/other.md)
|
||||
- 其它:[https 配置](./docs/ssl.md) [时钟同步](docs/linux/systemd-timesyncd.md) [收银台修改](docs/checkout/README.md)
|
||||
|
||||
## 🖼 功能截图
|
||||
@@ -80,21 +86,19 @@ docker run -d --restart=unless-stopped -p 8080:8080 v03413/bepusdt:latest
|
||||
|
||||
## 🏝️ 社区交流
|
||||
|
||||
- **Telegram 群组**:[https://t.me/BEpusdtChat](https://t.me/BEpusdtChat)
|
||||
- **Telegram 频道**:[https://t.me/BEpusdtChannel](https://t.me/BEpusdtChannel)
|
||||
- **Telegram 群组**:[https://t.me/VUPAYChat](https://t.me/VUPAYChat)
|
||||
- **Telegram 频道**:[https://t.me/VUPAYChannel](https://t.me/VUPAYChannel)
|
||||
- **安全问题反馈/联系**:https://u.viaeon.com
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
感谢原项目提供的灵感和参考:
|
||||
|
||||
- [EPusdt](./docs/faq/epusdt.md)
|
||||
|
||||
感谢为本项目作出贡献的开发者:
|
||||
|
||||
<a href="https://github.com/v03413/BEpusdt/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=v03413/BEpusdt" alt="BEpusdt 贡献者清单">
|
||||
<a href="https://git.viaeon.com/admin/vupay/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=admin/vupay" alt="VUPAY 贡献者清单">
|
||||
</a>
|
||||
|
||||
## 🌟 Star 历史
|
||||
|
||||
[](https://www.star-history.com/?repos=v03413%2Fbepusdt&type=date&legend=top-left)
|
||||
[](https://www.star-history.com/?repos=v03413%2Fvupay&type=date&legend=top-left)
|
||||
+10
-3
@@ -4,7 +4,7 @@ import "github.com/urfave/cli/v3"
|
||||
|
||||
var SQLiteFlag = &cli.StringFlag{
|
||||
Name: "sqlite",
|
||||
Value: "/var/lib/bepusdt/sqlite.db",
|
||||
Value: "/var/lib/vupay/sqlite.db",
|
||||
Usage: "SQLite 数据库文件路径",
|
||||
Sources: cli.EnvVars("SQLITE"),
|
||||
}
|
||||
@@ -12,13 +12,20 @@ var SQLiteFlag = &cli.StringFlag{
|
||||
var PostgresDSNFlag = &cli.StringFlag{
|
||||
Name: "postgres",
|
||||
Value: "",
|
||||
Usage: "PostgreSQL 数据库连接字符串 (DSN),例如: postgres://user:password@localhost:5432/bepusdt?sslmode=disable&connect_timeout=3",
|
||||
Usage: "PostgreSQL 数据库连接字符串 (DSN),例如: postgres://user:password@localhost:5432/vupay?sslmode=disable&connect_timeout=3",
|
||||
Sources: cli.EnvVars("POSTGRESQL_DSN"),
|
||||
}
|
||||
|
||||
var MysqlDSNFlag = &cli.StringFlag{
|
||||
Name: "mysql",
|
||||
Value: "",
|
||||
Usage: "MySQL 数据库连接字符串 (DSN),例如: user:pass@tcp(127.0.0.1:3306)/vupay?charset=utf8mb4&parseTime=True&loc=Local&timeout=3s",
|
||||
Sources: cli.EnvVars("MYSQL_DSN"),
|
||||
}
|
||||
|
||||
var LogFlag = &cli.StringFlag{
|
||||
Name: "log",
|
||||
Value: "/var/log/bepusdt/",
|
||||
Value: "/var/log/vupay/",
|
||||
Usage: "日志文件保存路径",
|
||||
Sources: cli.EnvVars("LOG"),
|
||||
}
|
||||
|
||||
+6
-5
@@ -5,21 +5,22 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/task"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/task"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var Reset = &cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "忘记密码时,此命令可重置账号密码登录入口",
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag},
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag, MysqlDSNFlag},
|
||||
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
|
||||
sqlite := c.String("sqlite")
|
||||
postgres := c.String("postgres")
|
||||
if err := model.Init(sqlite, postgres); err != nil {
|
||||
mysql := c.String("mysql")
|
||||
if err := model.Init(sqlite, postgres, mysql); err != nil {
|
||||
return ctx, fmt.Errorf("数据库初始化失败 %w", err)
|
||||
}
|
||||
|
||||
|
||||
+10
-9
@@ -12,12 +12,12 @@ import (
|
||||
|
||||
"context"
|
||||
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
"github.com/v03413/bepusdt/app/router"
|
||||
"github.com/v03413/bepusdt/app/task"
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/notifier"
|
||||
"git.viaeon.com/admin/vupay/app/router"
|
||||
"git.viaeon.com/admin/vupay/app/task"
|
||||
)
|
||||
|
||||
import (
|
||||
@@ -27,11 +27,12 @@ import (
|
||||
var Start = &cli.Command{
|
||||
Name: "start",
|
||||
Usage: "启动收款网关",
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag, LogFlag, ListenFlag},
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag, MysqlDSNFlag, LogFlag, ListenFlag},
|
||||
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
|
||||
postgres := c.String("postgres")
|
||||
mysql := c.String("mysql")
|
||||
sqlite := c.String("sqlite")
|
||||
if err := model.Init(sqlite, postgres); err != nil {
|
||||
if err := model.Init(sqlite, postgres, mysql); err != nil {
|
||||
return ctx, fmt.Errorf("数据库初始化失败 %w", err)
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ func start(ctx context.Context, cmd *cli.Command) error {
|
||||
notifier.Welcome()
|
||||
|
||||
fmt.Println(fmt.Sprintf("日志保存路径:%s", log.GetPath()))
|
||||
fmt.Println(fmt.Sprintf("BEpusdt 启动成功(%s),当前版本:%s", listen, app.Version))
|
||||
fmt.Println(fmt.Sprintf("VUPAY 启动成功(%s),当前版本:%s", listen, app.Version))
|
||||
|
||||
// 等待中断信号
|
||||
var signals = make(chan os.Signal, 1)
|
||||
|
||||
+2
-2
@@ -4,15 +4,15 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
)
|
||||
|
||||
var Version = &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "显示版本信息",
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
fmt.Println("BEpusdt 版本:" + app.Version)
|
||||
fmt.Println("VUPAY 版本:" + app.Version)
|
||||
|
||||
return nil
|
||||
},
|
||||
|
||||
+2
-2
@@ -2,14 +2,14 @@ package conf
|
||||
|
||||
const (
|
||||
Desc = "一款更好用的个人加密货币收款网关"
|
||||
Github = "https://github.com/v03413/BEpusdt"
|
||||
Github = "https://git.viaeon.com/admin/vupay"
|
||||
)
|
||||
|
||||
const Debug = false
|
||||
|
||||
const (
|
||||
Pid = "1000" // 暂时固定易支付商户ID
|
||||
Api = "https://api.bepusdt.online"
|
||||
Api = "https://api.vupay.online"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+4
-4
@@ -7,10 +7,10 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
type Api struct {
|
||||
@@ -30,7 +30,7 @@ func (Api) get(url string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("创建请求失败: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("BEpusdt/%s", app.Version))
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("VUPAY/%s", app.Version))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/notifier"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type Conf struct {
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/go-cache"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ package admin
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/task/notify"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/task/notify"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
|
||||
@@ -3,9 +3,9 @@ package admin
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
type Wallet struct {
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/handler/base"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/handler/base"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/v03413/go-cache"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
@@ -3,8 +3,8 @@ package base
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
const Pid = "1000" // 固定商户号
|
||||
@@ -121,7 +121,7 @@ func (e Epay) verify(data map[string]string) (submit, error) {
|
||||
pid, ok := data["pid"]
|
||||
if !ok || pid != Pid {
|
||||
|
||||
return params, fmt.Errorf("BEpusdt 易支付兼容模式,商户号【PID】必须固定为" + Pid)
|
||||
return params, fmt.Errorf("VUPAY 易支付兼容模式,商户号【PID】必须固定为" + Pid)
|
||||
}
|
||||
|
||||
var requiredFields = []string{"pid", "type", "out_trade_no", "notify_url", "return_url", "name", "money", "sign"}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package epusdt
|
||||
package vupay
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type Epusdt struct{}
|
||||
type Vupay struct{}
|
||||
|
||||
type createReq struct {
|
||||
OrderID string `json:"order_id" binding:"required"`
|
||||
@@ -78,7 +78,7 @@ func loadPayOrder(ctx *gin.Context, tradeID string) (model.Order, bool) {
|
||||
return order, true
|
||||
}
|
||||
|
||||
func (Epusdt) Notify(ctx *gin.Context) {
|
||||
func (Vupay) Notify(ctx *gin.Context) {
|
||||
rawData, err := ctx.GetRawData()
|
||||
if err != nil {
|
||||
ctx.String(200, "fail")
|
||||
@@ -97,7 +97,7 @@ func (Epusdt) Notify(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if utils.EpusdtSign(m, model.AuthToken()) != sign {
|
||||
if utils.VupaySign(m, model.AuthToken()) != sign {
|
||||
ctx.String(200, "fail")
|
||||
return
|
||||
}
|
||||
@@ -105,7 +105,7 @@ func (Epusdt) Notify(ctx *gin.Context) {
|
||||
ctx.String(200, "ok")
|
||||
}
|
||||
|
||||
func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
func (Vupay) CreateOrder(ctx *gin.Context) {
|
||||
var req createOrderReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("CreateOrder: request error: %s", err.Error())))
|
||||
@@ -137,7 +137,7 @@ func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
// 创建待付款订单
|
||||
order, err := model.BuildPendingOrder(model.OrderParams{
|
||||
Money: decimal.NewFromFloat(req.Amount),
|
||||
ApiType: model.OrderApiTypeEpusdtOrder,
|
||||
ApiType: model.OrderApiTypeVupayOrder,
|
||||
OrderId: req.OrderID,
|
||||
RedirectUrl: req.RedirectURL,
|
||||
NotifyUrl: req.NotifyURL,
|
||||
@@ -168,7 +168,7 @@ func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
func (Vupay) UpdateOrder(ctx *gin.Context) {
|
||||
// 接收 trade_id, currency, network 三个参数
|
||||
var req updateOrderReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
@@ -250,7 +250,7 @@ func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (Epusdt) CreateTransaction(ctx *gin.Context) {
|
||||
func (Vupay) CreateTransaction(ctx *gin.Context) {
|
||||
var req createReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("请求参数错误:%s", err.Error())))
|
||||
@@ -278,7 +278,7 @@ func (Epusdt) CreateTransaction(ctx *gin.Context) {
|
||||
|
||||
order, err := model.StartBuildOrder(model.OrderParams{
|
||||
Money: decimal.NewFromFloat(req.Amount),
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
Address: req.Address,
|
||||
AddressLocked: req.Amount == 0,
|
||||
OrderId: req.OrderID,
|
||||
@@ -313,7 +313,7 @@ func (Epusdt) CreateTransaction(ctx *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (Epusdt) CancelTransaction(ctx *gin.Context) {
|
||||
func (Vupay) CancelTransaction(ctx *gin.Context) {
|
||||
var req cancelReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("请求参数错误:%s", err.Error())))
|
||||
@@ -343,7 +343,7 @@ func (Epusdt) CancelTransaction(ctx *gin.Context) {
|
||||
ctx.JSON(200, respSuccJson(gin.H{"trade_id": req.TradeID}))
|
||||
}
|
||||
|
||||
func (Epusdt) Checkout(ctx *gin.Context) {
|
||||
func (Vupay) Checkout(ctx *gin.Context) {
|
||||
tradeId := ctx.Param("trade_id")
|
||||
if _, ok := model.GetTradeOrder(tradeId); !ok {
|
||||
ctx.String(200, "order not found")
|
||||
@@ -357,7 +357,7 @@ func (Epusdt) Checkout(ctx *gin.Context) {
|
||||
ctx.HTML(200, tmpl, gin.H{"trade_id": tradeId})
|
||||
}
|
||||
|
||||
func (Epusdt) GetMethods(ctx *gin.Context) {
|
||||
func (Vupay) GetMethods(ctx *gin.Context) {
|
||||
var req methodsReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("request error: %s", err.Error())))
|
||||
@@ -385,7 +385,7 @@ func (Epusdt) GetMethods(ctx *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (Epusdt) Info(ctx *gin.Context) {
|
||||
func (Vupay) Info(ctx *gin.Context) {
|
||||
var req infoReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("参数错误:%s", err.Error())))
|
||||
@@ -417,7 +417,7 @@ func (Epusdt) Info(ctx *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (Epusdt) SignVerify(ctx *gin.Context) {
|
||||
func (Vupay) SignVerify(ctx *gin.Context) {
|
||||
rawData, err := ctx.GetRawData()
|
||||
if err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("json 数据读取错误 %s", err.Error())))
|
||||
@@ -442,7 +442,7 @@ func (Epusdt) SignVerify(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if utils.EpusdtSign(m, model.AuthToken()) != sign {
|
||||
if utils.VupaySign(m, model.AuthToken()) != sign {
|
||||
ctx.JSON(200, respFailJson("签名错误"))
|
||||
ctx.Abort()
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ func Init(dir string) error {
|
||||
|
||||
var err error
|
||||
|
||||
be, err = newLogger(filepath.Join(dir, "bepusdt.log"))
|
||||
be, err = newLogger(filepath.Join(dir, "vupay.log"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+4
-4
@@ -7,9 +7,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/v03413/go-cache"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gorm.io/gorm"
|
||||
@@ -51,7 +51,7 @@ var defaultConf = map[ConfKey]string{
|
||||
SystemInstallLock: "0",
|
||||
RateSyncCoingeckoApiUrl: "https://api.coingecko.com",
|
||||
RateSyncHistoryDays: "30",
|
||||
MqttTopicPrefix: "bepusdt",
|
||||
MqttTopicPrefix: "vupay",
|
||||
HomeRedirectUrl: "",
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ type Conf struct {
|
||||
|
||||
func (c Conf) TableName() string {
|
||||
|
||||
return "bep_conf"
|
||||
return "vupay_conf"
|
||||
}
|
||||
|
||||
func SetK(k ConfKey, v string) {
|
||||
@@ -168,7 +168,7 @@ func ConfInit() {
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println("╔═══════════════════════════════════════════════════════════════════════")
|
||||
fmt.Println("║ 🎉 欢迎使用 BEpusdt - 首次运行检测,初始化配置完成")
|
||||
fmt.Println("║ 🎉 欢迎使用 VUPAY - 首次运行检测,初始化配置完成")
|
||||
fmt.Println("╚═══════════════════════════════════════════════════════════════════════")
|
||||
fmt.Println()
|
||||
fmt.Println("┏━━ 🔐 后台登录信息 (请立即保存!)")
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ const (
|
||||
)
|
||||
const (
|
||||
Classic MatchMode = "classic" // 经典模式,精确匹配
|
||||
HasPrefix MatchMode = "has_prefix" // 前缀匹配,允许多付
|
||||
HasPrefix MatchMode = "has_prefix" // 前缀匹配,按原子精度截断后比较,只容忍精度以下的多付
|
||||
RoundOff MatchMode = "round_off" // 数值修约,四舍五入,允许容错
|
||||
)
|
||||
|
||||
|
||||
@@ -5,25 +5,25 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 202607081430 - 删除 bep_order.trade_type_reselect 列
|
||||
// 202607081430 - 删除 vupay_order.trade_type_reselect 列
|
||||
func m202607081430DropOrderTradeTypeReselect() *gormigrate.Migration {
|
||||
return &gormigrate.Migration{
|
||||
ID: "202607081430_drop_order_trade_type_reselect",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
if !tx.Migrator().HasTable("bep_order") {
|
||||
if !tx.Migrator().HasTable("vupay_order") {
|
||||
return nil
|
||||
}
|
||||
if tx.Migrator().HasColumn("bep_order", "trade_type_reselect") {
|
||||
return tx.Exec("ALTER TABLE bep_order DROP COLUMN trade_type_reselect").Error
|
||||
if tx.Migrator().HasColumn("vupay_order", "trade_type_reselect") {
|
||||
return tx.Exec("ALTER TABLE vupay_order DROP COLUMN trade_type_reselect").Error
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
if !tx.Migrator().HasTable("bep_order") {
|
||||
if !tx.Migrator().HasTable("vupay_order") {
|
||||
return nil
|
||||
}
|
||||
if !tx.Migrator().HasColumn("bep_order", "trade_type_reselect") {
|
||||
return tx.Exec("ALTER TABLE bep_order ADD COLUMN trade_type_reselect INTEGER NOT NULL DEFAULT 0").Error
|
||||
if !tx.Migrator().HasColumn("vupay_order", "trade_type_reselect") {
|
||||
return tx.Exec("ALTER TABLE vupay_order ADD COLUMN trade_type_reselect INTEGER NOT NULL DEFAULT 0").Error
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableName = "bep_migration"
|
||||
const TableName = "vupay_migration"
|
||||
|
||||
var migrations = []*gormigrate.Migration{
|
||||
m202607081430DropOrderTradeTypeReselect(),
|
||||
|
||||
+51
-6
@@ -6,8 +6,9 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model/migration"
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/v03413/bepusdt/app/model/migration"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -24,12 +25,17 @@ type AutoTimeAt struct {
|
||||
UpdatedAt *Datetime `gorm:"column:updated_at;not null;comment:最后更新时间" json:"updated_at"`
|
||||
}
|
||||
|
||||
func Init(db, dsn string) error {
|
||||
if dsn != "" {
|
||||
return initPostgres(dsn)
|
||||
// Init 按优先级选择数据库:MySQL DSN > PostgreSQL DSN > SQLite 文件。
|
||||
// 三者互斥,填了哪个用哪个;都不填就走 SQLite(默认)。
|
||||
func Init(db, postgresDSN, mysqlDSN string) error {
|
||||
switch {
|
||||
case mysqlDSN != "":
|
||||
return initMysql(mysqlDSN)
|
||||
case postgresDSN != "":
|
||||
return initPostgres(postgresDSN)
|
||||
default:
|
||||
return initSqlite(db)
|
||||
}
|
||||
|
||||
return initSqlite(db)
|
||||
}
|
||||
|
||||
func initSqlite(db string) error {
|
||||
@@ -147,3 +153,42 @@ func Close() {
|
||||
_, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf("数据库资源关闭错误:%s", err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
func initMysql(dsn string) error {
|
||||
// 建议 DSN 里带上 charset=utf8mb4&parseTime=True&loc=Local,
|
||||
// 否则中文/时间字段会出问题:中文变 ?,时间按 UTC 存进去。
|
||||
Db, err = gorm.Open(mysql.New(mysql.Config{
|
||||
DSN: dsn,
|
||||
DefaultStringSize: 256,
|
||||
SkipInitializeWithVersion: false,
|
||||
}), &gorm.Config{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
{
|
||||
sqlDB, err := Db.DB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
sqlDB.SetMaxOpenConns(100)
|
||||
sqlDB.SetConnMaxLifetime(30 * time.Minute)
|
||||
sqlDB.SetConnMaxIdleTime(10 * time.Minute)
|
||||
}
|
||||
|
||||
if err = AutoMigrate(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var count int64
|
||||
Db.Model(&Conf{}).Count(&count)
|
||||
if count == 0 {
|
||||
ConfInit()
|
||||
}
|
||||
|
||||
FillDefaultConf()
|
||||
RefreshC()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ type NotifyRecord struct {
|
||||
|
||||
func (nr NotifyRecord) TableName() string {
|
||||
|
||||
return "bep_notify"
|
||||
return "vupay_notify"
|
||||
}
|
||||
|
||||
func IsNeedNotifyByTxid(txid string) bool {
|
||||
|
||||
+15
-15
@@ -9,12 +9,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -55,17 +55,17 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
OrderApiTypeEpusdt = "epusdt" // epusdt
|
||||
OrderApiTypeEpusdtOrder = "epusdt_order" // epusdt create-order
|
||||
OrderApiTypeEpay = "epay" // 彩虹易支付
|
||||
OrderApiTypeAdmin = "admin" // 管理后台
|
||||
OrderApiTypeVupay = "vupay" // vupay
|
||||
OrderApiTypeVupayOrder = "vupay_order" // vupay create-order
|
||||
OrderApiTypeEpay = "epay" // 彩虹易支付
|
||||
OrderApiTypeAdmin = "admin" // 管理后台
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
Id
|
||||
OrderId string `gorm:"column:order_id;type:varchar(128);not null;index;comment:商户ID" json:"order_id"`
|
||||
TradeId string `gorm:"column:trade_id;type:varchar(128);not null;uniqueIndex;comment:本地ID" json:"trade_id"`
|
||||
TradeType TradeType `gorm:"column:trade_type;type:varchar(20);not null;index;comment:交易类型" json:"trade_type"`
|
||||
TradeType TradeType `gorm:"column:trade_type;type:varchar(20);not null;index;index:idx_order_status_trade,priority:2;comment:交易类型" json:"trade_type"`
|
||||
Fiat Fiat `gorm:"column:fiat;type:varchar(16);not null;index;default:CNY;comment:法定货币" json:"fiat"`
|
||||
Crypto Crypto `gorm:"column:crypto;type:varchar(16);not null;index;default:USDT;comment:加密货币" json:"crypto"`
|
||||
CurrencyLimit string `gorm:"column:currency_limit;type:varchar(255);not null;default:'';comment:限定币种" json:"currency_limit"`
|
||||
@@ -76,11 +76,11 @@ type Order struct {
|
||||
FromAddress string `gorm:"column:from_address;type:varchar(128);not null;default:'';comment:支付地址" json:"from_address"`
|
||||
MatchAddress string `gorm:"column:match_address;type:varchar(128);not null;default:'';comment:校验地址" json:"match_address"`
|
||||
AddressLocked bool `gorm:"column:address_locked;not null;default:false;comment:地址锁定 1:独占 0:共享" json:"address_locked"`
|
||||
Status int `gorm:"column:status;not null;default:1;index;index:idx_order_notify_retry,priority:1;comment:交易状态" json:"status"`
|
||||
Status int `gorm:"column:status;not null;default:1;index;index:idx_order_notify_retry,priority:1;index:idx_order_status_trade,priority:1;comment:交易状态" json:"status"`
|
||||
Name string `gorm:"column:name;type:varchar(64);not null;default:'';comment:商品名称" json:"name"`
|
||||
ApiType string `gorm:"column:api_type;type:varchar(20);not null;default:'epusdt';comment:API类型" json:"api_type"`
|
||||
ReturnUrl string `gorm:"column:return_url;type:text;not null;default:'';comment:同步地址" json:"return_url"`
|
||||
NotifyUrl string `gorm:"column:notify_url;type:text;not null;default:'';comment:异步地址" json:"notify_url"`
|
||||
ApiType string `gorm:"column:api_type;type:varchar(20);not null;default:'vupay';comment:API类型" json:"api_type"`
|
||||
ReturnUrl string `gorm:"column:return_url;type:varchar(1024);not null;default:'';comment:同步地址" json:"return_url"`
|
||||
NotifyUrl string `gorm:"column:notify_url;type:varchar(1024);not null;default:'';comment:异步地址" json:"notify_url"`
|
||||
NotifyNum int `gorm:"column:notify_num;not null;default:0;index:idx_order_notify_retry,priority:3;comment:回调次数" json:"notify_num"`
|
||||
NotifyState int `gorm:"column:notify_state;not null;default:0;index:idx_order_notify_retry,priority:2;comment:回调状态 1:成功 0:失败" json:"notify_state"`
|
||||
RefHash string `gorm:"column:ref_hash;type:varchar(128);not null;default:'';index;comment:交易哈希" json:"ref_hash"`
|
||||
@@ -116,7 +116,7 @@ func (o *Order) CanReselectPayment() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if o.ApiType != OrderApiTypeEpusdtOrder && o.ApiType != OrderApiTypeAdmin {
|
||||
if o.ApiType != OrderApiTypeVupayOrder && o.ApiType != OrderApiTypeAdmin {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ func (o *Order) Network() any {
|
||||
}
|
||||
|
||||
func (o *Order) TableName() string {
|
||||
return "bep_order"
|
||||
return "vupay_order"
|
||||
}
|
||||
|
||||
func GetTradeOrder(tradeId string) (Order, bool) {
|
||||
|
||||
+5
-5
@@ -10,12 +10,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ type Rate struct {
|
||||
}
|
||||
|
||||
func (r *Rate) TableName() string {
|
||||
return "bep_rate"
|
||||
return "vupay_rate"
|
||||
}
|
||||
|
||||
func (r *Rate) BeforeCreate(*gorm.DB) error {
|
||||
@@ -68,7 +68,7 @@ func CoingeckoRate() error {
|
||||
}
|
||||
|
||||
req.Header.Set("x-cg-demo-api-key", GetC(RateSyncCoingeckoApiKey))
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("BEpusdt/%s", app.Version))
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("VUPAY/%s", app.Version))
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
)
|
||||
|
||||
// supportFiat 支持的法定货币
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type OrderParams struct {
|
||||
|
||||
+3
-3
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/xssnick/tonutils-go/address"
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ type Wallet struct {
|
||||
|
||||
func (wa *Wallet) TableName() string {
|
||||
|
||||
return "bep_wallet"
|
||||
return "vupay_wallet"
|
||||
}
|
||||
|
||||
func (wa *Wallet) SetStatus(status uint8) {
|
||||
|
||||
+3
-3
@@ -5,9 +5,9 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
type activeConf struct {
|
||||
@@ -55,7 +55,7 @@ func Reload() error {
|
||||
opts.AddBroker(fmt.Sprintf("tcp://%s:%s", newConf.host, newConf.port))
|
||||
opts.SetUsername(newConf.user)
|
||||
opts.SetPassword(newConf.pass)
|
||||
opts.SetClientID(fmt.Sprintf("BEpusdt %d", os.Getpid()))
|
||||
opts.SetClientID(fmt.Sprintf("VUPAY %d", os.Getpid()))
|
||||
opts.SetAutoReconnect(true)
|
||||
opts.SetOrderMatters(false)
|
||||
opts.SetOnConnectHandler(onConnectHandler)
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package mqtt
|
||||
|
||||
import (
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
// Publish 发布消息。若 MQTT 未连接则静默丢弃,返回 nil。
|
||||
|
||||
@@ -3,8 +3,8 @@ package mqtt
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
type callback struct {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package notifier
|
||||
|
||||
import "github.com/v03413/bepusdt/app/model"
|
||||
import "git.viaeon.com/admin/vupay/app/model"
|
||||
|
||||
type None struct{}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package notifier
|
||||
|
||||
import (
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/v03413/tronprotocol/core"
|
||||
)
|
||||
|
||||
@@ -201,7 +201,7 @@ func (t *Telegram) TronResourceChange(res model.TronResource) {
|
||||
|
||||
func (t *Telegram) Welcome() {
|
||||
text := `
|
||||
👋 欢迎使用 BEpusdt,` + conf.Desc + `,如果您看到此消息,说明系统已启动成功!
|
||||
👋 欢迎使用 VUPAY,` + conf.Desc + `,如果您看到此消息,说明系统已启动成功!
|
||||
|
||||
📌当前版本:` + app.Version + `
|
||||
🎉开源地址:` + conf.Github + `
|
||||
@@ -212,8 +212,7 @@ func (t *Telegram) Welcome() {
|
||||
ReplyMarkup: models.InlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]models.InlineKeyboardButton{
|
||||
{
|
||||
{Text: "📢 关注频道", URL: "https://t.me/BEpusdtChannel"},
|
||||
{Text: "💬 社区交流", URL: "https://t.me/BEpusdtChat"},
|
||||
{Text: "🌐 访问站点", URL: "https://u.viaeon.com"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ package notifier
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
func TestNonOrderTransferTitleUsesMatchAddress(t *testing.T) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package notifier
|
||||
|
||||
import (
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
type Wechat struct{}
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"git.viaeon.com/admin/vupay/app/handler/admin"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/admin"
|
||||
)
|
||||
|
||||
func adminInit(e *gin.Engine) {
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"git.viaeon.com/admin/vupay/app/handler/auth"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/auth"
|
||||
)
|
||||
|
||||
func authInit(e *gin.Engine) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/v03413/bepusdt/static"
|
||||
"git.viaeon.com/admin/vupay/static"
|
||||
)
|
||||
|
||||
func TestLangGeCheckoutTemplateIsEmbedded(t *testing.T) {
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"git.viaeon.com/admin/vupay/app/handler/epay"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/epay"
|
||||
)
|
||||
|
||||
func epayInit(engine *gin.Engine) {
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/memstore"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/go-cache"
|
||||
)
|
||||
|
||||
@@ -59,7 +59,7 @@ func Handler() *gin.Engine {
|
||||
|
||||
{
|
||||
staticInit(engine)
|
||||
epusdtInit(engine)
|
||||
vupayInit(engine)
|
||||
epayInit(engine)
|
||||
adminInit(engine)
|
||||
authInit(engine)
|
||||
@@ -131,7 +131,7 @@ func noRoute() gin.HandlerFunc {
|
||||
|
||||
func copyright() gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
ctx.Writer.Header().Set("Payment-Gateway", "https://github.com/v03413/BEpusdt")
|
||||
ctx.Writer.Header().Set("Payment-Gateway", "https://git.viaeon.com/admin/vupay")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/static"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/static"
|
||||
)
|
||||
|
||||
func staticInit(e *gin.Engine) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"git.viaeon.com/admin/vupay/app/handler/vupay"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/handler/epusdt"
|
||||
)
|
||||
|
||||
func epusdtInit(engine *gin.Engine) {
|
||||
func vupayInit(engine *gin.Engine) {
|
||||
epGrp := engine.Group("/pay")
|
||||
epHdr := new(epusdt.Epusdt)
|
||||
epHdr := new(vupay.Vupay)
|
||||
{
|
||||
epGrp.GET("/checkout/:trade_id", epHdr.Checkout)
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
func TestAmountMatchHasPrefix(t *testing.T) {
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.PaymentMatchMode: string(model.HasPrefix)})
|
||||
|
||||
cases := []struct {
|
||||
paid, order string
|
||||
want bool
|
||||
}{
|
||||
{"1.5", "1.5", true},
|
||||
{"1.50123", "1.5", true},
|
||||
{"1.509", "1.5", true},
|
||||
{"1.51", "1.5", false},
|
||||
{"1.4999", "1.5", false},
|
||||
{"2", "2", true},
|
||||
{"2.009", "2", true},
|
||||
{"2.01", "2", false},
|
||||
{"2.5", "2", false},
|
||||
{"10.379", "10.37", true},
|
||||
{"10.38", "10.37", false},
|
||||
{"20", "2", false},
|
||||
{"100.5", "100", false},
|
||||
{"123.456789", "123.45", true},
|
||||
// 订单金额小数位多于原子精度时按订单金额的小数位截断
|
||||
{"1.5059", "1.505", true},
|
||||
{"1.506", "1.505", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got := amountMatch(decimal.RequireFromString(c.paid), c.order, string(model.UsdtTrc20))
|
||||
if got != c.want {
|
||||
t.Errorf("paid %s order %s: got %v, want %v", c.paid, c.order, got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 同一地址并发订单按原子精度递增金额,截断后每笔付款最多对应其中一笔
|
||||
func TestAmountMatchHasPrefixConcurrentOrders(t *testing.T) {
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.PaymentMatchMode: string(model.HasPrefix)})
|
||||
|
||||
orders := []string{"1.5", "1.51", "1.52"}
|
||||
payments := map[string]string{"1.5": "1.5", "1.50123": "1.5", "1.51": "1.51", "1.519": "1.51", "1.52": "1.52"}
|
||||
for paid, want := range payments {
|
||||
var matched []string
|
||||
for _, o := range orders {
|
||||
if amountMatch(decimal.RequireFromString(paid), o, string(model.UsdtTrc20)) {
|
||||
matched = append(matched, o)
|
||||
}
|
||||
}
|
||||
if len(matched) != 1 || matched[0] != want {
|
||||
t.Errorf("paid %s matched %v, want only %s", paid, matched, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -10,16 +10,16 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
blockapi "git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
blockapi "github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type aptos struct {
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func arbitrumInit() {
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func baseInit() {
|
||||
|
||||
+3
-3
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func bscInit() {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
type rConf struct {
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func ethInit() {
|
||||
|
||||
+5
-5
@@ -12,16 +12,16 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
blockapi "git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
blockapi "github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+2
-2
@@ -7,10 +7,10 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
appMqtt "git.viaeon.com/admin/vupay/app/mqtt"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
appMqtt "github.com/v03413/bepusdt/app/mqtt"
|
||||
"github.com/v03413/go-cache"
|
||||
)
|
||||
|
||||
|
||||
+6
-6
@@ -4,11 +4,11 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
"github.com/v03413/bepusdt/app/task/notify"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/notifier"
|
||||
"git.viaeon.com/admin/vupay/app/task/notify"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -35,7 +35,7 @@ func notifyRetry(context.Context) {
|
||||
|
||||
func notifyRoll(context.Context) {
|
||||
for _, o := range model.GetOrderByStatus(model.OrderStatusWaiting) {
|
||||
notify.Bepusdt(o)
|
||||
notify.Vupay(o)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -10,12 +10,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/notifier"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
|
||||
"github.com/v03413/go-cache"
|
||||
"gorm.io/gorm"
|
||||
@@ -45,7 +45,7 @@ func Handle(order model.Order) error {
|
||||
if order.ApiType == model.OrderApiTypeEpay {
|
||||
err = epay(ctx, order)
|
||||
} else {
|
||||
err = epusdt(ctx, order)
|
||||
err = vupay(ctx, order)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -66,7 +66,7 @@ func epay(ctx context.Context, order model.Order) error {
|
||||
return err2
|
||||
}
|
||||
|
||||
postReq.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
postReq.Header.Set("Powered-By", "https://git.viaeon.com/admin/vupay")
|
||||
resp, err := client.Do(postReq)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -102,7 +102,7 @@ func epay(ctx context.Context, order model.Order) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func epusdt(ctx context.Context, order model.Order) error {
|
||||
func vupay(ctx context.Context, order model.Order) error {
|
||||
var data = make(map[string]interface{})
|
||||
var body = EpNotify{
|
||||
TradeId: order.TradeId,
|
||||
@@ -123,7 +123,7 @@ func epusdt(ctx context.Context, order model.Order) error {
|
||||
}
|
||||
|
||||
// 签名
|
||||
body.Signature = utils.EpusdtSign(data, model.AuthToken())
|
||||
body.Signature = utils.VupaySign(data, model.AuthToken())
|
||||
|
||||
// 再次序列化
|
||||
jsonBody, err = json.Marshal(body)
|
||||
@@ -136,8 +136,8 @@ func epusdt(ctx context.Context, order model.Order) error {
|
||||
}
|
||||
|
||||
postReq.Header.Set("Content-Type", "application/json")
|
||||
postReq.Header.Set("Powered-By", "https://github.com/v03413/bepusdt")
|
||||
postReq.Header.Set("User-Agent", "BEpusdt/"+app.Version)
|
||||
postReq.Header.Set("Powered-By", "https://git.viaeon.com/admin/vupay")
|
||||
postReq.Header.Set("User-Agent", "VUPAY/"+app.Version)
|
||||
resp, err := client.Do(postReq)
|
||||
if err != nil {
|
||||
markNotifyFail(order, err.Error())
|
||||
@@ -160,8 +160,8 @@ func epusdt(ctx context.Context, order model.Order) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Bepusdt(o model.Order) {
|
||||
if o.ApiType != model.OrderApiTypeEpusdt && o.ApiType != model.OrderApiTypeEpusdtOrder {
|
||||
func Vupay(o model.Order) {
|
||||
if o.ApiType != model.OrderApiTypeVupay && o.ApiType != model.OrderApiTypeVupayOrder {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -169,13 +169,13 @@ func Bepusdt(o model.Order) {
|
||||
var authToken = model.AuthToken()
|
||||
var client = &http.Client{Timeout: time.Second * 5}
|
||||
go func() {
|
||||
if err := deliverBepusdtStatusUpdate(model.Db, client, authToken, o); err != nil {
|
||||
log.Warn("notify BEpusdt Error:", err.Error())
|
||||
if err := deliverVupayStatusUpdate(model.Db, client, authToken, o); err != nil {
|
||||
log.Warn("notify VUPAY Error:", err.Error())
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func deliverBepusdtStatusUpdate(db *gorm.DB, client *http.Client, authToken string, o model.Order) error {
|
||||
func deliverVupayStatusUpdate(db *gorm.DB, client *http.Client, authToken string, o model.Order) error {
|
||||
if client == nil {
|
||||
client = &http.Client{Timeout: time.Second * 5}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func deliverBepusdtStatusUpdate(db *gorm.DB, client *http.Client, authToken stri
|
||||
return nil
|
||||
}
|
||||
|
||||
var key = fmt.Sprintf("bepusdt_notify_%d_%s", current.Status, current.TradeId)
|
||||
var key = fmt.Sprintf("vupay_notify_%d_%s", current.Status, current.TradeId)
|
||||
if _, ok := cache.Get(key); ok {
|
||||
return nil
|
||||
}
|
||||
@@ -215,7 +215,7 @@ func deliverBepusdtStatusUpdate(db *gorm.DB, client *http.Client, authToken stri
|
||||
return err
|
||||
}
|
||||
|
||||
body.Signature = utils.EpusdtSign(data, authToken)
|
||||
body.Signature = utils.VupaySign(data, authToken)
|
||||
|
||||
jsonBody, _ = json.Marshal(body)
|
||||
req, err := http.NewRequest("POST", current.NotifyUrl, strings.NewReader(string(jsonBody)))
|
||||
@@ -224,7 +224,7 @@ func deliverBepusdtStatusUpdate(db *gorm.DB, client *http.Client, authToken stri
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Powered-By", "https://github.com/v03413/BEpusdt")
|
||||
req.Header.Set("Powered-By", "https://git.viaeon.com/admin/vupay")
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
applog "github.com/v03413/bepusdt/app/log"
|
||||
applog "git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -52,25 +52,25 @@ func newWaitingOrder(notifyURL string) model.Order {
|
||||
confirmedAt := now
|
||||
|
||||
return model.Order{
|
||||
OrderId: "merchant-order-1",
|
||||
TradeId: "trade-order-1",
|
||||
TradeType: model.UsdtTrc20,
|
||||
Fiat: "CNY",
|
||||
Crypto: "USDT",
|
||||
Rate: "7.00",
|
||||
Amount: "1.00",
|
||||
Money: "7.00",
|
||||
Address: "TTestAddress1234567890",
|
||||
Status: model.OrderStatusWaiting,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
NotifyUrl: notifyURL,
|
||||
ExpiredAt: now.Add(10 * time.Minute),
|
||||
ConfirmedAt: &confirmedAt,
|
||||
AutoTimeAt: model.AutoTimeAt{CreatedAt: (*model.Datetime)(&now), UpdatedAt: (*model.Datetime)(&now)},
|
||||
OrderId: "merchant-order-1",
|
||||
TradeId: "trade-order-1",
|
||||
TradeType: model.UsdtTrc20,
|
||||
Fiat: "CNY",
|
||||
Crypto: "USDT",
|
||||
Rate: "7.00",
|
||||
Amount: "1.00",
|
||||
Money: "7.00",
|
||||
Address: "TTestAddress1234567890",
|
||||
Status: model.OrderStatusWaiting,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
NotifyUrl: notifyURL,
|
||||
ExpiredAt: now.Add(10 * time.Minute),
|
||||
ConfirmedAt: &confirmedAt,
|
||||
AutoTimeAt: model.AutoTimeAt{CreatedAt: (*model.Datetime)(&now), UpdatedAt: (*model.Datetime)(&now)},
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeliverBepusdtStatusUpdateDoesNotHoldDBWhileHTTPIsPending(t *testing.T) {
|
||||
func TestDeliverVupayStatusUpdateDoesNotHoldDBWhileHTTPIsPending(t *testing.T) {
|
||||
db := newNotifyTestDB(t)
|
||||
initNotifyTestLog(t)
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestDeliverBepusdtStatusUpdateDoesNotHoldDBWhileHTTPIsPending(t *testing.T)
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
go func() {
|
||||
errCh <- deliverBepusdtStatusUpdate(db, &http.Client{Timeout: 2 * time.Second}, "test-auth-token", order)
|
||||
errCh <- deliverVupayStatusUpdate(db, &http.Client{Timeout: 2 * time.Second}, "test-auth-token", order)
|
||||
}()
|
||||
|
||||
select {
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func plasmaInit() {
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func polygonInit() {
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
+74
-12
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
@@ -11,17 +12,17 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
blockapi "git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
blockapi "github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
// 参考文档
|
||||
@@ -37,6 +38,7 @@ type solana struct {
|
||||
retryMu sync.Mutex
|
||||
retryAttempts map[int]int
|
||||
retryScheduled map[int]*time.Timer
|
||||
retryStopped map[int]struct{}
|
||||
lookbackMu sync.Mutex
|
||||
lookbackNext int
|
||||
lookbackEnd int
|
||||
@@ -67,6 +69,7 @@ func newSolana() solana {
|
||||
client: utils.NewHttpClient(),
|
||||
retryAttempts: make(map[int]int),
|
||||
retryScheduled: make(map[int]*time.Timer),
|
||||
retryStopped: make(map[int]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +85,7 @@ func (s *solana) syncSlotForward(ctx context.Context) {
|
||||
|
||||
return
|
||||
}
|
||||
if s.pendingSlotRetryCount() > 0 {
|
||||
if s.pendingSlotRetryCount() >= solanaForwardPauseRetries {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -199,6 +202,13 @@ func (s *solana) slotParse(n any) {
|
||||
}
|
||||
|
||||
result, err := validateSolanaBlockResponse(body)
|
||||
if errors.Is(err, errSolanaBlockCleanedUp) { // 节点已清理该 slot,重试也拿不到;放弃,不暂停向前扫描
|
||||
conf.RecordFailure(network)
|
||||
s.stopSlotRetry(slot)
|
||||
log.Task.Error(fmt.Sprintf("Solana slot %d 已被节点清理,无法扫描,该 slot 内的付款需要人工核对:%s", slot, err))
|
||||
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
conf.RecordFailure(network)
|
||||
s.scheduleSlotRetry(slot)
|
||||
@@ -334,10 +344,14 @@ func solanaSignatureFinalized(status gjson.Result) bool {
|
||||
|
||||
// Solana JSON-RPC 错误码,参考 https://github.com/anza-xyz/agave/blob/master/rpc-client-api/src/custom_error.rs
|
||||
const (
|
||||
solanaErrBlockCleanedUp = -32001
|
||||
solanaErrSlotSkipped = -32007
|
||||
solanaErrLongTermStorageSlotSkipped = -32009
|
||||
)
|
||||
|
||||
// 节点只保留最近一段时间的区块,更早的 slot 返回 -32001,换一个时间重试也不会有
|
||||
var errSolanaBlockCleanedUp = errors.New("block cleaned up")
|
||||
|
||||
func validateSolanaBlockResponse(body []byte) (gjson.Result, error) {
|
||||
if !gjson.ValidBytes(body) {
|
||||
return gjson.Result{}, fmt.Errorf("invalid JSON response")
|
||||
@@ -348,6 +362,8 @@ func validateSolanaBlockResponse(body []byte) (gjson.Result, error) {
|
||||
switch rpcErr.Get("code").Int() {
|
||||
case solanaErrSlotSkipped, solanaErrLongTermStorageSlotSkipped: // 被跳过的 slot 没有区块,按空 slot 处理
|
||||
return gjson.Result{Type: gjson.Null}, nil
|
||||
case solanaErrBlockCleanedUp:
|
||||
return gjson.Result{}, fmt.Errorf("%w: %s", errSolanaBlockCleanedUp, rpcErr.Raw)
|
||||
}
|
||||
|
||||
return gjson.Result{}, fmt.Errorf("RPC error: %s", rpcErr.Raw)
|
||||
@@ -366,6 +382,11 @@ func validateSolanaBlockResponse(body []byte) (gjson.Result, error) {
|
||||
|
||||
func (s *solana) scheduleSlotRetry(slot int) {
|
||||
s.retryMu.Lock()
|
||||
if _, stopped := s.retryStopped[slot]; stopped {
|
||||
s.retryMu.Unlock()
|
||||
|
||||
return
|
||||
}
|
||||
if _, ok := s.retryScheduled[slot]; ok {
|
||||
s.retryMu.Unlock()
|
||||
|
||||
@@ -400,6 +421,24 @@ func (s *solana) scheduleSlotRetry(slot int) {
|
||||
s.retryMu.Unlock()
|
||||
}
|
||||
|
||||
func (s *solana) stopSlotRetry(slot int) {
|
||||
s.retryMu.Lock()
|
||||
delete(s.retryAttempts, slot)
|
||||
if timer, ok := s.retryScheduled[slot]; ok {
|
||||
timer.Stop()
|
||||
delete(s.retryScheduled, slot)
|
||||
}
|
||||
s.retryStopped[slot] = struct{}{}
|
||||
s.retryMu.Unlock()
|
||||
|
||||
// 防止同一 slot 的并发请求在终态响应之后重新建立重试;并发请求结束后无需长期保留。
|
||||
time.AfterFunc(time.Minute, func() {
|
||||
s.retryMu.Lock()
|
||||
delete(s.retryStopped, slot)
|
||||
s.retryMu.Unlock()
|
||||
})
|
||||
}
|
||||
|
||||
func (s *solana) resetSlotRetry(slot int) {
|
||||
s.retryMu.Lock()
|
||||
defer s.retryMu.Unlock()
|
||||
@@ -421,6 +460,10 @@ func (s *solana) pendingSlotRetryCount() int {
|
||||
// 单个 slot 最多重试 10 次,按 solanaRetryDelay 约 7 分钟
|
||||
const solanaSlotMaxRetries = 10
|
||||
|
||||
// 待重试的 slot 达到这个数量,说明节点整体故障,暂停向前扫描,避免新 slot 不断进入重试;
|
||||
// 个别 slot 失败时继续向前扫描,否则一个 slot 的重试会让之后的付款最多等约 7 分钟
|
||||
const solanaForwardPauseRetries = 10
|
||||
|
||||
func solanaRetryDelay(attempt int) time.Duration {
|
||||
delays := [...]time.Duration{2 * time.Second, 5 * time.Second, 15 * time.Second, 30 * time.Second, time.Minute}
|
||||
if attempt < 1 {
|
||||
@@ -544,13 +587,28 @@ func (s *solana) tradeConfirmHandle(ctx context.Context) {
|
||||
}
|
||||
|
||||
func (s *solana) lookbackSlots(ctx context.Context) {
|
||||
s.lookbackMu.Lock()
|
||||
defer s.lookbackMu.Unlock()
|
||||
|
||||
// 回溯到一半时订单已支付、取消,或已超出回溯时间,剩余区间不再需要。扫描空闲时这里不会执行到下面,
|
||||
// 不清空的话进度会一直保留,下一笔订单到来时接着扫这段旧 slot,节点可能早已清理
|
||||
if s.lookbackNext != 0 {
|
||||
pending, err := lookbackOrdersPending(s.lookbackOrderIDs)
|
||||
if err != nil { // 查询失败不等于订单已结束,保留进度,下一轮再判断
|
||||
log.Task.Warn("Solana 回溯订单查询失败,稍后重试:", err)
|
||||
|
||||
return
|
||||
}
|
||||
if !pending {
|
||||
log.Task.Info(fmt.Sprintf("Solana 回溯的订单已不需要回溯,丢弃剩余回溯区间 %d-%d", s.lookbackNext, s.lookbackEnd))
|
||||
s.resetLookback()
|
||||
}
|
||||
}
|
||||
|
||||
if syncBreak(conf.Solana, s.slotQueue.Len()) {
|
||||
return
|
||||
}
|
||||
|
||||
s.lookbackMu.Lock()
|
||||
defer s.lookbackMu.Unlock()
|
||||
|
||||
if s.lookbackNext == 0 {
|
||||
startAt, endAt, orderIDs, ok := pendingLookbackUnix(conf.Solana)
|
||||
if !ok {
|
||||
@@ -581,12 +639,16 @@ func (s *solana) lookbackSlots(ctx context.Context) {
|
||||
|
||||
if s.lookbackNext > s.lookbackEnd {
|
||||
markLookbackDone(s.lookbackOrderIDs)
|
||||
s.lookbackNext = 0
|
||||
s.lookbackEnd = 0
|
||||
s.lookbackOrderIDs = nil
|
||||
s.resetLookback()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *solana) resetLookback() {
|
||||
s.lookbackNext = 0
|
||||
s.lookbackEnd = 0
|
||||
s.lookbackOrderIDs = nil
|
||||
}
|
||||
|
||||
func validSolanaLookbackRange(start, end int64) bool {
|
||||
return start > 0 && end >= start
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
func TestSolanaConfirmOffsetUsesRPCSlot(t *testing.T) {
|
||||
@@ -44,7 +44,7 @@ func TestSolanaConfirmOffsetUsesRPCSlot(t *testing.T) {
|
||||
Money: "2736.93",
|
||||
Address: "F7p3dFrjRTbtRp8FRF6qHLomXbKRBzpvBLjtQcfcgmNe",
|
||||
Status: model.OrderStatusConfirming,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
NotifyUrl: srv.URL + "/notify",
|
||||
RefHash: "DohbsAfxAerDTAX9XS1b9jXY5XYMXQsCnyY3qu42eEEcTeJ6UzMbFs3JTdY14QgNKQPdy6yezdgbqLbnRVj6YB6",
|
||||
RefBlockNum: slot,
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
func scanSolanaTestBlock(t *testing.T, block []byte) []transfer {
|
||||
@@ -143,7 +143,7 @@ func TestSolanaTradeConfirmIgnoresFailedTransaction(t *testing.T) {
|
||||
Money: "1581.77",
|
||||
Address: "GpsvqTPP7triXkqH8mVtXEM6at9DJ41UHy5dYPTFe16H",
|
||||
Status: model.OrderStatusConfirming,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
NotifyUrl: srv.URL + "/notify",
|
||||
RefHash: "53bZ2UeqMGryYjbjKgB2nAo8umAMsPTP4dzBhR94SdV7f4YaxDvWqEdL5WQ46JSHsmLph3hBmEdHzTMdnYKMsbRz",
|
||||
RefBlockNum: 458281527,
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
// 模拟 n 个 slot 正在等待重试
|
||||
func (s *solana) setPendingSlotRetries(first, n int) {
|
||||
s.retryMu.Lock()
|
||||
defer s.retryMu.Unlock()
|
||||
|
||||
for slot := first; slot < first+n; slot++ {
|
||||
s.retryAttempts[slot] = 1
|
||||
}
|
||||
}
|
||||
|
||||
// 一个 slot 在等待重试时,向前扫描照常推进,之后的付款不用等它重试完
|
||||
func TestSolanaForwardContinuesWhileFewSlotsRetry(t *testing.T) {
|
||||
var head atomic.Int64
|
||||
srv := newSolanaSlotTestServer(t, &head)
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.RpcEndpointSolana: srv.URL, model.BlockHeightMaxDiff: fmt.Sprint(solanaTestMaxDiff)})
|
||||
createSolanaWaitingOrder(t)
|
||||
|
||||
const last = 458000000
|
||||
s := newSolana()
|
||||
s.lastSlotNum = last
|
||||
s.setPendingSlotRetries(last-9, solanaForwardPauseRetries-1)
|
||||
head.Store(last + 5)
|
||||
s.syncSlotForward(t.Context())
|
||||
|
||||
if s.lastSlotNum != last+5 {
|
||||
t.Fatalf("lastSlotNum = %d, want %d: forward sync paused by one slot retry", s.lastSlotNum, last+5)
|
||||
}
|
||||
select {
|
||||
case got := <-s.slotQueue.Out:
|
||||
if got != last+1 {
|
||||
t.Fatalf("first queued slot = %d, want %d", got, last+1)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatalf("no slot queued while one slot retries")
|
||||
}
|
||||
}
|
||||
|
||||
// 很多 slot 同时等待重试,说明节点整体故障,暂停向前扫描
|
||||
func TestSolanaForwardPausesWhileManySlotsRetry(t *testing.T) {
|
||||
var head atomic.Int64
|
||||
srv := newSolanaSlotTestServer(t, &head)
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.RpcEndpointSolana: srv.URL, model.BlockHeightMaxDiff: fmt.Sprint(solanaTestMaxDiff)})
|
||||
createSolanaWaitingOrder(t)
|
||||
|
||||
const last = 458000000
|
||||
s := newSolana()
|
||||
s.lastSlotNum = last
|
||||
s.setPendingSlotRetries(last-solanaForwardPauseRetries, solanaForwardPauseRetries)
|
||||
head.Store(last + 5)
|
||||
s.syncSlotForward(t.Context())
|
||||
|
||||
if s.lastSlotNum != last || s.slotQueue.Len() != 0 {
|
||||
t.Fatalf("lastSlotNum = %d, queued = %d; want forward sync paused at %d", s.lastSlotNum, s.slotQueue.Len(), last)
|
||||
}
|
||||
|
||||
s.resetSlotRetry(last - solanaForwardPauseRetries)
|
||||
s.syncSlotForward(t.Context())
|
||||
if s.lastSlotNum != last+5 {
|
||||
t.Fatalf("lastSlotNum = %d after retries dropped below threshold, want %d", s.lastSlotNum, last+5)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
func newSolanaSlotTestServer(t *testing.T, head *atomic.Int64) *httptest.Server {
|
||||
@@ -34,7 +34,7 @@ func createSolanaWaitingOrder(t *testing.T) {
|
||||
Money: "8.61",
|
||||
Address: "GpsvqTPP7triXkqH8mVtXEM6at9DJ41UHy5dYPTFe16H",
|
||||
Status: model.OrderStatusWaiting,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
ExpiredAt: time.Now().Add(10 * time.Minute),
|
||||
}, time.Now().Add(-time.Minute))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
func createSolanaLookbackOrder(t *testing.T, tradeID string, status int) model.Order {
|
||||
t.Helper()
|
||||
|
||||
return createTestOrder(t, model.Order{
|
||||
OrderId: "merchant-" + tradeID,
|
||||
TradeId: tradeID,
|
||||
TradeType: model.UsdcSolana,
|
||||
Rate: "7.00",
|
||||
Amount: "1.23",
|
||||
Money: "8.61",
|
||||
Address: "GpsvqTPP7triXkqH8mVtXEM6at9DJ41UHy5dYPTFe16H",
|
||||
Status: status,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
ExpiredAt: time.Now().Add(10 * time.Minute),
|
||||
}, time.Now().Add(-time.Minute))
|
||||
}
|
||||
|
||||
// 上一笔订单回溯到一半就取消了;一周后新订单到来时,不能接着扫上一笔订单留下的旧 slot
|
||||
func TestSolanaLookbackDropsRangeOfFinishedOrders(t *testing.T) {
|
||||
initTaskTestEnv(t, nil)
|
||||
lookbackDone.Clear()
|
||||
|
||||
canceled := createSolanaLookbackOrder(t, "lookback-canceled", model.OrderStatusCanceled)
|
||||
waiting := createSolanaLookbackOrder(t, "lookback-waiting", model.OrderStatusWaiting)
|
||||
lookbackDone.Store(waiting.ID, struct{}{}) // 新订单的回溯不在本测试范围,避免请求区块高度接口
|
||||
|
||||
s := newSolana()
|
||||
s.lookbackNext, s.lookbackEnd, s.lookbackOrderIDs = 459552217, 459552221, []int64{canceled.ID}
|
||||
s.lookbackSlots(t.Context())
|
||||
|
||||
select {
|
||||
case slot := <-s.slotQueue.Out:
|
||||
t.Fatalf("queued slot %d from the range of a canceled order", slot)
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
}
|
||||
if s.lookbackNext != 0 || s.lookbackEnd != 0 || s.lookbackOrderIDs != nil {
|
||||
t.Fatalf("lookback progress kept: next = %d, end = %d, orders = %v", s.lookbackNext, s.lookbackEnd, s.lookbackOrderIDs)
|
||||
}
|
||||
}
|
||||
|
||||
// 查询订单失败时不能当作订单已结束,保留进度,下一轮再判断
|
||||
func TestSolanaLookbackKeepsRangeOnDatabaseError(t *testing.T) {
|
||||
initTaskTestEnv(t, nil)
|
||||
lookbackDone.Clear()
|
||||
|
||||
waiting := createSolanaLookbackOrder(t, "lookback-waiting", model.OrderStatusWaiting)
|
||||
|
||||
const start, end = 462296900, 462296904
|
||||
s := newSolana()
|
||||
s.lookbackNext, s.lookbackEnd, s.lookbackOrderIDs = start, end, []int64{waiting.ID}
|
||||
db, err := model.Db.DB()
|
||||
if err != nil {
|
||||
t.Fatalf("get db: %v", err)
|
||||
}
|
||||
if err := db.Close(); err != nil {
|
||||
t.Fatalf("close db: %v", err)
|
||||
}
|
||||
s.lookbackSlots(t.Context())
|
||||
|
||||
if s.lookbackNext != start || s.lookbackEnd != end {
|
||||
t.Fatalf("lookback progress dropped on a database error: next = %d, end = %d", s.lookbackNext, s.lookbackEnd)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSolanaLookbackResumesRangeOfPendingOrders(t *testing.T) {
|
||||
initTaskTestEnv(t, nil)
|
||||
lookbackDone.Clear()
|
||||
|
||||
waiting := createSolanaLookbackOrder(t, "lookback-waiting", model.OrderStatusWaiting)
|
||||
|
||||
const start, end = 462296900, 462296904
|
||||
s := newSolana()
|
||||
s.lookbackNext, s.lookbackEnd, s.lookbackOrderIDs = start, end, []int64{waiting.ID}
|
||||
s.lookbackSlots(t.Context())
|
||||
|
||||
for want := start; want <= end; want++ {
|
||||
select {
|
||||
case got := <-s.slotQueue.Out:
|
||||
if got != want {
|
||||
t.Fatalf("queued slot = %d, want %d", got, want)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
t.Fatalf("slot %d not queued", want)
|
||||
}
|
||||
}
|
||||
if s.lookbackNext != 0 {
|
||||
t.Fatalf("lookbackNext = %d after the range was queued, want 0", s.lookbackNext)
|
||||
}
|
||||
if _, done := lookbackDone.Load(waiting.ID); !done {
|
||||
t.Fatalf("order %d not marked as looked back", waiting.ID)
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
// 预期结果由独立的解码脚本从主网交易得出:只统计两端代币账户都在 token balances 中的 USDT/USDC transfer、transferChecked
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
const solanaBlockCleanedUpResponse = `{"jsonrpc":"2.0","error":{"code":-32001,"message":"Block 459552217 cleaned up, does not exist on node. First available block: 461715420"},"id":1}`
|
||||
|
||||
func TestValidateSolanaBlockResponseCleanedUp(t *testing.T) {
|
||||
if _, err := validateSolanaBlockResponse([]byte(solanaBlockCleanedUpResponse)); !errors.Is(err, errSolanaBlockCleanedUp) {
|
||||
t.Fatalf("error = %v, want errSolanaBlockCleanedUp", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 并发处理同一个 slot 时,较晚返回的普通错误不能在 BlockCleanedUp 已经终止后重新建立重试
|
||||
func TestSolanaSlotParseCleanedUpWinsConcurrentFailure(t *testing.T) {
|
||||
firstStarted := make(chan struct{})
|
||||
releaseFirst := make(chan struct{})
|
||||
var calls atomic.Int64
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if calls.Add(1) == 1 {
|
||||
close(firstStarted)
|
||||
<-releaseFirst
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(solanaBlockCleanedUpResponse))
|
||||
}))
|
||||
defer srv.Close()
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.RpcEndpointSolana: srv.URL})
|
||||
|
||||
const slot = 459552217
|
||||
s := newSolana()
|
||||
t.Cleanup(s.stopSlotRetryTimers)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
s.slotParse(slot)
|
||||
close(done)
|
||||
}()
|
||||
<-firstStarted
|
||||
s.slotParse(slot)
|
||||
close(releaseFirst)
|
||||
<-done
|
||||
|
||||
if got := s.pendingSlotRetryCount(); got != 0 {
|
||||
t.Fatalf("pending retries after concurrent cleaned up = %d, want 0", got)
|
||||
}
|
||||
s.retryMu.Lock()
|
||||
_, scheduled := s.retryScheduled[slot]
|
||||
s.retryMu.Unlock()
|
||||
if scheduled {
|
||||
t.Fatalf("concurrent failure rescheduled cleaned up slot")
|
||||
}
|
||||
}
|
||||
|
||||
// 节点已清理的 slot 只请求一次就放弃,不留下待重试记录,向前扫描不会因此暂停;之前因为限流留下的重试也一并清除
|
||||
func TestSolanaSlotParseGivesUpCleanedUpSlot(t *testing.T) {
|
||||
var cleaned atomic.Bool
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if !cleaned.Load() {
|
||||
w.WriteHeader(http.StatusTooManyRequests)
|
||||
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(solanaBlockCleanedUpResponse))
|
||||
}))
|
||||
defer srv.Close()
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.RpcEndpointSolana: srv.URL})
|
||||
|
||||
const slot = 459552217
|
||||
s := newSolana()
|
||||
t.Cleanup(s.stopSlotRetryTimers)
|
||||
|
||||
s.slotParse(slot)
|
||||
if got := s.pendingSlotRetryCount(); got != 1 {
|
||||
t.Fatalf("pending retries after 429 = %d, want 1", got)
|
||||
}
|
||||
s.expireSlotRetryTimer(slot)
|
||||
|
||||
cleaned.Store(true)
|
||||
s.slotParse(slot)
|
||||
if got := s.pendingSlotRetryCount(); got != 0 {
|
||||
t.Fatalf("pending retries after cleaned up = %d, want 0: forward sync stays paused", got)
|
||||
}
|
||||
s.retryMu.Lock()
|
||||
_, scheduled := s.retryScheduled[slot]
|
||||
s.retryMu.Unlock()
|
||||
if scheduled {
|
||||
t.Fatalf("cleaned up slot still scheduled for retry")
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
"time"
|
||||
|
||||
"filippo.io/edwards25519"
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
// 订单过期后,按收款账户的链上历史对账一次。
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -96,7 +96,7 @@ func createReconcileTestOrder(t *testing.T, tradeID, amount string) model.Order
|
||||
Money: "2736.93",
|
||||
Address: reconcileTestOwner,
|
||||
Status: model.OrderStatusExpired,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
ExpiredAt: time.Now().Add(-5 * time.Minute),
|
||||
}, time.Now().Add(-15*time.Minute))
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
// 模拟重试定时器到期并再次扫描失败:取消定时器,下一次 scheduleSlotRetry 计为新的失败
|
||||
@@ -31,7 +31,7 @@ func (s *solana) stopSlotRetryTimers() {
|
||||
|
||||
func TestSolanaSlotRetryGivesUpAfterMaxRetries(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(`{"jsonrpc":"2.0","error":{"code":-32001,"message":"Block 457000000 cleaned up, does not exist on node. First available block: 457100000"},"id":1}`))
|
||||
_, _ = w.Write([]byte(`{"jsonrpc":"2.0","error":{"code":-32004,"message":"Block not available for slot 457000000"},"id":1}`))
|
||||
}))
|
||||
defer srv.Close()
|
||||
initTaskTestEnv(t, map[model.ConfKey]string{model.RpcEndpointSolana: srv.URL})
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
// 区块扫描队列最大长度,避免可能因为 Rpc Rate Limit 问题导致消费队列堆积,进而导致OOM,暂时简单限制队列长度
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
applog "git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/tidwall/gjson"
|
||||
applog "github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
// 任务测试的公共环境:临时日志目录、临时 SQLite 和主网交易 fixture
|
||||
@@ -22,7 +22,7 @@ func initTaskTestEnv(t *testing.T, kv map[model.ConfKey]string) {
|
||||
}
|
||||
t.Cleanup(applog.Close)
|
||||
|
||||
if err := model.Init(filepath.Join(t.TempDir(), "task-test.db"), ""); err != nil {
|
||||
if err := model.Init(filepath.Join(t.TempDir(), "task-test.db"), "", ""); err != nil {
|
||||
t.Fatalf("init db: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
@@ -68,7 +68,7 @@ func getTestOrder(t *testing.T, tradeID string) model.Order {
|
||||
func waitOrderNotified(t *testing.T, tradeID string) {
|
||||
t.Helper()
|
||||
|
||||
file := filepath.Join(applog.GetPath(), "bepusdt.log")
|
||||
file := filepath.Join(applog.GetPath(), "vupay.log")
|
||||
for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline); time.Sleep(50 * time.Millisecond) {
|
||||
body, _ := os.ReadFile(file)
|
||||
if strings.Contains(string(body), "订单回调成功") && strings.Contains(string(body), tradeID) {
|
||||
|
||||
+41
-33
@@ -7,14 +7,14 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
blockapi "git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
blockapi "github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/xssnick/tonutils-go/address"
|
||||
"github.com/xssnick/tonutils-go/tlb"
|
||||
tgo "github.com/xssnick/tonutils-go/ton"
|
||||
@@ -305,14 +305,38 @@ func (t *ton) processShard(ctx context.Context, shard *tgo.BlockIDExt, seqno uin
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://github.com/ton-blockchain/TEPs/blob/63fc78718dd9930f3e106954ebec743c3ad07993/text/0074-jettons-standard.md?plain=1#L226
|
||||
// https://github.com/ton-blockchain/token-contract/blob/1182ad99413242f09925d50e70ccb7e0e09f94d4/ft/jetton-wallet.fc#L43
|
||||
func (t *ton) parseInternalTransfer(shard *tgo.BlockIDExt, tx *tlb.Transaction, blockNum uint32) (transfer, bool) {
|
||||
// tonInboundMessage 提取交易的入站 internal 消息及其 ordinary 描述,两类转账解析共用
|
||||
func tonInboundMessage(tx *tlb.Transaction) (*tlb.InternalMessage, tlb.TransactionDescriptionOrdinary, bool) {
|
||||
var dsc tlb.TransactionDescriptionOrdinary
|
||||
if tx.IO.In == nil {
|
||||
return transfer{}, false
|
||||
return nil, dsc, false
|
||||
}
|
||||
in, ok := tx.IO.In.Msg.(*tlb.InternalMessage)
|
||||
if !ok || in.Bounced || in.Body == nil {
|
||||
return nil, dsc, false
|
||||
}
|
||||
if dsc, ok = tx.Description.(tlb.TransactionDescriptionOrdinary); !ok {
|
||||
return nil, dsc, false
|
||||
}
|
||||
if dsc.BouncePhase != nil {
|
||||
if _, ok = dsc.BouncePhase.Phase.(tlb.BouncePhaseOk); ok {
|
||||
return nil, dsc, false
|
||||
}
|
||||
}
|
||||
|
||||
return in, dsc, true
|
||||
}
|
||||
|
||||
// tonAccountAddr 统一输出为 non-bounceable 格式,与钱包 MatchAddr 保持一致
|
||||
func tonAccountAddr(addr *address.Address) string {
|
||||
return addr.Bounce(false).String()
|
||||
}
|
||||
|
||||
// https://github.com/ton-blockchain/TEPs/blob/63fc78718dd9930f3e106954ebec743c3ad07993/text/0074-jettons-standard.md?plain=1#L226
|
||||
// https://github.com/ton-blockchain/token-contract/blob/1182ad99413242f09925d50e70ccb7e0e09f94d4/ft/jetton-wallet.fc#L43
|
||||
func (t *ton) parseInternalTransfer(shard *tgo.BlockIDExt, tx *tlb.Transaction, blockNum uint32) (transfer, bool) {
|
||||
in, dsc, ok := tonInboundMessage(tx)
|
||||
if !ok {
|
||||
return transfer{}, false
|
||||
}
|
||||
s, err := in.Body.BeginParse()
|
||||
@@ -324,17 +348,12 @@ func (t *ton) parseInternalTransfer(shard *tgo.BlockIDExt, tx *tlb.Transaction,
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
transOrd, ok := tx.Description.(tlb.TransactionDescriptionOrdinary)
|
||||
if !ok {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
compute, ok := transOrd.ComputePhase.Phase.(tlb.ComputePhaseVM)
|
||||
compute, ok := dsc.ComputePhase.Phase.(tlb.ComputePhaseVM)
|
||||
if !ok || !compute.Success {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
if transOrd.ActionPhase == nil || !transOrd.ActionPhase.Success {
|
||||
if dsc.ActionPhase == nil || !dsc.ActionPhase.Success {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
@@ -359,8 +378,8 @@ func (t *ton) parseInternalTransfer(shard *tgo.BlockIDExt, tx *tlb.Transaction,
|
||||
Network: conf.Ton,
|
||||
TxHash: hex.EncodeToString(tx.Hash),
|
||||
Amount: decimal.NewFromBigInt(amount, conf.UsdtTonDecimals),
|
||||
FromAddress: fromOwner.Bounce(false).String(),
|
||||
RecvAddress: toJetton.Bounce(false).String(),
|
||||
FromAddress: tonAccountAddr(fromOwner),
|
||||
RecvAddress: tonAccountAddr(toJetton),
|
||||
Timestamp: time.Unix(int64(tx.Now), 0),
|
||||
TradeType: model.UsdtTon,
|
||||
BlockNum: int(blockNum),
|
||||
@@ -368,30 +387,19 @@ func (t *ton) parseInternalTransfer(shard *tgo.BlockIDExt, tx *tlb.Transaction,
|
||||
}
|
||||
|
||||
func (t *ton) parseTonTransfer(tx *tlb.Transaction, blockNum uint32) (transfer, bool) {
|
||||
in := tx.IO.In
|
||||
if in == nil {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
msg, ok := in.Msg.(*tlb.InternalMessage)
|
||||
msg, _, ok := tonInboundMessage(tx)
|
||||
if !ok {
|
||||
return transfer{}, false
|
||||
}
|
||||
if msg.Bounced {
|
||||
return transfer{}, false
|
||||
}
|
||||
if msg.Amount.Nano().Sign() <= 0 {
|
||||
return transfer{}, false
|
||||
}
|
||||
if msg.Body.BitsSize() != 0 {
|
||||
if msg.Amount.Nano().Sign() <= 0 || msg.Body.BitsSize() != 0 {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
return transfer{
|
||||
Network: conf.Ton,
|
||||
TxHash: hex.EncodeToString(tx.Hash),
|
||||
FromAddress: msg.SrcAddr.Bounce(false).String(),
|
||||
RecvAddress: msg.DstAddr.Bounce(false).String(),
|
||||
FromAddress: tonAccountAddr(msg.SrcAddr),
|
||||
RecvAddress: tonAccountAddr(msg.DstAddr),
|
||||
Timestamp: time.Unix(int64(tx.Now), 0),
|
||||
Amount: decimal.NewFromBigInt(msg.Amount.Nano(), conf.TonTonDecimals),
|
||||
TradeType: model.TonGram,
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"github.com/xssnick/tonutils-go/address"
|
||||
"github.com/xssnick/tonutils-go/tlb"
|
||||
tgo "github.com/xssnick/tonutils-go/ton"
|
||||
"github.com/xssnick/tonutils-go/tvm/cell"
|
||||
)
|
||||
|
||||
var (
|
||||
tonTestSrc = address.NewAddress(0, 0, make([]byte, 32))
|
||||
tonTestDst = address.NewAddress(0, 0, append(make([]byte, 31), 1))
|
||||
)
|
||||
|
||||
func tonTestTx(body *cell.Cell, nano uint64, dsc any) *tlb.Transaction {
|
||||
tx := &tlb.Transaction{AccountAddr: tonTestDst.Data(), Now: 1700000000, Hash: []byte{0xab}, Description: dsc}
|
||||
tx.IO.In = &tlb.Message{MsgType: tlb.MsgTypeInternal, Msg: &tlb.InternalMessage{
|
||||
SrcAddr: tonTestSrc,
|
||||
DstAddr: tonTestDst,
|
||||
Amount: tlb.FromNanoTONU(nano),
|
||||
Body: body,
|
||||
}}
|
||||
|
||||
return tx
|
||||
}
|
||||
|
||||
func tonTestOrdinary(success bool) tlb.TransactionDescriptionOrdinary {
|
||||
return tlb.TransactionDescriptionOrdinary{
|
||||
ComputePhase: tlb.ComputePhase{Phase: tlb.ComputePhaseVM{Success: success}},
|
||||
ActionPhase: &tlb.ActionPhase{Success: success},
|
||||
}
|
||||
}
|
||||
|
||||
func tonTestJettonBody(op uint32, amount uint64) *cell.Cell {
|
||||
return cell.BeginCell().
|
||||
MustStoreUInt(uint64(op), 32).
|
||||
MustStoreUInt(1, 64).
|
||||
MustStoreCoins(amount).
|
||||
MustStoreAddr(tonTestSrc).
|
||||
EndCell()
|
||||
}
|
||||
|
||||
func TestParseTonTransfer(t *testing.T) {
|
||||
empty := cell.BeginCell().EndCell()
|
||||
skipped := tlb.TransactionDescriptionOrdinary{
|
||||
ComputePhase: tlb.ComputePhase{Phase: tlb.ComputePhaseSkipped{}},
|
||||
Aborted: true,
|
||||
}
|
||||
returned := skipped
|
||||
returned.BouncePhase = &tlb.BouncePhase{Phase: tlb.BouncePhaseOk{}}
|
||||
noFunds := skipped
|
||||
noFunds.BouncePhase = &tlb.BouncePhase{Phase: tlb.BouncePhaseNoFunds{}}
|
||||
|
||||
bouncedIn := tonTestTx(empty, 1e9, tonTestOrdinary(true))
|
||||
bouncedIn.IO.In.Msg.(*tlb.InternalMessage).Bounced = true
|
||||
external := tonTestTx(empty, 1e9, tonTestOrdinary(true))
|
||||
external.IO.In.Msg = &tlb.ExternalMessage{}
|
||||
noIn := tonTestTx(empty, 1e9, tonTestOrdinary(true))
|
||||
noIn.IO.In = nil
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
tx *tlb.Transaction
|
||||
ok bool
|
||||
}{
|
||||
{"plain", tonTestTx(empty, 1e9, tonTestOrdinary(true)), true},
|
||||
{"uninit account", tonTestTx(empty, 1e9, skipped), true},
|
||||
{"uninit account, bounce unpaid", tonTestTx(empty, 1e9, noFunds), true},
|
||||
{"returned to sender", tonTestTx(empty, 1e9, returned), false},
|
||||
{"zero amount", tonTestTx(empty, 0, tonTestOrdinary(true)), false},
|
||||
{"with body", tonTestTx(tonTestJettonBody(tonOpInternalTransfer, 1), 1e9, tonTestOrdinary(true)), false},
|
||||
{"bounced inbound", bouncedIn, false},
|
||||
{"external inbound", external, false},
|
||||
{"no inbound", noIn, false},
|
||||
{"tick tock", tonTestTx(empty, 1e9, tlb.TransactionDescriptionTickTock{}), false},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
got, ok := (&ton{}).parseTonTransfer(c.tx, 100)
|
||||
if ok != c.ok {
|
||||
t.Errorf("%s: ok = %v, want %v", c.name, ok, c.ok)
|
||||
}
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if got.TradeType != model.TonGram || got.Amount.String() != "1" || got.BlockNum != 100 {
|
||||
t.Errorf("%s: unexpected transfer %+v", c.name, got)
|
||||
}
|
||||
if got.RecvAddress != tonTestDst.Bounce(false).String() || got.FromAddress != tonTestSrc.Bounce(false).String() {
|
||||
t.Errorf("%s: unexpected address %s <- %s", c.name, got.RecvAddress, got.FromAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseTonInternalTransfer(t *testing.T) {
|
||||
shard := &tgo.BlockIDExt{Workchain: 0}
|
||||
cases := []struct {
|
||||
name string
|
||||
tx *tlb.Transaction
|
||||
ok bool
|
||||
}{
|
||||
{"jetton received", tonTestTx(tonTestJettonBody(tonOpInternalTransfer, 2_500_000), 1, tonTestOrdinary(true)), true},
|
||||
{"other op", tonTestTx(tonTestJettonBody(0x7362d09c, 2_500_000), 1, tonTestOrdinary(true)), false},
|
||||
{"execution failed", tonTestTx(tonTestJettonBody(tonOpInternalTransfer, 2_500_000), 1, tonTestOrdinary(false)), false},
|
||||
{"zero amount", tonTestTx(tonTestJettonBody(tonOpInternalTransfer, 0), 1, tonTestOrdinary(true)), false},
|
||||
{"empty body", tonTestTx(cell.BeginCell().EndCell(), 1, tonTestOrdinary(true)), false},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
got, ok := (&ton{}).parseInternalTransfer(shard, c.tx, 100)
|
||||
if ok != c.ok {
|
||||
t.Errorf("%s: ok = %v, want %v", c.name, ok, c.ok)
|
||||
}
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if got.TradeType != model.UsdtTon || got.Amount.String() != "2.5" || got.RecvAddress != tonTestDst.Bounce(false).String() {
|
||||
t.Errorf("%s: unexpected transfer %+v", c.name, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
-14
@@ -3,17 +3,16 @@ package task
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/notifier"
|
||||
"git.viaeon.com/admin/vupay/app/task/notify"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
"github.com/v03413/bepusdt/app/task/notify"
|
||||
"github.com/v03413/tronprotocol/core"
|
||||
)
|
||||
|
||||
@@ -293,6 +292,22 @@ func hasLookbackOrders(tradeType []model.TradeType) bool {
|
||||
return count > 0
|
||||
}
|
||||
|
||||
// lookbackOrdersPending 判断这些订单中是否还有需要回溯的,条件与 hasLookbackOrders 相同
|
||||
func lookbackOrdersPending(orderIDs []int64) (bool, error) {
|
||||
if len(orderIDs) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
var count int64
|
||||
err := model.Db.Model(&model.Order{}).
|
||||
Where("id in (?)", orderIDs).
|
||||
Where("status in (?)", receivableOrderStatuses()).
|
||||
Where("expired_at > ?", time.Now().Add(model.GetLookbackHour())).
|
||||
Count(&count).Error
|
||||
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
func getLookbackUnix(network model.Network) (startAt, endAt int64, ok bool) {
|
||||
startAt, endAt, orderIDs, ok := pendingLookbackUnix(network)
|
||||
if ok {
|
||||
@@ -365,7 +380,7 @@ func expireWaitingOrders() {
|
||||
}
|
||||
|
||||
t.SetExpired()
|
||||
notify.Bepusdt(t)
|
||||
notify.Vupay(t)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +398,7 @@ func getConfirmingOrders(tradeType []model.TradeType) []model.Order {
|
||||
if time.Now().Unix() >= order.ExpiredAt.Unix() {
|
||||
if order.ConfirmedAt == nil || order.ConfirmedAt.IsZero() || !order.ConfirmedAt.Before(order.ExpiredAt) {
|
||||
order.SetFailed()
|
||||
notify.Bepusdt(order)
|
||||
notify.Vupay(order)
|
||||
|
||||
continue
|
||||
}
|
||||
@@ -401,16 +416,21 @@ func amountMatch(amount decimal.Decimal, target, tradeType string) bool {
|
||||
case model.Classic:
|
||||
return amount.String() == target
|
||||
case model.HasPrefix:
|
||||
s := amount.String()
|
||||
if !strings.HasPrefix(s, target) {
|
||||
t, err := decimal.NewFromString(target)
|
||||
if err != nil {
|
||||
log.Warn(err.Error())
|
||||
|
||||
return false
|
||||
}
|
||||
rest := s[len(target):]
|
||||
if rest == "" {
|
||||
return true
|
||||
|
||||
// 订单金额去掉了末尾的 0(1.50 存为 1.5),直接按字符串比前缀会让 1.5 的订单吃掉 1.51 的付款;
|
||||
// 按原子精度和订单金额小数位中的较大者截断实付金额再精确比较,只容忍精度以下的多付
|
||||
_, precision := model.GetAtomicity(model.TradeType(tradeType))
|
||||
if p := abs(t.Exponent()); p > precision {
|
||||
precision = p
|
||||
}
|
||||
|
||||
return strings.Contains(target, ".") || strings.HasPrefix(rest, ".")
|
||||
return amount.Truncate(precision).Equal(t)
|
||||
case model.RoundOff:
|
||||
t, err := decimal.NewFromString(target)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
)
|
||||
|
||||
func TestPendingLookbackUnixCoversEveryOrderWindow(t *testing.T) {
|
||||
@@ -52,7 +52,7 @@ func TestPendingLookbackUnixCoversEveryOrderWindow(t *testing.T) {
|
||||
Money: "7.00",
|
||||
Address: "GpsvqTPP7triXkqH8mVtXEM6at9DJ41UHy5dYPTFe16H",
|
||||
Status: w.status,
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeVupay,
|
||||
ExpiredAt: now.Add(w.expired),
|
||||
}, now.Add(w.created))
|
||||
}
|
||||
|
||||
+5
-5
@@ -9,17 +9,17 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
blockapi "git.viaeon.com/admin/vupay/app/core"
|
||||
"git.viaeon.com/admin/vupay/app/log"
|
||||
"git.viaeon.com/admin/vupay/app/model"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/panjf2000/ants/v2"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
blockapi "github.com/v03413/bepusdt/app/core"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/v03413/tronprotocol/api"
|
||||
"github.com/v03413/tronprotocol/core"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.viaeon.com/admin/vupay/app/conf"
|
||||
"git.viaeon.com/admin/vupay/app/utils"
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func xlayerInit() {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ func IsExist(path string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func EpusdtSign(data map[string]interface{}, token string) string {
|
||||
func VupaySign(data map[string]interface{}, token string) string {
|
||||
keys := make([]string, 0, len(data))
|
||||
for k := range data {
|
||||
if k == "signature" {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICpjCCAiugAwIBAgIRAIchZfw0tuX7qK3Vs3BftTowCgYIKoZIzj0EAwMwTzEL
|
||||
MAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNo
|
||||
IEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDIwHhcNMjYwNTEzMDAwMDAwWhcN
|
||||
MzIwOTAyMjM1OTU5WjAuMQswCQYDVQQGEwJVUzENMAsGA1UEChMESVNSRzEQMA4G
|
||||
A1UEAxMHUm9vdCBZRTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDwS/6vhrcVqcbBo
|
||||
+wgdI3fwn9x7DNJJOY/lTOti0vkwuRN87RhEhTH17E7XyFjWsPYhIPt/wzOqxTd2
|
||||
b+4ZJNy9ID04YywF9U5zasDVyGSNErVNtz8uSGh5izW87j77GaOB6zCB6DAOBgNV
|
||||
HQ8BAf8EBAMCAQYwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDwYDVR0TAQH/BAUwAwEB
|
||||
/zAdBgNVHQ4EFgQUo8gmWo6hTNA1Y/ybI8g6rlbzT1YwHwYDVR0jBBgwFoAUfEKW
|
||||
rt5LSDv6kviejM9ti6lyN5UwMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzAChhZo
|
||||
dHRwOi8veDIuaS5sZW5jci5vcmcvMBMGA1UdIAQMMAowCAYGZ4EMAQIBMCcGA1Ud
|
||||
HwQgMB4wHKAaoBiGFmh0dHA6Ly94Mi5jLmxlbmNyLm9yZy8wCgYIKoZIzj0EAwMD
|
||||
aQAwZgIxAMU19WCtmxVND8UHBZRoma49Z7jPs64Dma0eTu1OChVbB/2J7GV3nvYK
|
||||
Ax54uk1G9QIxAO0miLVJu8PLNiXXXkiE/gsK3CTRTF/aeo4bMX42Zw40csRU6AC2
|
||||
6hSW1/IWaas6dg==
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,12 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB2TCCAWCgAwIBAgIRAKQCa6LvbHwg1AR+XmWmk4AwCgYIKoZIzj0EAwMwLjEL
|
||||
MAkGA1UEBhMCVVMxDTALBgNVBAoTBElTUkcxEDAOBgNVBAMTB1Jvb3QgWUUwHhcN
|
||||
MjUwOTAzMDAwMDAwWhcNNDUwOTAyMjM1OTU5WjAuMQswCQYDVQQGEwJVUzENMAsG
|
||||
A1UEChMESVNSRzEQMA4GA1UEAxMHUm9vdCBZRTB2MBAGByqGSM49AgEGBSuBBAAi
|
||||
A2IABDwS/6vhrcVqcbBo+wgdI3fwn9x7DNJJOY/lTOti0vkwuRN87RhEhTH17E7X
|
||||
yFjWsPYhIPt/wzOqxTd2b+4ZJNy9ID04YywF9U5zasDVyGSNErVNtz8uSGh5izW8
|
||||
7j77GaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
|
||||
BBYEFKPIJlqOoUzQNWP8myPIOq5W809WMAoGCCqGSM49BAMDA2cAMGQCMHhMr8N9
|
||||
LdL1VQKs9BdV81r76eXRB6mtjuNjzk6/lBsPNToWLTDzGYgtQKO1jl63uAIwGV7m
|
||||
onyF377c+MM1oqVNs17sgu7F9YKZwgLmVbeOMDbKAXHtKMDLbiGllCcs8f47
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,35 @@
|
||||
# VUPAY(SQLite 版)—— 单机最简部署
|
||||
#
|
||||
# 用法:
|
||||
# 1) docker login git.viaeon.com # 私有镜像仓库,用 Gitea 账号/token
|
||||
# 2) docker compose up -d
|
||||
# 3) 浏览器打开 http://服务器IP:8080 走安装向导(记下「安全入口」和后台账号)
|
||||
#
|
||||
# 关键点:
|
||||
# - SQLite 数据库在容器内 /var/lib/vupay/sqlite.db,必须挂出来,否则删容器=丢单
|
||||
# - 日志在 /var/log/vupay/,也挂出来,排查掉单要靠它
|
||||
# - 默认 LISTEN 就是 :8080(0.0.0.0),容器内不用改;要只让反代访问就绑 127.0.0.1
|
||||
|
||||
services:
|
||||
vupay:
|
||||
image: git.viaeon.com/admin/vupay:latest # 想用官方镜像就换成 admin/vupay:latest
|
||||
container_name: vupay
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
# 前面有 Nginx/Caddy 反代时绑本机,别把后台裸奔在公网
|
||||
- "127.0.0.1:8080:8080"
|
||||
# 没有反代、想直接 IP:端口 访问,就用下面这行替换上面那行:
|
||||
# - "8080:8080"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
LISTEN: ":8080"
|
||||
SQLITE: /var/lib/vupay/sqlite.db
|
||||
LOG: /var/log/vupay/
|
||||
volumes:
|
||||
- ./data:/var/lib/vupay # sqlite.db 就在这里
|
||||
- ./logs:/var/log/vupay
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
@@ -0,0 +1,88 @@
|
||||
# VUPAY + MySQL 8 —— 需要 MySQL 的场景
|
||||
#
|
||||
# 注意:这是**本仓库(admin/VUPAY)加了 MySQL 支持之后**才能用的写法。
|
||||
# 上游 admin/vupay 的代码只有 SQLite 和 PostgreSQL,文档里那段 MYSQL_DSN 是过期内容。
|
||||
# 镜像:git.viaeon.com/admin/vupay:latest(>= e7a8dd9)
|
||||
#
|
||||
# 用法:
|
||||
# echo "DB_ROOT_PASSWORD=$(openssl rand -base64 24 | tr -d '/+=')" > .env
|
||||
# echo "DB_PASSWORD=$(openssl rand -base64 24 | tr -d '/+=')" >> .env
|
||||
# docker login git.viaeon.com
|
||||
# docker compose -f docker-compose.mysql.yml up -d
|
||||
#
|
||||
# 关于共享:MySQL 服务名/容器名都叫 `mysql`,挂在 external 网络 `shared-db` 上,
|
||||
# 这样同机的其它容器也能用 `mysql:3306` 复用它(每个应用给独立库 + 独立账号)。
|
||||
# 没有这个网络就先建:docker network create shared-db
|
||||
# 如果你用 AcePanel 面板,把下面的 `shared-db` 换成 `acepanel-network` 即可
|
||||
# (那是面板自带的共享网络,面板创建的容器都在里面)。
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --character-set-server=utf8mb4
|
||||
- --collation-server=utf8mb4_unicode_ci
|
||||
- --default-time-zone=+08:00
|
||||
# 小机器(1~2G 内存)建议打开下面三行,省内存也省 CPU
|
||||
# - --innodb-buffer-pool-size=256M
|
||||
# - --performance-schema=OFF
|
||||
# - --disable-log-bin
|
||||
# - --slow-query-log=ON # 慢查询落 ./mysqldata/<host>-slow.log
|
||||
# - --long-query-time=1
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:?先把 DB_ROOT_PASSWORD 写进 .env}
|
||||
MYSQL_DATABASE: vupay
|
||||
MYSQL_USER: vupay
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD:?先把 DB_PASSWORD 写进 .env}
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- ./mysqldata:/var/lib/mysql
|
||||
ports:
|
||||
# 只绑本机:宿主机命令行 / SSH 隧道能用,公网访问不到
|
||||
- "127.0.0.1:3306:3306"
|
||||
networks:
|
||||
- shared-db
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-u", "root", "-p$${DB_ROOT_PASSWORD}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
vupay:
|
||||
image: git.viaeon.com/admin/vupay:latest
|
||||
container_name: vupay
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
networks:
|
||||
- shared-db
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
LISTEN: ":8080"
|
||||
LOG: /var/log/vupay/
|
||||
# DSN 三个参数别省:charset=utf8mb4(中文)、parseTime=True(时间列)、loc=Local(时区)
|
||||
# host 用服务名 mysql(同类容器里写 127.0.0.1 会指向容器自身)
|
||||
MYSQL_DSN: vupay:${DB_PASSWORD}@tcp(mysql:3306)/vupay?charset=utf8mb4&parseTime=True&loc=Local&timeout=5s&readTimeout=10s&writeTimeout=10s
|
||||
volumes:
|
||||
- ./logs:/var/log/vupay
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
# 用面板(AcePanel)就把名字换成 acepanel-network,同样写 external: true
|
||||
shared-db:
|
||||
external: true
|
||||
@@ -0,0 +1,52 @@
|
||||
# VUPAY + PostgreSQL —— 生产推荐
|
||||
#
|
||||
# 说明:官方文档里那套 MySQL 写法是**过期的**(代码里已经没有任何 MySQL 分支),
|
||||
# 现在只支持 SQLite 和 PostgreSQL 两种。数据量大/要多实例就看这份。
|
||||
#
|
||||
# 用法:
|
||||
# echo "DB_PASSWORD=$(openssl rand -base64 24 | tr -d '/+=')" > .env
|
||||
# docker login git.viaeon.com
|
||||
# docker compose -f docker-compose.postgres.yml up -d
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:18-alpine
|
||||
container_name: vupay-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: vupay
|
||||
POSTGRES_USER: vupay
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:?先把 DB_PASSWORD 写进 .env}
|
||||
TZ: Asia/Shanghai
|
||||
volumes:
|
||||
- ./pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U vupay -d vupay"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
# 数据库不要暴露到公网
|
||||
expose:
|
||||
- "5432"
|
||||
|
||||
vupay:
|
||||
image: git.viaeon.com/admin/vupay:latest
|
||||
container_name: vupay
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
LISTEN: ":8080"
|
||||
LOG: /var/log/vupay/
|
||||
POSTGRESQL_DSN: postgres://vupay:${DB_PASSWORD}@db:5432/vupay?sslmode=disable&connect_timeout=3&timezone=Asia/Shanghai
|
||||
volumes:
|
||||
- ./logs:/var/log/vupay
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
+16
-5
@@ -21,11 +21,16 @@ COPY --from=web_builder /web/dist ./static/secure
|
||||
|
||||
ARG VERSION=unknown
|
||||
|
||||
RUN set -x \
|
||||
# 编译缓存 + 并行度限制:
|
||||
# - cache mount 让依赖只编一次,之后每次提交只重编 main 包(原来每次都全量重编)
|
||||
# - -p 4 把 go 的并行编译进程数钉死在 4,构建期间留一半核给同机的生产服务
|
||||
RUN --mount=type=cache,target=/go/pkg/mod \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
set -x \
|
||||
&& MODULE_PATH=$(go list -m) \
|
||||
&& CGO_ENABLED=0 go build -trimpath \
|
||||
&& CGO_ENABLED=0 go build -trimpath -p 4 \
|
||||
-ldflags="-X '${MODULE_PATH}/app.Version=${VERSION}' -s -w -buildid=" \
|
||||
-o bepusdt ./main
|
||||
-o vupay ./main
|
||||
|
||||
FROM alpine:3.20
|
||||
|
||||
@@ -34,11 +39,17 @@ ENV TZ=Asia/Shanghai
|
||||
# 安装所需的依赖
|
||||
RUN apk add --no-cache tzdata ca-certificates
|
||||
|
||||
COPY --from=builder /go/release/bepusdt /usr/local/bin/bepusdt
|
||||
# 补充根证书:Let's Encrypt 的 "ISRG Root YE"(2025 起签发的新根)
|
||||
# alpine/debian 的 ca-certificates 包里还没有它,缺了会导致对使用新根签发的站点
|
||||
# 发 HTTPS 回调时 TLS 校验失败(错误形如 x509: certificate signed by unknown authority)。
|
||||
COPY ca/ /usr/local/share/ca-certificates/
|
||||
RUN update-ca-certificates
|
||||
|
||||
COPY --from=builder /go/release/vupay /usr/local/bin/vupay
|
||||
|
||||
# 设置时区
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["bepusdt"]
|
||||
ENTRYPOINT ["vupay"]
|
||||
CMD ["start"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 1Panel 部署 BEpusdt 完整指南
|
||||
# 1Panel 部署 VUPAY 完整指南
|
||||
|
||||
> 📋 **前置条件**:本教程假定您已成功安装并配置好 1Panel 面板。
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
| 配置项 | 说明 |
|
||||
|----------|-----------------------------------------------------------------------------------------|
|
||||
| **镜像选择** | • **正式版**:`v03413/bepusdt:latest`(推荐生产环境)<br>• **开发版**:`v03413/bepusdt:nightly`(体验最新特性) |
|
||||
| **镜像选择** | • **正式版**:`admin/vupay:latest`(推荐生产环境)<br>• **开发版**:`admin/vupay:nightly`(体验最新特性) |
|
||||
| **端口映射** | • **本机访问**:`127.0.0.1:8080:8080`(推荐配合反向代理)<br>• **外网暴露**:`8080:8080`(不推荐,存在安全隐患) |
|
||||
|
||||
> ⚠️ **安全建议**:为确保服务安全,建议使用 `127.0.0.1` 绑定本地端口,再通过反向代理对外提供服务。
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
## 验证部署
|
||||
|
||||
配置完成后,通过浏览器访问您的域名,应能正常访问 BEpusdt 服务。
|
||||
配置完成后,通过浏览器访问您的域名,应能正常访问 VUPAY 服务。
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# 异次元发卡 BEpusdt 对接
|
||||
# 异次元发卡 VUPAY 对接
|
||||
|
||||
当前异次元官方应用商店里面已经上架了支付插件`BEpusdt`,直接在商店搜索安装使用即可。
|
||||
当前异次元官方应用商店里面已经上架了支付插件`VUPAY`,直接在商店搜索安装使用即可。
|
||||
+9
-9
@@ -3,7 +3,7 @@
|
||||
> 📡 **MQTT 实时推送**:系统支持将扫描到的链上交易广播到 MQTT 服务器,其它系统通过订阅即可实时获取数据,无需轮询
|
||||
> API。详见 [《MQTT 对接开发文档》](./mqtt.md)。
|
||||
|
||||
> 💡 **推荐阅读**:在开始对接前,建议先阅读 [《BEpusdt 执行原理说明》](./how-it-works.md)
|
||||
> 💡 **推荐阅读**:在开始对接前,建议先阅读 [《VUPAY 执行原理说明》](./how-it-works.md)
|
||||
> ,了解订单匹配机制、金额匹配模式与汇率浮动等核心原理,有助于更准确地理解本文档中的参数设计。
|
||||
|
||||
### 基础信息
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
> **两种订单模式说明**
|
||||
>
|
||||
> BEpusdt 的订单创建接口支持两种工作模式,通过 `amount` 参数决定:
|
||||
> VUPAY 的订单创建接口支持两种工作模式,通过 `amount` 参数决定:
|
||||
>
|
||||
> | 模式 | 触发条件 | 地址分配 | 匹配规则 | 典型场景 |
|
||||
> |------|---------|---------|---------|---------|
|
||||
@@ -449,7 +449,7 @@ POST /api/v1/pay/methods
|
||||
}
|
||||
```
|
||||
|
||||
假设 API Token 为:`epusdt_password_xasddawqe`
|
||||
假设 API Token 为:`vupay_password_xasddawqe`
|
||||
|
||||
**步骤 1:排序拼接**
|
||||
|
||||
@@ -460,7 +460,7 @@ amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&redire
|
||||
**步骤 2:追加 Token 并加密**
|
||||
|
||||
```text
|
||||
MD5(amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&redirect_url=http://example.com/redirectepusdt_password_xasddawqe)
|
||||
MD5(amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&redirect_url=http://example.com/redirectvupay_password_xasddawqe)
|
||||
```
|
||||
|
||||
**最终签名**:`1cd4b52df5587cfb1968b0c0c6e156cd`
|
||||
@@ -468,8 +468,8 @@ MD5(amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&re
|
||||
### 代码参考
|
||||
|
||||
- **PHP 实现
|
||||
**:[点击查看](https://github.com/v03413/Epay-BEpusdt/blob/b7fa8fd608d71ce50e0f8eabb1717783c96761ac/bepusdt_plugin.php#L108:L127)
|
||||
- **Python 实现**:[BEpusdt Python SDK](https://github.com/luoyanglang/bepusdt-python-sdk)
|
||||
**:[点击查看](https://github.com/v03413/Epay-VUPAY/blob/b7fa8fd608d71ce50e0f8eabb1717783c96761ac/vupay_plugin.php#L108:L127)
|
||||
- **Python 实现**:[VUPAY Python SDK](https://github.com/luoyanglang/vupay-python-sdk)
|
||||
|
||||
### 签名规则总结
|
||||
|
||||
@@ -533,6 +533,6 @@ MD5(amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&re
|
||||
|
||||
- [交易类型完整列表](../trade-type.md)
|
||||
- [订单回调通知](../notify/readme.md)
|
||||
- [易支付对接插件](https://github.com/v03413/Epay-BEpusdt)
|
||||
- [Python SDK](https://github.com/luoyanglang/bepusdt-python-sdk)
|
||||
- [原项目参考](https://github.com/assimon/epusdt/blob/master/wiki/API.md)
|
||||
- [易支付对接插件](https://github.com/v03413/Epay-VUPAY)
|
||||
- [Python SDK](https://github.com/luoyanglang/vupay-python-sdk)
|
||||
- [原项目参考](https://github.com/assimon/vupay/blob/master/wiki/API.md)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# DuJiao Next 对接 BEpusdt 集成指南
|
||||
# DuJiao Next 对接 VUPAY 集成指南
|
||||
|
||||
**当前教程针对的是新版独角 [Dujiao Next](https://dujiao-next.com/),旧版独角数卡对接[请看这个](../dujiaoka/dujiaoka.md)**
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
在开始配置前,请确保已满足以下条件:
|
||||
|
||||
**BEpusdt 部署信息**
|
||||
**VUPAY 部署信息**
|
||||
|
||||
- API 服务地址:`https://your-bepusdt.com`
|
||||
- API 服务地址:`https://your-vupay.com`
|
||||
- API 密钥:`your_api_token`
|
||||
|
||||
**DuJiao Next 部署信息**
|
||||
@@ -19,16 +19,16 @@
|
||||
|
||||
## 配置步骤
|
||||
|
||||
在 DuJiao Next 后台中选择渠道类型为 BEpusdt,按照以下格式进行配置。
|
||||
在 DuJiao Next 后台中选择渠道类型为 VUPAY,按照以下格式进行配置。
|
||||
|
||||

|
||||

|
||||
|
||||
**必填配置项**
|
||||
|
||||
| 配置项 | 说明 | 示例 |
|
||||
|-----------|--------------------|----------------------------------------------------|
|
||||
| 网关地址 | BEpusdt 的 API 服务地址 | `https://your-bepusdt.com` |
|
||||
| API Token | BEpusdt 的 API 密钥 | `your_api_token` |
|
||||
| 网关地址 | VUPAY 的 API 服务地址 | `https://your-vupay.com` |
|
||||
| API Token | VUPAY 的 API 密钥 | `your_api_token` |
|
||||
| 支付币种 | 支持的加密资产类型,严格区分大小写 | `usdt.trc20` |
|
||||
| 法币类型 | 支持的法定货币类型 | `CNY`、`USD`、`EUR`、`JPY`、`GBP` |
|
||||
| 异步通知地址 | 交易完成时的服务器异步回调地址 | `https://your-dujiao.com/api/v1/payments/callback` |
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
**配置说明**
|
||||
|
||||
- **支付币种**:详见 [支持的币种列表](https://github.com/v03413/BEpusdt/blob/main/docs/trade-type.md),必须严格区分大小写。
|
||||
- **支付币种**:详见 [支持的币种列表](https://git.viaeon.com/admin/vupay/blob/main/docs/trade-type.md),必须严格区分大小写。
|
||||
- **法币类型**:仅支持 `CNY`、`USD`、`EUR`、`JPY`、`GBP` 五种,必须严格区分大小写。
|
||||
|
||||
**⚠️ 重要说明:异步通知地址和同步回跳地址**
|
||||
@@ -62,6 +62,6 @@
|
||||
|
||||
若出现网关错误提示,请按照以下步骤排查:
|
||||
|
||||
- **检查网络连通性**:确认 DuJiao Next API 所在服务器能够正常访问 BEpusdt API 地址。
|
||||
- **检查 API Token**:确认所配置的 API Token 与 BEpusdt 中的密钥一致。
|
||||
- **查看日志**:检查 DuJiao Next 和 BEpusdt 的应用日志,获取更详细的错误信息。
|
||||
- **检查网络连通性**:确认 DuJiao Next API 所在服务器能够正常访问 VUPAY API 地址。
|
||||
- **检查 API Token**:确认所配置的 API Token 与 VUPAY 中的密钥一致。
|
||||
- **查看日志**:检查 DuJiao Next 和 VUPAY 的应用日志,获取更详细的错误信息。
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
## 重要提示
|
||||
|
||||
由于新版 `BEpusdt` 支持多区块链 USDT、超时回调等新特性,独角数卡自带的 `Epusdt` 插件已无法兼容,**必须替换原有插件**。
|
||||
由于新版 `VUPAY` 支持多区块链 USDT、超时回调等新特性,独角数卡自带的 `Vupay` 插件已无法兼容,**必须替换原有插件**。
|
||||
|
||||
> ⚠️ **重要警告**
|
||||
>
|
||||
> 独角数卡自带的 `Epusdt` 插件无法直接使用,强行使用必定出现问题!
|
||||
> 独角数卡自带的 `Vupay` 插件无法直接使用,强行使用必定出现问题!
|
||||
|
||||
## 插件替换说明
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
|
||||
下载更新后的控制器文件:
|
||||
```
|
||||
https://raw.githubusercontent.com/v03413/dujiaoka/refs/heads/master/app/Http/Controllers/Pay/EpusdtController.php
|
||||
https://raw.githubusercontent.com/v03413/dujiaoka/refs/heads/master/app/Http/Controllers/Pay/VupayController.php
|
||||
```
|
||||
|
||||
2. **替换原有文件**
|
||||
|
||||
将下载的文件替换到独角数卡网站目录:
|
||||
```
|
||||
app/Http/Controllers/Pay/EpusdtController.php
|
||||
app/Http/Controllers/Pay/VupayController.php
|
||||
```
|
||||
|
||||
## 配置步骤
|
||||
|
||||
确保 `BEpusdt` 已成功安装并运行后,按照以下步骤配置:
|
||||
确保 `VUPAY` 已成功安装并运行后,按照以下步骤配置:
|
||||
|
||||
### 1. 进入支付配置
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
|
||||
| 参数名称 | 填写内容 | 说明 |
|
||||
|------------|-----------------------------------------------------------|---------------------------------------------------------------------------|
|
||||
| **商户ID** | 与 `BEpusdt` 中 `AUTH_TOKEN` 参数保持一致 | 用于身份验证 |
|
||||
| **商户ID** | 与 `VUPAY` 中 `AUTH_TOKEN` 参数保持一致 | 用于身份验证 |
|
||||
| **支付标识** | 收款交易类型 | 可选值:`tron.trx`、`usdt.trc20`、`usdt.erc20` 等<br/>[完整列表参考](../../trade-type.md) |
|
||||
| **商户密钥** | `https://your-domain.com/api/v1/order/create-transaction` | ⚠️ 请将 `your-domain.com` 替换为实际域名 |
|
||||
| **支付处理路由** | `pay/epusdt` | 固定值,无需修改 |
|
||||
| **支付处理路由** | `pay/vupay` | 固定值,无需修改 |
|
||||
|
||||
### 3. 完成配置
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
## 常见问题
|
||||
|
||||
- 如果遇到支付失败,请检查 `BEpusdt` 服务是否正常运行
|
||||
- 如果遇到支付失败,请检查 `VUPAY` 服务是否正常运行
|
||||
- 确认商户密钥中的域名是否正确配置
|
||||
- 验证 `AUTH_TOKEN` 是否与独角数卡中的商户ID一致
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
# EdgeKey 对接 BEpusdt 教程
|
||||
# EdgeKey 对接 VUPAY 教程
|
||||
|
||||
**当前教程对接BEpusdt(v1.23.5)通过测试验收**
|
||||
**当前教程对接VUPAY(v1.23.5)通过测试验收**
|
||||
|
||||
## 配置步骤
|
||||
|
||||
**配置说明**
|
||||
|
||||
- **网关地址**:只需填写域名,如 `https://test.shop.com`,系统会自动拼接 API 路径(`/api/v1/order/create-order`)。
|
||||
- **App ID 和 App Secret**:在 BEpusdt 后台「系统管理 → 基本设置 → API 设置」中获取。
|
||||
- **支付币种**:用户在 BEpusdt 收银台页面自由选择支付币种,具体在 BEpusdt 后台配置。
|
||||
- **App ID 和 App Secret**:在 VUPAY 后台「系统管理 → 基本设置 → API 设置」中获取。
|
||||
- **支付币种**:用户在 VUPAY 收银台页面自由选择支付币种,具体在 VUPAY 后台配置。
|
||||
|
||||
**配置步骤示例**:
|
||||
1. 登录 EdgeKey 管理后台
|
||||
2. 进入「支付配置」页面
|
||||
3. 选择 BEpusdt 标签页
|
||||
3. 选择 VUPAY 标签页
|
||||
4. 填写具体配置
|
||||
5. 启用支付方式:点击右上角的启用开关
|
||||
6. 保存配置:点击「保存配置」按钮
|
||||
@@ -34,18 +34,18 @@
|
||||
- **Notify URL**:异步通知地址,支付完成后系统会回调此地址
|
||||
- **Return URL**:同步回跳地址,用户支付完成后跳转的页面
|
||||
|
||||
**BEpusdt专用字段**:
|
||||
- **App ID**:BEpusdt后台获取的应用ID
|
||||
- **App Secret**:BEpusdt后台获取的应用密钥(API密钥)
|
||||
**VUPAY专用字段**:
|
||||
- **App ID**:VUPAY后台获取的应用ID
|
||||
- **App Secret**:VUPAY后台获取的应用密钥(API密钥)
|
||||
|
||||
|
||||
## 异步通知地址和同步回跳地址
|
||||
|
||||
这两个地址的路由部分 **严格按要求填写**,只需将域名部分替换为您实际部署的 EdgeKey 服务器地址:
|
||||
|
||||
- **异步通知地址**:`/api/payments/bepusdt/notify`
|
||||
- 路由固定为 `/api/payments/bepusdt/notify`
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `/api/payments/bepusdt/notify`
|
||||
- **异步通知地址**:`/api/payments/vupay/notify`
|
||||
- 路由固定为 `/api/payments/vupay/notify`
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `/api/payments/vupay/notify`
|
||||
|
||||
- **同步回跳地址**:`/order/{orderNo}?token={token}`
|
||||
- 路由固定为 `/order/{orderNo}?token={token}`(`:orderNo` 和 `{token}` 为动态参数)
|
||||
@@ -56,24 +56,24 @@
|
||||
配置完成后,请按照以下步骤进行测试:
|
||||
|
||||
1. 进入 EdgeKey 前台,选择一个商品进行购买。
|
||||
2. 在结算页面选择 BEpusdt 支付方式。
|
||||
2. 在结算页面选择 VUPAY 支付方式。
|
||||
3. 观察是否正常跳转到收银台页面。
|
||||
|
||||
## 故障排查
|
||||
|
||||
若出现网关错误提示,请按照以下步骤排查:
|
||||
|
||||
- **检查网络连通性**:确认 EdgeKey 服务器能够正常访问 BEpusdt API 地址。
|
||||
- **检查 App ID 和 App Secret**:确认所配置的 App ID 和 App Secret 与 BEpusdt 中的一致。
|
||||
- **检查网络连通性**:确认 EdgeKey 服务器能够正常访问 VUPAY API 地址。
|
||||
- **检查 App ID 和 App Secret**:确认所配置的 App ID 和 App Secret 与 VUPAY 中的一致。
|
||||
- **检查回调地址**:确保异步通知地址可以从外部访问,且格式正确。
|
||||
- **检查站点设置**:确保在「站点设置」中配置了正确的网站地址。
|
||||
- **查看日志**:检查 EdgeKey 和 BEpusdt 的应用日志,获取更详细的错误信息。
|
||||
- **查看日志**:检查 EdgeKey 和 VUPAY 的应用日志,获取更详细的错误信息。
|
||||
|
||||
## BEpusdt 工作模式
|
||||
## VUPAY 工作模式
|
||||
|
||||
本项目使用 **收银台模式**(`/api/v1/order/create-order`),用户在 BEpusdt 收银台页面自由选择支付链,无需在代码中指定 `trade_type`。
|
||||
本项目使用 **收银台模式**(`/api/v1/order/create-order`),用户在 VUPAY 收银台页面自由选择支付链,无需在代码中指定 `trade_type`。
|
||||
|
||||
## 相关链接
|
||||
|
||||
- [BEpusdt 项目主页](https://github.com/v03413/bepusdt)
|
||||
- [VUPAY 项目主页](https://git.viaeon.com/admin/vupay)
|
||||
- [EdgeKey 项目主页](https://github.com/34892002/edgeKey)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user