Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b321da7bba | ||
|
|
fc86061ecc | ||
|
|
62fc6947b8 | ||
|
|
efd1ce348a | ||
|
|
43c579198a | ||
|
|
e180b52c9a | ||
|
|
3ca46e7fb9 | ||
|
|
8076cd4b75 | ||
|
|
e5e847f18f | ||
|
|
54e73e48e4 | ||
|
|
451da12e09 | ||
|
|
06694a92e8 | ||
|
|
6bf42ddc1b | ||
|
|
1f92306b03 | ||
|
|
096cb9523a | ||
|
|
79982c935f | ||
|
|
d1beeafbe8 | ||
|
|
3ebfdb424c | ||
|
|
95503b75fd | ||
|
|
7ef226b722 | ||
|
|
3639dad003 | ||
|
|
bd50f293b4 | ||
|
|
482bbf92e2 | ||
|
|
275a2a3d22 | ||
|
|
cec21fa0a7 | ||
|
|
4ce3c9b2f6 | ||
|
|
a6381c4aac | ||
|
|
1e5896ac96 | ||
|
|
6ac02a9214 | ||
|
|
827bc48c1d | ||
|
|
36907635b6 | ||
|
|
aafbac7b7b | ||
|
|
5120f193cb | ||
|
|
befc24487d | ||
|
|
3203c5d9e5 | ||
|
|
7eddf82957 | ||
|
|
af023b085f | ||
|
|
11ceb32773 | ||
|
|
f6e6d485dd | ||
|
|
74ed3fdc91 | ||
|
|
2edf26857e | ||
|
|
ff2989bc18 | ||
|
|
13d3fad174 | ||
|
|
5e598cd2f3 | ||
|
|
c350868195 | ||
|
|
d458ef7ca3 | ||
|
|
8033ccfe93 | ||
|
|
10257024ca | ||
|
|
96d0b5f6c1 | ||
|
|
9ac18ade71 | ||
|
|
f4bdee12e1 | ||
|
|
1e52f40a6c | ||
|
|
24372a9639 | ||
|
|
f28ae2aa8d | ||
|
|
54eb29756a | ||
|
|
2bf1406566 | ||
|
|
46af120fd7 | ||
|
|
11592ded0b | ||
|
|
94440de2d3 | ||
|
|
68b42a098d | ||
|
|
ea113e6e90 | ||
|
|
9981df3839 | ||
|
|
68f59eba48 | ||
|
|
c659103e02 | ||
|
|
db2b5e32b6 | ||
|
|
041f7e9cef | ||
|
|
1e52ee2d44 | ||
|
|
97565fb490 | ||
|
|
1e68d067af | ||
|
|
82caa97e3b | ||
|
|
eeb7ac1f79 | ||
|
|
468fe8b0c2 | ||
|
|
48b7c0b414 | ||
|
|
c8304a05cd | ||
|
|
34127df014 | ||
|
|
f4a225baea | ||
|
|
126905400d | ||
|
|
89bd4caba4 | ||
|
|
c84ca4ab30 | ||
|
|
3be13ebb6f | ||
|
|
584998bf02 | ||
|
|
f14a7680af | ||
|
|
cd6994d611 | ||
|
|
64ab143e0e | ||
|
|
8525dd4722 | ||
|
|
90e672f7f8 | ||
|
|
cb5aed93c6 | ||
|
|
e46706370c | ||
|
|
34e7dc6b81 | ||
|
|
5a0d333f71 | ||
|
|
9f89015722 | ||
|
|
609a850e61 | ||
|
|
43614ee3c5 | ||
|
|
a603e201c1 | ||
|
|
4081e7e5ab | ||
|
|
17b0d1cad1 | ||
|
|
742d05d253 | ||
|
|
1b0df627a5 | ||
|
|
94ba4b7c5b | ||
|
|
14644e00a5 | ||
|
|
be2ef02923 | ||
|
|
6ccd93a161 |
@@ -7,8 +7,5 @@ LOG=/var/log/bepusdt/
|
||||
# SQLite 数据库文件路径(如果使用 MySQL,此项可忽略)
|
||||
SQLITE=/var/lib/bepusdt/sqlite.db
|
||||
|
||||
# MySQL 数据库
|
||||
# MYSQL_DSN=user:password@tcp(127.0.0.1:3306)/bepusdt?charset=utf8mb4&parseTime=True&loc=Local&timeout=3s&readTimeout=10s&writeTimeout=10s
|
||||
|
||||
# PostgreSQL 数据库
|
||||
# POSTGRESQL_DSN=postgres://user:password@localhost:5432/bepusdt?sslmode=disable&connect_timeout=3
|
||||
# POSTGRESQL_DSN=postgres://user:password@localhost:5432/bepusdt?sslmode=disable&connect_timeout=3&timezone=Asia/Shanghai
|
||||
@@ -20,7 +20,7 @@ body:
|
||||
- label: 我明白任何人针对我提交的问题没有义务提供帮助,包括项目维护者。
|
||||
required: true
|
||||
- label: 我没有阅读这个清单,只是闭眼选中了所有的复选框,请关闭这个 Issue 。
|
||||
required: true
|
||||
required: false
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: 问题类型
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
name: pr-check
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
- ready_for_review
|
||||
concurrency:
|
||||
group: pr-check-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
permissions:
|
||||
contents: read
|
||||
env:
|
||||
APP_NAME: bepusdt
|
||||
jobs:
|
||||
docker-build:
|
||||
name: Docker Build
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Generate App Version
|
||||
run: |
|
||||
echo "APP_VERSION=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
|
||||
echo "VERSION_TAG=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Build Docker image (no push)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./dockerfile
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
load: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
VERSION=${{ env.VERSION_TAG }}
|
||||
tags: |
|
||||
${{ env.APP_NAME }}:pr-${{ github.event.pull_request.number }}
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
with:
|
||||
node-version: '25'
|
||||
- name: Install pnpm
|
||||
run: npm install -g pnpm
|
||||
run: npm install -g pnpm@10
|
||||
- name: Install frontend dependencies
|
||||
working-directory: ./web
|
||||
run: pnpm install --frozen-lockfile --shamefully-hoist
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.25.4'
|
||||
go-version: '1.26.2'
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
|
||||
@@ -7,4 +7,5 @@ conf.toml
|
||||
# Added by goreleaser init:
|
||||
dist/
|
||||
static/web
|
||||
*.log
|
||||
static/secure
|
||||
*.log
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# BEpusdt (Better Easy Payment USDT)
|
||||
|
||||
<p align="center">
|
||||
<img src="./static/payment/assets/img/tether.svg" width="15%" alt="tether">
|
||||
<img src="./static/checkout/official/assets/img/bepusdt.svg" width="15%" alt="tether">
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://www.gnu.org/licenses/gpl-3.0.html">
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
缘起于`Epusdt`,但不仅限于此,加入了一些新特性,致力于成为一款更好用的个人`加密货币`收款网关。
|
||||
|
||||
> 原始 EPusdt 项目已被转手,现与本项目再没任何联系、两个项目完全独立运营,[具体说明](./docs/faq/epusdt.md)。
|
||||
|
||||
## 🎉 新特性
|
||||
|
||||
### 🌟 目前支持收款网络
|
||||
@@ -42,13 +44,8 @@
|
||||
- ️✅ 支持主流区块网络 不仅限于`USDT`
|
||||
- ✅ 支持主流法定货币 汇率自动更新
|
||||
- ✅ 轻依赖 单体二进制文件 部署便捷
|
||||
- ✅ 支持非订单交易监控 余额变动通知
|
||||
- ✅ 支持自定义支付精度与递增颗粒度
|
||||
- ✅ 底层区块扫描 安全确认 速度稳定
|
||||
- ✅ 支持波场能量代理 回收实时监控
|
||||
- ✅ 原生兼容`易支付`收单 接入便捷
|
||||
- ✅ 完整独立WEB后台 方便配置管理
|
||||
- ✅ 收银台支持中英适配 助力出海需求
|
||||
- ✅ 地址独占模式 底层支持不定额收款
|
||||
- ✅ 支持MQTT消息发布 交易信息即时广播
|
||||
- ✅ 快速迭代期 超多实用特性功能等你发现
|
||||
@@ -64,14 +61,14 @@ docker run -d --restart=unless-stopped -p 8080:8080 v03413/bepusdt:latest
|
||||
|
||||
- 安装:[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)
|
||||
- 对接:[独角数卡](docs/api/dujiaoka/dujiaoka.md) [彩虹易支付](https://github.com/v03413/Epay-BEpusdt) [whmcs](https://github.com/v03413/whmcs-gateway-epusdt) [其它](docs/api/other.md)
|
||||
- 其它:[https 配置](./docs/ssl.md) [时钟同步](docs/linux/systemd-timesyncd.md) [收银台修改](docs/payment-template/README.md)
|
||||
- 对接:[独角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)
|
||||
- 其它:[https 配置](./docs/ssl.md) [时钟同步](docs/linux/systemd-timesyncd.md) [收银台修改](docs/checkout/README.md)
|
||||
|
||||
## 🖼 功能截图
|
||||
|
||||
| 前台收银 | 后台订单 | Telegram 通知 |
|
||||
|-------------------------------------------------|--------------------------------------------------|--------------------------------------------------------|
|
||||
| <img src=./docs/images/1.png alt=收银台 width=300> | <img src=./docs/images/2.png alt=后台订单 width=300> | <img src=./docs/images/3.png alt=Telegram通知 width=300> |
|
||||
| 前台收银 | 后台订单 | 订单通知 |
|
||||
|--------------------------------------------------------|------------------------------------------------------|---------------------------------------------------------------|
|
||||
| <img src=./docs/images/checkout.png alt=收银台 width=300> | <img src=./docs/images/admin.png alt=后台订单 width=300> | <img src=./docs/images/telegram.png alt=Telegram通知 width=300> |
|
||||
|
||||
## ❓ 常见问题
|
||||
|
||||
@@ -79,13 +76,7 @@ docker run -d --restart=unless-stopped -p 8080:8080 v03413/bepusdt:latest
|
||||
- [服务器流量消耗说明解释](./docs/faq/bandwidth.md)
|
||||
- [后台入口账密忘记重置教程](./docs/faq/login-reset.md)
|
||||
- [Telegram 通知 Chat ID 获取教程](docs/faq/telegram-chat-id.md)
|
||||
- [推荐配置提高 Tron 扫块稳定性‼️](./docs/tron-grid/readme.md)
|
||||
- [EVM RPC 节点稳定性说明指南‼️](./docs/faq/evm-rpc-endpoint.md)
|
||||
|
||||
## ⚠️ 重要提示
|
||||
|
||||
- **订单交易强依赖时间**:请确保服务器时间准确,否则可能导致订单异常
|
||||
- **网络环境要求**:请确保服务器网络环境稳定,否则可能影响功能正常运行
|
||||
- [区块 RPC 节点稳定性说明指南‼️](./docs/faq/rpc-endpoint.md)
|
||||
|
||||
## 🏝️ 社区交流
|
||||
|
||||
@@ -94,7 +85,15 @@ docker run -d --restart=unless-stopped -p 8080:8080 v03413/bepusdt:latest
|
||||
|
||||
## 🙏 致谢
|
||||
|
||||
- [Epusdt](https://github.com/assimon/epusdt)
|
||||
感谢原项目提供的灵感和参考:
|
||||
|
||||
- [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>
|
||||
|
||||
## 🌟 Star 历史
|
||||
|
||||
|
||||
@@ -9,13 +9,6 @@ var SQLiteFlag = &cli.StringFlag{
|
||||
Sources: cli.EnvVars("SQLITE"),
|
||||
}
|
||||
|
||||
var MySQLDSNFlag = &cli.StringFlag{
|
||||
Name: "mysql",
|
||||
Value: "",
|
||||
Usage: "MySQL 数据库连接字符串 (DSN),例如: user:password@tcp(127.0.0.1:3306)/bepusdt?charset=utf8mb4&parseTime=True&loc=Local&timeout=3s&readTimeout=10s&writeTimeout=10s",
|
||||
Sources: cli.EnvVars("MYSQL_DSN"),
|
||||
}
|
||||
|
||||
var PostgresDSNFlag = &cli.StringFlag{
|
||||
Name: "postgres",
|
||||
Value: "",
|
||||
|
||||
@@ -15,12 +15,11 @@ import (
|
||||
var Reset = &cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "忘记密码时,此命令可重置账号密码登录入口",
|
||||
Flags: []cli.Flag{SQLiteFlag, MySQLDSNFlag, PostgresDSNFlag},
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag},
|
||||
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
|
||||
mysql := c.String("mysql")
|
||||
postgres := c.String("postgres")
|
||||
sqlite := c.String("sqlite")
|
||||
if err := model.Init(sqlite, mysql, postgres); err != nil {
|
||||
postgres := c.String("postgres")
|
||||
if err := model.Init(sqlite, postgres); err != nil {
|
||||
return ctx, fmt.Errorf("数据库初始化失败 %w", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,11 @@ import (
|
||||
var Start = &cli.Command{
|
||||
Name: "start",
|
||||
Usage: "启动收款网关",
|
||||
Flags: []cli.Flag{SQLiteFlag, MySQLDSNFlag, PostgresDSNFlag, LogFlag, ListenFlag},
|
||||
Flags: []cli.Flag{SQLiteFlag, PostgresDSNFlag, LogFlag, ListenFlag},
|
||||
Before: func(ctx context.Context, c *cli.Command) (context.Context, error) {
|
||||
mysql := c.String("mysql")
|
||||
postgres := c.String("postgres")
|
||||
sqlite := c.String("sqlite")
|
||||
if err := model.Init(sqlite, mysql, postgres); err != nil {
|
||||
if err := model.Init(sqlite, postgres); err != nil {
|
||||
return ctx, fmt.Errorf("数据库初始化失败 %w", err)
|
||||
}
|
||||
|
||||
@@ -83,6 +82,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))
|
||||
|
||||
// 等待中断信号
|
||||
|
||||
@@ -8,6 +8,12 @@ const (
|
||||
const Debug = false
|
||||
|
||||
const (
|
||||
Pid = "1000" // 暂时固定易支付商户ID
|
||||
Api = "https://api.bepusdt.online"
|
||||
)
|
||||
|
||||
const (
|
||||
Ton = "ton" // The Open Network
|
||||
Bsc = "bsc" // Binance Smart Chain
|
||||
Tron = "tron"
|
||||
Aptos = "aptos"
|
||||
@@ -21,6 +27,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
UsdtTon = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"
|
||||
UsdtErc20 = "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||
UsdtBep20 = "0x55d398326f99059ff775485246999027b3197955"
|
||||
UsdtXlayer = "0x779ded0c9e1022225f8e0630b35a9b54be713736"
|
||||
@@ -50,6 +57,7 @@ const (
|
||||
UsdtArbitrumDecimals = -6 // USDT Arbitrum小数位数
|
||||
UsdtAptosDecimals = -6 // USDT Aptos小数位数
|
||||
UsdtSolanaDecimals = -6 // USDT Solana小数位数
|
||||
UsdtTonDecimals = -6 // USDT Ton小数位数
|
||||
|
||||
UsdcEthDecimals = -6 // USDC ERC20小数位数
|
||||
UsdcPolygonDecimals = -6 // USDC Polygon小数位数
|
||||
@@ -61,6 +69,7 @@ const (
|
||||
UsdcAptosDecimals = -6 // USDC Aptos小数位数
|
||||
UsdcSolanaDecimals = -6 // USDC Solana小数位数
|
||||
|
||||
TonTonDecimals = -9 // TON Ton小数位数
|
||||
BscBnbDecimals = -18 // BSC BNB 小数位数
|
||||
EthereumEthDecimals = -18 // Ethereum ETH 小数位数
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package conf
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const maxRecords = 1000
|
||||
@@ -15,8 +16,15 @@ type stat struct {
|
||||
succ int // 成功记录数
|
||||
}
|
||||
|
||||
type info struct {
|
||||
Block string `json:"block"`
|
||||
Succ string `json:"succ"`
|
||||
Time int64 `json:"time"`
|
||||
}
|
||||
|
||||
var (
|
||||
data sync.Map // map[string]*stat
|
||||
last sync.Map
|
||||
)
|
||||
|
||||
func getStat(net string) *stat {
|
||||
@@ -26,7 +34,8 @@ func getStat(net string) *stat {
|
||||
return val.(*stat)
|
||||
}
|
||||
|
||||
func RecordSuccess(net string) {
|
||||
func RecordSuccess(net, block string) {
|
||||
last.Store(net, info{Block: block, Succ: GetSuccessRate(net), Time: time.Now().Unix()})
|
||||
s := getStat(net)
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
@@ -60,6 +69,17 @@ func RecordFailure(net string) {
|
||||
}
|
||||
}
|
||||
|
||||
func GetStats() map[string]info {
|
||||
var m = make(map[string]info)
|
||||
last.Range(func(k, v interface{}) bool {
|
||||
m[k.(string)] = v.(info)
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GetSuccessRate(net string) string {
|
||||
s := getStat(net)
|
||||
s.mu.RLock()
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
type Api struct {
|
||||
api string
|
||||
}
|
||||
|
||||
func New() Api {
|
||||
return Api{
|
||||
api: conf.Api,
|
||||
}
|
||||
}
|
||||
|
||||
func (Api) get(url string) ([]byte, error) {
|
||||
client := &http.Client{Timeout: 5 * time.Second}
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("创建请求失败: %w", err)
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", fmt.Sprintf("BEpusdt/%s", app.Version))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("请求失败: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("读取响应失败: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New(gjson.GetBytes(body, "error").String())
|
||||
}
|
||||
|
||||
return body, nil
|
||||
}
|
||||
|
||||
func (Api) error(err error) {
|
||||
log.Warn("Api Error:", err.Error())
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type BoundaryResp struct {
|
||||
Start int64 `json:"start"`
|
||||
End int64 `json:"end"`
|
||||
}
|
||||
|
||||
func (a Api) GetBoundaryHeights(start, end int64, network string) (int64, int64) {
|
||||
url := fmt.Sprintf("%s/api/block/get_boundary_heights?network=%s&start=%d&end=%d",
|
||||
a.api, network, start, end)
|
||||
|
||||
body, err := a.get(url)
|
||||
if err != nil {
|
||||
a.error(err)
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
var response BoundaryResp
|
||||
if err := json.Unmarshal(body, &response); err != nil {
|
||||
a.error(err)
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
return response.Start, response.End
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"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"
|
||||
@@ -106,19 +107,6 @@ func (Conf) Sets(ctx *gin.Context) {
|
||||
data = append(data, model.Conf{K: model.ConfKey(k), V: v})
|
||||
}
|
||||
|
||||
for _, v := range data {
|
||||
if v.K == model.PaymentStaticPath && v.V != "" && !utils.IsExist(v.V) {
|
||||
base.BadRequest(ctx, "静态资源路径不存在,请确认后重新配置:"+v.V)
|
||||
|
||||
return
|
||||
}
|
||||
if v.K == model.ApiAuthToken {
|
||||
base.BadRequest(ctx, "安全考虑,不允许自定义修改 API 对接令牌")
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
model.Db.Where("k IN ?", keys).Delete(&model.Conf{})
|
||||
model.Db.Create(&data)
|
||||
|
||||
@@ -127,6 +115,35 @@ func (Conf) Sets(ctx *gin.Context) {
|
||||
base.Ok(ctx, "配置成功")
|
||||
}
|
||||
|
||||
func (Conf) Rpc(ctx *gin.Context) {
|
||||
var keys = []model.ConfKey{
|
||||
model.RpcEndpointPlasma,
|
||||
model.RpcEndpointBsc,
|
||||
model.RpcEndpointSolana,
|
||||
model.RpcEndpointXlayer,
|
||||
model.RpcEndpointPolygon,
|
||||
model.RpcEndpointArbitrum,
|
||||
model.RpcEndpointEthereum,
|
||||
model.RpcEndpointBase,
|
||||
model.RpcEndpointAptos,
|
||||
model.RpcEndpointTron,
|
||||
model.RpcEndpointTronGridApiKey,
|
||||
model.RpcGlobalConfigUrlTon,
|
||||
}
|
||||
|
||||
var rpc = make(map[model.ConfKey]string)
|
||||
var items = make([]model.Conf, 0)
|
||||
model.Db.Where("k IN ?", keys).Find(&items)
|
||||
for _, item := range items {
|
||||
rpc[item.K] = item.V
|
||||
}
|
||||
|
||||
base.Ok(ctx, gin.H{
|
||||
"rpc": rpc,
|
||||
"stats": conf.GetStats(),
|
||||
})
|
||||
}
|
||||
|
||||
func (Conf) Notifier(ctx *gin.Context) {
|
||||
var req notifierConf
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
@@ -156,6 +173,10 @@ func (Conf) NotifierTest(ctx *gin.Context) {
|
||||
base.Ok(ctx, "发送测试成功")
|
||||
}
|
||||
|
||||
func (Conf) CheckoutList(ctx *gin.Context) {
|
||||
base.Ok(ctx, model.CheckoutList())
|
||||
}
|
||||
|
||||
func (Conf) ResetApiAuthToken(ctx *gin.Context) {
|
||||
model.SetK(model.ApiAuthToken, strings.ToUpper(utils.Md5String(utils.StrSha256(time.Now().String()))))
|
||||
|
||||
|
||||
@@ -1,19 +1,37 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
type Dashboard struct {
|
||||
}
|
||||
|
||||
type homeReq struct {
|
||||
Fiat string `json:"fiat" binding:"required"`
|
||||
Fiat string `json:"fiat" binding:"required"`
|
||||
Range string `json:"range"`
|
||||
TZ string `json:"tz"`
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Force bool `json:"force"`
|
||||
}
|
||||
|
||||
type dashboardPoint struct {
|
||||
Date string `json:"date"`
|
||||
OrdersTotal int64 `json:"orders_total"`
|
||||
OrdersPaid int64 `json:"orders_paid"`
|
||||
OrdersSuccess int64 `json:"orders_success"`
|
||||
OrdersFailed int64 `json:"orders_failed"`
|
||||
GMVPaid string `json:"gmv_paid"`
|
||||
}
|
||||
|
||||
func (Dashboard) Home(ctx *gin.Context) {
|
||||
@@ -24,13 +42,33 @@ func (Dashboard) Home(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var rows = make([]model.Order, 0)
|
||||
model.Db.Where("fiat = ? and status = ?", req.Fiat, model.OrderStatusSuccess).Find(&rows)
|
||||
rangeKey, from, to, loc, err := resolveDashboardRange(req)
|
||||
if err != nil {
|
||||
base.BadRequest(ctx, err.Error())
|
||||
|
||||
var today = time.Now().Format("2006-01-02")
|
||||
var totalMoney, todayMoney float64
|
||||
var totalCount, todayCount int64
|
||||
var monthly = make(map[string]float64)
|
||||
return
|
||||
}
|
||||
|
||||
cacheKey := dashboardCacheKey(req.Fiat, rangeKey, loc.String(), from, to)
|
||||
if !req.Force {
|
||||
if data, ok := cache.Get(cacheKey); ok {
|
||||
base.Ok(ctx, data)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
data := buildDashboardHome(req, rangeKey, from, to, loc)
|
||||
cache.Set(cacheKey, data, dashboardCacheTTL(rangeKey, to, loc))
|
||||
base.Ok(ctx, data)
|
||||
}
|
||||
|
||||
func buildDashboardHome(req homeReq, rangeKey string, from, to time.Time, loc *time.Location) gin.H {
|
||||
var rows = make([]model.Order, 0)
|
||||
model.Db.Where("fiat = ? and created_at >= ? and created_at <= ?", req.Fiat, from, to).Find(&rows)
|
||||
|
||||
var totalCount, pendingCount, confirmingCount, successCount, expiredCount, failedCount, notifyFailedCount int64
|
||||
gmvPaid := decimal.Zero
|
||||
var tokenMap = map[model.Crypto]float64{
|
||||
model.USDT: 0,
|
||||
model.USDC: 0,
|
||||
@@ -38,38 +76,198 @@ func (Dashboard) Home(ctx *gin.Context) {
|
||||
model.BNB: 0,
|
||||
model.ETH: 0,
|
||||
}
|
||||
points := make([]dashboardPoint, 0)
|
||||
pointMap := make(map[string]int)
|
||||
for day := dayStart(from, loc); !day.After(dayStart(to, loc)); day = day.AddDate(0, 0, 1) {
|
||||
date := day.Format("2006-01-02")
|
||||
point := dashboardPoint{
|
||||
Date: date,
|
||||
GMVPaid: "0.00",
|
||||
}
|
||||
points = append(points, point)
|
||||
pointMap[date] = len(points) - 1
|
||||
}
|
||||
|
||||
for _, itm := range rows {
|
||||
money := cast.ToFloat64(itm.Money)
|
||||
|
||||
totalMoney += money
|
||||
totalCount++
|
||||
if itm.CreatedAt.Format("2006-01-02") == today {
|
||||
todayMoney += money
|
||||
todayCount++
|
||||
createdAt := time.Now().In(loc)
|
||||
if itm.CreatedAt != nil {
|
||||
createdAt = time.Time(*itm.CreatedAt).In(loc)
|
||||
}
|
||||
date := createdAt.Format("2006-01-02")
|
||||
pointIndex, ok := pointMap[date]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
point := &points[pointIndex]
|
||||
|
||||
if crypto, err := model.GetCrypto(itm.TradeType); err == nil {
|
||||
point.OrdersTotal++
|
||||
|
||||
switch itm.Status {
|
||||
case model.OrderStatusWaiting:
|
||||
pendingCount++
|
||||
case model.OrderStatusConfirming:
|
||||
confirmingCount++
|
||||
case model.OrderStatusExpired:
|
||||
expiredCount++
|
||||
case model.OrderStatusSuccess:
|
||||
successCount++
|
||||
point.OrdersSuccess++
|
||||
point.OrdersPaid++
|
||||
|
||||
money, _ := decimal.NewFromString(itm.Money)
|
||||
gmvPaid = gmvPaid.Add(money)
|
||||
pointMoney, _ := decimal.NewFromString(point.GMVPaid)
|
||||
point.GMVPaid = pointMoney.Add(money).Round(2).StringFixed(2)
|
||||
|
||||
crypto := itm.Crypto
|
||||
if crypto == "" {
|
||||
if tradeCrypto, err := model.GetCrypto(itm.TradeType); err == nil {
|
||||
crypto = tradeCrypto
|
||||
}
|
||||
}
|
||||
if _, ok := tokenMap[crypto]; !ok {
|
||||
tokenMap[crypto] = 0
|
||||
}
|
||||
tokenAmount := cast.ToFloat64(itm.Amount)
|
||||
if tokenAmount == 0 {
|
||||
tokenAmount = cast.ToFloat64(itm.Money)
|
||||
}
|
||||
tokenMap[crypto] += tokenAmount
|
||||
|
||||
tokenMap[crypto] += money
|
||||
if itm.NotifyState == model.OrderNotifyStateFail {
|
||||
notifyFailedCount++
|
||||
}
|
||||
case model.OrderStatusFailed:
|
||||
failedCount++
|
||||
point.OrdersFailed++
|
||||
}
|
||||
|
||||
var month = itm.CreatedAt.Time().Format("2006/01")
|
||||
if _, ok := monthly[month]; !ok {
|
||||
monthly[month] = 0
|
||||
}
|
||||
monthly[month] += money
|
||||
}
|
||||
|
||||
base.Ok(ctx, gin.H{
|
||||
"total_money": totalMoney,
|
||||
"total_count": totalCount,
|
||||
"today_money": todayMoney,
|
||||
"today_count": todayCount,
|
||||
"token_map": tokenMap,
|
||||
"monthly": monthly,
|
||||
})
|
||||
successRate := "0.00"
|
||||
finishedCount := successCount + expiredCount + failedCount
|
||||
if finishedCount > 0 {
|
||||
rate := decimal.NewFromInt(successCount).Div(decimal.NewFromInt(finishedCount)).Mul(decimal.NewFromInt(100))
|
||||
successRate = rate.Round(2).StringFixed(2)
|
||||
}
|
||||
|
||||
return gin.H{
|
||||
"range": rangeKey,
|
||||
"from": from.In(loc).Format(time.RFC3339),
|
||||
"to": to.In(loc).Format(time.RFC3339),
|
||||
"timezone": loc.String(),
|
||||
"currency": req.Fiat,
|
||||
"kpi": gin.H{
|
||||
"orders_total": totalCount,
|
||||
"orders_pending": pendingCount,
|
||||
"orders_confirming": confirmingCount,
|
||||
"gmv_paid": gmvPaid.Round(2).StringFixed(2),
|
||||
"orders_success": successCount,
|
||||
"orders_failed": failedCount,
|
||||
"notify_failed": notifyFailedCount,
|
||||
"order_success_rate": successRate,
|
||||
},
|
||||
"token_map": tokenMap,
|
||||
"points": points,
|
||||
}
|
||||
}
|
||||
|
||||
func dashboardCacheKey(fiat, rangeKey, timezone string, from, to time.Time) string {
|
||||
return fmt.Sprintf("dashboard:home:v1:%s:%s:%s:%d:%d", fiat, rangeKey, timezone, from.Unix(), to.Unix())
|
||||
}
|
||||
|
||||
func dashboardCacheTTL(rangeKey string, to time.Time, loc *time.Location) time.Duration {
|
||||
switch rangeKey {
|
||||
case "today":
|
||||
return 10 * time.Second
|
||||
case "30d":
|
||||
return time.Minute
|
||||
case "custom":
|
||||
if to.Before(dayStart(time.Now().In(loc), loc)) {
|
||||
return 5 * time.Minute
|
||||
}
|
||||
|
||||
return 30 * time.Second
|
||||
default:
|
||||
return 30 * time.Second
|
||||
}
|
||||
}
|
||||
|
||||
func resolveDashboardRange(req homeReq) (string, time.Time, time.Time, *time.Location, error) {
|
||||
loc := time.Local
|
||||
if req.TZ != "" {
|
||||
if loadedLoc, err := time.LoadLocation(req.TZ); err == nil {
|
||||
loc = loadedLoc
|
||||
}
|
||||
}
|
||||
|
||||
rangeKey := req.Range
|
||||
if rangeKey == "" {
|
||||
rangeKey = "7d"
|
||||
}
|
||||
|
||||
now := time.Now().In(loc)
|
||||
switch rangeKey {
|
||||
case "today":
|
||||
start := dayStart(now, loc)
|
||||
return rangeKey, start, dayEnd(start), loc, nil
|
||||
case "30d":
|
||||
yesterday := dayStart(now, loc).AddDate(0, 0, -1)
|
||||
start := yesterday.AddDate(0, 0, -29)
|
||||
return rangeKey, start, dayEnd(yesterday), loc, nil
|
||||
case "custom":
|
||||
from, err := parseDashboardDate(req.From, loc, true)
|
||||
if err != nil {
|
||||
return "", time.Time{}, time.Time{}, nil, err
|
||||
}
|
||||
to, err := parseDashboardDate(req.To, loc, false)
|
||||
if err != nil {
|
||||
return "", time.Time{}, time.Time{}, nil, err
|
||||
}
|
||||
if to.Before(from) {
|
||||
return "", time.Time{}, time.Time{}, nil, errors.New("自定义统计周期结束时间不能早于开始时间")
|
||||
}
|
||||
|
||||
return rangeKey, from, to, loc, nil
|
||||
case "7d":
|
||||
fallthrough
|
||||
default:
|
||||
yesterday := dayStart(now, loc).AddDate(0, 0, -1)
|
||||
start := yesterday.AddDate(0, 0, -6)
|
||||
return "7d", start, dayEnd(yesterday), loc, nil
|
||||
}
|
||||
}
|
||||
|
||||
func parseDashboardDate(value string, loc *time.Location, start bool) (time.Time, error) {
|
||||
if value == "" {
|
||||
return time.Time{}, errors.New("请选择自定义统计周期")
|
||||
}
|
||||
|
||||
layouts := []string{time.RFC3339, "2006-01-02 15:04:05", "2006-01-02"}
|
||||
for _, layout := range layouts {
|
||||
t, err := time.ParseInLocation(layout, value, loc)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if layout == "2006-01-02" {
|
||||
if start {
|
||||
return dayStart(t, loc), nil
|
||||
}
|
||||
return dayEnd(t), nil
|
||||
}
|
||||
|
||||
return t.In(loc), nil
|
||||
}
|
||||
|
||||
return time.Time{}, errors.New("自定义统计周期格式错误")
|
||||
}
|
||||
|
||||
func dayStart(t time.Time, loc *time.Location) time.Time {
|
||||
local := t.In(loc)
|
||||
return time.Date(local.Year(), local.Month(), local.Day(), 0, 0, 0, 0, loc)
|
||||
}
|
||||
|
||||
func dayEnd(t time.Time) time.Time {
|
||||
start := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
|
||||
return start.Add(24*time.Hour - time.Nanosecond)
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (Order) Create(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
// NotifyURL RedirectURL 同为付款链接
|
||||
url := model.CheckoutCashier(host, order.TradeId)
|
||||
url := model.CheckoutUrl(host, order.TradeId)
|
||||
|
||||
// Update order with generated URLs
|
||||
hostUri := model.GetK(model.ApiAppUri)
|
||||
@@ -201,10 +201,17 @@ func (Order) Paid(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if order.Status == model.OrderStatusCanceled {
|
||||
base.BadRequest(ctx, "交易已取消,无法补单")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
confirmedAt := time.Now()
|
||||
var update = map[string]interface{}{
|
||||
"ref_hash": req.RefHash,
|
||||
"status": model.OrderStatusSuccess,
|
||||
"confirmed_at": model.Datetime(time.Now()),
|
||||
"confirmed_at": model.Datetime(confirmedAt),
|
||||
}
|
||||
|
||||
err := model.Db.Model(&order).Updates(update).Error
|
||||
@@ -214,6 +221,10 @@ func (Order) Paid(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
order.RefHash = req.RefHash
|
||||
order.Status = model.OrderStatusSuccess
|
||||
order.ConfirmedAt = &confirmedAt
|
||||
|
||||
go notify.Handle(order)
|
||||
|
||||
base.Ok(ctx, "操作成功")
|
||||
@@ -250,6 +261,37 @@ func (Order) ManualNotify(ctx *gin.Context) {
|
||||
base.Ok(ctx, "订单回调成功!")
|
||||
}
|
||||
|
||||
func (Order) Cancel(ctx *gin.Context) {
|
||||
var req base.IDRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
base.BadRequest(ctx, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var order model.Order
|
||||
model.Db.Where("id = ?", req.ID).Find(&order)
|
||||
if order.ID == 0 {
|
||||
base.BadRequest(ctx, "订单不存在")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if order.Status != model.OrderStatusWaiting {
|
||||
base.BadRequest(ctx, "仅允许取消未支付订单")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if err := order.SetCanceled(); err != nil {
|
||||
base.Error(ctx, err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
base.Ok(ctx, "订单取消成功")
|
||||
}
|
||||
|
||||
func (Order) Del(ctx *gin.Context) {
|
||||
var req base.IDListRequest
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
|
||||
@@ -61,17 +61,12 @@ func (Wallet) Add(ctx *gin.Context) {
|
||||
OtherNotify: req.OtherNotify,
|
||||
}
|
||||
|
||||
if !wallet.IsValid() {
|
||||
base.BadRequest(ctx, "钱包地址格式不合法,请检查")
|
||||
if err := wallet.Validate(); err != nil {
|
||||
base.BadRequest(ctx, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 非大小写敏感的地址,统一转为小写存储
|
||||
if !model.AddrCaseSens(model.TradeType(wallet.TradeType)) {
|
||||
wallet.MatchAddr = strings.ToLower(wallet.MatchAddr)
|
||||
}
|
||||
|
||||
if err := model.Db.Create(&wallet).Error; err != nil {
|
||||
base.Error(ctx, err)
|
||||
|
||||
@@ -158,17 +153,12 @@ func (Wallet) Mod(ctx *gin.Context) {
|
||||
w.OtherNotify = *req.OtherNotify
|
||||
}
|
||||
|
||||
if !w.IsValid() {
|
||||
base.BadRequest(ctx, "钱包地址格式不合法,请检查")
|
||||
if err := w.Validate(); err != nil {
|
||||
base.BadRequest(ctx, err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 非大小写敏感的地址,统一转为小写存储
|
||||
if !model.AddrCaseSens(model.TradeType(w.TradeType)) {
|
||||
w.MatchAddr = strings.ToLower(w.Address)
|
||||
}
|
||||
|
||||
if err := model.Db.Save(&w).Error; err != nil {
|
||||
base.Error(ctx, err)
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ func (Auth) Info(ctx *gin.Context) {
|
||||
"trade_type": model.GetAllAlias(),
|
||||
"trade_fiat": model.GetSupportFiat(),
|
||||
"trade_crypto": model.GetSupportCrypto(),
|
||||
"trade_network": model.GetAllNetwork(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -302,7 +303,7 @@ func (Auth) Menu(ctx *gin.Context) {
|
||||
Disable: false,
|
||||
KeepAlive: true,
|
||||
Affix: false,
|
||||
Link: "https://github.com/v03413/BEpusdt/blob/main/docs/api/api.md",
|
||||
Link: "",
|
||||
Iframe: false,
|
||||
IsFull: false,
|
||||
Roles: []string{"admin"},
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -112,7 +111,7 @@ func (e Epay) Submit(ctx *gin.Context) {
|
||||
host = "https://" + ctx.Request.Host
|
||||
}
|
||||
|
||||
ctx.Redirect(http.StatusFound, model.CheckoutCounter(host, order.TradeId))
|
||||
ctx.Redirect(http.StatusFound, model.CheckoutUrl(host, order.TradeId))
|
||||
}
|
||||
|
||||
// verify 验证请求参数
|
||||
@@ -186,12 +185,3 @@ func (e Epay) sign(data map[string]string, token string) string {
|
||||
|
||||
return md5sum
|
||||
}
|
||||
|
||||
func BuildNotifyParams(order model.Order) string {
|
||||
var signStr = utils.Md5String(fmt.Sprintf("money=%s&name=%s&out_trade_no=%s&pid=%s&trade_no=%s&trade_status=TRADE_SUCCESS&type=%s",
|
||||
cast.ToString(order.Money), order.Name, order.OrderId, Pid, order.TradeId, order.TradeType) + model.AuthToken())
|
||||
var params = fmt.Sprintf("money=%s&name=%s&out_trade_no=%s&pid=%s&trade_no=%s&trade_status=TRADE_SUCCESS&type=%s",
|
||||
cast.ToString(order.Money), url.QueryEscape(order.Name), url.QueryEscape(order.OrderId), Pid, order.TradeId, order.TradeType)
|
||||
|
||||
return fmt.Sprintf("%s&sign=%s", params, signStr)
|
||||
}
|
||||
|
||||
@@ -5,14 +5,11 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/v03413/bepusdt/app/handler/epay"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
@@ -57,57 +54,28 @@ type cancelReq struct {
|
||||
Signature string `json:"signature" binding:"required"`
|
||||
}
|
||||
|
||||
type infoReq struct {
|
||||
TradeID string `json:"trade_id" binding:"required"`
|
||||
}
|
||||
|
||||
type methodsReq struct {
|
||||
TradeID string `json:"trade_id" binding:"required"`
|
||||
Currency string `json:"currency"`
|
||||
}
|
||||
|
||||
type PaymentItem struct {
|
||||
Amount string `json:"amount"`
|
||||
ActualAmount string `json:"actual_amount"`
|
||||
Fiat string `json:"fiat"`
|
||||
ExchangeRate string `json:"exchange_rate"`
|
||||
Currency string `json:"currency"`
|
||||
Network string `json:"network"`
|
||||
TokenNetName string `json:"token_net_name"`
|
||||
TokenCustomName string `json:"token_custom_name"`
|
||||
IsPopular bool `json:"is_popular"`
|
||||
}
|
||||
|
||||
func (Epusdt) SignVerify(ctx *gin.Context) {
|
||||
rawData, err := ctx.GetRawData()
|
||||
if err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("json 数据读取错误 %s", err.Error())))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
m := make(map[string]any)
|
||||
if err = json.Unmarshal(rawData, &m); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("json 数据解析错误 %s", err.Error())))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
sign, ok := m["signature"]
|
||||
func loadPayOrder(ctx *gin.Context, tradeID string) (model.Order, bool) {
|
||||
order, ok := model.GetTradeOrder(tradeID)
|
||||
if !ok {
|
||||
ctx.JSON(200, respFailJson("签名丢失"))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
ctx.JSON(200, respFailJson("order not found"))
|
||||
return model.Order{}, false
|
||||
}
|
||||
|
||||
if utils.EpusdtSign(m, model.AuthToken()) != sign {
|
||||
ctx.JSON(200, respFailJson("签名错误"))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
if order.FingerprintBound() && !order.MatchFingerprint(utils.ClientFingerprint(ctx)) {
|
||||
ctx.JSON(200, respFailJson("order not found"))
|
||||
return model.Order{}, false
|
||||
}
|
||||
|
||||
ctx.Request.Body = io.NopCloser(bytes.NewBuffer(rawData)) // 回写数据
|
||||
ctx.Next()
|
||||
return order, true
|
||||
}
|
||||
|
||||
func (Epusdt) Notify(ctx *gin.Context) {
|
||||
@@ -137,7 +105,6 @@ func (Epusdt) Notify(ctx *gin.Context) {
|
||||
ctx.String(200, "ok")
|
||||
}
|
||||
|
||||
// CreateOrder Order creation API
|
||||
func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
var req createOrderReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
@@ -170,7 +137,7 @@ func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
// 创建待付款订单
|
||||
order, err := model.BuildPendingOrder(model.OrderParams{
|
||||
Money: decimal.NewFromFloat(req.Amount),
|
||||
ApiType: model.OrderApiTypeEpusdt,
|
||||
ApiType: model.OrderApiTypeEpusdtOrder,
|
||||
OrderId: req.OrderID,
|
||||
RedirectUrl: req.RedirectURL,
|
||||
NotifyUrl: req.NotifyURL,
|
||||
@@ -195,12 +162,12 @@ func (Epusdt) CreateOrder(ctx *gin.Context) {
|
||||
"status": order.Status,
|
||||
"amount": order.Money,
|
||||
"expiration_time": uint64(order.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
"payment_url": model.CheckoutCashier(host, order.TradeId),
|
||||
"network": GetPaymentItem("", order),
|
||||
"payment_url": model.CheckoutUrl(host, order.TradeId),
|
||||
"network": order.GetMethods(""),
|
||||
"reselect": order.CanReselectPayment(),
|
||||
}))
|
||||
}
|
||||
|
||||
// UpdateOrder 更新订单,返回付款链接。更新订单不需要签名,因为创建订单时已经验证,只需要提交参数更新订单即可。
|
||||
func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
// 接收 trade_id, currency, network 三个参数
|
||||
var req updateOrderReq
|
||||
@@ -215,10 +182,28 @@ func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
host = "https://" + ctx.Request.Host
|
||||
}
|
||||
|
||||
// 获取订单
|
||||
order, ok := model.GetTradeOrder(req.TradeID)
|
||||
order, ok := loadPayOrder(ctx, req.TradeID)
|
||||
if !ok {
|
||||
ctx.JSON(200, respFailJson("order not found"))
|
||||
return
|
||||
}
|
||||
|
||||
// 仅待付订单才可更新订单
|
||||
if order.Status != model.OrderStatusWaiting {
|
||||
ctx.JSON(200, respFailJson("update order failed: order status does not allow payment updates"))
|
||||
return
|
||||
}
|
||||
|
||||
if order.TradeType != "" && !order.CanReselectPayment() {
|
||||
ctx.JSON(200, respFailJson("update order failed: order status does not allow payment updates"))
|
||||
return
|
||||
}
|
||||
|
||||
fp := utils.ClientFingerprint(ctx)
|
||||
|
||||
// 拒绝过期订单
|
||||
remaining := time.Until(order.ExpiredAt)
|
||||
if remaining <= 0 {
|
||||
ctx.JSON(200, respFailJson("update order failed: order expired"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -233,14 +218,15 @@ func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
// 注意:RebuildOrder 需要 OrderParams,我们需要从现有订单构造参数
|
||||
money, _ := decimal.NewFromString(order.Money)
|
||||
params := model.OrderParams{
|
||||
Money: money,
|
||||
OrderId: order.OrderId,
|
||||
TradeType: tradeType, // 新的交易类型
|
||||
RedirectUrl: order.ReturnUrl,
|
||||
NotifyUrl: order.NotifyUrl,
|
||||
Name: order.Name,
|
||||
Timeout: int64(order.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
Fiat: order.Fiat,
|
||||
Money: money,
|
||||
OrderId: order.OrderId,
|
||||
TradeType: tradeType, // 新的交易类型
|
||||
RedirectUrl: order.ReturnUrl,
|
||||
NotifyUrl: order.NotifyUrl,
|
||||
Name: order.Name,
|
||||
Timeout: int64(math.Ceil(remaining.Seconds())),
|
||||
Fiat: order.Fiat,
|
||||
ClientFingerprint: fp,
|
||||
}
|
||||
|
||||
newOrder, err := model.RebuildOrder(order, params)
|
||||
@@ -260,7 +246,7 @@ func (Epusdt) UpdateOrder(ctx *gin.Context) {
|
||||
"actual_amount": newOrder.Amount,
|
||||
"token": newOrder.Address,
|
||||
"expiration_time": uint64(newOrder.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
"payment_url": model.CheckoutCounter(host, newOrder.TradeId),
|
||||
"payment_url": model.CheckoutUrl(host, newOrder.TradeId),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -323,7 +309,7 @@ func (Epusdt) CreateTransaction(ctx *gin.Context) {
|
||||
"actual_amount": order.Amount,
|
||||
"token": order.Address,
|
||||
"expiration_time": uint64(order.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
"payment_url": model.CheckoutCounter(utils.GetRequestHost(ctx.Request), order.TradeId),
|
||||
"payment_url": model.CheckoutUrl(utils.GetRequestHost(ctx.Request), order.TradeId),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -357,204 +343,114 @@ func (Epusdt) CancelTransaction(ctx *gin.Context) {
|
||||
ctx.JSON(200, respSuccJson(gin.H{"trade_id": req.TradeID}))
|
||||
}
|
||||
|
||||
func (Epusdt) CheckoutCounter(ctx *gin.Context) {
|
||||
func (Epusdt) Checkout(ctx *gin.Context) {
|
||||
tradeId := ctx.Param("trade_id")
|
||||
order, ok := model.GetTradeOrder(tradeId)
|
||||
if !ok {
|
||||
ctx.String(200, "订单不存在")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
uri, err := url.ParseRequestURI(order.ReturnUrl)
|
||||
if err != nil {
|
||||
ctx.String(200, "同步地址错误")
|
||||
log.Error("同步地址解析错误", err.Error())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, string(order.TradeType+".html"), gin.H{
|
||||
"http_host": uri.Host,
|
||||
"amount": order.Amount,
|
||||
"address": order.Address,
|
||||
"expire": int64(order.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
"return_url": order.ReturnUrl,
|
||||
"usdt_rate": order.Rate,
|
||||
"trade_id": tradeId,
|
||||
"order_id": order.OrderId,
|
||||
"trade_type": order.TradeType,
|
||||
"money": order.Money,
|
||||
"fiat": order.Fiat,
|
||||
})
|
||||
}
|
||||
|
||||
func (Epusdt) CheckoutCashier(ctx *gin.Context) {
|
||||
tradeId := ctx.Param("trade_id")
|
||||
order, ok := model.GetTradeOrder(tradeId)
|
||||
if !ok {
|
||||
if _, ok := model.GetTradeOrder(tradeId); !ok {
|
||||
ctx.String(200, "order not found")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
uri, err := url.ParseRequestURI(order.ReturnUrl)
|
||||
if err != nil {
|
||||
ctx.String(200, "sync address error")
|
||||
log.Error("CheckoutCashier: sync address error: ", err.Error())
|
||||
// 收银台模板
|
||||
tmpl := model.GetC(model.PaymentCheckout) + "/checkout.html"
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, "cashier.html", gin.H{
|
||||
"http_host": uri.Host,
|
||||
"amount": order.Amount,
|
||||
"expire": int64(order.ExpiredAt.Sub(time.Now()).Seconds()),
|
||||
"return_url": order.ReturnUrl,
|
||||
"trade_id": tradeId,
|
||||
"order_id": order.OrderId,
|
||||
"name": order.Name,
|
||||
"money": order.Money,
|
||||
"fiat": order.Fiat,
|
||||
"network": GetPaymentItem("", order),
|
||||
})
|
||||
ctx.HTML(200, tmpl, gin.H{"trade_id": tradeId})
|
||||
}
|
||||
|
||||
func (Epusdt) CheckStatus(ctx *gin.Context) {
|
||||
tradeId := ctx.Param("trade_id")
|
||||
order, ok := model.GetTradeOrder(tradeId)
|
||||
if !ok {
|
||||
ctx.JSON(200, respFailJson("订单不存在"))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var returnUrl string
|
||||
if order.Status == model.OrderStatusSuccess {
|
||||
returnUrl = order.ReturnUrl
|
||||
if order.ApiType == model.OrderApiTypeEpay {
|
||||
// 易支付兼容
|
||||
returnUrl = fmt.Sprintf("%s?%s", returnUrl, epay.BuildNotifyParams(order))
|
||||
}
|
||||
}
|
||||
|
||||
// 返回响应数据
|
||||
ctx.JSON(200, gin.H{
|
||||
"trade_id": tradeId,
|
||||
"trade_hash": order.RefHash,
|
||||
"status": order.Status,
|
||||
"return_url": returnUrl,
|
||||
})
|
||||
}
|
||||
|
||||
func (Epusdt) GetPaymentMethods(ctx *gin.Context) {
|
||||
func (Epusdt) GetMethods(ctx *gin.Context) {
|
||||
var req methodsReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(500, respFailJson(fmt.Sprintf("request error: %s", err.Error())))
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("request error: %s", err.Error())))
|
||||
return
|
||||
}
|
||||
|
||||
order, ok := model.GetTradeOrder(req.TradeID)
|
||||
order, ok := loadPayOrder(ctx, req.TradeID)
|
||||
if !ok {
|
||||
ctx.JSON(400, respFailJson("order not found"))
|
||||
return
|
||||
}
|
||||
|
||||
if order.Status == model.OrderStatusExpired {
|
||||
ctx.JSON(400, respFailJson("order expired"))
|
||||
if order.Status != model.OrderStatusWaiting {
|
||||
ctx.JSON(200, respFailJson("error: Invalid order status"))
|
||||
return
|
||||
}
|
||||
|
||||
if order.TradeType != "" && !order.CanReselectPayment() {
|
||||
ctx.JSON(200, respFailJson("error: The order status does not allow retrieving the payment method"))
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, respSuccJson(gin.H{
|
||||
"methods": GetPaymentItem(model.Crypto(req.Currency), order),
|
||||
"methods": order.GetMethods(model.Crypto(req.Currency)),
|
||||
"network_sort": model.GetC(model.PaymentNetworkSort),
|
||||
}))
|
||||
}
|
||||
|
||||
func GetPaymentItem(crypto model.Crypto, order model.Order) []PaymentItem {
|
||||
fiat := order.Fiat
|
||||
|
||||
var methods = make([]PaymentItem, 0)
|
||||
allTrades := model.GetAllTradeConfig()
|
||||
|
||||
// 解析限定币种
|
||||
var whitelist = make(map[string]bool)
|
||||
var blacklist = make(map[string]bool)
|
||||
if order.CurrencyLimit != "" {
|
||||
for _, c := range strings.Split(order.CurrencyLimit, ",") {
|
||||
c = strings.TrimSpace(c)
|
||||
if strings.HasPrefix(c, "-") {
|
||||
blacklist[strings.ToUpper(strings.TrimPrefix(c, "-"))] = true
|
||||
} else {
|
||||
whitelist[strings.ToUpper(c)] = true
|
||||
}
|
||||
}
|
||||
func (Epusdt) Info(ctx *gin.Context) {
|
||||
var req infoReq
|
||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("参数错误:%s", err.Error())))
|
||||
return
|
||||
}
|
||||
|
||||
for tradeTypeStr, conf := range allTrades {
|
||||
// 如果指定了货币,则进行过滤
|
||||
if crypto != "" && conf.Crypto != crypto {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check blacklist
|
||||
if len(blacklist) > 0 && blacklist[string(conf.Crypto)] {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check whitelist
|
||||
if len(whitelist) > 0 && !whitelist[string(conf.Crypto)] {
|
||||
continue
|
||||
}
|
||||
|
||||
// 检查是否有可用钱包
|
||||
count := len(model.GetAvailableAddress(model.TradeType(tradeTypeStr)))
|
||||
if count == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 获取汇率配置的浮动语法
|
||||
syntax := model.GetK(model.ConfKey(fmt.Sprintf("rate_float_%s_%s", conf.Crypto, fiat)))
|
||||
|
||||
// 获取汇率
|
||||
rate, err := model.GetOrderRate(conf.Crypto, fiat, syntax)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("GetPaymentMethods: get order rate error: %s", err.Error()))
|
||||
continue
|
||||
}
|
||||
|
||||
// 计算实际支付金额 (加密货币)
|
||||
// Money 是法币金额
|
||||
moneyDecimal, _ := decimal.NewFromString(order.Money)
|
||||
|
||||
// 计算精度
|
||||
atom, precision := model.GetAtomicity(model.TradeType(tradeTypeStr))
|
||||
actualAmount := moneyDecimal.DivRound(rate, precision)
|
||||
if actualAmount.LessThan(atom) {
|
||||
actualAmount = atom
|
||||
}
|
||||
|
||||
methods = append(methods, PaymentItem{
|
||||
Amount: order.Money,
|
||||
ActualAmount: actualAmount.String(),
|
||||
Fiat: string(fiat),
|
||||
ExchangeRate: rate.String(),
|
||||
Currency: string(conf.Crypto),
|
||||
Network: string(conf.Network),
|
||||
TokenNetName: conf.NetworkName,
|
||||
TokenCustomName: "", // 暂为空
|
||||
IsPopular: false, // 暂为 false
|
||||
})
|
||||
order, ok := loadPayOrder(ctx, req.TradeID)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Sort by Currency A-Z
|
||||
sort.Slice(methods, func(i, j int) bool {
|
||||
if methods[i].Currency != methods[j].Currency {
|
||||
return methods[i].Currency < methods[j].Currency
|
||||
}
|
||||
return methods[i].Network < methods[j].Network
|
||||
})
|
||||
ctx.JSON(200, respSuccJson(gin.H{
|
||||
"network": order.Network(), // 网络信息
|
||||
"trade_id": order.TradeId, // 交易编号
|
||||
"order_id": order.OrderId, // 商户订单
|
||||
"trade_type": order.TradeType, // 交易类型
|
||||
"status": order.Status, // 订单状态
|
||||
"money": order.Money, // 订单金额
|
||||
"actual_amount": order.Amount, // 实付数额
|
||||
"token": order.Address, // 收款地址
|
||||
"fiat": order.Fiat, // 法币类型
|
||||
"name": order.Name, // 商品名称
|
||||
"expired_at": order.ExpiredAt.Unix(), // 截止时间
|
||||
"created_at": order.CreatedAt.Time().Unix(), // 创建时间
|
||||
"trade_url": order.GetTxUrl(), // 链上详情
|
||||
"support_url": model.GetC(model.PaymentSupportUrl), // 客服链接
|
||||
"redirect_url": order.RedirectUrl(), // 跳转地址
|
||||
"reselect": order.CanReselectPayment(), // 是否允许确认交易类型后重选
|
||||
}))
|
||||
}
|
||||
|
||||
return methods
|
||||
func (Epusdt) SignVerify(ctx *gin.Context) {
|
||||
rawData, err := ctx.GetRawData()
|
||||
if err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("json 数据读取错误 %s", err.Error())))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
m := make(map[string]any)
|
||||
if err = json.Unmarshal(rawData, &m); err != nil {
|
||||
ctx.JSON(200, respFailJson(fmt.Sprintf("json 数据解析错误 %s", err.Error())))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
sign, ok := m["signature"]
|
||||
if !ok {
|
||||
ctx.JSON(200, respFailJson("签名丢失"))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if utils.EpusdtSign(m, model.AuthToken()) != sign {
|
||||
ctx.JSON(200, respFailJson("签名错误"))
|
||||
ctx.Abort()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Request.Body = io.NopCloser(bytes.NewBuffer(rawData)) // 回写数据
|
||||
ctx.Next()
|
||||
}
|
||||
|
||||
func respFailJson(message string) gin.H {
|
||||
@@ -563,6 +459,5 @@ func respFailJson(message string) gin.H {
|
||||
}
|
||||
|
||||
func respSuccJson(data interface{}) gin.H {
|
||||
|
||||
return gin.H{"status_code": 200, "message": "success", "data": data, "request_id": ""}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ var (
|
||||
Task *logrus.Logger
|
||||
be *logrus.Logger
|
||||
loggers []*lumberjack.Logger
|
||||
logPath string
|
||||
)
|
||||
|
||||
func newLogger(file string) (*logrus.Logger, error) {
|
||||
@@ -42,7 +43,6 @@ func newLogger(file string) (*logrus.Logger, error) {
|
||||
|
||||
func Init(dir string) error {
|
||||
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
|
||||
|
||||
return fmt.Errorf("创建日志目录失败:%w", err)
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ func Init(dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
logPath = dir
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -82,6 +84,10 @@ func GetWriter() *io.PipeWriter {
|
||||
return be.Writer()
|
||||
}
|
||||
|
||||
func GetPath() string {
|
||||
return logPath
|
||||
}
|
||||
|
||||
func Close() {
|
||||
for _, f := range loggers {
|
||||
if f != nil {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package model
|
||||
|
||||
type Checkout struct {
|
||||
Name string `json:"name"`
|
||||
Author string `json:"author"`
|
||||
Desc string `json:"desc"`
|
||||
Link string `json:"link"`
|
||||
}
|
||||
|
||||
var checkoutMap = make(map[string]Checkout)
|
||||
|
||||
// RegisterCheckout 注册收银台模板
|
||||
func RegisterCheckout(name string, checkout Checkout) {
|
||||
checkoutMap[name] = checkout
|
||||
}
|
||||
|
||||
func CheckoutList() map[string]Checkout {
|
||||
return checkoutMap
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"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"
|
||||
@@ -15,6 +16,44 @@ import (
|
||||
)
|
||||
|
||||
var confCache sync.Map
|
||||
var defaultConf = map[ConfKey]string{
|
||||
ApiAppUri: "",
|
||||
RateSyncInterval: "3600",
|
||||
AtomUSDT: "0.01",
|
||||
AtomUSDC: "0.01",
|
||||
AtomTRX: "0.01",
|
||||
AtomBNB: "0.00001",
|
||||
AtomETH: "0.000001",
|
||||
AtomGRAM: "0.01",
|
||||
MonitorMinAmount: "0.01",
|
||||
PaymentMinAmount: "0.01",
|
||||
PaymentMaxAmount: "99999",
|
||||
RpcEndpointTron: "grpc.trongrid.io:50051",
|
||||
RpcEndpointBsc: "https://binance-smart-chain-public.nodies.app/",
|
||||
RpcEndpointSolana: "https://solana-rpc.publicnode.com/",
|
||||
RpcEndpointXlayer: "https://xlayerrpc.okx.com/",
|
||||
RpcEndpointPolygon: "https://polygon-public.nodies.app/",
|
||||
RpcEndpointArbitrum: "https://arb1.arbitrum.io/rpc",
|
||||
RpcEndpointEthereum: "https://ethereum-public.nodies.app/",
|
||||
RpcEndpointBase: "https://base-public.nodies.app/",
|
||||
RpcEndpointAptos: "https://aptos-rest.publicnode.com/",
|
||||
RpcEndpointPlasma: "https://rpc.plasma.to/",
|
||||
RpcGlobalConfigUrlTon: "https://ton.org/global-config.json",
|
||||
NotifyMaxRetry: "10",
|
||||
BlockHeightMaxDiff: "1000",
|
||||
BlockOffsetConfirm: "0",
|
||||
PaymentTimeout: "1200", // 20分钟
|
||||
PaymentCheckout: "official", // 官方模板
|
||||
PaymentMatchMode: string(Classic),
|
||||
PaymentSupportUrl: "",
|
||||
PaymentLookbackHour: "3",
|
||||
PaymentNetworkSort: "",
|
||||
SystemInstallLock: "0",
|
||||
RateSyncCoingeckoApiUrl: "https://api.coingecko.com",
|
||||
RateSyncHistoryDays: "30",
|
||||
MqttTopicPrefix: "bepusdt",
|
||||
HomeRedirectUrl: "",
|
||||
}
|
||||
|
||||
type Conf struct {
|
||||
K ConfKey `gorm:"column:k;type:varchar(32);not null;primaryKey" json:"key"`
|
||||
@@ -96,22 +135,13 @@ func RefreshC() {
|
||||
}
|
||||
}
|
||||
|
||||
func CheckoutCounter(host, id string) string {
|
||||
func CheckoutUrl(host, id string) string {
|
||||
uri := GetK(ApiAppUri)
|
||||
if uri == "" {
|
||||
uri = host
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/pay/checkout-counter/%s", uri, id)
|
||||
}
|
||||
|
||||
func CheckoutCashier(host, id string) string {
|
||||
uri := GetK(ApiAppUri)
|
||||
if uri == "" {
|
||||
uri = host
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s/pay/cashier/%s", uri, id)
|
||||
return fmt.Sprintf("%s/pay/checkout/%s", uri, id)
|
||||
}
|
||||
|
||||
func ConfInit() {
|
||||
@@ -122,47 +152,19 @@ func ConfInit() {
|
||||
var password = hash[20:30]
|
||||
var encrypt, _ = bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
var data = map[ConfKey]string{
|
||||
ApiAppUri: "",
|
||||
ApiAuthToken: token,
|
||||
AdminSecret: utils.StrSha256(hash),
|
||||
AdminSecure: secure,
|
||||
AdminUsername: username,
|
||||
AdminPassword: string(encrypt),
|
||||
RateSyncInterval: "3600",
|
||||
AtomUSDT: "0.01",
|
||||
AtomUSDC: "0.01",
|
||||
AtomTRX: "0.01",
|
||||
AtomBNB: "0.00001",
|
||||
AtomETH: "0.000001",
|
||||
MonitorMinAmount: "0.01",
|
||||
PaymentMinAmount: "0.01",
|
||||
PaymentMaxAmount: "99999",
|
||||
RpcEndpointTron: "grpc.trongrid.io:50051",
|
||||
RpcEndpointBsc: "https://binance-smart-chain-public.nodies.app/",
|
||||
RpcEndpointSolana: "https://solana-rpc.publicnode.com/",
|
||||
RpcEndpointXlayer: "https://xlayerrpc.okx.com/",
|
||||
RpcEndpointPolygon: "https://polygon-public.nodies.app/",
|
||||
RpcEndpointArbitrum: "https://arb1.arbitrum.io/rpc",
|
||||
RpcEndpointEthereum: "https://ethereum-public.nodies.app/",
|
||||
RpcEndpointBase: "https://base-public.nodies.app/",
|
||||
RpcEndpointAptos: "https://aptos-rest.publicnode.com/",
|
||||
RpcEndpointPlasma: "https://rpc.plasma.to/",
|
||||
NotifyMaxRetry: "10",
|
||||
BlockHeightMaxDiff: "1000",
|
||||
BlockOffsetConfirm: "0",
|
||||
PaymentTimeout: "1200", // 20分钟
|
||||
PaymentStaticPath: "",
|
||||
PaymentMatchMode: string(Classic),
|
||||
SystemInstallLock: "0",
|
||||
RateSyncCoingeckoApiUrl: "https://api.coingecko.com",
|
||||
RateSyncCoingeckoApiKey: "",
|
||||
MqttTopicPrefix: "bepusdt",
|
||||
ApiAuthToken: token,
|
||||
AdminSecret: utils.StrSha256(hash),
|
||||
AdminSecure: secure,
|
||||
AdminUsername: username,
|
||||
AdminPassword: string(encrypt),
|
||||
}
|
||||
|
||||
var rows = make([]Conf, 0)
|
||||
for k, v := range data {
|
||||
rows = append(rows, Conf{K: k, V: v})
|
||||
}
|
||||
for k, v := range defaultConf {
|
||||
rows = append(rows, Conf{K: k, V: v})
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println("╔═══════════════════════════════════════════════════════════════════════")
|
||||
@@ -224,5 +226,40 @@ func GetInstallInfo() gin.H {
|
||||
}
|
||||
|
||||
func GetTronGridApiKeys() []string {
|
||||
return strings.Split(GetK(RpcEndpointTronGridApiKey), ",")
|
||||
arr := strings.Split(GetC(RpcEndpointTronGridApiKey), ",")
|
||||
keys := make([]string, 0)
|
||||
for _, v := range arr {
|
||||
if v != "" {
|
||||
keys = append(keys, v)
|
||||
}
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
func FillDefaultConf() {
|
||||
var existKeys []string
|
||||
Db.Model(&Conf{}).Pluck("k", &existKeys)
|
||||
|
||||
existSet := make(map[ConfKey]struct{}, len(existKeys))
|
||||
for _, k := range existKeys {
|
||||
existSet[ConfKey(k)] = struct{}{}
|
||||
}
|
||||
|
||||
var rows []Conf
|
||||
for k, v := range defaultConf {
|
||||
if _, ok := existSet[k]; !ok {
|
||||
rows = append(rows, Conf{K: k, V: v})
|
||||
}
|
||||
}
|
||||
if len(rows) > 0 {
|
||||
Db.Create(&rows)
|
||||
}
|
||||
}
|
||||
|
||||
func GetLookbackHour() time.Duration {
|
||||
var hour = time.Hour * -1
|
||||
var num = cast.ToInt(GetC(PaymentLookbackHour))
|
||||
|
||||
return time.Duration(num) * hour
|
||||
}
|
||||
|
||||
@@ -43,13 +43,17 @@ const (
|
||||
AtomTRX ConfKey = "atom_trx"
|
||||
AtomBNB ConfKey = "atom_bnb"
|
||||
AtomETH ConfKey = "atom_eth"
|
||||
AtomGRAM ConfKey = "atom_gram"
|
||||
|
||||
MonitorMinAmount ConfKey = "monitor_min_amount" // 监控最小金额,低于此金额的入账不进行通知
|
||||
PaymentMinAmount ConfKey = "payment_min_amount"
|
||||
PaymentMaxAmount ConfKey = "payment_max_amount"
|
||||
PaymentTimeout ConfKey = "payment_timeout" // 订单支付超时时间,单位秒
|
||||
PaymentStaticPath ConfKey = "payment_static_path" // 收银台静态资源路径
|
||||
PaymentMatchMode ConfKey = "payment_match_mode" // 订单金额匹配模式
|
||||
MonitorMinAmount ConfKey = "monitor_min_amount" // 监控最小金额,低于此金额的入账不进行通知
|
||||
PaymentMinAmount ConfKey = "payment_min_amount"
|
||||
PaymentMaxAmount ConfKey = "payment_max_amount"
|
||||
PaymentTimeout ConfKey = "payment_timeout" // 订单支付超时时间,单位秒
|
||||
PaymentCheckout ConfKey = "payment_checkout" // 收银台模板
|
||||
PaymentMatchMode ConfKey = "payment_match_mode" // 订单金额匹配模式
|
||||
PaymentSupportUrl ConfKey = "payment_support_url" // 订单支付客服链接
|
||||
PaymentLookbackHour ConfKey = "payment_lookback_hour" // 订单回溯时间
|
||||
PaymentNetworkSort ConfKey = "payment_network_sort" // 收银台网络顺序,逗号分隔
|
||||
|
||||
RpcEndpointPlasma ConfKey = "rpc_endpoint_plasma" // Plasma RPC节点
|
||||
RpcEndpointBsc ConfKey = "rpc_endpoint_bsc" // BSC RPC节点
|
||||
@@ -62,13 +66,16 @@ const (
|
||||
RpcEndpointAptos ConfKey = "rpc_endpoint_aptos" // APTOS RPC节点
|
||||
RpcEndpointTron ConfKey = "rpc_endpoint_tron" // TRON RPC节点
|
||||
RpcEndpointTronGridApiKey ConfKey = "rpc_endpoint_tron_grid_api_key" // TRON RPC节点 TronGrid Api Key
|
||||
RpcGlobalConfigUrlTon ConfKey = "rpc_global_config_url_ton" // Ton Global Config Url
|
||||
|
||||
RateSyncCoingeckoApiUrl ConfKey = "rate_sync_coingecko_api_url" // 汇率同步 Coingecko Api URL
|
||||
RateSyncCoingeckoApiKey ConfKey = "rate_sync_coingecko_api_key" // 汇率同步 Coingecko Api Key
|
||||
RateSyncInterval ConfKey = "rate_sync_interval" // 汇率同步间隔,单位秒
|
||||
NotifyMaxRetry ConfKey = "notify_max_retry" // 最大重试次数,订单回调失败
|
||||
BlockHeightMaxDiff ConfKey = "block_height_max_diff" // 区块高度最大差值,超过此值则以当前区块高度为准,重新开始扫描
|
||||
BlockOffsetConfirm ConfKey = "block_offset_confirm" // 区块偏移确认数,扫描时以当前区块高度减去此偏移量为准,避免重链导致的订单回调失败
|
||||
RateSyncHistoryDays ConfKey = "rate_sync_history_days" // 历史汇率保存天数
|
||||
|
||||
NotifyMaxRetry ConfKey = "notify_max_retry" // 最大重试次数,订单回调失败
|
||||
BlockHeightMaxDiff ConfKey = "block_height_max_diff" // 区块高度最大差值,超过此值则以当前区块高度为准,重新开始扫描
|
||||
BlockOffsetConfirm ConfKey = "block_offset_confirm" // 区块偏移确认数,扫描时以当前区块高度减去此偏移量为准,避免重链导致的订单回调失败
|
||||
|
||||
MqttHost ConfKey = "mqtt_host"
|
||||
MqttPort ConfKey = "mqtt_port"
|
||||
@@ -82,6 +89,7 @@ const (
|
||||
NotifierChannel ConfKey = "notifier_channel" // 通知渠道 (telegram, wechat, email
|
||||
|
||||
SystemInstallLock ConfKey = "system_install_lock" // 系统安装锁
|
||||
HomeRedirectUrl ConfKey = "home_redirect_url"
|
||||
)
|
||||
const (
|
||||
CNY Fiat = "CNY"
|
||||
@@ -96,6 +104,7 @@ const (
|
||||
TRX Crypto = "TRX"
|
||||
BNB Crypto = "BNB"
|
||||
ETH Crypto = "ETH"
|
||||
GRAM Crypto = "GRAM" // 其实就是 Ton
|
||||
)
|
||||
const (
|
||||
Classic MatchMode = "classic" // 经典模式,精确匹配
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// 202607081430 - 删除 bep_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") {
|
||||
return nil
|
||||
}
|
||||
if tx.Migrator().HasColumn("bep_order", "trade_type_reselect") {
|
||||
return tx.Exec("ALTER TABLE bep_order DROP COLUMN trade_type_reselect").Error
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Rollback: func(tx *gorm.DB) error {
|
||||
if !tx.Migrator().HasTable("bep_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
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"github.com/go-gormigrate/gormigrate/v2"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableName = "bep_migration"
|
||||
|
||||
var migrations = []*gormigrate.Migration{
|
||||
m202607081430DropOrderTradeTypeReselect(),
|
||||
}
|
||||
|
||||
func Run(db *gorm.DB, initModels []any) error {
|
||||
if err := db.AutoMigrate(initModels...); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := &gormigrate.Options{TableName: TableName}
|
||||
|
||||
// 旧版升级/全新安装,构建迁移表
|
||||
if !db.Migrator().HasTable(TableName) {
|
||||
if err := db.Exec("CREATE TABLE " + TableName + " (id VARCHAR(255) PRIMARY KEY)").Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
m := gormigrate.New(db, options, migrations)
|
||||
|
||||
return m.Migrate()
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/driver/mysql"
|
||||
"github.com/v03413/bepusdt/app/model/migration"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -24,19 +24,16 @@ type AutoTimeAt struct {
|
||||
UpdatedAt *Datetime `gorm:"column:updated_at;not null;comment:最后更新时间" json:"updated_at"`
|
||||
}
|
||||
|
||||
func Init(path, mysql, postgres string) error {
|
||||
if postgres != "" {
|
||||
return initPostgres(postgres)
|
||||
}
|
||||
if mysql != "" {
|
||||
return initMySQL(mysql)
|
||||
func Init(db, dsn string) error {
|
||||
if dsn != "" {
|
||||
return initPostgres(dsn)
|
||||
}
|
||||
|
||||
return initSqlite(path)
|
||||
return initSqlite(db)
|
||||
}
|
||||
|
||||
func initSqlite(path string) error {
|
||||
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
|
||||
func initSqlite(db string) error {
|
||||
if err := os.MkdirAll(filepath.Dir(db), os.ModePerm); err != nil {
|
||||
|
||||
return fmt.Errorf("创建数据库目录失败:%w", err)
|
||||
}
|
||||
@@ -47,7 +44,7 @@ func initSqlite(path string) error {
|
||||
"&_pragma=busy_timeout(8000)"+ // 8 秒超时,兼顾慢速磁盘
|
||||
"&_pragma=synchronous(NORMAL)"+ // NORMAL 模式,性能与安全平衡
|
||||
"&_pragma=wal_autocheckpoint(1500)", // 适中的 checkpoint 频率
|
||||
path)
|
||||
db)
|
||||
Db, err = gorm.Open(sqlite.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
|
||||
@@ -76,48 +73,7 @@ func initSqlite(path string) error {
|
||||
ConfInit()
|
||||
}
|
||||
|
||||
RefreshC()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func initMySQL(dsn string) error {
|
||||
var err error
|
||||
Db, err = gorm.Open(mysql.New(mysql.Config{
|
||||
DSN: dsn,
|
||||
DefaultStringSize: 256, // string 类型字段的默认长度
|
||||
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
|
||||
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
|
||||
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
|
||||
SkipInitializeWithVersion: false, // 根据当前 MySQL 版本自动配置
|
||||
}), &gorm.Config{})
|
||||
if err != nil {
|
||||
|
||||
return fmt.Errorf("数据库初始化失败:%w", err)
|
||||
}
|
||||
|
||||
{
|
||||
sqlDB, err := Db.DB()
|
||||
if err != nil {
|
||||
|
||||
return fmt.Errorf("获取数据库连接失败:%w", err)
|
||||
}
|
||||
sqlDB.SetMaxOpenConns(100)
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
sqlDB.SetConnMaxLifetime(time.Hour)
|
||||
}
|
||||
|
||||
if err = AutoMigrate(); err != nil {
|
||||
|
||||
return fmt.Errorf("数据库结构迁移失败:%w", err)
|
||||
}
|
||||
|
||||
var count int64
|
||||
Db.Model(&Conf{}).Count(&count)
|
||||
if count == 0 {
|
||||
ConfInit()
|
||||
}
|
||||
|
||||
FillDefaultConf()
|
||||
RefreshC()
|
||||
|
||||
return nil
|
||||
@@ -157,13 +113,20 @@ func initPostgres(dsn string) error {
|
||||
ConfInit()
|
||||
}
|
||||
|
||||
FillDefaultConf()
|
||||
RefreshC()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func AutoMigrate() error {
|
||||
return Db.AutoMigrate(&Wallet{}, &Order{}, &NotifyRecord{}, &Conf{}, &Rate{})
|
||||
return migration.Run(Db, []any{
|
||||
&Wallet{},
|
||||
&Order{},
|
||||
&NotifyRecord{},
|
||||
&Conf{},
|
||||
&Rate{},
|
||||
})
|
||||
}
|
||||
|
||||
func Close() {
|
||||
|
||||
@@ -4,10 +4,17 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"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 (
|
||||
@@ -24,6 +31,7 @@ const (
|
||||
BscBnb TradeType = "bsc.bnb"
|
||||
EthereumEth TradeType = "ethereum.eth"
|
||||
TronTrx TradeType = "tron.trx"
|
||||
TonGram TradeType = "ton.gram"
|
||||
|
||||
UsdtTrc20 TradeType = "usdt.trc20"
|
||||
UsdcTrc20 TradeType = "usdc.trc20"
|
||||
@@ -43,48 +51,86 @@ const (
|
||||
UsdtAptos TradeType = "usdt.aptos"
|
||||
UsdcAptos TradeType = "usdc.aptos"
|
||||
UsdtPlasma TradeType = "usdt.plasma"
|
||||
UsdtTon TradeType = "usdt.ton"
|
||||
)
|
||||
|
||||
const (
|
||||
OrderApiTypeEpusdt = "epusdt" // epusdt
|
||||
OrderApiTypeEpay = "epay" // 彩虹易支付
|
||||
OrderApiTypeAdmin = "admin" // 管理后台
|
||||
OrderApiTypeEpusdt = "epusdt" // epusdt
|
||||
OrderApiTypeEpusdtOrder = "epusdt_order" // epusdt 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"`
|
||||
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"`
|
||||
Rate string `gorm:"column:rate;type:varchar(10);not null;comment:交易汇率" json:"rate"`
|
||||
Amount string `gorm:"column:amount;type:varchar(32);not null;default:0.00;comment:交易数额" json:"amount"`
|
||||
Money string `gorm:"column:money;type:varchar(32);not null;default:0.00;comment:交易金额" json:"money"`
|
||||
Address string `gorm:"column:address;type:varchar(128);index;not null;comment:收款地址" json:"address"`
|
||||
FromAddress string `gorm:"column:from_address;type:varchar(128);not null;default:'';comment:支付地址" json:"from_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;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:varchar(255);not null;default:'';comment:同步地址" json:"return_url"`
|
||||
NotifyUrl string `gorm:"column:notify_url;type:varchar(255);not null;default:'';comment:异步地址" json:"notify_url"`
|
||||
NotifyNum int `gorm:"column:notify_num;not null;default:0;comment:回调次数" json:"notify_num"`
|
||||
NotifyState int `gorm:"column:notify_state;not null;default:0;comment:回调状态 1:成功 0:失败" json:"notify_state"`
|
||||
RefHash string `gorm:"column:ref_hash;type:varchar(128);not null;default:'';index;comment:交易哈希" json:"ref_hash"`
|
||||
RefBlockNum int `gorm:"column:ref_block_num;not null;default:0;comment:区块索引" json:"ref_block_num"`
|
||||
ExpiredAt time.Time `gorm:"column:expired_at;not null;comment:失效时间" json:"expired_at"`
|
||||
ConfirmedAt *time.Time `gorm:"column:confirmed_at;not null;comment:交易确认时间" json:"confirmed_at"`
|
||||
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"`
|
||||
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"`
|
||||
Rate string `gorm:"column:rate;type:varchar(10);not null;comment:交易汇率" json:"rate"`
|
||||
Amount string `gorm:"column:amount;type:varchar(32);not null;default:0.00;comment:交易数额" json:"amount"`
|
||||
Money string `gorm:"column:money;type:varchar(32);not null;default:0.00;comment:交易金额" json:"money"`
|
||||
Address string `gorm:"column:address;type:varchar(128);index;not null;comment:收款地址" json:"address"`
|
||||
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"`
|
||||
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:varchar(255);not null;default:'';comment:同步地址" json:"return_url"`
|
||||
NotifyUrl string `gorm:"column:notify_url;type:varchar(255);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"`
|
||||
RefBlockNum int `gorm:"column:ref_block_num;not null;default:0;comment:区块索引" json:"ref_block_num"`
|
||||
ExpiredAt time.Time `gorm:"column:expired_at;not null;comment:失效时间" json:"expired_at"`
|
||||
ConfirmedAt *time.Time `gorm:"column:confirmed_at;not null;comment:交易确认时间" json:"confirmed_at"`
|
||||
ClientFingerprint string `gorm:"column:client_fingerprint;type:varchar(64);not null;default:'';comment:'客户端指纹'" json:"-"`
|
||||
AutoTimeAt
|
||||
}
|
||||
|
||||
type MethodItem struct {
|
||||
Amount string `json:"amount"`
|
||||
ActualAmount string `json:"actual_amount"`
|
||||
Fiat string `json:"fiat"`
|
||||
ExchangeRate string `json:"exchange_rate"`
|
||||
Currency string `json:"currency"`
|
||||
Network string `json:"network"`
|
||||
TokenNetName string `json:"token_net_name"`
|
||||
TokenCustomName string `json:"token_custom_name"`
|
||||
IsPopular bool `json:"is_popular"`
|
||||
}
|
||||
|
||||
func (o *Order) SetCanceled() error {
|
||||
core.New()
|
||||
o.Status = OrderStatusCanceled
|
||||
|
||||
return Db.Save(o).Error
|
||||
}
|
||||
|
||||
// CanReselectPayment 判断订单是否支持重选交易类型
|
||||
func (o *Order) CanReselectPayment() bool {
|
||||
if o.Status != OrderStatusWaiting {
|
||||
return false
|
||||
}
|
||||
|
||||
if o.ApiType != OrderApiTypeEpusdtOrder && o.ApiType != OrderApiTypeAdmin {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (o *Order) FingerprintBound() bool {
|
||||
return o.ClientFingerprint != ""
|
||||
}
|
||||
|
||||
func (o *Order) MatchFingerprint(fingerprint string) bool {
|
||||
return !o.FingerprintBound() || o.ClientFingerprint == fingerprint
|
||||
}
|
||||
|
||||
func (o *Order) SetExpired() {
|
||||
o.Status = OrderStatusExpired
|
||||
|
||||
@@ -103,7 +149,7 @@ func (o *Order) SetFailed() {
|
||||
Db.Save(o)
|
||||
}
|
||||
|
||||
func (o *Order) MarkConfirming(blockNum int, from, hash string, at time.Time, amount decimal.Decimal) {
|
||||
func (o *Order) MarkConfirming(blockNum int, from, hash string, at time.Time, amount decimal.Decimal) error {
|
||||
o.FromAddress = from
|
||||
o.ConfirmedAt = &at
|
||||
o.RefHash = hash
|
||||
@@ -115,7 +161,7 @@ func (o *Order) MarkConfirming(blockNum int, from, hash string, at time.Time, am
|
||||
o.Money = rate.Mul(amount).String()
|
||||
}
|
||||
|
||||
Db.Save(o)
|
||||
return Db.Save(o).Error
|
||||
}
|
||||
|
||||
func (o *Order) SetNotifyState(state int) error {
|
||||
@@ -159,6 +205,138 @@ func (o *Order) GetTxUrl() string {
|
||||
return GetTxUrl(o.TradeType, o.RefHash)
|
||||
}
|
||||
|
||||
func (o *Order) RedirectUrl() string {
|
||||
var redirect = o.ReturnUrl
|
||||
if o.Status == OrderStatusSuccess && o.ApiType == OrderApiTypeEpay {
|
||||
redirect = fmt.Sprintf("%s?%s", redirect, o.BuildNotifyParams())
|
||||
}
|
||||
|
||||
return redirect
|
||||
}
|
||||
|
||||
func (o *Order) BuildNotifyParams() string {
|
||||
var signStr = utils.Md5String(fmt.Sprintf("money=%s&name=%s&out_trade_no=%s&pid=%s&trade_no=%s&trade_status=TRADE_SUCCESS&type=%s",
|
||||
cast.ToString(o.Money), o.Name, o.OrderId, conf.Pid, o.TradeId, o.TradeType) + AuthToken())
|
||||
var params = fmt.Sprintf("money=%s&name=%s&out_trade_no=%s&pid=%s&trade_no=%s&trade_status=TRADE_SUCCESS&type=%s",
|
||||
cast.ToString(o.Money), url.QueryEscape(o.Name), url.QueryEscape(o.OrderId), conf.Pid, o.TradeId, o.TradeType)
|
||||
|
||||
return fmt.Sprintf("%s&sign=%s", params, signStr)
|
||||
}
|
||||
|
||||
func (o *Order) GetMethods(crypto Crypto) []MethodItem {
|
||||
var items = make([]MethodItem, 0)
|
||||
if o.Status != OrderStatusWaiting {
|
||||
return items
|
||||
}
|
||||
if o.TradeType != "" && !o.CanReselectPayment() {
|
||||
return items
|
||||
}
|
||||
|
||||
allTrades := GetAllTradeConfig()
|
||||
|
||||
// 解析限定币种
|
||||
var whitelist = make(map[string]bool)
|
||||
var blacklist = make(map[string]bool)
|
||||
if o.CurrencyLimit != "" {
|
||||
for _, c := range strings.Split(o.CurrencyLimit, ",") {
|
||||
c = strings.TrimSpace(c)
|
||||
if strings.HasPrefix(c, "-") {
|
||||
blacklist[strings.ToUpper(strings.TrimPrefix(c, "-"))] = true
|
||||
} else {
|
||||
whitelist[strings.ToUpper(c)] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for tradeTypeStr, typeConf := range allTrades {
|
||||
// 如果指定了货币,则进行过滤
|
||||
if crypto != "" && typeConf.Crypto != crypto {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check blacklist
|
||||
if len(blacklist) > 0 && blacklist[string(typeConf.Crypto)] {
|
||||
continue
|
||||
}
|
||||
|
||||
// Check whitelist
|
||||
if len(whitelist) > 0 && !whitelist[string(typeConf.Crypto)] {
|
||||
continue
|
||||
}
|
||||
|
||||
// 检查是否有可用钱包
|
||||
count := len(GetAvailableWallets(TradeType(tradeTypeStr)))
|
||||
if count == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// 获取汇率配置的浮动语法
|
||||
syntax := GetK(ConfKey(fmt.Sprintf("rate_float_%s_%s", typeConf.Crypto, o.Fiat)))
|
||||
|
||||
// 获取汇率
|
||||
rate, err := GetOrderRate(typeConf.Crypto, o.Fiat, syntax)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("GetPaymentMethods: get order rate error: %s", err.Error()))
|
||||
continue
|
||||
}
|
||||
|
||||
// 计算实际支付金额 (加密货币)
|
||||
// Money 是法币金额
|
||||
moneyDecimal, _ := decimal.NewFromString(o.Money)
|
||||
|
||||
// 计算精度
|
||||
atom, precision := GetAtomicity(TradeType(tradeTypeStr))
|
||||
actualAmount := moneyDecimal.DivRound(rate, precision)
|
||||
if actualAmount.LessThan(atom) {
|
||||
actualAmount = atom
|
||||
}
|
||||
|
||||
items = append(items, MethodItem{
|
||||
Amount: o.Money,
|
||||
ActualAmount: actualAmount.String(),
|
||||
Fiat: string(o.Fiat),
|
||||
ExchangeRate: rate.String(),
|
||||
Currency: string(typeConf.Crypto),
|
||||
Network: string(typeConf.Network),
|
||||
TokenNetName: typeConf.NetworkName,
|
||||
TokenCustomName: "", // 暂为空
|
||||
IsPopular: false, // 暂为 false
|
||||
})
|
||||
}
|
||||
|
||||
// Sort by Currency A-Z
|
||||
sort.Slice(items, func(i, j int) bool {
|
||||
if items[i].Currency != items[j].Currency {
|
||||
return items[i].Currency < items[j].Currency
|
||||
}
|
||||
return items[i].Network < items[j].Network
|
||||
})
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
func (o *Order) Network() any {
|
||||
type network struct {
|
||||
Alias string `json:"alias"`
|
||||
Name string `json:"name"`
|
||||
Crypto Crypto `json:"crypto"`
|
||||
Network Network `json:"network"`
|
||||
}
|
||||
|
||||
var net = network{}
|
||||
info, ok := registry[o.TradeType]
|
||||
if !ok {
|
||||
return net
|
||||
}
|
||||
|
||||
net.Name = info.NetworkName
|
||||
net.Alias = info.Alias
|
||||
net.Crypto = info.Crypto
|
||||
net.Network = info.Network
|
||||
|
||||
return net
|
||||
}
|
||||
|
||||
func (o *Order) TableName() string {
|
||||
return "bep_order"
|
||||
}
|
||||
@@ -180,17 +358,22 @@ func GetOrderByStatus(Status int) []Order {
|
||||
|
||||
func GetNotifyFailedTradeOrders() ([]Order, error) {
|
||||
var orders []Order
|
||||
maxRetry := cast.ToInt(GetC(NotifyMaxRetry))
|
||||
if maxRetry <= 0 {
|
||||
maxRetry = cast.ToInt(defaultConf[NotifyMaxRetry])
|
||||
}
|
||||
|
||||
res := Db.Where("status = ?", OrderStatusSuccess).
|
||||
Where("notify_num <= ?", GetC(NotifyMaxRetry)).
|
||||
Where("notify_state = ?", OrderNotifyStateFail).Find(&orders)
|
||||
Where("notify_state = ?", OrderNotifyStateFail).
|
||||
Where("notify_num <= ?", maxRetry).Find(&orders)
|
||||
|
||||
return orders, res.Error
|
||||
}
|
||||
|
||||
// CalcTradeAmount 计算当前实际可用的交易金额
|
||||
func CalcTradeAmount(address []string, rate decimal.Decimal, p OrderParams) (string, string, error) {
|
||||
func CalcTradeAmount(wallets []Wallet, rate decimal.Decimal, p OrderParams) (Wallet, string, error) {
|
||||
if p.AddressLocked {
|
||||
return LockTradeAddress(address, p.TradeType)
|
||||
return LockTradeAddress(wallets, p.TradeType)
|
||||
}
|
||||
|
||||
var orders []Order
|
||||
@@ -203,7 +386,7 @@ func CalcTradeAmount(address []string, rate decimal.Decimal, p OrderParams) (str
|
||||
|
||||
atom, precision := GetAtomicity(p.TradeType)
|
||||
if rate.LessThanOrEqual(decimal.Zero) || precision <= 0 {
|
||||
return "", "", errors.New(fmt.Sprintf("[%v - %v]原子颗粒度计算异常,联系管理员处理!", atom, precision))
|
||||
return Wallet{}, "", errors.New(fmt.Sprintf("[%v - %v]原子颗粒度计算异常,联系管理员处理!", atom, precision))
|
||||
}
|
||||
|
||||
amount := p.Money.DivRound(rate, precision)
|
||||
@@ -214,36 +397,36 @@ func CalcTradeAmount(address []string, rate decimal.Decimal, p OrderParams) (str
|
||||
var i = 0
|
||||
var m = 100
|
||||
for {
|
||||
for _, addr := range address {
|
||||
k := addr + amount.String()
|
||||
for _, w := range wallets {
|
||||
k := w.GetMatchAddr() + amount.String()
|
||||
if _, ok := lock[k]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
return addr, amount.String(), nil
|
||||
return w, amount.String(), nil
|
||||
}
|
||||
|
||||
// 已经被占用,每次递增一个原子精度
|
||||
amount = amount.Add(atom)
|
||||
if i++; i > m {
|
||||
return "", "", errors.New("计算交易金额异常,联系管理员处理!")
|
||||
return Wallet{}, "", errors.New("计算交易金额异常,联系管理员处理!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LockTradeAddress 检测交易地址,独占使用
|
||||
func LockTradeAddress(address []string, t TradeType) (string, string, error) {
|
||||
func LockTradeAddress(wallets []Wallet, t TradeType) (Wallet, string, error) {
|
||||
zero := decimal.Zero.String()
|
||||
status := []int{OrderStatusConfirming, OrderStatusWaiting}
|
||||
for _, addr := range address {
|
||||
for _, w := range wallets {
|
||||
var o Order
|
||||
Db.Where("address = ? and status in (?) and trade_type = ? and address_locked = ?", addr, status, t, true).Order("id desc").Limit(1).Find(&o)
|
||||
Db.Where("match_address = ? and status in (?) and trade_type = ? and address_locked = ?", w.GetMatchAddr(), status, t, true).Order("id desc").Limit(1).Find(&o)
|
||||
if o.ID == 0 {
|
||||
return addr, zero, nil
|
||||
return w, zero, nil
|
||||
}
|
||||
}
|
||||
|
||||
return "", zero, errors.New("暂无可用钱包地址")
|
||||
return Wallet{}, zero, errors.New("暂无可用钱包地址")
|
||||
}
|
||||
|
||||
// CalcTradeExpiredAt 计算订单过期时间 最小180,最大3600,默认1200
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"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"
|
||||
@@ -67,6 +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))
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -24,10 +24,23 @@ var supportCrypto = map[Crypto]CoinId{
|
||||
TRX: "tron",
|
||||
BNB: "binancecoin",
|
||||
ETH: "ethereum",
|
||||
GRAM: "the-open-network",
|
||||
}
|
||||
|
||||
// TradeType 交易类型,当下类型开始增多,现在这里统一管理、尽量收缩配置项
|
||||
var registry = map[TradeType]TradeTypeConf{
|
||||
UsdtTon: {
|
||||
Alias: "USDT・Ton",
|
||||
NetworkName: "Ton",
|
||||
Network: conf.Ton,
|
||||
Crypto: USDT,
|
||||
Contract: conf.UsdtTon,
|
||||
Decimal: conf.UsdtTonDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://tonscan.org/tx/%s#overview",
|
||||
EndpointKey: RpcGlobalConfigUrlTon,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
UsdtPlasma: {
|
||||
Alias: "USDT・Plasma",
|
||||
NetworkName: "Plasma",
|
||||
@@ -41,7 +54,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdtTrc20: {
|
||||
Alias: "USDT・TRC20",
|
||||
NetworkName: "TRC20",
|
||||
NetworkName: "Tron",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDT,
|
||||
Contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // 占位,目前实际没使用
|
||||
@@ -53,7 +66,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdtErc20: {
|
||||
Alias: "USDT・ERC20",
|
||||
NetworkName: "ERC20",
|
||||
NetworkName: "Ethereum",
|
||||
Network: conf.Ethereum,
|
||||
Crypto: USDT,
|
||||
Contract: conf.UsdtErc20,
|
||||
@@ -64,7 +77,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdtBep20: {
|
||||
Alias: "USDT・BEP20",
|
||||
NetworkName: "BEP20",
|
||||
NetworkName: "Bsc",
|
||||
Network: conf.Bsc,
|
||||
Crypto: USDT,
|
||||
Contract: conf.UsdtBep20,
|
||||
@@ -131,7 +144,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdcErc20: {
|
||||
Alias: "USDC・ERC20",
|
||||
NetworkName: "ERC20",
|
||||
NetworkName: "Ethereum",
|
||||
Network: conf.Ethereum,
|
||||
Crypto: USDC,
|
||||
Contract: conf.UsdcErc20,
|
||||
@@ -142,7 +155,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdcBep20: {
|
||||
Alias: "USDC・BEP20",
|
||||
NetworkName: "BEP20",
|
||||
NetworkName: "Bsc",
|
||||
Network: conf.Bsc,
|
||||
Crypto: USDC,
|
||||
Contract: conf.UsdcBep20,
|
||||
@@ -197,7 +210,7 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
},
|
||||
UsdcTrc20: {
|
||||
Alias: "USDC・TRC20",
|
||||
NetworkName: "TRC20",
|
||||
NetworkName: "Tron",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDC,
|
||||
Contract: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", // 占位,目前实际没使用
|
||||
@@ -273,6 +286,21 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
ExplorerFmt: "https://bscscan.com/tx/%s",
|
||||
EndpointKey: RpcEndpointBsc,
|
||||
},
|
||||
TonGram: {
|
||||
Alias: "Ton・Gram",
|
||||
NetworkName: "Ton",
|
||||
Network: conf.Ton,
|
||||
Crypto: GRAM,
|
||||
Native: true,
|
||||
Decimal: conf.TonTonDecimals,
|
||||
AmountRange: Range{
|
||||
MinAmount: decimal.NewFromFloat(0.00001),
|
||||
MaxAmount: decimal.NewFromFloat(1000000),
|
||||
},
|
||||
ExplorerFmt: "https://tonscan.org/tx/%s#overview",
|
||||
EndpointKey: RpcGlobalConfigUrlTon,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -314,6 +342,15 @@ func GetAllAlias() map[string]string {
|
||||
return alias
|
||||
}
|
||||
|
||||
func GetAllNetwork() map[string]string {
|
||||
var networks = make(map[string]string)
|
||||
for _, c := range registry {
|
||||
networks[string(c.Network)] = c.NetworkName
|
||||
}
|
||||
|
||||
return networks
|
||||
}
|
||||
|
||||
func GetAllTradeConfig() map[string]TradeTypeConf {
|
||||
var config = make(map[string]TradeTypeConf)
|
||||
|
||||
|
||||
@@ -13,26 +13,32 @@ import (
|
||||
)
|
||||
|
||||
type OrderParams struct {
|
||||
Money decimal.Decimal `json:"money"` // 交易金额 (单位:法币)s
|
||||
ApiType string `json:"api_type"` // 支付 API 类型
|
||||
Address string `json:"address"` // 收款地址
|
||||
OrderId string `json:"order_id"` // 商户订单 ID
|
||||
TradeType TradeType `json:"trade_type"` // 交易类型
|
||||
RedirectUrl string `json:"redirect_url"` // 成功跳转地址
|
||||
NotifyUrl string `json:"notify_url"` // 异步通知地址
|
||||
Name string `json:"name"` // 商品名称
|
||||
Timeout int64 `json:"timeout"` // 订单超时时间(秒)
|
||||
Rate string `json:"rate"` // 强制指定汇率
|
||||
Fiat Fiat `json:"fiat"` // 法币类型
|
||||
CurrencyLimit string `json:"currency_limit"` // 限定币种
|
||||
AddressLocked bool `json:"address_locked"` // 地址独占锁定
|
||||
Money decimal.Decimal `json:"money"` // 交易金额 (单位:法币)s
|
||||
ApiType string `json:"api_type"` // 支付 API 类型
|
||||
Address string `json:"address"` // 收款地址
|
||||
OrderId string `json:"order_id"` // 商户订单 ID
|
||||
TradeType TradeType `json:"trade_type"` // 交易类型
|
||||
RedirectUrl string `json:"redirect_url"` // 成功跳转地址
|
||||
NotifyUrl string `json:"notify_url"` // 异步通知地址
|
||||
Name string `json:"name"` // 商品名称
|
||||
Timeout int64 `json:"timeout"` // 订单超时时间(秒)
|
||||
Rate string `json:"rate"` // 强制指定汇率
|
||||
Fiat Fiat `json:"fiat"` // 法币类型
|
||||
CurrencyLimit string `json:"currency_limit"` // 限定币种
|
||||
AddressLocked bool `json:"address_locked"` // 地址独占锁定
|
||||
ClientFingerprint string `json:"client_fingerprint"` // 客户端指纹
|
||||
}
|
||||
|
||||
type Addr struct {
|
||||
Address string // 对外前端收款地址
|
||||
MatchAddr string // 对内订单校验地址
|
||||
}
|
||||
|
||||
type Trade struct {
|
||||
Crypto Crypto
|
||||
Rate decimal.Decimal
|
||||
Address string
|
||||
Amount string
|
||||
Wallet Wallet
|
||||
Crypto Crypto
|
||||
Rate decimal.Decimal
|
||||
Amount string
|
||||
}
|
||||
|
||||
var buildMutex sync.Mutex
|
||||
@@ -85,7 +91,7 @@ func StartBuildOrder(p OrderParams) (Order, error) {
|
||||
return BuildOrder(p, data)
|
||||
}
|
||||
|
||||
func BuildOrder(p OrderParams, data Trade) (Order, error) {
|
||||
func BuildOrder(p OrderParams, trade Trade) (Order, error) {
|
||||
tradeId, err := utils.GenerateTradeId()
|
||||
if err != nil {
|
||||
return Order{}, err
|
||||
@@ -97,10 +103,11 @@ func BuildOrder(p OrderParams, data Trade) (Order, error) {
|
||||
TradeId: tradeId,
|
||||
RefHash: tradeId,
|
||||
TradeType: p.TradeType,
|
||||
Rate: fmt.Sprintf("%v", data.Rate),
|
||||
Amount: data.Amount,
|
||||
Rate: fmt.Sprintf("%v", trade.Rate),
|
||||
Amount: trade.Amount,
|
||||
Money: p.Money.String(),
|
||||
Address: data.Address,
|
||||
Address: trade.Wallet.GetPaymentAddr(),
|
||||
MatchAddress: trade.Wallet.GetMatchAddr(),
|
||||
AddressLocked: p.Money.IsZero(), // 零值订单,地址锁定 独占
|
||||
Status: OrderStatusWaiting,
|
||||
Name: p.Name,
|
||||
@@ -111,7 +118,7 @@ func BuildOrder(p OrderParams, data Trade) (Order, error) {
|
||||
NotifyState: OrderNotifyStateFail,
|
||||
ExpiredAt: CalcTradeExpiredAt(p.Timeout),
|
||||
Fiat: p.Fiat,
|
||||
Crypto: data.Crypto,
|
||||
Crypto: trade.Crypto,
|
||||
CurrencyLimit: p.CurrencyLimit,
|
||||
ConfirmedAt: &zero, // 默认填充一个0值时间,尽量避免数据库出现允许 NULL 值存在
|
||||
}
|
||||
@@ -119,10 +126,6 @@ func BuildOrder(p OrderParams, data Trade) (Order, error) {
|
||||
if tradeOrder.Name == "" {
|
||||
tradeOrder.Name = tradeOrder.OrderId
|
||||
}
|
||||
if tradeOrder.CurrencyLimit == "" {
|
||||
tradeOrder.CurrencyLimit = string(data.Crypto)
|
||||
}
|
||||
|
||||
if err = Db.Create(&tradeOrder).Error; err != nil {
|
||||
log.Error("订单创建失败:", err.Error())
|
||||
return Order{}, err
|
||||
@@ -147,30 +150,32 @@ func BuildTrade(p OrderParams) (Trade, error) {
|
||||
return Trade{}, fmt.Errorf("%s %s 汇率异常", crypto, p.Fiat)
|
||||
}
|
||||
|
||||
var wallet = GetAvailableAddress(p.TradeType)
|
||||
if p.Address != "" {
|
||||
wallet = []string{p.Address}
|
||||
if !AddrCaseSens(p.TradeType) { // 交易类型不区分大小写,统一转小写;这个地址最后的交易匹配要用到,千万不能错
|
||||
wallet = []string{strings.ToLower(p.Address)}
|
||||
var wallets = GetAvailableWallets(p.TradeType)
|
||||
if p.Address != "" { // 指定地址
|
||||
w, err := NewWallet(p.Address, p.TradeType)
|
||||
if err != nil {
|
||||
return Trade{}, err
|
||||
}
|
||||
|
||||
wallets = []Wallet{w}
|
||||
}
|
||||
|
||||
if len(wallet) == 0 {
|
||||
if len(wallets) == 0 {
|
||||
return Trade{}, fmt.Errorf("%s 未检测到可用钱包地址", p.TradeType)
|
||||
}
|
||||
|
||||
// 计算交易金额
|
||||
address, amount, err := CalcTradeAmount(wallet, rate, p)
|
||||
wallet, amount, err := CalcTradeAmount(wallets, rate, p)
|
||||
if err != nil {
|
||||
|
||||
return Trade{}, err
|
||||
}
|
||||
|
||||
return Trade{
|
||||
Crypto: crypto,
|
||||
Rate: rate,
|
||||
Address: address,
|
||||
Amount: amount,
|
||||
Crypto: crypto,
|
||||
Rate: rate,
|
||||
Wallet: wallet,
|
||||
Amount: amount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -184,8 +189,13 @@ func RebuildOrder(t Order, p OrderParams) (Order, error) {
|
||||
return t, err
|
||||
}
|
||||
|
||||
if t.TradeType == "" && p.ClientFingerprint != "" {
|
||||
t.ClientFingerprint = p.ClientFingerprint
|
||||
}
|
||||
|
||||
t.Fiat = p.Fiat
|
||||
t.Address = data.Address
|
||||
t.Address = data.Wallet.GetPaymentAddr()
|
||||
t.MatchAddress = data.Wallet.GetMatchAddr()
|
||||
t.Crypto = data.Crypto
|
||||
t.Amount = data.Amount
|
||||
t.Money = p.Money.String()
|
||||
@@ -193,7 +203,31 @@ func RebuildOrder(t Order, p OrderParams) (Order, error) {
|
||||
t.Rate = fmt.Sprintf("%v", data.Rate)
|
||||
t.ExpiredAt = CalcTradeExpiredAt(p.Timeout)
|
||||
|
||||
return t, Db.Save(&t).Error
|
||||
query := Db.Model(&Order{}).Where("id = ?", t.ID)
|
||||
if p.ClientFingerprint != "" {
|
||||
query = query.Where("(client_fingerprint = '' OR client_fingerprint = ?)", p.ClientFingerprint)
|
||||
}
|
||||
|
||||
res := query.Updates(map[string]any{
|
||||
"fiat": t.Fiat,
|
||||
"address": t.Address,
|
||||
"match_address": t.MatchAddress,
|
||||
"crypto": t.Crypto,
|
||||
"amount": t.Amount,
|
||||
"money": t.Money,
|
||||
"trade_type": t.TradeType,
|
||||
"rate": t.Rate,
|
||||
"expired_at": t.ExpiredAt,
|
||||
"client_fingerprint": t.ClientFingerprint,
|
||||
})
|
||||
if res.Error != nil {
|
||||
return t, res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return t, fmt.Errorf("client fingerprint mismatch")
|
||||
}
|
||||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// BuildPendingOrder 创建待支付订单(不锁定地址和汇率)
|
||||
@@ -226,9 +260,9 @@ func BuildPendingOrder(p OrderParams) (Order, error) {
|
||||
}
|
||||
|
||||
return BuildOrder(p, Trade{
|
||||
Crypto: crypto,
|
||||
Rate: decimal.Zero,
|
||||
Amount: "0",
|
||||
Address: "",
|
||||
Crypto: crypto,
|
||||
Rate: decimal.Zero,
|
||||
Amount: "0",
|
||||
Wallet: Wallet{},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/xssnick/tonutils-go/address"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -33,26 +38,58 @@ func (wa *Wallet) SetStatus(status uint8) {
|
||||
Db.Save(wa)
|
||||
}
|
||||
|
||||
func (wa *Wallet) IsValid() bool {
|
||||
func (wa *Wallet) Validate() error {
|
||||
tradeType := TradeType(wa.TradeType)
|
||||
wa.MatchAddr = wa.Address
|
||||
|
||||
// Tron 地址验证
|
||||
if tradeType == TronTrx || tradeType == UsdtTrc20 || tradeType == UsdcTrc20 {
|
||||
return utils.IsValidTronAddress(wa.Address)
|
||||
switch tradeType {
|
||||
case TronTrx, UsdtTrc20, UsdcTrc20:
|
||||
if !utils.IsValidTronAddress(wa.Address) {
|
||||
return errors.New("钱包地址格式不合法,请检查")
|
||||
}
|
||||
case UsdtSolana, UsdcSolana:
|
||||
if !utils.IsValidSolanaAddress(wa.Address) {
|
||||
return errors.New("钱包地址格式不合法,请检查")
|
||||
}
|
||||
case UsdtAptos, UsdcAptos:
|
||||
if !utils.IsValidAptosAddress(wa.Address) {
|
||||
return errors.New("钱包地址格式不合法,请检查")
|
||||
}
|
||||
case UsdtTon:
|
||||
if !strings.HasPrefix(wa.Address, "UQ") {
|
||||
return errors.New("TON 地址必须以 UQ 开头")
|
||||
}
|
||||
owner, err := address.ParseAddr(wa.Address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
addr, err := utils.GetJettonWalletAddr(utils.NewTonClient(GetC(RpcGlobalConfigUrlTon)), address.MustParseAddr(conf.UsdtTon), owner)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wa.MatchAddr = addr.Bounce(false).String()
|
||||
return nil
|
||||
case TonGram:
|
||||
if !strings.HasPrefix(wa.Address, "UQ") {
|
||||
return errors.New("TON 地址必须以 UQ 开头")
|
||||
}
|
||||
owner, err := address.ParseAddr(wa.Address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wa.MatchAddr = owner.Bounce(false).String()
|
||||
return nil
|
||||
default:
|
||||
if !utils.IsValidEvmAddress(wa.Address) {
|
||||
return errors.New("钱包地址格式不合法,请检查")
|
||||
}
|
||||
}
|
||||
|
||||
// Solana 地址验证
|
||||
if tradeType == UsdtSolana || tradeType == UsdcSolana {
|
||||
return utils.IsValidSolanaAddress(wa.Address)
|
||||
if !AddrCaseSens(tradeType) {
|
||||
wa.MatchAddr = strings.ToLower(wa.Address)
|
||||
}
|
||||
|
||||
// Aptos 地址验证
|
||||
if tradeType == UsdtAptos || tradeType == UsdcAptos {
|
||||
return utils.IsValidAptosAddress(wa.Address)
|
||||
}
|
||||
|
||||
// 默认使用 EVM 地址验证(Ethereum, BSC, Polygon, Arbitrum, Base, X Layer)
|
||||
return utils.IsValidEvmAddress(wa.Address)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wa *Wallet) SetOtherNotify(notify uint8) {
|
||||
@@ -92,14 +129,32 @@ func (wa *Wallet) GetNetwork() Network {
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetAvailableAddress(t TradeType) []string {
|
||||
var rows []Wallet
|
||||
Db.Where("trade_type = ? and status = ?", t, WaStatusEnable).Find(&rows)
|
||||
func (wa *Wallet) GetPaymentAddr() string {
|
||||
if wa.TradeType == string(UsdtTon) {
|
||||
|
||||
wallets := make([]string, 0, len(rows))
|
||||
for _, w := range rows {
|
||||
wallets = append(wallets, w.MatchAddr)
|
||||
return wa.Address
|
||||
}
|
||||
|
||||
return wa.MatchAddr
|
||||
}
|
||||
|
||||
func (wa *Wallet) GetMatchAddr() string {
|
||||
return wa.MatchAddr
|
||||
}
|
||||
|
||||
func GetAvailableWallets(t TradeType) []Wallet {
|
||||
var wallets = make([]Wallet, 0)
|
||||
|
||||
Db.Where("trade_type = ? and status = ?", t, WaStatusEnable).Find(&wallets)
|
||||
|
||||
return wallets
|
||||
}
|
||||
|
||||
func NewWallet(address string, tradeType TradeType) (Wallet, error) {
|
||||
wa := Wallet{Address: address, TradeType: string(tradeType)}
|
||||
if err := wa.Validate(); err != nil {
|
||||
return Wallet{}, err
|
||||
}
|
||||
|
||||
return wa, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package mqtt
|
||||
|
||||
import mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
import (
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
)
|
||||
|
||||
// Publish 发布消息。若 MQTT 未连接则静默丢弃,返回 nil。
|
||||
func Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token {
|
||||
@@ -12,5 +15,16 @@ func Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.To
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Publish(topic, qos, retained, payload)
|
||||
token := c.Publish(topic, qos, retained, payload)
|
||||
if qos > 0 {
|
||||
go func() {
|
||||
token.Wait()
|
||||
if err := token.Error(); err != nil {
|
||||
log.Warn("MQTT publish error: " + err.Error())
|
||||
return
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return token
|
||||
}
|
||||
|
||||
@@ -141,10 +141,7 @@ func (t *Telegram) NotifyFail(o model.Order, reason string) {
|
||||
}
|
||||
|
||||
func (t *Telegram) NonOrderTransfer(trans model.TronTransfer, wa model.Wallet) {
|
||||
title := "收入"
|
||||
if trans.RecvAddress != wa.Address {
|
||||
title = "支出"
|
||||
}
|
||||
title := nonOrderTransferTitle(trans, wa)
|
||||
|
||||
text := fmt.Sprintf(
|
||||
"\\#账户%s \\#非订单交易\n\\-\\-\\-\n```\n💲交易数额:%v \n💍交易类别:"+strings.ToUpper(string(trans.TradeType))+"\n⏱️交易时间:%v\n✅接收地址:%v\n🅾️发送地址:%v```\n",
|
||||
@@ -168,6 +165,14 @@ func (t *Telegram) NonOrderTransfer(trans model.TronTransfer, wa model.Wallet) {
|
||||
})
|
||||
}
|
||||
|
||||
func nonOrderTransferTitle(trans model.TronTransfer, wa model.Wallet) string {
|
||||
if trans.RecvAddress == wa.MatchAddr {
|
||||
return "收入"
|
||||
}
|
||||
|
||||
return "支出"
|
||||
}
|
||||
|
||||
func (t *Telegram) TronResourceChange(res model.TronResource) {
|
||||
title := "代理"
|
||||
if res.Type == core.Transaction_Contract_UnDelegateResourceContract {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package notifier
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
)
|
||||
|
||||
func TestNonOrderTransferTitleUsesMatchAddress(t *testing.T) {
|
||||
trans := model.TronTransfer{
|
||||
RecvAddress: "0xf9dff4e813644edc7d9b1b535100b7e92333f743",
|
||||
FromAddress: "0x6cba0ff7e76b225ee3b975c3096d828f012c8c72",
|
||||
}
|
||||
wallet := model.Wallet{
|
||||
Address: "0xF9DFF4E813644eDc7D9b1b535100b7e92333f743",
|
||||
MatchAddr: "0xf9dff4e813644edc7d9b1b535100b7e92333f743",
|
||||
}
|
||||
|
||||
if title := nonOrderTransferTitle(trans, wallet); title != "收入" {
|
||||
t.Fatalf("title = %q, want %q", title, "收入")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNonOrderTransferTitleMarksOutgoingTransfer(t *testing.T) {
|
||||
trans := model.TronTransfer{
|
||||
RecvAddress: "0xrecipient",
|
||||
FromAddress: "0xf9dff4e813644edc7d9b1b535100b7e92333f743",
|
||||
}
|
||||
wallet := model.Wallet{
|
||||
Address: "0xF9DFF4E813644eDc7D9b1b535100b7e92333f743",
|
||||
MatchAddr: "0xf9dff4e813644edc7d9b1b535100b7e92333f743",
|
||||
}
|
||||
|
||||
if title := nonOrderTransferTitle(trans, wallet); title != "支出" {
|
||||
t.Fatalf("title = %q, want %q", title, "支出")
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ func adminInit(e *gin.Engine) {
|
||||
var confRtr = e.Group("/api/conf")
|
||||
var confHdr = new(admin.Conf)
|
||||
{
|
||||
GetRegister(confRtr, "/rpc", true, confHdr.Rpc)
|
||||
PostRegister(confRtr, "/set", true, confHdr.Set)
|
||||
PostRegister(confRtr, "/get", true, confHdr.Get)
|
||||
PostRegister(confRtr, "/del", true, confHdr.Del)
|
||||
@@ -16,6 +17,7 @@ func adminInit(e *gin.Engine) {
|
||||
PostRegister(confRtr, "/sets", true, confHdr.Sets)
|
||||
PostRegister(confRtr, "/notifier", true, confHdr.Notifier)
|
||||
PostRegister(confRtr, "/notifier_test", true, confHdr.NotifierTest)
|
||||
PostRegister(confRtr, "/checkout_list", true, confHdr.CheckoutList)
|
||||
PostRegister(confRtr, "/reset_api_auth_token", true, confHdr.ResetApiAuthToken)
|
||||
}
|
||||
|
||||
@@ -36,6 +38,7 @@ func adminInit(e *gin.Engine) {
|
||||
PostRegister(orderRtr, "/detail", true, orderHdr.Detail)
|
||||
PostRegister(orderRtr, "/paid", true, orderHdr.Paid)
|
||||
PostRegister(orderRtr, "/manual_notify", true, orderHdr.ManualNotify)
|
||||
PostRegister(orderRtr, "/cancel", true, orderHdr.Cancel)
|
||||
PostRegister(orderRtr, "/del", true, orderHdr.Del)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/v03413/bepusdt/static"
|
||||
)
|
||||
|
||||
func TestLangGeCheckoutTemplateIsEmbedded(t *testing.T) {
|
||||
checkout, err := readCheckoutInfoFromFS(static.Checkout, "checkout/langge")
|
||||
if err != nil {
|
||||
t.Fatalf("read langge checkout info: %v", err)
|
||||
}
|
||||
|
||||
if checkout.Name != "LangGe design" {
|
||||
t.Fatalf("unexpected checkout name: %q", checkout.Name)
|
||||
}
|
||||
if checkout.Author == "" {
|
||||
t.Fatal("checkout author is required")
|
||||
}
|
||||
if checkout.Desc == "" {
|
||||
t.Fatal("checkout desc is required")
|
||||
}
|
||||
|
||||
view, err := fs.ReadFile(static.Checkout, "checkout/langge/views/checkout.html")
|
||||
if err != nil {
|
||||
t.Fatalf("read langge checkout template: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(view), "{{ .trade_id }}") {
|
||||
t.Fatal("langge checkout template must only depend on trade_id server injection")
|
||||
}
|
||||
|
||||
tmpl := template.New("default")
|
||||
if !registerTemplatesFromFS(tmpl, static.Checkout, "checkout/langge", "langge") {
|
||||
t.Fatal("langge checkout template was not registered")
|
||||
}
|
||||
if tmpl.Lookup("langge/checkout.html") == nil {
|
||||
t.Fatal("langge checkout template was not registered under expected name")
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,7 @@ func epusdtInit(engine *gin.Engine) {
|
||||
epGrp := engine.Group("/pay")
|
||||
epHdr := new(epusdt.Epusdt)
|
||||
{
|
||||
epGrp.GET("/checkout-counter/:trade_id", epHdr.CheckoutCounter)
|
||||
epGrp.GET("/cashier/:trade_id", epHdr.CheckoutCashier)
|
||||
epGrp.GET("/check-status/:trade_id", epHdr.CheckStatus)
|
||||
epGrp.GET("/checkout/:trade_id", epHdr.Checkout)
|
||||
}
|
||||
|
||||
orderGrp := engine.Group("/api/v1/order")
|
||||
@@ -22,10 +20,11 @@ func epusdtInit(engine *gin.Engine) {
|
||||
orderGrp.POST("/create-order", epHdr.CreateOrder)
|
||||
}
|
||||
|
||||
payApiGrp := engine.Group("/api/v1/pay")
|
||||
payGrp := engine.Group("/api/v1/pay")
|
||||
{
|
||||
payApiGrp.POST("/methods", epHdr.GetPaymentMethods)
|
||||
payApiGrp.POST("/update-order", epHdr.UpdateOrder)
|
||||
payApiGrp.POST("/notify", epHdr.Notify)
|
||||
payGrp.POST("/info", epHdr.Info)
|
||||
payGrp.POST("/notify", epHdr.Notify)
|
||||
payGrp.POST("/methods", epHdr.GetMethods)
|
||||
payGrp.POST("/update-order", epHdr.UpdateOrder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,11 @@ func Handler() *gin.Engine {
|
||||
sess := sessions.Default(ctx)
|
||||
if secure, ok := sess.Get(conf.AdminSecureK).(bool); ok && secure {
|
||||
ctx.HTML(200, "secure.html", gin.H{})
|
||||
return
|
||||
}
|
||||
|
||||
if url := model.GetC(model.HomeRedirectUrl); url != "" {
|
||||
ctx.Redirect(302, url)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +1,136 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
"github.com/v03413/bepusdt/static"
|
||||
)
|
||||
|
||||
func staticInit(e *gin.Engine) {
|
||||
customPath := model.GetK(model.PaymentStaticPath)
|
||||
if customPath != "" && utils.IsExist(customPath) {
|
||||
initCustomPayment(e, customPath)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
initDefaultPayment(e)
|
||||
}
|
||||
|
||||
func initCustomPayment(e *gin.Engine, path string) {
|
||||
tmpl := template.New("customer")
|
||||
|
||||
template.Must(tmpl.ParseGlob(filepath.Join(path, "views", "*.html")))
|
||||
template.Must(tmpl.ParseFS(static.Secure, "secure/secure.html"))
|
||||
e.SetHTMLTemplate(tmpl)
|
||||
|
||||
e.StaticFS("/payment/assets", http.Dir(filepath.Join(path, "assets")))
|
||||
e.StaticFS("/secure/assets", http.FS(subFS(static.Secure, "secure/assets")))
|
||||
|
||||
log.Info("成功注册自定义静态资源路径:", path)
|
||||
}
|
||||
|
||||
func initDefaultPayment(e *gin.Engine) {
|
||||
tmpl := template.New("default")
|
||||
|
||||
template.Must(tmpl.ParseFS(static.Secure, "secure/secure.html"))
|
||||
template.Must(tmpl.ParseFS(static.Payment, "payment/views/*.html"))
|
||||
e.SetHTMLTemplate(tmpl)
|
||||
|
||||
checkoutFS, checkoutRoot, checkoutSourceDesc := checkoutSource()
|
||||
log.Info("当前使用", checkoutSourceDesc)
|
||||
|
||||
// 注册收银台模板和静态资源
|
||||
entries, err := fs.ReadDir(checkoutFS, checkoutRoot)
|
||||
if err != nil {
|
||||
panic(errors.New(fmt.Sprintf("收银台模板读取异常:%v", err)))
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := entry.Name()
|
||||
dir := path.Join(checkoutRoot, name)
|
||||
checkout, err := readCheckoutInfoFromFS(checkoutFS, dir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if registerTemplatesFromFS(tmpl, checkoutFS, dir, name) {
|
||||
model.RegisterCheckout(name, checkout)
|
||||
log.Info("前台收银模板注册成功:", name)
|
||||
}
|
||||
|
||||
registerAssetsFromFS(e, checkoutFS, dir, "/checkout/"+name+"/assets")
|
||||
}
|
||||
|
||||
e.SetHTMLTemplate(tmpl)
|
||||
e.StaticFS("/payment/assets", http.FS(subFS(static.Payment, "payment/assets")))
|
||||
e.StaticFS("/secure/assets", http.FS(subFS(static.Secure, "secure/assets")))
|
||||
}
|
||||
|
||||
func checkoutSource() (fs.FS, string, string) {
|
||||
const externalStaticDir = "static"
|
||||
const checkoutRoot = "checkout"
|
||||
const externalCheckoutDir = externalStaticDir + "/" + checkoutRoot
|
||||
|
||||
if info, err := os.Stat(externalCheckoutDir); err == nil && info.IsDir() {
|
||||
return os.DirFS(externalStaticDir), checkoutRoot, "外部收银台模板目录:" + externalCheckoutDir
|
||||
} else if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
return static.Checkout, checkoutRoot, "内嵌收银台模板(外部目录读取失败:" + err.Error() + ")"
|
||||
}
|
||||
|
||||
return static.Checkout, checkoutRoot, "内嵌收银台模板"
|
||||
}
|
||||
|
||||
func readCheckoutInfoFromFS(src fs.FS, baseDir string) (model.Checkout, error) {
|
||||
infoPath := path.Join(baseDir, "checkout.json")
|
||||
data, err := fs.ReadFile(src, infoPath)
|
||||
if err != nil {
|
||||
return model.Checkout{}, fmt.Errorf("checkout.json 不存在或读取失败: %w", err)
|
||||
}
|
||||
|
||||
var checkout model.Checkout
|
||||
if err := json.Unmarshal(data, &checkout); err != nil {
|
||||
return model.Checkout{}, fmt.Errorf("解析 checkout.json 失败: %w", err)
|
||||
}
|
||||
|
||||
return checkout, nil
|
||||
}
|
||||
|
||||
func registerTemplatesFromFS(tmpl *template.Template, src fs.FS, baseDir, namePrefix string) bool {
|
||||
viewsDir := path.Join(baseDir, "views")
|
||||
files, err := fs.ReadDir(src, viewsDir)
|
||||
if err != nil {
|
||||
log.Error("读取模板目录失败:", err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
registered := false
|
||||
for _, f := range files {
|
||||
if f.IsDir() || !strings.HasSuffix(f.Name(), ".html") {
|
||||
continue
|
||||
}
|
||||
|
||||
content, rErr := fs.ReadFile(src, path.Join(viewsDir, f.Name()))
|
||||
if rErr != nil {
|
||||
log.Error("读取模板文件失败:", rErr.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
name := f.Name()
|
||||
if namePrefix != "" {
|
||||
name = namePrefix + "/" + name
|
||||
}
|
||||
|
||||
if _, pErr := tmpl.New(name).Parse(string(content)); pErr != nil {
|
||||
log.Error("解析模板失败:", pErr.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
registered = true
|
||||
}
|
||||
|
||||
return registered
|
||||
}
|
||||
|
||||
func registerAssetsFromFS(e *gin.Engine, src fs.FS, baseDir, routePath string) {
|
||||
assetsDir := path.Join(baseDir, "assets")
|
||||
if _, err := fs.Stat(src, assetsDir); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
e.StaticFS(routePath, http.FS(subFS(src, assetsDir)))
|
||||
}
|
||||
|
||||
func subFS(src fs.FS, dir string) fs.FS {
|
||||
sub, _ := fs.Sub(src, dir)
|
||||
|
||||
|
||||
@@ -8,14 +8,15 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"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"
|
||||
@@ -27,7 +28,6 @@ type aptos struct {
|
||||
lastVersion int
|
||||
versionQueue *chanx.UnboundedChan[version]
|
||||
client *http.Client
|
||||
earliestBlockTs atomic.Int64
|
||||
}
|
||||
|
||||
type version struct {
|
||||
@@ -54,16 +54,16 @@ func init() {
|
||||
Register(Task{Callback: apt.versionDispatch})
|
||||
Register(Task{Callback: apt.syncVersionForward, Duration: time.Second * 3})
|
||||
Register(Task{Callback: apt.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: apt.lookbackVersion, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
func newAptos() aptos {
|
||||
return aptos{
|
||||
versionChunkSize: 100, // 目前好像最大就只能100
|
||||
versionChunkSize: 100,
|
||||
versionConfirmedOffset: 1000,
|
||||
lastVersion: 0,
|
||||
versionQueue: chanx.NewUnboundedChan[version](context.Background(), 30),
|
||||
client: utils.NewHttpClient(),
|
||||
earliestBlockTs: atomic.Int64{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +103,6 @@ func (a *aptos) syncVersionForward(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if a.lastVersion == 0 {
|
||||
a.syncVersionBackward(ctx, now)
|
||||
}
|
||||
|
||||
if now-a.lastVersion > 10000 {
|
||||
a.lastVersion = now - a.versionChunkSize
|
||||
}
|
||||
@@ -133,43 +129,33 @@ func (a *aptos) syncVersionForward(ctx context.Context) {
|
||||
a.lastVersion = now
|
||||
}
|
||||
|
||||
func (a *aptos) syncVersionBackward(ctx context.Context, now int) {
|
||||
var o model.Order
|
||||
trade := model.GetNetworkTrades(conf.Aptos)
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)",
|
||||
model.OrderStatusWaiting, trade).Order("created_at asc").Limit(1).Find(&o)
|
||||
if o.ID == 0 {
|
||||
func (a *aptos) lookbackVersion(ctx context.Context) {
|
||||
if syncBreak(conf.Aptos, a.versionQueue.Len()) {
|
||||
return
|
||||
}
|
||||
|
||||
start := o.CreatedAt.Time().Unix()
|
||||
startAt, endAt, ok := getLookbackUnix(conf.Aptos)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
if syncBreak(conf.Aptos, a.versionQueue.Len()) {
|
||||
return
|
||||
}
|
||||
|
||||
if a.earliestBlockTs.Load() != 0 && a.earliestBlockTs.Load() < start {
|
||||
return
|
||||
}
|
||||
|
||||
a.versionQueue.In <- version{
|
||||
Start: now - a.versionChunkSize,
|
||||
Limit: a.versionChunkSize,
|
||||
}
|
||||
|
||||
now = now - a.versionChunkSize
|
||||
}
|
||||
start, end := blockapi.New().GetBoundaryHeights(startAt, endAt, conf.Aptos)
|
||||
for i := int(start); i <= int(end); i += a.versionChunkSize {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
}()
|
||||
if syncBreak(conf.Aptos, a.versionQueue.Len()) {
|
||||
return
|
||||
}
|
||||
limit := a.versionChunkSize
|
||||
if i+limit > int(end) {
|
||||
limit = int(end) - i + 1
|
||||
}
|
||||
a.versionQueue.In <- version{Start: i, Limit: limit}
|
||||
time.Sleep(time.Millisecond * 200) // 速率控制
|
||||
}
|
||||
}
|
||||
|
||||
func (a *aptos) versionDispatch(ctx context.Context) {
|
||||
@@ -207,7 +193,7 @@ func (a *aptos) versionParse(n any) {
|
||||
var net = conf.Aptos
|
||||
var url = fmt.Sprintf("%sv1/transactions?start=%d&limit=%d", model.Endpoint(conf.Aptos), p.Start, p.Limit)
|
||||
|
||||
conf.RecordSuccess(net)
|
||||
conf.RecordSuccess(net, cast.ToString(p.Start+p.Limit))
|
||||
resp, err := a.client.Get(url)
|
||||
if err != nil {
|
||||
conf.RecordFailure(net)
|
||||
@@ -245,7 +231,6 @@ func (a *aptos) versionParse(n any) {
|
||||
for _, trans := range gjson.ParseBytes(body).Array() {
|
||||
tsNano := trans.Get("timestamp").Int() * 1000
|
||||
timestamp := time.Unix(tsNano/1e9, tsNano%1e9)
|
||||
a.recordEarliestBlockTs(timestamp.Unix())
|
||||
|
||||
ver := int(trans.Get("version").Int())
|
||||
hash := trans.Get("hash").String()
|
||||
@@ -466,15 +451,3 @@ func (a *aptos) tradeConfirmHandle(ctx context.Context) {
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (a *aptos) recordEarliestBlockTs(unix int64) {
|
||||
for {
|
||||
current := a.earliestBlockTs.Load()
|
||||
if current != 0 && unix >= current {
|
||||
return
|
||||
}
|
||||
if a.earliestBlockTs.CompareAndSwap(current, unix) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ func arbitrumInit() {
|
||||
Register(Task{Callback: arb.blockDispatch})
|
||||
Register(Task{Callback: arb.syncBlocksForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: arb.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: arb.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ func baseInit() {
|
||||
Register(Task{Callback: base.blockDispatch})
|
||||
Register(Task{Callback: base.syncBlocksForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: base.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: base.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -29,4 +29,5 @@ func bscInit() {
|
||||
Register(Task{Callback: bsc.blockDispatch})
|
||||
Register(Task{Callback: bsc.syncBlocksForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: bsc.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: bsc.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import (
|
||||
func ethInit() {
|
||||
ctx := context.Background()
|
||||
eth := evm{
|
||||
Network: conf.Ethereum,
|
||||
Network: conf.Ethereum,
|
||||
LookbackInterval: time.Second * 2,
|
||||
Block: block{
|
||||
ConfirmedOffset: 12,
|
||||
},
|
||||
@@ -29,4 +30,5 @@ func ethInit() {
|
||||
Register(Task{Callback: eth.blockDispatch})
|
||||
Register(Task{Callback: eth.syncBlocksForward, Duration: time.Second * 12})
|
||||
Register(Task{Callback: eth.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: eth.lookbackBlocks, Duration: time.Second * 20})
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"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"
|
||||
@@ -42,12 +43,12 @@ type evmNative struct {
|
||||
}
|
||||
|
||||
type evm struct {
|
||||
Network string
|
||||
Block block
|
||||
Native evmNative
|
||||
Client *http.Client
|
||||
AvgBlockTime int64 // 平均出块时间,单位秒;一个大概值,用于计算首次启动时需要回溯的区块数量,尽量准确设置,默认1秒一个区块
|
||||
blockScanQueue *chanx.UnboundedChan[evmBlock]
|
||||
Network string
|
||||
Block block
|
||||
Native evmNative
|
||||
Client *http.Client
|
||||
blockScanQueue *chanx.UnboundedChan[evmBlock]
|
||||
LookbackInterval time.Duration // 回溯时每批入队的间隔,控制 RPC 调用速率;默认 500ms
|
||||
}
|
||||
|
||||
type evmBlock struct {
|
||||
@@ -101,10 +102,7 @@ func (e *evm) syncBlocksForward(ctx context.Context) {
|
||||
|
||||
var lastBlockNumber int64
|
||||
if v, ok := chainBlockNum.Load(e.Network); ok {
|
||||
|
||||
lastBlockNumber = v.(int64)
|
||||
} else {
|
||||
e.syncBlocksBackward(now) // 不存在,说明是第一次启动
|
||||
}
|
||||
|
||||
if now-lastBlockNumber > cast.ToInt64(model.GetC(model.BlockHeightMaxDiff)) {
|
||||
@@ -128,42 +126,38 @@ func (e *evm) syncBlocksForward(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *evm) syncBlocksBackward(now int64) {
|
||||
if e.AvgBlockTime <= 0 { // 未设置平均出块时间,默认1秒一个
|
||||
e.AvgBlockTime = 1
|
||||
}
|
||||
|
||||
var o model.Order
|
||||
trade := model.GetNetworkTrades(model.Network(e.Network))
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trade).Order("created_at asc").Limit(1).Find(&o)
|
||||
if o.ID == 0 {
|
||||
|
||||
func (e *evm) lookbackBlocks(ctx context.Context) {
|
||||
if syncBreak(e.Network, e.blockScanQueue.Len()) {
|
||||
return
|
||||
}
|
||||
|
||||
sub := ((time.Now().Unix() - o.CreatedAt.Time().Unix()) / e.AvgBlockTime) + 30 //计算需要回溯的区块数量,同时冗余30个区块
|
||||
start := now - sub
|
||||
startAt, endAt, ok := getLookbackUnix(model.Network(e.Network))
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
interval := e.LookbackInterval
|
||||
if interval <= 0 {
|
||||
interval = time.Millisecond * 300
|
||||
}
|
||||
|
||||
for from := start; from <= now; from += blockParseMaxNum {
|
||||
if syncBreak(e.Network, e.blockScanQueue.Len()) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
to := from + blockParseMaxNum - 1
|
||||
if to > now {
|
||||
to = now
|
||||
}
|
||||
|
||||
e.blockScanQueue.In <- evmBlock{From: from, To: to}
|
||||
|
||||
<-ticker.C
|
||||
start, end := blockapi.New().GetBoundaryHeights(startAt, endAt, e.Network)
|
||||
for i := start; i <= end; i += blockParseMaxNum {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
}()
|
||||
if syncBreak(e.Network, e.blockScanQueue.Len()) {
|
||||
return
|
||||
}
|
||||
to := i + blockParseMaxNum - 1
|
||||
if to > end {
|
||||
to = end
|
||||
}
|
||||
e.blockScanQueue.In <- evmBlock{From: i, To: to}
|
||||
time.Sleep(interval)
|
||||
}
|
||||
}
|
||||
|
||||
func (e *evm) blockDispatch(ctx context.Context) {
|
||||
@@ -234,7 +228,7 @@ func (e *evm) getBlockByNumber(a any) {
|
||||
return
|
||||
}
|
||||
|
||||
conf.RecordSuccess(e.Network)
|
||||
conf.RecordSuccess(e.Network, cast.ToString(b.To))
|
||||
|
||||
nativeTransfers := make([]transfer, 0)
|
||||
blockTimestamp := make(map[string]time.Time)
|
||||
@@ -396,7 +390,7 @@ func (e *evm) tradeConfirmHandle(ctx context.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if last.(int)-o.RefBlockNum < e.Block.ConfirmedOffset {
|
||||
if cast.ToInt(last)-o.RefBlockNum < e.Block.ConfirmedOffset {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -480,9 +474,5 @@ func syncBreak(network string, num int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
model.Db.Model(&model.Order{}).
|
||||
Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trades).
|
||||
Count(&count)
|
||||
|
||||
return count == 0
|
||||
return !hasLookbackOrders(trades)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"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"
|
||||
)
|
||||
@@ -37,3 +38,9 @@ func notifyRoll(context.Context) {
|
||||
notify.Bepusdt(o)
|
||||
}
|
||||
}
|
||||
|
||||
// notifyOrderSuccess 统一触发订单成功后的回调与订单通知。
|
||||
func notifyOrderSuccess(order model.Order) {
|
||||
go notify.Handle(order)
|
||||
go notifier.Success(order)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/spf13/cast"
|
||||
"github.com/v03413/bepusdt/app"
|
||||
epay2 "github.com/v03413/bepusdt/app/handler/epay"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/notifier"
|
||||
@@ -60,7 +59,7 @@ func Handle(order model.Order) error {
|
||||
|
||||
func epay(ctx context.Context, order model.Order) error {
|
||||
var client = http.Client{Timeout: time.Second * 5}
|
||||
var notifyUrl = fmt.Sprintf("%s?%s", order.NotifyUrl, epay2.BuildNotifyParams(order))
|
||||
var notifyUrl = fmt.Sprintf("%s?%s", order.NotifyUrl, order.BuildNotifyParams())
|
||||
|
||||
postReq, err2 := http.NewRequestWithContext(ctx, "GET", notifyUrl, nil)
|
||||
if err2 != nil {
|
||||
@@ -162,7 +161,7 @@ func epusdt(ctx context.Context, order model.Order) error {
|
||||
}
|
||||
|
||||
func Bepusdt(o model.Order) {
|
||||
if o.ApiType != model.OrderApiTypeEpusdt {
|
||||
if o.ApiType != model.OrderApiTypeEpusdt && o.ApiType != model.OrderApiTypeEpusdtOrder {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ func plasmaInit() {
|
||||
Register(Task{Callback: xpl.blockDispatch})
|
||||
Register(Task{Callback: xpl.syncBlocksForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: xpl.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: xpl.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -23,4 +23,5 @@ func polygonInit() {
|
||||
Register(Task{Callback: pol.blockDispatch})
|
||||
Register(Task{Callback: pol.syncBlocksForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: pol.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: pol.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
func init() {
|
||||
var rate = Rate{}
|
||||
|
||||
Register(Task{Duration: time.Hour, Callback: rate.Clear})
|
||||
Register(Task{Duration: time.Second * 5, Callback: rate.Sync})
|
||||
}
|
||||
|
||||
@@ -34,3 +35,13 @@ func (Rate) Sync(ctx context.Context) {
|
||||
log.Warn(fmt.Sprintf("同步汇率失败: %s", err.Error()))
|
||||
}
|
||||
}
|
||||
|
||||
func (Rate) Clear(ctx context.Context) {
|
||||
days := cast.ToInt(model.GetC(model.RateSyncHistoryDays))
|
||||
if days <= 0 {
|
||||
days = 1
|
||||
}
|
||||
|
||||
createdAt := time.Now().AddDate(0, 0, -days)
|
||||
model.Db.Where("created_at < ?", createdAt).Delete(&model.Rate{})
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"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"
|
||||
@@ -46,6 +47,7 @@ func init() {
|
||||
Register(Task{Callback: sol.slotDispatch})
|
||||
Register(Task{Callback: sol.syncSlotForward, Duration: time.Second * 5})
|
||||
Register(Task{Callback: sol.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: sol.lookbackSlots, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
func newSolana() solana {
|
||||
@@ -95,10 +97,6 @@ func (s *solana) syncSlotForward(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if s.lastSlotNum == 0 { // 首次启动,往后追溯
|
||||
s.syncSlotBackward(now)
|
||||
}
|
||||
|
||||
if now-s.lastSlotNum > cast.ToInt(model.GetC(model.BlockHeightMaxDiff)) { // 区块高度变化过大,强制丢块重扫
|
||||
s.lastSlotNum = now
|
||||
}
|
||||
@@ -117,40 +115,6 @@ func (s *solana) syncSlotForward(ctx context.Context) {
|
||||
s.lastSlotNum = now
|
||||
}
|
||||
|
||||
func (s *solana) syncSlotBackward(now int) {
|
||||
if now == 0 || s.lastSlotNum != 0 {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var o model.Order
|
||||
trade := model.GetNetworkTrades(conf.Solana)
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trade).Order("created_at asc").Limit(1).Find(&o)
|
||||
if o.ID == 0 {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Solana 大概1秒3个区块(大概值,实际存在波动)
|
||||
num := int((time.Now().Unix() - o.CreatedAt.Time().Unix() + 1) * 3) // 计算需要反向扫描的区块数量
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Millisecond * 125)
|
||||
defer ticker.Stop()
|
||||
|
||||
for i := 0; i < num; i++ {
|
||||
if syncBreak(conf.Solana, s.slotQueue.Len()) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
s.slotQueue.In <- now - i
|
||||
|
||||
<-ticker.C
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *solana) slotDispatch(ctx context.Context) {
|
||||
p, err := ants.NewPoolWithFunc(3, s.slotParse)
|
||||
if err != nil {
|
||||
@@ -183,7 +147,7 @@ func (s *solana) slotParse(n any) {
|
||||
post := []byte(fmt.Sprintf(`{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[%d,{"encoding":"json","maxSupportedTransactionVersion":0,"transactionDetails":"full","rewards":false}]}`, slot))
|
||||
network := conf.Solana
|
||||
|
||||
conf.RecordSuccess(network)
|
||||
conf.RecordSuccess(network, cast.ToString(slot))
|
||||
resp, err := s.client.Post(model.Endpoint(conf.Solana), "application/json", bytes.NewBuffer(post))
|
||||
if err != nil {
|
||||
conf.RecordFailure(network)
|
||||
@@ -418,3 +382,28 @@ func (s *solana) tradeConfirmHandle(ctx context.Context) {
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (s *solana) lookbackSlots(ctx context.Context) {
|
||||
if syncBreak(conf.Solana, s.slotQueue.Len()) {
|
||||
return
|
||||
}
|
||||
|
||||
startAt, endAt, ok := getLookbackUnix(conf.Solana)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
start, end := blockapi.New().GetBoundaryHeights(startAt, endAt, conf.Solana)
|
||||
for i := int(start); i <= int(end); i++ {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
if syncBreak(conf.Solana, s.slotQueue.Len()) {
|
||||
return
|
||||
}
|
||||
s.slotQueue.In <- i
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"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/xssnick/tonutils-go/address"
|
||||
"github.com/xssnick/tonutils-go/tlb"
|
||||
tgo "github.com/xssnick/tonutils-go/ton"
|
||||
)
|
||||
|
||||
const tonMasterChainID = -1
|
||||
const tonMasterShard = int64(-0x8000000000000000)
|
||||
const tonOpInternalTransfer = uint32(0x178d4519)
|
||||
|
||||
type ton struct {
|
||||
lastBlockSeqno uint32
|
||||
shardTipMap sync.Map // key: "workchain:shard", value: uint32 last processed shard seqno
|
||||
blockScanQueue *chanx.UnboundedChan[uint32]
|
||||
clientOnce sync.Once
|
||||
api tgo.APIClientWrapped
|
||||
}
|
||||
|
||||
var tn ton
|
||||
|
||||
func init() {
|
||||
tn = ton{
|
||||
blockScanQueue: chanx.NewUnboundedChan[uint32](context.Background(), 30),
|
||||
}
|
||||
|
||||
Register(Task{Callback: tn.syncMBSeqnoForward})
|
||||
Register(Task{Duration: time.Second, Callback: tn.blockDispatch})
|
||||
Register(Task{Duration: time.Second * 3, Callback: tn.tradeConfirmHandle})
|
||||
Register(Task{Duration: time.Second * 15, Callback: tn.lookbackBlocks})
|
||||
}
|
||||
|
||||
func (t *ton) syncMBSeqnoForward(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
if t.syncBreak() {
|
||||
time.Sleep(time.Second * 3)
|
||||
continue
|
||||
}
|
||||
|
||||
// 初始化:首次获取当前最新高度作为起点
|
||||
if t.lastBlockSeqno == 0 {
|
||||
mb, err := t.client().CurrentMasterchainInfo(ctx)
|
||||
if err != nil {
|
||||
log.Task.Warn(fmt.Sprintf("get current masterchain info: %v", err))
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
t.lastBlockSeqno = mb.SeqNo - 1
|
||||
}
|
||||
|
||||
nextSeqno := t.lastBlockSeqno + 1
|
||||
|
||||
// 阻塞直到 nextSeqno 在节点上可用,无需轮询
|
||||
mb, err := t.client().WaitForBlock(nextSeqno).GetMasterchainInfo(ctx)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.Task.Warn(fmt.Sprintf("WaitForBlock GetMasterchainInfo err: %v", err))
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
now := mb.SeqNo
|
||||
|
||||
// 区块高度变化过大,强制丢块重扫
|
||||
if now-t.lastBlockSeqno > cast.ToUint32(model.GetC(model.BlockHeightMaxDiff)) {
|
||||
t.lastBlockSeqno = now - 1
|
||||
}
|
||||
|
||||
// 待扫描区块入列
|
||||
for n := t.lastBlockSeqno + 1; n <= now; n++ {
|
||||
t.blockScanQueue.In <- n
|
||||
}
|
||||
|
||||
t.lastBlockSeqno = now
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ton) blockDispatch(ctx context.Context) {
|
||||
p, err := ants.NewPoolWithFunc(5, t.blockParse)
|
||||
if err != nil {
|
||||
log.Task.Warn("Error creating pool:", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
defer p.Release()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case n, ok := <-t.blockScanQueue.Out:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if err := p.Invoke(n); err != nil {
|
||||
|
||||
log.Task.Warn("Tron Error invoking process block:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ton) blockParse(n any) {
|
||||
var seqno = n.(uint32)
|
||||
var ctx, cancel = context.WithTimeout(context.Background(), time.Second*60)
|
||||
defer cancel()
|
||||
|
||||
mb, err := t.client().LookupBlock(ctx, tonMasterChainID, tonMasterShard, seqno)
|
||||
if err != nil {
|
||||
conf.RecordFailure(conf.Ton)
|
||||
log.Task.Warn("Ton LookupBlock ", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
conf.RecordSuccess(conf.Ton, cast.ToString(seqno))
|
||||
|
||||
// 目前实际来看,basechain 还未分裂,所以 len(shardsTip) == 1
|
||||
shardsTip, err := t.client().GetBlockShardsInfo(ctx, mb)
|
||||
if err != nil {
|
||||
conf.RecordFailure(conf.Ton)
|
||||
log.Task.Warn(fmt.Sprintf("get shards info seqno=%d err: %v", seqno, err))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
for _, tip := range shardsTip {
|
||||
start := tip.SeqNo
|
||||
key := fmt.Sprintf("%d:%d", tip.Workchain, tip.Shard)
|
||||
if old, loaded := t.shardTipMap.Swap(key, tip.SeqNo); loaded {
|
||||
start = old.(uint32) + 1
|
||||
}
|
||||
|
||||
for s := start; s <= tip.SeqNo; s++ {
|
||||
shardBlock, err := t.client().LookupBlock(ctx, tip.Workchain, tip.Shard, s)
|
||||
if err != nil {
|
||||
conf.RecordFailure(conf.Ton)
|
||||
log.Task.Warn(fmt.Sprintf("lookup shard block workchain=%d shard=%d seqno=%d err: %v", tip.Workchain, tip.Shard, s, err))
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if err := t.processShard(ctx, shardBlock, seqno); err != nil {
|
||||
conf.RecordFailure(conf.Ton)
|
||||
log.Task.Warn(fmt.Sprintf("process shard block workchain=%d shard=%d seqno=%d err: %v", tip.Workchain, tip.Shard, s, err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Task.Info(fmt.Sprintf("区块扫描完成(Ton): %d 成功率:%s", seqno, conf.GetSuccessRate(conf.Ton)))
|
||||
}
|
||||
|
||||
func (t *ton) syncBreak() bool {
|
||||
if t.blockScanQueue.Len() >= blockQueueLimit {
|
||||
log.Task.Warn("ton 同步阻塞,当前区块消费堆积数量:", t.blockScanQueue.Len())
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
if mqttSubscribed(conf.Ton) {
|
||||
return false
|
||||
}
|
||||
|
||||
var count int64 = 0
|
||||
trade := []model.TradeType{model.UsdtTon, model.TonGram}
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trade).Count(&count)
|
||||
if count > 0 {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
model.Db.Model(&model.Wallet{}).Where("other_notify = ? and trade_type in (?)", model.WaOtherEnable, trade).Count(&count)
|
||||
if count > 0 {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *ton) processShard(ctx context.Context, shard *tgo.BlockIDExt, seqno uint32) error {
|
||||
data, err := t.client().GetBlockData(ctx, shard)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
txs, err := data.ListTransactions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var transfers = make([]transfer, 0)
|
||||
for _, tx := range txs {
|
||||
if tonTrans, ok := t.parseTonTransfer(tx, seqno); ok {
|
||||
transfers = append(transfers, tonTrans)
|
||||
}
|
||||
if jettonTrans, ok := t.parseInternalTransfer(shard, tx, seqno); ok {
|
||||
transfers = append(transfers, jettonTrans)
|
||||
}
|
||||
}
|
||||
|
||||
if len(transfers) > 0 {
|
||||
transferQueue.In <- transfers
|
||||
}
|
||||
|
||||
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) {
|
||||
if tx.IO.In == nil {
|
||||
return transfer{}, false
|
||||
}
|
||||
in, ok := tx.IO.In.Msg.(*tlb.InternalMessage)
|
||||
if !ok || in.Bounced || in.Body == nil {
|
||||
return transfer{}, false
|
||||
}
|
||||
s, err := in.Body.BeginParse()
|
||||
if err != nil || s.BitsLeft() < 32 {
|
||||
return transfer{}, false
|
||||
}
|
||||
v, err := s.LoadUInt(32)
|
||||
if err != nil || uint32(v) != tonOpInternalTransfer {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
transOrd, ok := tx.Description.(tlb.TransactionDescriptionOrdinary)
|
||||
if !ok {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
compute, ok := transOrd.ComputePhase.Phase.(tlb.ComputePhaseVM)
|
||||
if !ok || !compute.Success {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
if transOrd.ActionPhase == nil || !transOrd.ActionPhase.Success {
|
||||
return transfer{}, false
|
||||
}
|
||||
|
||||
if err = s.SkipBits(64); err != nil {
|
||||
return transfer{}, false
|
||||
}
|
||||
amount, err := s.LoadBigCoins()
|
||||
if err != nil || amount.Sign() <= 0 {
|
||||
return transfer{}, false
|
||||
}
|
||||
fromOwner, err := s.LoadAddr()
|
||||
if err != nil {
|
||||
return transfer{}, false
|
||||
}
|
||||
if fromOwner.Type() != address.StdAddress {
|
||||
fromOwner = address.NewAddress(0, byte(fromOwner.Workchain()), fromOwner.Data())
|
||||
}
|
||||
|
||||
toJetton := address.NewAddress(0, byte(shard.Workchain), tx.AccountAddr)
|
||||
|
||||
return transfer{
|
||||
Network: conf.Ton,
|
||||
TxHash: hex.EncodeToString(tx.Hash),
|
||||
Amount: decimal.NewFromBigInt(amount, conf.UsdtTonDecimals),
|
||||
FromAddress: fromOwner.Bounce(false).String(),
|
||||
RecvAddress: toJetton.Bounce(false).String(),
|
||||
Timestamp: time.Unix(int64(tx.Now), 0),
|
||||
TradeType: model.UsdtTon,
|
||||
BlockNum: int(blockNum),
|
||||
}, true
|
||||
}
|
||||
|
||||
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)
|
||||
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 {
|
||||
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(),
|
||||
Timestamp: time.Unix(int64(tx.Now), 0),
|
||||
Amount: decimal.NewFromBigInt(msg.Amount.Nano(), conf.TonTonDecimals),
|
||||
TradeType: model.TonGram,
|
||||
BlockNum: int(blockNum),
|
||||
}, true
|
||||
}
|
||||
|
||||
func (t *ton) tradeConfirmHandle(context.Context) {
|
||||
var orders = getConfirmingOrders([]model.TradeType{model.UsdtTon, model.TonGram})
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for _, order := range orders {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
// 一旦某笔交易所在的 shard block 被 MasterChain block 引用(commit),则该交易获得最终性(finality)。
|
||||
markFinalConfirmed(order)
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
func (t *ton) client() tgo.APIClientWrapped {
|
||||
t.clientOnce.Do(func() {
|
||||
t.api = utils.NewTonClient(model.GetC(model.RpcGlobalConfigUrlTon))
|
||||
})
|
||||
|
||||
return t.api
|
||||
}
|
||||
|
||||
func (t *ton) lookbackBlocks(ctx context.Context) {
|
||||
if t.syncBreak() {
|
||||
return
|
||||
}
|
||||
|
||||
startAt, endAt, ok := getLookbackUnix(conf.Ton)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
start, end := blockapi.New().GetBoundaryHeights(startAt, endAt, conf.Ton)
|
||||
for i := start; i <= end; i++ {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
if t.syncBreak() {
|
||||
return
|
||||
}
|
||||
t.blockScanQueue.In <- uint32(i)
|
||||
time.Sleep(time.Millisecond * 200) // 速率控制
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
@@ -41,6 +42,9 @@ var resourceQueue = chanx.NewUnboundedChan[[]resource](context.Background(), 30)
|
||||
var notOrderQueue = chanx.NewUnboundedChan[[]transfer](context.Background(), 30) // 非订单队列
|
||||
var transferQueue = chanx.NewUnboundedChan[[]transfer](context.Background(), 30) // 交易转账队列
|
||||
|
||||
// lookbackDone 记录已触发过回溯的订单 ID,每个订单只回溯一次。
|
||||
var lookbackDone sync.Map // key: int64 order ID, value: struct{}
|
||||
|
||||
const batchInterval = time.Second * 1 // 批处理缓解数据库读取压力
|
||||
const orderCheckInterval = time.Second * 10 // 订单过期检查间隔
|
||||
|
||||
@@ -68,19 +72,21 @@ func orderTransferHandle(ctx context.Context) {
|
||||
case <-ticker.C:
|
||||
// 每10秒强制检查一次过期订单,即使没有交易,防止无交易时订单不过期
|
||||
var shouldCheck = time.Since(lastCheckTime) >= orderCheckInterval
|
||||
if len(batch) == 0 && !shouldCheck {
|
||||
continue
|
||||
}
|
||||
|
||||
if shouldCheck {
|
||||
lastCheckTime = time.Now()
|
||||
}
|
||||
|
||||
var other = make([]transfer, 0)
|
||||
var orders = getAllWaitingOrders() // 内部包含过期检查逻辑
|
||||
if len(batch) == 0 {
|
||||
if shouldCheck {
|
||||
expireWaitingOrders()
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
var other = make([]transfer, 0)
|
||||
var orders = getReceivableOrders()
|
||||
|
||||
for _, t := range batch {
|
||||
// 判断数额是否在允许范围内
|
||||
if !model.IsAmountValid(t.TradeType, t.Amount) {
|
||||
@@ -98,21 +104,18 @@ func orderTransferHandle(ctx context.Context) {
|
||||
|
||||
var matched bool
|
||||
for i, o := range orderList {
|
||||
// 金额匹配
|
||||
if !o.AddressLocked && !amountMatch(t.Amount, o.Amount, string(o.TradeType)) {
|
||||
if !orderTransferMatch(o, t) {
|
||||
continue
|
||||
}
|
||||
|
||||
// 有效期检测
|
||||
if !o.CreatedAt.Before(t.Timestamp) || !o.ExpiredAt.After(t.Timestamp) {
|
||||
// 订单匹配 进入确认流程
|
||||
if err := o.MarkConfirming(t.BlockNum, t.FromAddress, t.TxHash, t.Timestamp, t.Amount); err != nil {
|
||||
log.Task.Warn("mark order confirming failed:", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// 从内存 map 中移除已匹配订单,防止同批次其他 transfer 重复匹配
|
||||
orders[key] = append(orderList[:i], orderList[i+1:]...)
|
||||
|
||||
// 订单匹配 进入确认流程
|
||||
o.MarkConfirming(t.BlockNum, t.FromAddress, t.TxHash, t.Timestamp, t.Amount)
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
@@ -127,10 +130,36 @@ func orderTransferHandle(ctx context.Context) {
|
||||
}
|
||||
|
||||
batch = batch[:0]
|
||||
|
||||
if shouldCheck {
|
||||
expireWaitingOrders()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func orderTransferMatch(o model.Order, t transfer) bool {
|
||||
if o.TradeType != t.TradeType || orderMatchAddress(o) != t.RecvAddress {
|
||||
return false
|
||||
}
|
||||
if !o.AddressLocked && !amountMatch(t.Amount, o.Amount, string(o.TradeType)) {
|
||||
return false
|
||||
}
|
||||
if !o.CreatedAt.Before(t.Timestamp) || !o.ExpiredAt.After(t.Timestamp) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func orderMatchAddress(o model.Order) string {
|
||||
if o.MatchAddress != "" {
|
||||
return o.MatchAddress
|
||||
}
|
||||
|
||||
return o.Address
|
||||
}
|
||||
|
||||
func notOrderTransferHandle(ctx context.Context) {
|
||||
var batch = make([]transfer, 0, 1000)
|
||||
ticker := time.NewTicker(batchInterval)
|
||||
@@ -227,29 +256,100 @@ func tronResourceHandle(ctx context.Context) {
|
||||
|
||||
func markFinalConfirmed(o model.Order) {
|
||||
o.SetSuccess()
|
||||
|
||||
go notify.Handle(o) // 订单回调
|
||||
go notifier.Success(o) // 消息通知
|
||||
notifyOrderSuccess(o)
|
||||
}
|
||||
|
||||
func getAllWaitingOrders() map[string][]model.Order {
|
||||
var tradeOrders = model.GetOrderByStatus(model.OrderStatusWaiting)
|
||||
var data = make(map[string][]model.Order)
|
||||
for _, t := range tradeOrders {
|
||||
if time.Now().Unix() >= t.ExpiredAt.Unix() { // 订单过期
|
||||
t.SetExpired()
|
||||
notify.Bepusdt(t)
|
||||
func receivableOrderStatuses() []int {
|
||||
return []int{model.OrderStatusWaiting, model.OrderStatusExpired}
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
func getReceivableOrders() map[string][]model.Order {
|
||||
var orders []model.Order
|
||||
db := model.Db.Where("status in (?)", receivableOrderStatuses()).
|
||||
Where("expired_at > ?", time.Now().Add(model.GetLookbackHour())).
|
||||
Order("created_at asc")
|
||||
db.Find(&orders)
|
||||
|
||||
key := t.Address + string(t.TradeType)
|
||||
data := make(map[string][]model.Order)
|
||||
for _, t := range orders {
|
||||
key := orderMatchAddress(t) + string(t.TradeType)
|
||||
data[key] = append(data[key], t)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func hasLookbackOrders(tradeType []model.TradeType) bool {
|
||||
var count int64
|
||||
db := model.Db.Model(&model.Order{}).
|
||||
Where("status in (?)", receivableOrderStatuses()).
|
||||
Where("expired_at > ?", time.Now().Add(model.GetLookbackHour()))
|
||||
if len(tradeType) > 0 {
|
||||
db = db.Where("trade_type in (?)", tradeType)
|
||||
}
|
||||
|
||||
db.Count(&count)
|
||||
|
||||
return count > 0
|
||||
}
|
||||
|
||||
func getLookbackUnix(network model.Network) (startAt, endAt int64, ok bool) {
|
||||
trade := model.GetNetworkTrades(network)
|
||||
if len(trade) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
lookback := time.Now().Add(model.GetLookbackHour())
|
||||
var all []model.Order
|
||||
model.Db.Model(&model.Order{}).
|
||||
Where("status in (?) and trade_type in (?)", receivableOrderStatuses(), trade).
|
||||
Where("expired_at > ?", lookback).
|
||||
Order("created_at asc").
|
||||
Find(&all)
|
||||
|
||||
// 过滤掉已经回溯过的订单
|
||||
pending := make([]model.Order, 0, len(all))
|
||||
for _, o := range all {
|
||||
if _, done := lookbackDone.Load(o.ID); !done {
|
||||
pending = append(pending, o)
|
||||
}
|
||||
}
|
||||
if len(pending) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// 起点:最早的创建时间(已按 created_at asc 排序)
|
||||
startAt = pending[0].CreatedAt.Time().Unix()
|
||||
|
||||
// 终点:最晚的已过期 expired_at;若全部尚未过期则用当前时间
|
||||
endAt = time.Now().Unix()
|
||||
for _, o := range pending {
|
||||
if o.ExpiredAt.Before(time.Now()) && o.ExpiredAt.Unix() > startAt {
|
||||
endAt = o.ExpiredAt.Unix()
|
||||
}
|
||||
}
|
||||
|
||||
ok = true
|
||||
|
||||
// 标记这批订单已回溯,后续不再重复触发
|
||||
for _, o := range pending {
|
||||
lookbackDone.Store(o.ID, struct{}{})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func expireWaitingOrders() {
|
||||
for _, t := range model.GetOrderByStatus(model.OrderStatusWaiting) {
|
||||
if time.Now().Unix() < t.ExpiredAt.Unix() {
|
||||
continue
|
||||
}
|
||||
|
||||
t.SetExpired()
|
||||
notify.Bepusdt(t)
|
||||
}
|
||||
}
|
||||
|
||||
func getConfirmingOrders(tradeType []model.TradeType) []model.Order {
|
||||
var orders = make([]model.Order, 0)
|
||||
var data = make([]model.Order, 0)
|
||||
@@ -262,10 +362,12 @@ func getConfirmingOrders(tradeType []model.TradeType) []model.Order {
|
||||
|
||||
for _, order := range orders {
|
||||
if time.Now().Unix() >= order.ExpiredAt.Unix() {
|
||||
order.SetFailed()
|
||||
notify.Bepusdt(order)
|
||||
if order.ConfirmedAt == nil || order.ConfirmedAt.IsZero() || !order.ConfirmedAt.Before(order.ExpiredAt) {
|
||||
order.SetFailed()
|
||||
notify.Bepusdt(order)
|
||||
|
||||
continue
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
data = append(data, order)
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"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"
|
||||
@@ -37,6 +38,9 @@ type tron struct {
|
||||
blockScanQueue *chanx.UnboundedChan[int]
|
||||
conn map[string]*grpc.ClientConn
|
||||
connMu sync.RWMutex
|
||||
retryMu sync.Mutex
|
||||
retryAttempts map[int]int
|
||||
retryScheduled map[int]*time.Timer
|
||||
}
|
||||
|
||||
var tr tron
|
||||
@@ -46,6 +50,7 @@ func init() {
|
||||
Register(Task{Duration: time.Second, Callback: tr.blockDispatch})
|
||||
Register(Task{Duration: time.Second * 3, Callback: tr.syncBlocksForward})
|
||||
Register(Task{Duration: time.Second * 5, Callback: tr.tradeConfirmHandle})
|
||||
Register(Task{Duration: time.Second * 15, Callback: tr.lookbackBlocks})
|
||||
}
|
||||
|
||||
func newTron() tron {
|
||||
@@ -54,6 +59,8 @@ func newTron() tron {
|
||||
blockConfirmedOffset: 30,
|
||||
blockScanQueue: chanx.NewUnboundedChan[int](context.Background(), 30),
|
||||
conn: make(map[string]*grpc.ClientConn),
|
||||
retryAttempts: make(map[int]int),
|
||||
retryScheduled: make(map[int]*time.Timer),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +92,6 @@ func (t *tron) syncBlocksForward(context.Context) {
|
||||
|
||||
// 区块高度变化过大,强制丢块重扫
|
||||
if now-t.lastBlockNum > cast.ToInt(model.GetC(model.BlockHeightMaxDiff)) {
|
||||
t.syncBlocksBackward(now)
|
||||
t.lastBlockNum = now - 1
|
||||
}
|
||||
|
||||
@@ -104,41 +110,32 @@ func (t *tron) syncBlocksForward(context.Context) {
|
||||
t.lastBlockNum = now
|
||||
}
|
||||
|
||||
// syncBlocksBackward 反向同步区块,针对程序启动前就已经存在待支付订单时,补齐之前的区块数据,自适应偏移数量
|
||||
func (t *tron) syncBlocksBackward(now int) {
|
||||
var o model.Order
|
||||
trade := model.GetNetworkTrades(conf.Tron)
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trade).Order("created_at asc").Limit(1).Find(&o)
|
||||
if o.ID == 0 {
|
||||
|
||||
func (t *tron) lookbackBlocks(ctx context.Context) {
|
||||
if t.syncBreak() {
|
||||
return
|
||||
}
|
||||
|
||||
// 波场出块速度大概3秒一个,同时再冗余5个区块
|
||||
num := (time.Now().Unix() - o.CreatedAt.Time().Unix() + 1) / 3 // 计算需要反向扫描的区块数量
|
||||
start := now - int(num) - 5 // 计算反向扫描的起始区块高度
|
||||
startAt, endAt, ok := getLookbackUnix(conf.Tron)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for b := now; b >= start; {
|
||||
if t.syncBreak() {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < 10 && b >= start; i++ {
|
||||
t.blockScanQueue.In <- b
|
||||
b--
|
||||
}
|
||||
|
||||
<-ticker.C
|
||||
start, end := blockapi.New().GetBoundaryHeights(startAt, endAt, conf.Tron)
|
||||
for i := int(start); i <= int(end); i++ {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
}()
|
||||
if t.syncBreak() {
|
||||
return
|
||||
}
|
||||
t.blockScanQueue.In <- i
|
||||
time.Sleep(time.Millisecond * 250) // 速率控制
|
||||
}
|
||||
}
|
||||
|
||||
func (t *tron) blockDispatch(context.Context) {
|
||||
func (t *tron) blockDispatch(ctx context.Context) {
|
||||
p, err := ants.NewPoolWithFunc(2, t.blockParse)
|
||||
if err != nil {
|
||||
log.Task.Warn("Error creating pool:", err)
|
||||
@@ -148,11 +145,19 @@ func (t *tron) blockDispatch(context.Context) {
|
||||
|
||||
defer p.Release()
|
||||
|
||||
for n := range t.blockScanQueue.Out {
|
||||
if err := p.Invoke(n); err != nil {
|
||||
t.blockScanQueue.In <- n
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case n, ok := <-t.blockScanQueue.Out:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if err := p.Invoke(n); err != nil {
|
||||
t.scheduleBlockRetry(n, 0)
|
||||
|
||||
log.Task.Warn("Tron Error invoking process block:", err)
|
||||
log.Task.Warn("Tron Error invoking process block:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,19 +173,20 @@ func (t *tron) blockParse(n any) {
|
||||
return
|
||||
}
|
||||
|
||||
conf.RecordSuccess(conf.Tron)
|
||||
|
||||
var ctx, cancel = context.WithTimeout(context.Background(), time.Second*5)
|
||||
bok, err2 := api.NewWalletClient(conn).GetBlockByNum2(ctx, &api.NumberMessage{Num: int64(num)})
|
||||
cancel()
|
||||
if err2 != nil {
|
||||
conf.RecordFailure(conf.Tron)
|
||||
t.blockScanQueue.In <- int(num)
|
||||
t.scheduleBlockRetry(num, 0)
|
||||
log.Task.Warn("GetBlockByNum2 ", err2)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
conf.RecordSuccess(conf.Tron, cast.ToString(num))
|
||||
t.resetBlockRetry(num)
|
||||
|
||||
var resources = make([]resource, 0)
|
||||
var transfers = make([]transfer, 0)
|
||||
var timestamp = time.UnixMilli(bok.GetBlockHeader().GetRawData().GetTimestamp())
|
||||
@@ -332,7 +338,6 @@ func (t *tron) blockParse(n any) {
|
||||
if len(transfers) > 0 {
|
||||
transferQueue.In <- transfers
|
||||
}
|
||||
|
||||
if len(resources) > 0 {
|
||||
resourceQueue.In <- resources
|
||||
}
|
||||
@@ -478,14 +483,13 @@ func (t *tron) syncBreak() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var count int64 = 0
|
||||
trade := []model.TradeType{model.TronTrx, model.UsdtTrc20, model.UsdcTrc20}
|
||||
model.Db.Model(&model.Order{}).Where("status = ? and trade_type in (?)", model.OrderStatusWaiting, trade).Count(&count)
|
||||
if count > 0 {
|
||||
if hasLookbackOrders(trade) {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
var count int64 = 0
|
||||
model.Db.Model(&model.Wallet{}).Where("other_notify = ? and trade_type in (?)", model.WaOtherEnable, trade).Count(&count)
|
||||
if count > 0 {
|
||||
|
||||
@@ -495,6 +499,67 @@ func (t *tron) syncBreak() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *tron) scheduleBlockRetry(num int, delay time.Duration) {
|
||||
t.retryMu.Lock()
|
||||
if _, ok := t.retryScheduled[num]; ok {
|
||||
t.retryMu.Unlock()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
attempt := t.retryAttempts[num] + 1
|
||||
t.retryAttempts[num] = attempt
|
||||
|
||||
if delay <= 0 {
|
||||
delay = tronRetryDelay(attempt)
|
||||
}
|
||||
|
||||
var timer *time.Timer
|
||||
timer = time.AfterFunc(delay, func() {
|
||||
t.retryMu.Lock()
|
||||
if t.retryScheduled[num] != timer {
|
||||
t.retryMu.Unlock()
|
||||
|
||||
return
|
||||
}
|
||||
delete(t.retryScheduled, num)
|
||||
t.retryMu.Unlock()
|
||||
|
||||
if t.blockScanQueue.Len() >= blockQueueLimit {
|
||||
log.Task.Warn("Tron 重试延后,当前区块消费堆积数量:", t.blockScanQueue.Len())
|
||||
t.scheduleBlockRetry(num, delay)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
t.blockScanQueue.In <- num
|
||||
})
|
||||
t.retryScheduled[num] = timer
|
||||
t.retryMu.Unlock()
|
||||
}
|
||||
|
||||
func (t *tron) resetBlockRetry(num int) {
|
||||
t.retryMu.Lock()
|
||||
defer t.retryMu.Unlock()
|
||||
|
||||
delete(t.retryAttempts, num)
|
||||
if timer, ok := t.retryScheduled[num]; ok {
|
||||
timer.Stop()
|
||||
delete(t.retryScheduled, num)
|
||||
}
|
||||
}
|
||||
|
||||
func tronRetryDelay(attempt int) time.Duration {
|
||||
if attempt < 1 {
|
||||
attempt = 1
|
||||
}
|
||||
if attempt > 5 {
|
||||
attempt = 5
|
||||
}
|
||||
|
||||
return time.Duration(1<<uint(attempt-1)) * 5 * time.Second
|
||||
}
|
||||
|
||||
func (t *tron) client() (*grpc.ClientConn, error) {
|
||||
var endpoint = model.Endpoint(conf.Tron)
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
func xlayerInit() {
|
||||
ctx := context.Background()
|
||||
xlayer := evm{
|
||||
Network: conf.Xlayer,
|
||||
Network: conf.Xlayer,
|
||||
LookbackInterval: time.Millisecond * 300,
|
||||
Block: block{
|
||||
RollDelayOffset: 3,
|
||||
ConfirmedOffset: 12,
|
||||
@@ -24,4 +25,5 @@ func xlayerInit() {
|
||||
Register(Task{Callback: xlayer.blockDispatch})
|
||||
Register(Task{Callback: xlayer.syncBlocksForward, Duration: time.Second * 3})
|
||||
Register(Task{Callback: xlayer.tradeConfirmHandle, Duration: time.Second * 5})
|
||||
Register(Task{Callback: xlayer.lookbackBlocks, Duration: time.Second * 15})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/xssnick/tonutils-go/address"
|
||||
"github.com/xssnick/tonutils-go/liteclient"
|
||||
tgo "github.com/xssnick/tonutils-go/ton"
|
||||
"github.com/xssnick/tonutils-go/ton/jetton"
|
||||
)
|
||||
|
||||
func NewTonClient(configUrl string) tgo.APIClientWrapped {
|
||||
pool := liteclient.NewConnectionPool()
|
||||
if err := pool.AddConnectionsFromConfigUrl(context.Background(), configUrl); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return tgo.NewAPIClient(pool).WithRetryTimeout(3, time.Second*5)
|
||||
}
|
||||
|
||||
func GetJettonWalletAddr(api tgo.APIClientWrapped, master *address.Address, owner *address.Address) (*address.Address, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
|
||||
client := jetton.NewJettonMasterClient(api, master)
|
||||
wallet, err := client.GetJettonWallet(ctx, owner)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return wallet.Address(), err
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/gin-gonic/gin"
|
||||
nid "github.com/matoous/go-nanoid/v2"
|
||||
)
|
||||
|
||||
@@ -253,3 +255,30 @@ func GetRequestHost(r *http.Request) string {
|
||||
|
||||
return scheme + "://" + r.Host
|
||||
}
|
||||
|
||||
// ClientFingerprint 客户端指纹
|
||||
func ClientFingerprint(ctx *gin.Context) string {
|
||||
ip := ctx.ClientIP()
|
||||
|
||||
if parsed := net.ParseIP(ip); parsed != nil {
|
||||
if v4 := parsed.To4(); v4 != nil {
|
||||
ip = fmt.Sprintf("%d.%d.%d.0", v4[0], v4[1], v4[2])
|
||||
} else if v6 := parsed.To16(); v6 != nil {
|
||||
var masked [16]byte
|
||||
copy(masked[:8], v6[:8])
|
||||
ip = net.IP(masked[:]).String()
|
||||
}
|
||||
}
|
||||
|
||||
parts := []string{
|
||||
ip,
|
||||
ctx.GetHeader("User-Agent"),
|
||||
ctx.GetHeader("Accept-Language"),
|
||||
ctx.GetHeader("Accept-Encoding"),
|
||||
ctx.GetHeader("Accept"),
|
||||
ctx.GetHeader("Sec-CH-UA"),
|
||||
ctx.GetHeader("Sec-CH-UA-Platform"),
|
||||
}
|
||||
|
||||
return StrSha256(strings.Join(parts, "|"))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM node:25.2.1 AS web_builder
|
||||
|
||||
# 安装 pnpm
|
||||
RUN npm install -g pnpm
|
||||
RUN npm install -g pnpm@10
|
||||
|
||||
WORKDIR /web
|
||||
COPY web/package.json web/pnpm-lock.yaml ./
|
||||
@@ -11,7 +11,7 @@ RUN pnpm install --frozen-lockfile --shamefully-hoist
|
||||
COPY web/ ./
|
||||
RUN pnpm run build:prod
|
||||
|
||||
FROM golang:1.24.3-alpine3.20 AS builder
|
||||
FROM golang:1.26.2-alpine3.23 AS builder
|
||||
|
||||
ENV GO111MODULE=on
|
||||
WORKDIR /go/release
|
||||
@@ -182,6 +182,9 @@ POST /api/v1/order/create-order
|
||||
| fiat | string | ❌ | 法币类型,默认 `CNY`<br/>可选:`CNY`、`USD`、`EUR`、`GBP`、`JPY` |
|
||||
| name | string | ❌ | 商品名称 |
|
||||
| timeout | number | ❌ | 订单超时时间(秒),最低 180 秒<br/>留空则使用配置 `payment_timeout`,默认 600 秒 |
|
||||
| reselect | boolean | ❌ | 是否允许用户确认付款币种/网络后再次返回重选。<br/>仅对 `create-order` 创建的收银台订单生效;不传则使用后台“订单交易类型重选”全局开关,默认开启 |
|
||||
|
||||
> 传入 `reselect` 时,该参数需要参与签名计算。boolean 值按 JSON 布尔值传递,并按 `true` / `false` 小写字符串参与签名拼接。
|
||||
|
||||
#### 请求示例
|
||||
|
||||
@@ -195,6 +198,7 @@ POST /api/v1/order/create-order
|
||||
"notify_url": "https://example.com/notify",
|
||||
"redirect_url": "https://example.com/success",
|
||||
"timeout": 1200,
|
||||
"reselect": true,
|
||||
"signature": "1cd4b52df5587cfb1968b0c0c6e156cd"
|
||||
}
|
||||
```
|
||||
@@ -212,6 +216,7 @@ POST /api/v1/order/create-order
|
||||
| data.status | string | 订单状态,1 表示待付款 |
|
||||
| data.expiration_time | number | 订单有效期(秒) |
|
||||
| data.payment_url | string | 收银台订单链接 |
|
||||
| data.reselect | boolean | 当前订单是否允许用户确认付款币种/网络后再次返回重选。该值与 `/api/v1/pay/info` 的 `reselect` 语义一致,取自订单当前状态与订单自身配置 |
|
||||
|
||||
#### 响应示例
|
||||
|
||||
@@ -225,12 +230,15 @@ POST /api/v1/order/create-order
|
||||
"order_id": "20250120001",
|
||||
"amount": "28.88",
|
||||
"expiration_time": 1200,
|
||||
"reselect": true,
|
||||
"payment_url": "https://example.com/pay/cashier/b3d2477c-d945-41da-96b7-f925bbd1b415"
|
||||
},
|
||||
"request_id": ""
|
||||
}
|
||||
```
|
||||
|
||||
> `reselect` 为 `true` 时,收银台可在用户选定付款币种/网络后提供“返回重选”入口;为 `false` 时,用户确认付款方式后不能再次切换。普通 `create-transaction` 创建的订单不支持交易类型重选。
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
@@ -238,7 +246,7 @@ POST /api/v1/order/create-order
|
||||
<details>
|
||||
<summary><strong>4. 更新订单付款方式</strong> 为收银台订单选定支付链,获取具体收款地址与金额。</summary>
|
||||
|
||||
> **注意**:使用相同 `trade_id` 更新订单时,系统会根据最新交易类型更新订单付款方式。
|
||||
> **注意**:使用相同 `trade_id` 更新订单时,系统会根据最新交易类型更新订单付款方式。若订单已选定付款方式,则只有 `reselect` 为 `true` 且订单仍处于待支付状态时,才允许再次调用本接口切换付款币种/网络。
|
||||
|
||||
#### 请求地址
|
||||
|
||||
@@ -486,10 +494,11 @@ MD5(amount=42¬ify_url=http://example.com/notify&order_id=20220201030210321&re
|
||||
|
||||
### 2. 订单重建机制是什么?
|
||||
|
||||
当使用相同 `order_id` 创建订单时:
|
||||
当使用相同 `order_id` 创建订单时,不同接口的处理方式不同:
|
||||
|
||||
- ✅ 更新订单金额、交易类型、收款地址、法币类型
|
||||
- ✅ **会** 重置超时时间
|
||||
- `create-transaction`:如果旧订单仍处于待支付状态,会按新参数重建订单,并重新计算超时时间
|
||||
- `create-order`:如果旧订单仍处于待支付状态,会返回已有订单,不会重置超时时间;后续调用 `update-order` 选择或重选付款币种/网络时,也会保留订单剩余有效期
|
||||
- 已支付成功或确认中的订单不会被重建
|
||||
|
||||
### 3. 支持哪些交易类型?
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 104 KiB |
@@ -1,202 +1,67 @@
|
||||
# Dujiao-Next 对接教程
|
||||
# DuJiao Next 对接 BEpusdt 集成指南
|
||||
|
||||
本文档介绍如何在 [Dujiao-Next](https://github.com/dujiao-next/dujiao-next)(独角next)中对接 BEpusdt。
|
||||
**当前教程针对的是新版独角 [Dujiao Next](https://dujiao-next.com/),旧版独角数卡对接[请看这个](../dujiaoka/dujiaoka.md)**
|
||||
|
||||
## 前置条件
|
||||
## 前提条件
|
||||
|
||||
- BEpusdt 已成功安装并运行
|
||||
- Dujiao-Next 已部署
|
||||
在开始配置前,请确保已满足以下条件:
|
||||
|
||||
**BEpusdt 部署信息**
|
||||
|
||||
- API 服务地址:`https://your-bepusdt.com`
|
||||
- API 密钥:`your_api_token`
|
||||
|
||||
**DuJiao Next 部署信息**
|
||||
|
||||
- 部署地址:`https://your-dujiao.com`
|
||||
- 已进入后台管理界面
|
||||
- 已找到支付渠道管理 > 新增渠道功能
|
||||
|
||||
## 配置步骤
|
||||
|
||||
### 1. 进入支付渠道配置
|
||||
在 DuJiao Next 后台中选择渠道类型为 BEpusdt,按照以下格式进行配置。
|
||||
|
||||
Dujiao-Next 后台 → 支付渠道 → 新增渠道
|
||||

|
||||
|
||||
### 2. 基本参数填写
|
||||
**必填配置项**
|
||||
|
||||
| 参数名称 | 填写内容 | 说明 |
|
||||
|---------|---------|------|
|
||||
| 渠道名称 | USDT-TRC20 支付 | 自定义名称,建议包含币种 |
|
||||
| 渠道类型 | `epusdt` | 固定值,选择 BEpusdt |
|
||||
| 支付方式 | `usdt-trc20` / `usdc-trc20` / `trx` | 选择支持的币种 |
|
||||
| 交互方式 | `qr` 或 `redirect` | 二维码或跳转收银台 |
|
||||
| 配置项 | 说明 | 示例 |
|
||||
|-----------|--------------------|----------------------------------------------------|
|
||||
| 网关地址 | BEpusdt 的 API 服务地址 | `https://your-bepusdt.com` |
|
||||
| API Token | BEpusdt 的 API 密钥 | `your_api_token` |
|
||||
| 支付币种 | 支持的加密资产类型,严格区分大小写 | `usdt.trc20` |
|
||||
| 法币类型 | 支持的法定货币类型 | `CNY`、`USD`、`EUR`、`JPY`、`GBP` |
|
||||
| 异步通知地址 | 交易完成时的服务器异步回调地址 | `https://your-dujiao.com/api/v1/payments/callback` |
|
||||
| 同步回跳地址 | 用户支付完成后的页面跳转地址 | `https://your-dujiao.com/pay` |
|
||||
|
||||
### 3. 支持的渠道类型
|
||||
**配置说明**
|
||||
|
||||
Dujiao-Next 支持以下 BEpusdt 币种:
|
||||
- **支付币种**:详见 [支持的币种列表](https://github.com/v03413/BEpusdt/blob/main/docs/trade-type.md),必须严格区分大小写。
|
||||
- **法币类型**:仅支持 `CNY`、`USD`、`EUR`、`JPY`、`GBP` 五种,必须严格区分大小写。
|
||||
|
||||
| 渠道类型 | 说明 | 对应 trade_type |
|
||||
|---------|------|----------------|
|
||||
| `usdt-trc20` | USDT (TRC20) | `usdt.trc20` |
|
||||
| `usdc-trc20` | USDC (TRC20) | `usdc.trc20` |
|
||||
| `trx` | TRX | `tron.trx` |
|
||||
**⚠️ 重要说明:异步通知地址和同步回跳地址**
|
||||
|
||||
> **注意**:选择渠道类型后,系统会自动设置对应的 `trade_type`,无需手动填写。
|
||||
这两个地址的路由部分 **严格按要求修改**,只需将域名部分替换为您实际部署的 DuJiao Next 服务器地址:
|
||||
|
||||
### 4. 渠道配置参数
|
||||
- **异步通知地址**:`https://your-dujiao.com/api/v1/payments/callback`
|
||||
- 路由固定为 `/api/v1/payments/callback`
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `https://example.com/api/v1/payments/callback`
|
||||
|
||||
在「渠道配置」中填写以下 JSON:
|
||||
- **同步回跳地址**:`https://your-dujiao.com/pay`
|
||||
- 路由固定为 `/pay`
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `https://example.com/pay`
|
||||
|
||||
```json
|
||||
{
|
||||
"gateway_url": "https://your-bepusdt-domain.com",
|
||||
"auth_token": "your-api-token",
|
||||
"fiat": "CNY",
|
||||
"notify_url": "https://your-api-domain.com/api/v1/payments/callback",
|
||||
"return_url": "https://your-user-domain.com/pay"
|
||||
}
|
||||
```
|
||||
## 配置验证
|
||||
|
||||
### 5. 配置参数说明
|
||||
配置完成后,请按照以下步骤进行测试:
|
||||
|
||||
| 参数 | 必填 | 说明 | 示例 |
|
||||
|------|------|------|------|
|
||||
| `gateway_url` | ✅ | BEpusdt 网关地址 | `https://pay.example.com` |
|
||||
| `auth_token` | ✅ | BEpusdt API Token | 从 BEpusdt 后台获取 |
|
||||
| `trade_type` | ❌ | 交易类型(自动设置) | `usdt.trc20` / `usdc.trc20` / `tron.trx` |
|
||||
| `fiat` | ❌ | 法币类型,默认 `CNY` | `CNY` / `USD` |
|
||||
| `notify_url` | ✅ | 异步回调地址 | `https://api.example.com/api/v1/payments/callback` |
|
||||
| `return_url` | ✅ | 支付成功跳转地址 | `https://shop.example.com/pay` |
|
||||
1. 进入 DuJiao Next 前台,进行支付测试。
|
||||
2. 观察是否正常跳转到支付页面。
|
||||
|
||||
> **重要提示**:
|
||||
> - `trade_type` 会根据「支付方式」自动设置,无需在配置中填写
|
||||
> - `notify_url` 路径必须是 `/api/v1/payments/callback`(不是 `/api/public/payment/callback`)
|
||||
> - `return_url` 路径必须是 `/pay`(不是 `/order` 或 `/payment`)
|
||||
## 故障排查
|
||||
|
||||
## 获取 API Token
|
||||
若出现网关错误提示,请按照以下步骤排查:
|
||||
|
||||
1. 登录 BEpusdt 后台
|
||||
2. 系统管理 → 基本设置 → API 设置
|
||||
3. 复制「对接令牌」
|
||||
|
||||
## 配置示例
|
||||
|
||||
### 示例 1:USDT-TRC20 支付
|
||||
|
||||
```
|
||||
渠道名称: USDT-TRC20 支付
|
||||
渠道类型: epusdt
|
||||
支付方式: usdt-trc20
|
||||
交互方式: qr
|
||||
|
||||
渠道配置:
|
||||
{
|
||||
"gateway_url": "http://127.0.0.1:8088",
|
||||
"auth_token": "your-token-here",
|
||||
"fiat": "CNY",
|
||||
"notify_url": "https://api.example.com/api/v1/payments/callback",
|
||||
"return_url": "https://shop.example.com/pay"
|
||||
}
|
||||
```
|
||||
|
||||
### 示例 2:TRX 支付
|
||||
|
||||
```
|
||||
渠道名称: TRX 支付
|
||||
渠道类型: epusdt
|
||||
支付方式: trx
|
||||
交互方式: redirect
|
||||
|
||||
渠道配置:
|
||||
{
|
||||
"gateway_url": "http://127.0.0.1:8088",
|
||||
"auth_token": "your-token-here",
|
||||
"fiat": "CNY",
|
||||
"notify_url": "https://api.example.com/api/v1/payments/callback",
|
||||
"return_url": "https://shop.example.com/pay"
|
||||
}
|
||||
```
|
||||
|
||||
## 回调机制说明
|
||||
|
||||
### 异步通知(notify_url)
|
||||
|
||||
BEpusdt 会在支付状态变化时,向 `notify_url` 发送 POST 请求:
|
||||
|
||||
```
|
||||
POST /api/v1/payments/callback
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
order_id=xxx&trade_id=xxx&amount=xxx&actual_amount=xxx&token=xxx&...&signature=xxx
|
||||
```
|
||||
|
||||
Dujiao-Next 会验证签名并更新订单状态。
|
||||
|
||||
### 同步跳转(return_url)
|
||||
|
||||
用户支付完成后,BEpusdt 会跳转到 `return_url`,并附带参数:
|
||||
|
||||
```
|
||||
https://shop.example.com/pay?order_id=xxx&epusdt_return=1
|
||||
```
|
||||
|
||||
Dujiao-Next 前端会检测 `epusdt_return=1` 参数,自动查询订单状态并显示支付结果。
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 1. 支付创建失败
|
||||
|
||||
**可能原因**:
|
||||
- `gateway_url` 配置错误或 BEpusdt 服务未运行
|
||||
- `auth_token` 与 BEpusdt 配置不一致
|
||||
- 网络连接问题(检查防火墙)
|
||||
|
||||
**解决方法**:
|
||||
- 检查 BEpusdt 服务状态:`curl http://your-bepusdt/health`
|
||||
- 验证 API Token 是否正确
|
||||
- 查看 Dujiao-Next 后端日志
|
||||
|
||||
### 2. 回调未收到或订单状态未更新
|
||||
|
||||
**可能原因**:
|
||||
- `notify_url` 配置错误(路径必须是 `/api/v1/payments/callback`)
|
||||
- BEpusdt 无法访问回调地址(网络/防火墙问题)
|
||||
- 签名验证失败
|
||||
|
||||
**解决方法**:
|
||||
- 确认回调地址可被外网访问:`curl https://your-api/api/v1/payments/callback`
|
||||
- 检查 BEpusdt 日志中的回调错误
|
||||
- 检查 Dujiao-Next 后端日志中的签名验证信息
|
||||
|
||||
### 3. 支付完成后跳转错误
|
||||
|
||||
**可能原因**:
|
||||
- `return_url` 路径配置错误(必须是 `/pay` 不是 `/payment` 或 `/order`)
|
||||
- 前端路由配置问题
|
||||
|
||||
**解决方法**:
|
||||
- 确认 `return_url` 配置为:`https://your-user-domain.com/pay`
|
||||
- 清除浏览器缓存后重试
|
||||
|
||||
### 4. 签名验证失败
|
||||
|
||||
**可能原因**:
|
||||
- `auth_token` 不一致(注意前后空格)
|
||||
- 回调参数被中间件修改
|
||||
|
||||
**解决方法**:
|
||||
- 确保 `auth_token` 完全一致
|
||||
- 检查是否有反向代理修改了请求参数
|
||||
|
||||
### 5. 金额不匹配
|
||||
|
||||
**可能原因**:
|
||||
- 汇率波动导致实际支付金额与订单金额不同
|
||||
- BEpusdt 配置的汇率源问题
|
||||
|
||||
**解决方法**:
|
||||
- BEpusdt 会返回 `actual_amount`(实际支付金额),Dujiao-Next 会记录此金额
|
||||
- 可在订单详情中查看实际支付金额
|
||||
|
||||
## 技术支持
|
||||
|
||||
- Dujiao-Next: [GitHub Issues](https://github.com/dujiao-next/dujiao-next/issues)
|
||||
- BEpusdt: [Telegram 群组](https://t.me/BEpusdtChat)
|
||||
|
||||
---
|
||||
|
||||
**贡献者**: 狼哥 ([@luoyanglang](https://github.com/luoyanglang) | Telegram: [@luoyanglang](https://t.me/luoyanglang))
|
||||
|
||||
> 本文档适用于 Dujiao-Next 最新版本和 BEpusdt 最新版本
|
||||
> 最后更新:2026-02-13
|
||||
- **检查网络连通性**:确认 DuJiao Next API 所在服务器能够正常访问 BEpusdt API 地址。
|
||||
- **检查 API Token**:确认所配置的 API Token 与 BEpusdt 中的密钥一致。
|
||||
- **查看日志**:检查 DuJiao Next 和 BEpusdt 的应用日志,获取更详细的错误信息。
|
||||
|
||||
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 65 KiB |
@@ -0,0 +1,79 @@
|
||||
# EdgeKey 对接 BEpusdt 教程
|
||||
|
||||
**当前教程对接BEpusdt(v1.23.5)通过测试验收**
|
||||
|
||||
## 配置步骤
|
||||
|
||||
**配置说明**
|
||||
|
||||
- **网关地址**:只需填写域名,如 `https://test.shop.com`,系统会自动拼接 API 路径(`/api/v1/order/create-order`)。
|
||||
- **App ID 和 App Secret**:在 BEpusdt 后台「系统管理 → 基本设置 → API 设置」中获取。
|
||||
- **支付币种**:用户在 BEpusdt 收银台页面自由选择支付币种,具体在 BEpusdt 后台配置。
|
||||
|
||||
**配置步骤示例**:
|
||||
1. 登录 EdgeKey 管理后台
|
||||
2. 进入「支付配置」页面
|
||||
3. 选择 BEpusdt 标签页
|
||||
4. 填写具体配置
|
||||
5. 启用支付方式:点击右上角的启用开关
|
||||
6. 保存配置:点击「保存配置」按钮
|
||||
|
||||

|
||||
|
||||
### 重要提示
|
||||
填写完配置信息后,点击右上角的 **启用** 开关,然后点击 **保存配置** 按钮。
|
||||
⚠️ **重要提示**:启用支付前,请先前往「站点设置」配置网站地址,否则无法获取支付结果。
|
||||
|
||||

|
||||
|
||||
## 配置字段说明
|
||||
|
||||
**通用字段说明**:
|
||||
- **显示名称**:支付方式在前台显示的名称,用户可自定义
|
||||
- **网关地址**:支付网关服务域名,系统会自动处理接口路径
|
||||
- **Notify URL**:异步通知地址,支付完成后系统会回调此地址
|
||||
- **Return URL**:同步回跳地址,用户支付完成后跳转的页面
|
||||
|
||||
**BEpusdt专用字段**:
|
||||
- **App ID**:BEpusdt后台获取的应用ID
|
||||
- **App Secret**:BEpusdt后台获取的应用密钥(API密钥)
|
||||
|
||||
|
||||
## 异步通知地址和同步回跳地址
|
||||
|
||||
这两个地址的路由部分 **严格按要求填写**,只需将域名部分替换为您实际部署的 EdgeKey 服务器地址:
|
||||
|
||||
- **异步通知地址**:`/api/payments/bepusdt/notify`
|
||||
- 路由固定为 `/api/payments/bepusdt/notify`
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `/api/payments/bepusdt/notify`
|
||||
|
||||
- **同步回跳地址**:`/order/{orderNo}?token={token}`
|
||||
- 路由固定为 `/order/{orderNo}?token={token}`(`:orderNo` 和 `{token}` 为动态参数)
|
||||
- 示例:若部署地址为 `https://example.com`,则填写 `/order/{orderNo}?token={token}`
|
||||
|
||||
## 配置验证
|
||||
|
||||
配置完成后,请按照以下步骤进行测试:
|
||||
|
||||
1. 进入 EdgeKey 前台,选择一个商品进行购买。
|
||||
2. 在结算页面选择 BEpusdt 支付方式。
|
||||
3. 观察是否正常跳转到收银台页面。
|
||||
|
||||
## 故障排查
|
||||
|
||||
若出现网关错误提示,请按照以下步骤排查:
|
||||
|
||||
- **检查网络连通性**:确认 EdgeKey 服务器能够正常访问 BEpusdt API 地址。
|
||||
- **检查 App ID 和 App Secret**:确认所配置的 App ID 和 App Secret 与 BEpusdt 中的一致。
|
||||
- **检查回调地址**:确保异步通知地址可以从外部访问,且格式正确。
|
||||
- **检查站点设置**:确保在「站点设置」中配置了正确的网站地址。
|
||||
- **查看日志**:检查 EdgeKey 和 BEpusdt 的应用日志,获取更详细的错误信息。
|
||||
|
||||
## BEpusdt 工作模式
|
||||
|
||||
本项目使用 **收银台模式**(`/api/v1/order/create-order`),用户在 BEpusdt 收银台页面自由选择支付链,无需在代码中指定 `trade_type`。
|
||||
|
||||
## 相关链接
|
||||
|
||||
- [BEpusdt 项目主页](https://github.com/v03413/bepusdt)
|
||||
- [EdgeKey 项目主页](https://github.com/34892002/edgeKey)
|
||||
@@ -15,10 +15,11 @@
|
||||
|
||||
以下是常见程序的对接文档,请根据您的实际需求选择相应教程进行配置。如遇问题,请仔细核对操作步骤,或在相关技术社区寻求协助。
|
||||
|
||||
- [独角Dujiao-Next](https://dujiao-next.com/payment/guide#_3-7-bepusdt)
|
||||
- [独角Dujiao-Next](./dujiao-next/dujiao-next.md)
|
||||
- [独角数卡(旧版)](./dujiaoka/dujiaoka.md)
|
||||
- [彩虹易支付](https://github.com/v03413/Epay-BEpusdt)
|
||||
- [WHMCS](https://github.com/v03413/whmcs-gateway-epusdt)
|
||||
- [异次元发卡](acg-faka/README.md)
|
||||
- [萌次元商城](./mcy-faka/mcy-shop.md)
|
||||
|
||||
- [EdgeKey](./edge-key/edge-key.md)
|
||||
- [WooCommerce/WordPress 收款插件-BEpusdt for WooCommerce](https://github.com/immonsterx/bepusdt-woocommerce)
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
# 收银台模板开发指南
|
||||
|
||||
本文档面向开发者,介绍收银台模板的**目录结构与开发规范**,帮助你完成两类任务:
|
||||
|
||||
- **修改默认模板**:在官方内置模板的基础上调整样式或逻辑
|
||||
- **新增自定义模板**:从零创建一套独立的收银台主题
|
||||
|
||||
---
|
||||
|
||||
## 模板目录结构
|
||||
|
||||
每套模板放在 `static/checkout/` 下的一个子目录中,目录名即模板的唯一标识。结构如下:
|
||||
|
||||
```
|
||||
<模板目录名>/
|
||||
├── checkout.json # 【必须】模板元数据
|
||||
├── views/
|
||||
│ └── checkout.html # 【必须】主模板 HTML
|
||||
└── assets/ # 【可选】静态资源
|
||||
├── css/
|
||||
├── js/
|
||||
├── img/
|
||||
└── locales/
|
||||
```
|
||||
|
||||
BEpusdt 启动时会扫描该目录,自动注册所有合法模板,并在后台「收银台模板」下拉框中展示。
|
||||
|
||||
---
|
||||
|
||||
## checkout.json
|
||||
|
||||
模板的元数据配置文件,用于在后台展示模板信息:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "模板显示名称",
|
||||
"author": "作者或团队",
|
||||
"desc": "一句话描述",
|
||||
"link": "模板主页或仓库地址"
|
||||
}
|
||||
```
|
||||
|
||||
`name` 为必填项,其余可选。
|
||||
|
||||
---
|
||||
|
||||
## views/checkout.html
|
||||
|
||||
标准的 Go `html/template` 文件。服务端只注入一个变量:
|
||||
|
||||
```
|
||||
{{ .trade_id }} // 当前订单的交易 ID
|
||||
```
|
||||
|
||||
**所有订单数据均通过前端 AJAX 请求获取**,不在服务端渲染。可以用任意前端框架或原生 JS 实现交互逻辑,参考官方模板
|
||||
`static/checkout/official/assets/js/checkout.js` 的写法。
|
||||
|
||||
---
|
||||
|
||||
## assets 静态资源
|
||||
|
||||
`assets/` 下的文件会被挂载到 `/checkout/<模板目录名>/assets/` 路由,在 HTML 中**必须使用绝对路径**引用:
|
||||
|
||||
```html
|
||||
|
||||
<link rel="stylesheet" href="/checkout/my-theme/assets/css/style.css">
|
||||
<script src="/checkout/my-theme/assets/js/main.js"></script>
|
||||
```
|
||||
|
||||
第三方 JS 库建议本地化放入 `assets/js/`,避免依赖外部 CDN。
|
||||
|
||||
---
|
||||
|
||||
## 任务一:修改默认模板
|
||||
|
||||
默认模板 `official` 的源文件位于 `static/checkout/official/`,直接在该目录下修改即可。
|
||||
|
||||
**1. 克隆源码**
|
||||
|
||||
```bash
|
||||
git clone https://github.com/v03413/BEpusdt.git
|
||||
cd BEpusdt
|
||||
```
|
||||
|
||||
**2. 按需修改**
|
||||
|
||||
- 品牌色 → `static/checkout/official/assets/css/checkout.css` 中的 CSS 变量
|
||||
- Logo / 图标 → 替换 `static/checkout/official/assets/img/` 下的图片并更新引用
|
||||
- 页面结构 → 编辑 `static/checkout/official/views/checkout.html`
|
||||
- 交互逻辑 → 编辑 `static/checkout/official/assets/js/checkout.js`
|
||||
- 多语言文案 → 编辑 `static/checkout/official/assets/locales/zh.json`、`en.json`
|
||||
|
||||
**3. 重新编译**(见[部署与验证](#部署与验证))
|
||||
|
||||
---
|
||||
|
||||
## 任务二:新增自定义模板
|
||||
|
||||
**1. 创建目录**
|
||||
|
||||
```bash
|
||||
mkdir -p my-theme/views my-theme/assets/{css,js,img}
|
||||
```
|
||||
|
||||
**2. 编写 checkout.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "My Theme",
|
||||
"author": "yourname",
|
||||
"desc": "简洁风格收银台",
|
||||
"link": ""
|
||||
}
|
||||
```
|
||||
|
||||
**3. 编写 views/checkout.html**
|
||||
|
||||
从 `{{ .trade_id }}` 获取交易 ID,通过 AJAX 调用后端接口拉取订单数据,轮询检测支付状态,完成后跳转。可直接参考官方模板的
|
||||
`checkout.js` 逻辑复用。
|
||||
|
||||
静态资源路径前缀为 `/checkout/my-theme/assets/`。
|
||||
|
||||
**4. 放置静态资源**
|
||||
|
||||
将 CSS、JS、图片等放入 `assets/` 对应子目录。
|
||||
|
||||
---
|
||||
|
||||
## 部署与验证
|
||||
|
||||
`static/checkout/` 目录通过 Go `//go:embed` 在**编译时**打包进程序二进制。这意味着:
|
||||
|
||||
- 新增或修改模板后,必须**重新编译**才能生效
|
||||
- 运行时无法热加载,不存在"上传到服务器某个路径"这种方式
|
||||
|
||||
### 步骤
|
||||
|
||||
**1. 将模板目录放入源码**
|
||||
|
||||
把你的模板目录放到 `static/checkout/` 下:
|
||||
|
||||
```
|
||||
static/checkout/
|
||||
├── official/ # 内置官方模板
|
||||
└── my-theme/ # 你的模板
|
||||
├── checkout.json
|
||||
├── views/
|
||||
│ └── checkout.html
|
||||
└── assets/
|
||||
```
|
||||
|
||||
**2. 重新编译**
|
||||
|
||||
```bash
|
||||
go build -o bepusdt ./main
|
||||
```
|
||||
|
||||
或使用项目已有的构建脚本/Dockerfile。
|
||||
|
||||
**3. 验证注册结果**
|
||||
|
||||
启动程序后查看日志,出现以下内容说明模板注册成功:
|
||||
|
||||
```
|
||||
前台收银模板注册成功: my-theme
|
||||
```
|
||||
|
||||
**4. 在后台切换模板**
|
||||
|
||||
进入 **系统管理 → 基本设置 → API 设置**,在「收银台模板」中选择对应模板名称并保存。
|
||||
|
||||
---
|
||||
|
||||
## 注意事项
|
||||
|
||||
- `checkout.json` 缺失或 JSON 格式有误会导致程序启动失败
|
||||
- `views/checkout.html` 缺失时该模板会被跳过,不影响其他模板加载
|
||||
- 目录名会出现在 URL 中,建议用小写字母与连字符,如 `my-theme`
|
||||
@@ -0,0 +1,29 @@
|
||||
# BEpusdt 与 EPusdt 项目说明
|
||||
|
||||
## 项目背景
|
||||
|
||||
### EPusdt
|
||||
|
||||
EPusdt 是与独角数卡(开源数字商品销售系统)配套的个人 USDT 收款网关,两个项目由同一作者
|
||||
@assimon 开发。
|
||||
|
||||
### BEpusdt
|
||||
|
||||
BEpusdt 由独立作者开发;由于 EPusdt 在一段时间内缺乏积极维护,结合个人需求和对区块链技术的兴趣,才开发了 BEpusdt 项目。
|
||||
BEpusdt 项目名称含义:在 EPusdt 前添加字母 `B`(代表 `Better`),寓意更简单、更好用的 USDT 收款网关。
|
||||
|
||||
## 项目演进
|
||||
|
||||
| 时间 | 事件 |
|
||||
|-------------|-----------------------------|
|
||||
| 2022 年 3 月 | EPusdt 项目发布,4 月基本完善,后续基本无更新 |
|
||||
| 2023 年 10 月 | BEpusdt 项目建立,持续迭代更新至今 |
|
||||
| 2026 年 3 月 | EPusdt 项目转让给其他开发者接手维护 |
|
||||
|
||||
## ⚠️ 重要声明
|
||||
|
||||
**BEpusdt 与转让后的 EPusdt 项目没有任何联系、无共同维护者。两个项目完全独立运营。**
|
||||
|
||||
## 致谢
|
||||
|
||||
感谢原作者 [@assimon](https://github.com/assimon) 开源的 EPusdt 项目,为本项目的诞生提供了灵感和参考。
|
||||
@@ -0,0 +1,71 @@
|
||||
# RPC 节点配置指南
|
||||
|
||||
## Tron 节点
|
||||
|
||||
### TronGrid Api Key(强烈推荐)
|
||||
|
||||
> 系统默认内置的 Tron 公共 RPC 节点为 `grpc.trongrid.io:50051`,虽然目前无明显频率限制,但长期使用后被限流是必然趋势。
|
||||
> 强烈建议配置 TronGrid Api Key,以提高 Tron 扫块稳定性,避免因节点频率限制导致订单确认失败等问题;基础计划完全免费,足以满足个人需求,无需额外付费!
|
||||
|
||||
#### 获取 Api Key
|
||||
|
||||
1. 访问 https://www.trongrid.io/register 使用邮箱注册账号并完成登录。
|
||||
2. 登录后找到 `API Keys` 选项,点击 `Create API Key`,填写名称后提交即可。
|
||||
|
||||
#### 配置 Api Key
|
||||
|
||||
你的 Api Key 应类似:`648870c0-xxxx-xxxx-xxxx-c7ac4ec263b0`
|
||||
|
||||
拿到之后登录 BEpusdt 后台,进入 `系统管理` -> `区块节点` -> `Tron 网络`,将 Api Key 填入 `TronGrid Api Key` 输入框,保存即可生效。
|
||||
|
||||
---
|
||||
|
||||
## EVM 链节点
|
||||
|
||||
### RPC 节点在 BEpusdt 中的作用
|
||||
|
||||
BEpusdt 在区块扫描过程中,所有区块数据均通过 RPC 节点获取。因此,**RPC 节点的性能和稳定性直接影响系统的收款体验**。
|
||||
|
||||
### 内置公益节点
|
||||
|
||||
BEpusdt 默认内置了一批公益 RPC
|
||||
节点,详见[源代码配置](https://github.com/v03413/BEpusdt/blob/0e1e22cebbf4a2127786e62b2b8b4d2175054c0b/app/model/conf.go#L140)。
|
||||
|
||||
#### 公益节点的局限性
|
||||
|
||||
- **稳定性难以保证**:公益节点由第三方维护,服务质量无法长期保障
|
||||
- **网络质量差异大**:部分 VPS 的网络状况本身较差,容易导致请求失败
|
||||
- **覆盖面不完整**:虽然这些节点已在开发中测试,但无法覆盖所有场景
|
||||
|
||||
这也是常见问题"为什么无法收款"或"为什么换台服务器就好了"的主要原因。
|
||||
|
||||
#### 建议
|
||||
|
||||
- 优先选择大型云服务提供商的服务器部署 BEpusdt,确保国际网络连接质量
|
||||
- 在非必要情况下,考虑禁用钱包交易监控功能,以降低 RPC 节点的请求压力
|
||||
|
||||
### 第三方 RPC 服务
|
||||
|
||||
#### Chainlist
|
||||
|
||||
**官网**:https://chainlist.org/
|
||||
|
||||
Chainlist 是一个聚合各类区块链网络 RPC 节点信息的平台,用户可以:
|
||||
|
||||
- 查找适合自己需求的 RPC 节点
|
||||
- 一键复制配置信息
|
||||
- 直接集成到应用中
|
||||
|
||||
> **注意**:第三方提供的节点质量需自行测试和评估。
|
||||
|
||||
#### Nodies(推荐)
|
||||
|
||||
**官网**:https://www.nodies.app/
|
||||
|
||||
Nodies 是一个商业 RPC 服务提供商,具有以下特点:
|
||||
|
||||
- 提供企业级的高质量 RPC 节点服务
|
||||
- 性能和稳定性有保障,适合生产环境使用
|
||||
- 提供免费配额,可满足个人单节点的使用需求
|
||||
- 需付费才能获得更高的配额和优先级支持
|
||||
|
||||
|
Before Width: | Height: | Size: 253 KiB |
|
Before Width: | Height: | Size: 509 KiB After Width: | Height: | Size: 509 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 59 KiB |
@@ -1,96 +0,0 @@
|
||||
# 收银台自定义修改指南
|
||||
|
||||
## 概述
|
||||
|
||||
本文档介绍如何自定义修改 BEpusdt 收银台的网页模板。本指南假设您已具备基本的 Linux/Docker 和前端开发知识。
|
||||
|
||||
## 获取默认资源文件
|
||||
|
||||
收银台的网页资源文件位于官方仓库:
|
||||
|
||||
https://github.com/v03413/BEpusdt/tree/main/static/payment
|
||||
|
||||
## 目录结构
|
||||
|
||||
```bash
|
||||
./payment
|
||||
├── assets
|
||||
│ ├── css # 样式文件
|
||||
│ ├── i18n # 国际化配置
|
||||
│ ├── img # 图片资源
|
||||
│ ├── js # JavaScript 文件
|
||||
│ └── locales # 多语言文件
|
||||
└── views
|
||||
├── bsc.bnb.html
|
||||
├── ethereum.eth.html
|
||||
├── index.html
|
||||
├── installed.html
|
||||
├── tron.trx.html
|
||||
├── usdc.aptos.html
|
||||
├── usdc.arbitrum.html
|
||||
├── usdc.base.html
|
||||
└── ...
|
||||
```
|
||||
|
||||
**目录说明:**
|
||||
|
||||
- **assets** - 静态资源文件(CSS、JavaScript、图片、国际化文件)
|
||||
- **views** - 各币种对应的收银台 HTML 模板文件,每个 HTML 文件对应一个币种的收银台页面
|
||||
|
||||
## 修改步骤
|
||||
|
||||
### 1. 修改网页模板
|
||||
|
||||
在 `views` 目录下编辑相应的 HTML 文件进行自定义修改。
|
||||
|
||||
### 2. 上传资源文件到服务器
|
||||
|
||||
#### Linux 直接部署
|
||||
|
||||
将修改后的整个 `payment` 目录上传到服务器指定路径:
|
||||
|
||||
```bash
|
||||
# 示例:上传到 /root/test/payment/
|
||||
scp -r ./payment user@server:/root/test/
|
||||
```
|
||||
|
||||
#### Docker 部署
|
||||
|
||||
**选项 A:使用 Volume 挂载(推荐)**
|
||||
|
||||
在启动容器时挂载本地目录,避免每次都复制文件:
|
||||
|
||||
```bash
|
||||
docker run -v /root/test/payment:/app/static/payment <image_id>
|
||||
```
|
||||
|
||||
**选项 B:复制到运行中的容器**
|
||||
|
||||
```bash
|
||||
docker cp payment/ <container_id>:/app/static/
|
||||
```
|
||||
|
||||
### 3. 配置静态资源路径
|
||||
|
||||

|
||||
|
||||
1. 登录 BEpusdt 后台管理系统
|
||||
2. 进入 **系统管理** → **基本设置** → **API 设置**
|
||||
3. 在**静态资源路径**字段中填入完整目录路径
|
||||
4. 点击保存
|
||||
|
||||
### 4. 重启服务并验证
|
||||
|
||||
重启 BEpusdt 服务:
|
||||
|
||||
```bash
|
||||
# Linux 直接部署
|
||||
systemctl restart bepusdt
|
||||
|
||||
# Docker 部署
|
||||
docker restart <container_id>
|
||||
```
|
||||
|
||||
查看服务日志,确认出现资源注册成功提示(如下图所示),则表示配置正确。之后访问当请求到对应的交易类型收银台时便能看到修改效果。
|
||||
|
||||

|
||||
@@ -15,5 +15,6 @@
|
||||
| Arbitrum-One | `usdt.arbitrum` | `usdc.arbitrum` | |
|
||||
| Base | | `usdc.base` | |
|
||||
| Plasma | `usdt.plasma` | | |
|
||||
| Ton | `usdt.ton` | | `ton.gram` |
|
||||
|
||||
---
|
||||
|
Before Width: | Height: | Size: 694 KiB |
@@ -1,19 +0,0 @@
|
||||
# TronGrid
|
||||
|
||||
> 系统默认内置 Tron 的公共RPC节点是:`grpc.trongrid.io:50051`,虽然目前无频率限制,但时间一长增加限制是必然趋势;
|
||||
> 所以强烈建议配置 TronGrid Api Key 提高 Tron 扫块稳定性,避免因节点频率限制导致订单确认失败等问题,
|
||||
> **而且基础服务计划足以满足个人需求,无需额外付费!**。
|
||||
|
||||
## 获取 Api Key
|
||||
|
||||
1. 访问 https://www.trongrid.io/register 使用邮箱注册账号并完成登录。
|
||||
2. 登录后找到`API Keys`选项,点击`Create API Key`填写名称后提交即可。
|
||||
|
||||
## 配置 Api Key
|
||||
|
||||
你的`Api Key`应该是类似这个样子:`648870c0-xxxx-xxxx-xxxx-c7ac4ec263b0`
|
||||
拿到之后登录 BEpusdt 后台,进入`系统管理`->`区块节点`->`Tron 网置`,将 Api Key 填入`TronGrid Api Key`输入框,保存即可生效。
|
||||
|
||||
如图:
|
||||
|
||||

|
||||
@@ -1,49 +1,51 @@
|
||||
module github.com/v03413/bepusdt
|
||||
|
||||
go 1.24.3
|
||||
go 1.26.2
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcutil v1.1.6
|
||||
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1
|
||||
github.com/gin-contrib/sessions v1.0.4
|
||||
github.com/gin-gonic/gin v1.10.1
|
||||
github.com/gin-contrib/sessions v1.1.0
|
||||
github.com/gin-gonic/gin v1.12.0
|
||||
github.com/glebarez/sqlite v1.11.0
|
||||
github.com/go-telegram/bot v1.17.0
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.6
|
||||
github.com/go-telegram/bot v1.20.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/matoous/go-nanoid/v2 v2.1.0
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible
|
||||
github.com/panjf2000/ants/v2 v2.11.3
|
||||
github.com/panjf2000/ants/v2 v2.12.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/sirupsen/logrus v1.9.4
|
||||
github.com/smallnest/chanx v1.2.0
|
||||
github.com/spf13/cast v1.9.2
|
||||
github.com/spf13/cast v1.10.0
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/urfave/cli/v3 v3.5.0
|
||||
github.com/urfave/cli/v3 v3.8.0
|
||||
github.com/v03413/go-cache v0.0.0-20250922030915-0ab5b738a932
|
||||
github.com/v03413/tronprotocol v0.0.0-20240824084238-bbd62f5e0158
|
||||
golang.org/x/crypto v0.42.0
|
||||
google.golang.org/grpc v1.73.0
|
||||
gorm.io/driver/mysql v1.6.0
|
||||
github.com/xssnick/tonutils-go v1.17.2
|
||||
golang.org/x/crypto v0.51.0
|
||||
google.golang.org/grpc v1.81.0
|
||||
gorm.io/driver/postgres v1.6.0
|
||||
gorm.io/gorm v1.31.1
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
filippo.io/edwards25519 v1.2.0 // indirect
|
||||
github.com/BurntSushi/toml v1.6.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.3 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/bytedance/gopkg v0.1.4 // indirect
|
||||
github.com/bytedance/sonic v1.15.1 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.7 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
|
||||
github.com/gin-contrib/sse v1.1.1 // indirect
|
||||
github.com/glebarez/go-sqlite v1.22.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.9.3 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.2 // indirect
|
||||
github.com/goccy/go-json v0.10.6 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/context v1.1.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
@@ -51,38 +53,40 @@ require (
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/pgx/v5 v5.6.0 // indirect
|
||||
github.com/jackc/pgx/v5 v5.9.2 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/ncruces/go-strftime v1.0.0 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.26 // indirect
|
||||
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/match v1.2.0 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.14 // indirect
|
||||
golang.org/x/arch v0.18.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
|
||||
golang.org/x/net v0.44.0 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.33.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
go.mongodb.org/mongo-driver/v2 v2.6.0 // indirect
|
||||
golang.org/x/arch v0.26.0 // indirect
|
||||
golang.org/x/net v0.53.0 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.44.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260504160031-60b97b32f348 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
modernc.org/libc v1.65.10 // indirect
|
||||
modernc.org/libc v1.72.2 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
modernc.org/sqlite v1.38.0 // indirect
|
||||
modernc.org/sqlite v1.50.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
|
||||
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
@@ -27,14 +27,16 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
|
||||
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
|
||||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0=
|
||||
github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=
|
||||
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
|
||||
github.com/bytedance/sonic v1.15.1 h1:nJD5PmM0vY7J8CT6MxoqbVAAMhkSmV2HgRAUrrpLoOw=
|
||||
github.com/bytedance/sonic v1.15.1/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA=
|
||||
github.com/bytedance/sonic/loader v0.5.1 h1:Ygpfa9zwRCCKSlrp5bBP/b/Xzc3VxsAW+5NIYXrOOpI=
|
||||
github.com/bytedance/sonic/loader v0.5.1/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI=
|
||||
github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -50,20 +52,22 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
|
||||
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
|
||||
github.com/gin-contrib/sessions v1.0.4 h1:ha6CNdpYiTOK/hTp05miJLbpTSNfOnFg5Jm2kbcqy8U=
|
||||
github.com/gin-contrib/sessions v1.0.4/go.mod h1:ccmkrb2z6iU2osiAHZG3x3J4suJK+OU27oqzlWOqQgs=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/sessions v1.1.0 h1:00mhHfNEGF5sP2fwxa98aRqj1FOJdL6IkR86n2hOiBo=
|
||||
github.com/gin-contrib/sessions v1.1.0/go.mod h1:TyYZDIs6qCQg2SOoYPgMT9pAkmZceVNEJMcv5qbIy60=
|
||||
github.com/gin-contrib/sse v1.1.1 h1:uGYpNwTacv5R68bSGMapo62iLTRa9l5zxGCps4hK6ko=
|
||||
github.com/gin-contrib/sse v1.1.1/go.mod h1:QXzuVkA0YO7o/gun03UI1Q+FTI8ZV/n5t03kIQAI89s=
|
||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||
github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ=
|
||||
github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc=
|
||||
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
||||
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.6 h1:VtX+l1Stj2v5RGubVQk0LS/8EPGXR+ldcOyCmlmKoyg=
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.6/go.mod h1:PZpedQc4tWaxn6kvXicwhinh3L0seLpMc5ReKRX5id4=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
@@ -72,14 +76,14 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
|
||||
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||
github.com/go-telegram/bot v1.17.0 h1:Hs0kGxSj97QFqOQP0zxduY/4tSx8QDzvNI9uVRS+zmY=
|
||||
github.com/go-telegram/bot v1.17.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/go-playground/validator/v10 v10.30.2 h1:JiFIMtSSHb2/XBUbWM4i/MpeQm9ZK2xqPNk8vgvu5JQ=
|
||||
github.com/go-playground/validator/v10 v10.30.2/go.mod h1:mAf2pIOVXjTEBrwUMGKkCWKKPs9NheYGabeB04txQSc=
|
||||
github.com/go-telegram/bot v1.20.0 h1:4Pea/qTidSspr4WBJw9FbHUMNhYeqszBqQUfsQEyFbc=
|
||||
github.com/go-telegram/bot v1.20.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
|
||||
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
|
||||
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
@@ -111,13 +115,15 @@ github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2e
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
|
||||
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
|
||||
github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw=
|
||||
github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
@@ -132,10 +138,8 @@ github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlT
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
@@ -144,8 +148,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE=
|
||||
github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@@ -153,8 +157,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
|
||||
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
@@ -164,92 +168,104 @@ github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
|
||||
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
|
||||
github.com/panjf2000/ants/v2 v2.12.0 h1:u9JhESo83i/GkZnhfTNuFMMWcNt7mnV1bGJ6FT4wXH8=
|
||||
github.com/panjf2000/ants/v2 v2.12.0/go.mod h1:tSQuaNQ6r6NRhPt+IZVUevvDyFMTs+eS4ztZc52uJTY=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pierrec/lz4/v4 v4.1.26 h1:GrpZw1gZttORinvzBdXPUXATeqlJjqUG/D87TKMnhjY=
|
||||
github.com/pierrec/lz4/v4 v4.1.26/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b h1:aUNXCGgukb4gtY99imuIeoh8Vr0GSwAlYxPAhqZrpFc=
|
||||
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
|
||||
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
|
||||
github.com/smallnest/chanx v1.2.0 h1:RLyldZBbQZ4O0dSvdkTMHo4+mDw20Bc1jXXTHf+ymZo=
|
||||
github.com/smallnest/chanx v1.2.0/go.mod h1:+4nWMF0+CqEcU74SnX2NxaGqZ8zX4pcQ8Jcs77DbX5A=
|
||||
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
|
||||
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM=
|
||||
github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.14 h1:yOQvXCBc3Ij46LRkRoh4Yd5qK6LVOgi0bYOXfb7ifjw=
|
||||
github.com/ugorji/go/codec v1.2.14/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/urfave/cli/v3 v3.5.0 h1:qCuFMmdayTF3zmjG8TSsoBzrDqszNrklYg2x3g4MSgw=
|
||||
github.com/urfave/cli/v3 v3.5.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/urfave/cli/v3 v3.8.0 h1:XqKPrm0q4P0q5JpoclYoCAv0/MIvH/jZ2umzuf8pNTI=
|
||||
github.com/urfave/cli/v3 v3.8.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/v03413/go-cache v0.0.0-20250922030915-0ab5b738a932 h1:Z2aWpconrfks7x1QZgmxHyS5i2rXOYIvQZrzhaCOFrI=
|
||||
github.com/v03413/go-cache v0.0.0-20250922030915-0ab5b738a932/go.mod h1:QKQ2xRbIt1CAA6767Z00YzFWXQ9ihmoIJi7A14klR2g=
|
||||
github.com/v03413/tronprotocol v0.0.0-20240824084238-bbd62f5e0158 h1:zAlBqlv+ljSO0AOvHQo2ur/MiCZFdwMYPVf7Hu0vezE=
|
||||
github.com/v03413/tronprotocol v0.0.0-20240824084238-bbd62f5e0158/go.mod h1:ToWfuVvvk9OTE5i0nisoXPWxVdeBdEduj7ddlwf/s9M=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
github.com/xssnick/tonutils-go v1.17.2 h1:WMBjyqJsgnZuc3UU/shxia47DQLjK+3oJtK0Xx2qgIg=
|
||||
github.com/xssnick/tonutils-go v1.17.2/go.mod h1:Ind3q0JM2N/63zfWR7rSGmUpUZaiGxregm9nZc/xGx4=
|
||||
go.mongodb.org/mongo-driver/v2 v2.6.0 h1:b9sJOYrkmt4l8bY43ZenFBcPlhYIjaOfYHLtbB/5qi8=
|
||||
go.mongodb.org/mongo-driver/v2 v2.6.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
|
||||
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
|
||||
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
|
||||
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
|
||||
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
|
||||
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc=
|
||||
golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
golang.org/x/arch v0.26.0 h1:jZ6dpec5haP/fUv1kLCbuJy6dnRrfX6iVK08lZBFpk4=
|
||||
golang.org/x/arch v0.26.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4=
|
||||
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
||||
golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI=
|
||||
golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg=
|
||||
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
|
||||
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
|
||||
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
|
||||
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -259,37 +275,35 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
|
||||
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
|
||||
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
|
||||
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
||||
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
|
||||
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260504160031-60b97b32f348 h1:U8orV30l6KpDsi9dxU0CoJZGbjS8EEpw+6ba+XwGPQA=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260504160031-60b97b32f348/go.mod h1:Yzdzr5OOZFgSsEV2D/Xi9NL3bszpXFAg0hFJiRohcD8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 h1:pfIbyB44sWzHiCpRqIen67ZQnVXSfIxWrqUMk1qwODE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/grpc v1.81.0 h1:W3G9N3KQf3BU+YuCtGKJk0CmxQNbAISICD/9AORxLIw=
|
||||
google.golang.org/grpc v1.81.0/go.mod h1:xGH9GfzOyMTGIOXBJmXt+BX/V0kcdQbdcuwQ/zNw42I=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
@@ -301,34 +315,35 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
|
||||
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
|
||||
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
|
||||
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
|
||||
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
|
||||
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||
modernc.org/cc/v4 v4.26.1 h1:+X5NtzVBn0KgsBCBe+xkDC7twLb/jNVj9FPgiwSQO3s=
|
||||
modernc.org/cc/v4 v4.26.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
||||
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
|
||||
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
|
||||
modernc.org/fileutil v1.3.3 h1:3qaU+7f7xxTUmvU1pJTZiDLAIoJVdUSSauJNHg9yXoA=
|
||||
modernc.org/fileutil v1.3.3/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
|
||||
modernc.org/cc/v4 v4.28.1 h1:XpLbkYVQ24E8tX5u8+yWGvaxerxkR/S4zqxI8ZoSBuc=
|
||||
modernc.org/cc/v4 v4.28.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ=
|
||||
modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
|
||||
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
|
||||
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/libc v1.65.10 h1:ZwEk8+jhW7qBjHIT+wd0d9VjitRyQef9BnzlzGwMODc=
|
||||
modernc.org/libc v1.65.10/go.mod h1:StFvYpx7i/mXtBAfVOjaU0PWZOvIRoZSgXhrwXzr8Po=
|
||||
modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
|
||||
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.72.2 h1:HwRjrHwX7hZIFCfRyw6otVlY+BoZEHFQmHQa5B0BzDE=
|
||||
modernc.org/libc v1.72.2/go.mod h1:43RZAMuEX483KwP1bW+3lTFm3dzwFpl6R8HMEutqy/w=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
||||
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
|
||||
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.38.0 h1:+4OrfPQ8pxHKuWG4md1JpR/EYAh3Md7TdejuuzE7EUI=
|
||||
modernc.org/sqlite v1.38.0/go.mod h1:1Bj+yES4SVvBZ4cBOpVZ6QgesMCKpJZDq0nxYzOpmNE=
|
||||
modernc.org/sqlite v1.50.0 h1:eMowQSWLK0MeiQTdmz3lqoF5dqclujdlIKeJA11+7oM=
|
||||
modernc.org/sqlite v1.50.0/go.mod h1:m0w8xhwYUVY3H6pSDwc3gkJ/irZT/0YEXwBlhaxQEew=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15.3358 9.02074C15.1513 9.02074 14.9754 8.94122 14.8526 8.80304L14.2096 8.07662C14.1139 7.96856 13.9756 7.90603 13.8313 7.90603C13.6869 7.90603 13.5488 7.96778 13.453 8.07662L12.9011 8.70037C12.7204 8.90417 12.461 9.02151 12.1885 9.02151H3.5071C3.26008 9.7263 3.09873 10.4705 3.03467 11.2432H11.2305C11.3748 11.2432 11.5124 11.1845 11.6119 11.0803L12.3754 10.2844C12.4703 10.1848 12.6023 10.1285 12.7397 10.1285H12.7714C12.9157 10.1285 13.0539 10.1902 13.1496 10.2991L13.7927 11.0255C13.9154 11.1637 14.0907 11.2432 14.276 11.2432H20.9656C20.9017 10.4705 20.7404 9.7263 20.4933 9.02151L15.3358 9.02074Z" fill="black"/>
|
||||
<path d="M7.99453 15.9135C8.13888 15.9135 8.27629 15.8548 8.37587 15.7506L9.13933 14.9546C9.23429 14.8551 9.36628 14.7988 9.5037 14.7988H9.53535C9.67971 14.7988 9.81791 14.8605 9.91365 14.9693L10.5567 15.6958C10.6794 15.8339 10.8546 15.9135 11.0398 15.9135H20.1058C20.4454 15.2118 20.694 14.4583 20.8422 13.6702H12.1406C11.9561 13.6702 11.7802 13.5906 11.6575 13.4525L11.0145 12.7261C10.9187 12.618 10.7806 12.5554 10.6361 12.5554C10.4917 12.5554 10.3536 12.6172 10.2579 12.7261L9.70595 13.3498C9.52531 13.5536 9.26593 13.671 8.99343 13.671H3.1582C3.30642 14.4599 3.55498 15.2125 3.89465 15.9143L7.99453 15.9135Z" fill="black"/>
|
||||
<path d="M14.4263 6.59423C14.5706 6.59423 14.708 6.53557 14.8077 6.43135L15.5711 5.63547C15.6661 5.53588 15.798 5.47953 15.9355 5.47953H15.9671C16.1114 5.47953 16.2496 5.54128 16.3454 5.65014L16.9885 6.37654C17.1112 6.51473 17.2864 6.59423 17.4717 6.59423H19.1954C17.5535 4.41191 14.942 3 12.0009 3C9.05964 3 6.4481 4.41191 4.80615 6.59423H14.4263Z" fill="black"/>
|
||||
<path d="M8.60571 18.1377C8.42122 18.1377 8.24521 18.0581 8.12247 17.9199L7.47943 17.1936C7.38371 17.0855 7.24552 17.0229 7.10117 17.0229C6.95681 17.0229 6.81864 17.0847 6.72291 17.1936L6.17097 17.8173C5.99033 18.0211 5.73095 18.1384 5.45844 18.1384H5.42139C7.06411 19.8985 9.40238 21 12.0001 21C14.5976 21 16.9359 19.8985 18.5787 18.1384L8.60571 18.1377Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -0,0 +1,9 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.51514 8.47125V15.5274C4.51514 15.9779 4.75959 16.3944 5.15552 16.6189L11.3599 20.1477C11.7558 20.3722 12.2432 20.3722 12.6392 20.1477L18.8435 16.6189C19.2394 16.3944 19.4839 15.9779 19.4839 15.5274V8.47125C19.4839 8.02072 19.2394 7.60418 18.8435 7.37966L12.6392 3.85086C12.2432 3.62634 11.7558 3.62634 11.3599 3.85086L5.15401 7.37966C4.75809 7.60418 4.51514 8.02072 4.51514 8.47125Z" fill="#213147"/>
|
||||
<path d="M13.3531 13.3677L12.4682 15.7577C12.4442 15.8241 12.4442 15.8965 12.4682 15.963L13.9905 20.0752L15.7511 19.0738L13.638 13.3677C13.59 13.2363 13.401 13.2363 13.3531 13.3677Z" fill="#12AAFF"/>
|
||||
<path d="M15.1273 9.3485C15.0793 9.21704 14.8903 9.21704 14.8423 9.3485L13.9575 11.7384C13.9334 11.8049 13.9334 11.8773 13.9575 11.9437L16.4515 18.6764L18.2122 17.6749L15.1273 9.3485Z" fill="#12AAFF"/>
|
||||
<path d="M11.9984 4.11521C12.0419 4.11521 12.0854 4.12703 12.1244 4.14771L18.8387 7.96602C18.9166 8.01033 18.9647 8.09305 18.9647 8.1802V15.8153C18.9647 15.904 18.9166 15.9852 18.8387 16.0295L12.1244 19.8479C12.0869 19.87 12.0419 19.8803 11.9984 19.8803C11.955 19.8803 11.9114 19.8685 11.8725 19.8479L5.15817 16.0325C5.08019 15.9881 5.0322 15.9055 5.0322 15.8183V8.18167C5.0322 8.09305 5.08019 8.01181 5.15817 7.9675L11.8725 4.14919C11.9114 4.12703 11.955 4.11521 11.9984 4.11521ZM11.9984 3C11.76 3 11.52 3.06056 11.3056 3.18316L4.59277 6.99999C4.16386 7.24371 3.8999 7.69423 3.8999 8.18167V15.8168C3.8999 16.3043 4.16386 16.7548 4.59277 16.9985L11.3071 20.8168C11.5215 20.938 11.76 21 11.9999 21C12.2384 21 12.4783 20.9395 12.6928 20.8168L19.407 16.9985C19.836 16.7548 20.0999 16.3043 20.0999 15.8168V8.18167C20.0999 7.69423 19.836 7.24371 19.407 6.99999L12.6913 3.18316C12.4768 3.06056 12.2369 3 11.9984 3Z" fill="#9DCCED"/>
|
||||
<path d="M7.55859 18.6854L8.17649 17.0192L9.41975 18.0369L8.25747 19.0827L7.55859 18.6854Z" fill="#213147"/>
|
||||
<path d="M11.4334 7.63513H9.73114C9.60366 7.63513 9.48969 7.71342 9.44619 7.83158L5.79736 17.6838L7.55804 18.6854L11.5758 7.83602C11.6133 7.73853 11.5398 7.63513 11.4334 7.63513Z" fill="white"/>
|
||||
<path d="M14.4117 7.63513H12.7095C12.582 7.63513 12.468 7.71342 12.4245 7.83158L8.2583 19.0812L10.019 20.0827L14.5542 7.83602C14.5902 7.73853 14.5166 7.63513 14.4117 7.63513Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.0009 4.70623C3.0009 4.12129 3.0009 3.82882 3.11069 3.60474C3.21598 3.38966 3.39056 3.21508 3.60564 3.10979C3.82972 3 4.12219 3 4.70623 3H19.2938C19.8787 3 20.1703 3 20.3953 3.10979C20.6103 3.21508 20.784 3.39056 20.8893 3.60474C21 3.82972 21 4.12219 21 4.70623V19.2938C21 19.8787 21 20.1703 20.8893 20.3953C20.784 20.6103 20.6094 20.784 20.3953 20.8893C20.1703 21 19.8778 21 19.2938 21H4.70623C4.12129 21 3.82972 21 3.60474 20.8893C3.38966 20.784 3.21598 20.6094 3.11069 20.3953C3 20.1703 3 19.8778 3 19.2938V4.70623H3.0009Z" fill="#0000FF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 658 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.09 5.75501L12 3L16.91 5.75501L15.1099 6.77501L12 5.03501L8.895 6.77501L7.09 5.75501ZM16.91 9.23501L15.1099 8.215L12 9.95504L8.895 8.215L7.09 9.23501V11.27L10.19 13.01V16.485L12 17.505L13.805 16.485V13.01L16.91 11.27V9.23501ZM16.91 14.75V12.71L15.1099 13.7301V15.7651L16.91 14.75ZM18.195 15.47L15.09 17.2051V19.245L20.0001 16.485V10.9751L18.195 11.9901V15.47ZM16.39 7.495L18.19 8.51501V10.55L20.0001 9.53501V7.495L18.195 6.47503L16.39 7.50001V7.495ZM10.19 17.9449V19.9799L12 21L13.805 19.9799V17.95L12 18.965L10.195 17.9449H10.19ZM7.09 14.745L8.89001 15.7651V13.7301L7.09 12.71V14.75V14.745ZM10.19 7.495L12 8.51501L13.805 7.495L12 6.47503L10.195 7.50001L10.19 7.495ZM5.80499 8.51501L7.61 7.495L5.80999 6.47503L4 7.50001V9.54002L5.80499 10.555V8.52001V8.51501ZM5.80499 11.9901L4 10.9751V16.485L8.91 19.245V17.2L5.80999 15.465V11.9851L5.80499 11.9901Z" fill="#F0B90B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 982 B |
@@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12 3V9.65149L17.6247 12.1672L12 3Z" fill="#8FFCF3"/>
|
||||
<path d="M11.9996 3L6.375 12.1662L11.9996 9.65255V3Z" fill="#CABCF8"/>
|
||||
<path d="M12 16.4778V21L17.6247 13.2156L12 16.4778Z" fill="#CBA7F5"/>
|
||||
<path d="M11.9996 21V16.4778L6.375 13.2156L11.9996 21Z" fill="#74A0F3"/>
|
||||
<path d="M12 15.4295L17.6247 12.1673L12 9.65158V15.4295Z" fill="#CBA7F5"/>
|
||||
<path d="M6.375 12.1673L11.9996 15.4295V9.65158L6.375 12.1673Z" fill="#74A0F3"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9996 15.4294L6.375 12.1672L11.9996 3L17.6242 12.1662L11.9996 15.4294ZM6.74774 11.9016L11.9093 3.49138V9.60635L6.74774 11.9016ZM6.67109 12.1305L11.9093 9.80374V15.168L6.67109 12.1305ZM12.0889 9.80374V15.168L17.3229 12.1305L12.0889 9.80374ZM12.0889 9.60635L17.2505 11.9016L12.0889 3.49138V9.60635Z" fill="#202699"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9996 16.4064L6.375 13.2114L11.9996 20.9999L17.6242 13.2103L11.9996 16.4064ZM7.00498 13.7731L11.9093 16.5639V20.5684L7.00498 13.7731ZM12.0889 16.5639V20.5684L16.9942 13.7731L12.0889 16.5639Z" fill="#202699"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M16.3644 15.217L20.6338 12.7816C20.8601 12.6521 21 12.4122 21 12.1547V7.2838C21 7.02631 20.8601 6.7864 20.6338 6.65702L16.3644 4.22156C16.138 4.09218 15.8569 4.09344 15.6319 4.22156L11.3623 6.65702C11.136 6.7864 10.9961 7.02631 10.9961 7.2838V15.9882L8.00191 17.6951L5.00763 15.9882V12.5729L8.00191 10.866L9.97646 11.9927V9.70168L8.36809 8.78352C8.25748 8.72071 8.13032 8.68679 8.00191 8.68679C7.87349 8.68679 7.74634 8.72071 7.63573 8.78352L3.36617 11.2191C3.13986 11.3484 3 11.5882 3 11.8457V16.7167C3 16.9742 3.13986 17.2141 3.36617 17.3434L7.63573 19.779C7.86205 19.907 8.14177 19.907 8.36809 19.779L12.6376 17.3434C12.864 17.2141 13.0039 16.9742 13.0039 16.7167V8.01231L13.0571 7.98216L15.9968 6.30534L18.9911 8.01231V11.4275L15.9968 13.1344L14.0247 12.0103V14.3013L15.6306 15.217C15.857 15.345 16.1379 15.345 16.3629 15.217H16.3644Z" fill="url(#paint0_linear_328_59720)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_328_59720" x1="2.94151" y1="17.194" x2="20.1188" y2="7.10065" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A726C1"/>
|
||||
<stop offset="0.88" stop-color="#803BDF"/>
|
||||
<stop offset="1" stop-color="#7B3FE4"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,19 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M18.4128 7.90222C18.3006 8.00534 18.1544 8.06331 18.002 8.06496H3.57973C3.06788 8.06496 2.80933 7.47961 3.16368 7.13707L5.53262 4.85345C5.64271 4.74715 5.78907 4.68664 5.94209 4.68414H20.4208C20.9379 4.68414 21.1912 5.27474 20.8316 5.61859L18.4128 7.90222Z" fill="url(#paint0_linear_328_59991)"/>
|
||||
<path d="M18.4128 19.1584C18.2999 19.2595 18.1536 19.3156 18.002 19.3159H3.57973C3.06788 19.3159 2.80933 18.7357 3.16368 18.3932L5.53262 16.1031C5.643 15.998 5.78972 15.9396 5.94209 15.9403H20.4208C20.9379 15.9403 21.1912 16.5256 20.8316 16.8682L18.4128 19.1584Z" fill="url(#paint1_linear_328_59991)"/>
|
||||
<path d="M18.4128 10.4727C18.2999 10.3716 18.1536 10.3155 18.002 10.3152H3.57973C3.06788 10.3152 2.80933 10.8954 3.16368 11.2379L5.53262 13.5281C5.64442 13.6308 5.79021 13.6889 5.94209 13.6909H20.4208C20.9379 13.6909 21.1912 13.1055 20.8316 12.763L18.4128 10.4727Z" fill="url(#paint2_linear_328_59991)"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_328_59991" x1="3.00094" y1="55.0406" x2="21.4588" y2="54.8714" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#599DB0"/>
|
||||
<stop offset="1" stop-color="#47F8C3"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_328_59991" x1="3.00094" y1="9.16751" x2="21.3414" y2="9.02716" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#C44FE2"/>
|
||||
<stop offset="1" stop-color="#73B0D0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_328_59991" x1="4.03645" y1="12.003" x2="20.3027" y2="12.003" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#778CBF"/>
|
||||
<stop offset="1" stop-color="#5DCDC9"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M18.0777 3H5.9216C3.68652 3 2.2699 5.41095 3.3943 7.35991L10.8966 20.3632C11.3862 21.2123 12.6131 21.2123 13.1027 20.3632L20.6065 7.35991C21.7294 5.41402 20.3128 3 18.0792 3H18.0777ZM10.8906 16.4637L9.25667 13.3017L5.31426 6.2508C5.05423 5.79949 5.37549 5.2212 5.92007 5.2212H10.889V16.4653L10.8906 16.4637ZM18.682 6.24926L14.7412 13.3032L13.1073 16.4637V5.21975H18.0762C18.6208 5.21975 18.9421 5.79796 18.682 6.24926Z" fill="#0098EA"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 549 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.41958 3.18579C4.48795 3.11039 4.5754 3.05483 4.67269 3.02495C4.76997 2.99507 4.87352 2.99196 4.97243 3.01598L16.8757 5.93028C16.9472 5.94689 17.0145 5.97827 17.0732 6.02242L19.4952 7.7889C19.6129 7.87561 19.6924 8.00447 19.7171 8.14848C19.7419 8.29251 19.71 8.44047 19.6281 8.56157L11.2959 20.7531C11.2373 20.8395 11.1559 20.9078 11.0608 20.9506C10.9655 20.9932 10.8604 21.0088 10.7569 20.9952C10.6534 20.9818 10.5558 20.9398 10.4749 20.874C10.3939 20.8083 10.3327 20.7213 10.2982 20.6228L4.30638 3.75311C4.27274 3.65729 4.26548 3.55418 4.28542 3.45459C4.30532 3.35501 4.35167 3.26262 4.41958 3.1871M6.3835 6.2304L10.543 17.9415L11.2275 11.8734L6.3835 6.2304ZM12.3411 12.0682L11.6461 18.2429L17.53 9.63303L12.3411 12.0682ZM18.0604 8.13772L14.2682 9.91736L16.81 7.22684L18.0604 8.13772ZM15.6648 6.79509L6.41115 4.53105L11.8369 10.8493L15.6648 6.79509Z" fill="#C4342B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1,11 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.8208 14.3415V19.0143H19.0953C19.2674 19.0143 19.4069 18.8748 19.4069 18.7029V14.653C19.4069 14.481 19.2674 14.3415 19.0953 14.3415H17.8208Z" fill="black" fill-opacity="0.5"/>
|
||||
<path d="M17.8208 4.98566V9.65853H19.0953C19.2674 9.65853 19.4069 9.51903 19.4069 9.34698V5.29719C19.4069 5.12513 19.2674 4.98566 19.0953 4.98566H17.8208Z" fill="black" fill-opacity="0.5"/>
|
||||
<path d="M20.209 4.98566V9.65853H20.6859C20.8579 9.65853 20.9974 9.51903 20.9974 9.34698V5.29719C20.9974 5.12513 20.8579 4.98566 20.6859 4.98566H20.209Z" fill="black" fill-opacity="0.3"/>
|
||||
<path d="M20.2114 14.3415V19.0143H20.6883C20.8603 19.0143 20.9998 18.8748 20.9998 18.7029V14.653C20.9998 14.481 20.8603 14.3415 20.6883 14.3415H20.2114Z" fill="black" fill-opacity="0.3"/>
|
||||
<path d="M12.0263 9.66925H7.9956C7.82434 9.66925 7.68555 9.80706 7.68555 9.97705V13.9788C7.68555 14.1488 7.82434 14.2867 7.9956 14.2867H12.0263C12.1974 14.2867 12.3363 14.1488 12.3363 13.9788V9.97705C12.3363 9.80706 12.1974 9.66925 12.0263 9.66925Z" fill="black"/>
|
||||
<path d="M7.36136 4.98566H3.31153C3.13948 4.98566 3 5.12513 3 5.29719V9.34698C3 9.51903 3.13948 9.65853 3.31153 9.65853H7.36136C7.53342 9.65853 7.67288 9.51903 7.67288 9.34698V5.29719C7.67288 5.12513 7.53342 4.98566 7.36136 4.98566Z" fill="black"/>
|
||||
<path d="M16.7051 4.98566H12.6553C12.4832 4.98566 12.3438 5.12513 12.3438 5.29719V9.34698C12.3438 9.51903 12.4832 9.65853 12.6553 9.65853H16.7051C16.8772 9.65853 17.0167 9.51903 17.0167 9.34698V5.29719C17.0167 5.12513 16.8772 4.98566 16.7051 4.98566Z" fill="black"/>
|
||||
<path d="M7.36136 14.3309H3.31153C3.13948 14.3309 3 14.4703 3 14.6425V18.6922C3 18.8644 3.13948 19.0037 3.31153 19.0037H7.36136C7.53342 19.0037 7.67288 18.8644 7.67288 18.6922V14.6425C7.67288 14.4703 7.53342 14.3309 7.36136 14.3309Z" fill="black"/>
|
||||
<path d="M16.7051 14.3309H12.6553C12.4832 14.3309 12.3438 14.4703 12.3438 14.6425V18.6922C12.3438 18.8644 12.4832 19.0037 12.6553 19.0037H16.7051C16.8772 19.0037 17.0167 18.8644 17.0167 18.6922V14.6425C17.0167 14.4703 16.8772 14.3309 16.7051 14.3309Z" fill="black"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.09 5.75501L12 3L16.91 5.75501L15.11 6.77501L12 5.03501L8.895 6.77501L7.09 5.75501ZM16.91 9.23501L15.11 8.215L12 9.95504L8.895 8.215L7.09 9.23501V11.27L10.19 13.01V16.485L12 17.505L13.8051 16.485V13.01L16.91 11.27V9.23501ZM16.91 14.75V12.71L15.11 13.7301V15.7651L16.91 14.75ZM18.195 15.47L15.09 17.2051V19.245L20.0001 16.485V10.9751L18.195 11.9901V15.47ZM16.3901 7.495L18.19 8.51501V10.55L20.0001 9.53501V7.495L18.195 6.47503L16.3901 7.50001V7.495ZM10.19 17.9449V19.9799L12 21L13.8051 19.9799V17.95L12 18.965L10.195 17.9449H10.19ZM7.09 14.745L8.89001 15.7651V13.7301L7.09 12.71V14.75V14.745ZM10.19 7.495L12 8.51501L13.8051 7.495L12 6.47503L10.195 7.50001L10.19 7.495ZM5.805 8.51501L7.61 7.495L5.80999 6.47503L4 7.50001V9.54002L5.805 10.555V8.52001V8.51501ZM5.805 11.9901L4 10.9751V16.485L8.91 19.245V17.2L5.80999 15.465V11.9851L5.805 11.9901Z" fill="#F0B90B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 975 B |
@@ -0,0 +1,10 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M12.0001 3V9.65073L17.6249 12.1661L12.0001 3Z" fill="#8FFCF3"/>
|
||||
<path d="M11.9999 3L6.37512 12.1661L11.9999 9.65073V3Z" fill="#CABCF8"/>
|
||||
<path d="M12.0001 16.477V20.9993L17.6249 13.2146L12.0001 16.477Z" fill="#CBA7F5"/>
|
||||
<path d="M11.9999 20.9993V16.477L6.37512 13.2146L11.9999 20.9993Z" fill="#74A0F3"/>
|
||||
<path d="M12.0001 15.4291L17.6249 12.1668L12.0001 9.65137V15.4291Z" fill="#CBA7F5"/>
|
||||
<path d="M6.37512 12.1668L11.9999 15.4291V9.65137L6.37512 12.1668Z" fill="#74A0F3"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9999 15.4285L6.37512 12.1661L11.9999 3L17.6248 12.1661L11.9999 15.4285ZM6.74861 11.9006L11.9099 3.49048V9.60573L6.74861 11.9006ZM6.67211 12.1301L11.9099 9.80373V15.1675L6.67211 12.1301ZM12.0899 9.80373V15.1675L17.3232 12.1301L12.0899 9.80373ZM12.0899 9.60573L17.2512 11.9006L12.0899 3.49048V9.60573Z" fill="#202699"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9999 16.4057L6.37512 13.2109L11.9999 21L17.6248 13.2109L11.9999 16.4057ZM7.0051 13.7734L11.9099 16.5632V20.5681L7.0051 13.7734ZM12.0899 16.5632V20.5681L16.9948 13.7734L12.0899 16.5632Z" fill="#202699"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M20.6612 7.21947L12.8153 19.7135C12.7198 19.8645 12.5876 19.9886 12.4313 20.0747C12.2748 20.1608 12.0991 20.2059 11.9206 20.2059C11.7406 20.2063 11.5636 20.1608 11.4061 20.0737C11.2486 19.9867 11.1159 19.8609 11.0205 19.7083L3.32824 7.21418C3.11275 6.86398 2.99909 6.46066 3.00001 6.04947C3.00976 5.44241 3.25994 4.86401 3.69566 4.4412C4.13139 4.01838 4.71703 3.78568 5.32412 3.79417H18.6865C19.9624 3.79417 21 4.80006 21 6.04417C21 6.45712 20.8835 6.86476 20.6612 7.21947ZM5.21824 6.80123L10.9411 15.6266V5.91182H5.81647C5.22353 5.91182 4.95883 6.30359 5.21824 6.80123ZM13.0588 15.6266L18.7818 6.80123C19.0465 6.30359 18.7765 5.91182 18.1835 5.91182H13.0588V15.6266Z" fill="#0088CC"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 798 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.41836 3.186C4.48661 3.11044 4.57404 3.05477 4.67138 3.02487C4.7687 2.99497 4.87233 2.99197 4.97122 3.01619L16.8749 5.9306C16.9464 5.94809 17.0136 5.97968 17.0733 6.02256L19.4953 7.78835C19.6137 7.87479 19.6938 8.00391 19.7187 8.14839C19.7435 8.2929 19.7112 8.44138 19.6284 8.56235L11.2959 20.7537C11.2372 20.8399 11.1558 20.9079 11.0606 20.9506C10.9655 20.9932 10.8605 21.0087 10.7571 20.9953C10.6537 20.9819 10.5561 20.9401 10.475 20.8744C10.3941 20.8089 10.3327 20.7222 10.298 20.624L4.30552 3.75354C4.27144 3.65765 4.26394 3.55432 4.2838 3.45451C4.30366 3.35469 4.35016 3.26155 4.41836 3.186ZM6.38273 6.23073L10.5428 17.9425L11.227 11.8728L6.38273 6.23073ZM12.3401 12.0686L11.6451 18.2437L17.5292 9.63308L12.3401 12.0686ZM18.0601 8.13812L14.2673 9.91807L16.81 7.22702L18.0601 8.13812ZM15.6647 6.79601L6.40982 4.52981L11.8359 10.8494L15.6647 6.79601Z" fill="#C4342B"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |