415 Commits
Author SHA1 Message Date
admin 647e1b96b1 feat(db): 支持 MySQL(MYSQL_DSN 环境变量 / --mysql 参数)
Docker Build (Gitea) / Build and Push Docker Image (push) Successful in 46s
- app/cmd/flag.go: 新增 MysqlDSNFlag(env MYSQL_DSN)
- start/reset: 读取并传给 model.Init
- model.Init 改为三选一:MySQL > PostgreSQL > SQLite
- 新增 initMysql():连接池参数对齐 Postgres 那套(10/100、30m 生命周期)
- order.go: return_url / notify_url 从 TEXT 改 VARCHAR(1024)
  MySQL 8 不允许 TEXT 列带 DEFAULT(Error 1101),改 varchar 三库通用

实测(真 mysql:8.0 容器):6 张表全部建出,bep_order 列类型符合预期
2026-11-24 19:58:08 +08:00
v03413 5791328de4 refactor: 合并 TON 转账解析的入站消息处理并补充单元测试 2026-11-13 09:20:39 +08:00
sylearn c592d3fb7a fix: fold truncate matching into has_prefix
Per review, drop the separate truncate mode and use its logic for
has_prefix instead. Order amounts are stored without trailing zeros
(1.50 as "1.5"), so the plain string prefix check let the 1.5 order
claim a 1.51 payment meant for a concurrent order on the same address.
Truncate the received amount to the larger of the atom precision and
the order's own decimals, then compare exactly: overpayment below the
atom precision still matches, underpayment and overpayment of a full
atom no longer do.
2026-11-01 22:49:44 +09:00
sylearn 5cb1d6f099 feat: add truncate amount match mode
Truncate the received amount to the atom precision before an exact comparison, so overpayment below the atom precision still matches while concurrent orders on one address (1.50, 1.51, ...) never claim each other's payments.
2026-10-31 23:45:49 +09:00
莫名 ebff24a190 Merge pull request #246 from sylearn/fix/solana-forward-tolerates-slot-retries
fix(solana): keep scanning forward while a few slots retry
2026-10-29 17:33:31 +08:00
莫名 5a1f9def13 Merge pull request #244 from sylearn/fix/solana-pruned-slot-no-retry
fix(solana): give up on slots the node has cleaned up
2026-10-29 17:33:22 +08:00
sylearn 6784a98c8e test(solana): cover backpressure threshold and recovery 2026-10-29 00:46:44 +08:00
sylearn d54669a8aa fix(solana): keep cleaned slots terminal under concurrency 2026-10-29 00:46:26 +08:00
sylearn 5b3a1ded6d fix(solana): keep lookback progress when the order query fails
lookbackOrdersPending ignored the query error, so a failed read counted
as "no order needs a lookback" and dropped the progress of a range that
was still needed. Return the error and keep the progress until the next
tick can check again.
2026-10-28 13:27:18 +08:00
sylearn 144cdb8c40 fix(solana): keep scanning forward while a few slots retry
syncSlotForward stops fetching the head slot as soon as any slot waits
for a retry. One slot that keeps failing with a timeout, 429 or -32004
therefore holds back every later payment until it succeeds or is given
up after about 7 minutes, although the following slots can be fetched
normally.

Pause forward scanning only when solanaForwardPauseRetries (10) slots
wait for a retry. That still stops new slots from piling into the retry
set during a node outage, while a single failing slot no longer delays
new payments.
2026-10-28 13:24:12 +08:00
sylearn 9131b9d5c4 fix(solana): give up on slots the node has cleaned up
getBlock returns -32001 (BlockCleanedUp) for a slot older than the
node's first available block. Retrying cannot succeed, yet the slot was
retried 10 times over about 7 minutes, and forward scanning stays paused
while any retry is pending.

In production a lookback range from a week earlier hit this for 627
slots at once: forward scanning stopped for about 10 minutes and the
node started to answer 429, which delayed a real payment by four
minutes.

Treat -32001 as final: log an ERROR with the slot number, clear any
retry left from an earlier failure of the same slot, and do not schedule
another one. Other errors keep the bounded retry. The existing retry
test now uses -32004 (block not available), a transient error.
2026-10-28 12:59:38 +08:00
sylearn 2fdb6e81d3 fix(solana): drop lookback ranges of finished orders
lookbackSlots keeps its progress (lookbackNext/lookbackEnd) across ticks,
but returns early through syncBreak once no order needs scanning. When an
order is paid, canceled or expires before its range is fully queued, the
remainder stays in memory. The next Solana order, possibly days later,
resumes that old range first.

In production the remainder was 627 slots from a week earlier. The RPC
node had already pruned them (-32001), every slot was retried, forward
scanning paused while retries were pending, and the node started to
answer 429. A payment made 90 seconds after the order was created was
seen four minutes late.

Before resuming, check that at least one order of the range still needs
a lookback (same condition as hasLookbackOrders); otherwise drop the
remaining range. The check runs before syncBreak so the state is also
cleared while scanning is idle.
2026-10-28 12:58:19 +08:00
莫名 3a1201e485 Merge branch 'main' into feat/solana-reconcile-expired-orders 2026-10-19 17:14:33 +08:00
莫名 a88d36918a Merge pull request #238 from sylearn/fix/solana-no-skip-while-lagging
fix(solana): keep catching up instead of skipping slots
2026-10-19 17:12:43 +08:00
莫名 46665ce060 Merge pull request #237 from sylearn/fix/solana-slot-retry-limit
fix(solana): stop retrying permanently failing slots
2026-10-19 17:12:28 +08:00
莫名 a4ed778a94 Merge pull request #241 from sylearn/refactor/solana-parse-transaction
refactor(solana): extract transaction parsing with mainnet fixtures
2026-10-19 17:11:38 +08:00
莫名 03980768c7 Merge pull request #239 from sylearn/fix/solana-confirm-offset-from-status
fix(solana): check confirmations from the signature status
2026-10-19 17:11:17 +08:00
莫名 79a67fa942 Merge pull request #240 from sylearn/fix/lookback-window-end
fix(task): cover every pending order window in lookback
2026-10-19 17:10:52 +08:00
莫名 6f1b1ef6f6 Merge pull request #235 from sylearn/fix/solana-lookback-range
fix(solana): validate and resume lookback ranges
2026-10-19 17:09:02 +08:00
sylearnandClaude Opus 5.5 014bb8e12b feat(solana): reconcile expired orders against token account history
Block scanning gives every slot one chance. A skipped or abandoned slot,
a restart, or an incomplete lookback range loses a payment for good, and
nothing finds it again.

Once a Solana order has been expired for a minute (up to two hours), look
it up once in the receiving token accounts' own history:

- token accounts: the wallet's associated token account, derived locally,
  plus any other account from getTokenAccountsByOwner when the node
  supports it (publicnode's free tier rejects that method);
- getSignaturesForAddress back to the order's creation time, keeping
  successful signatures inside the order window that no order has used;
- getTransaction, parsed with parseTransaction and checked with the
  existing orderTransferMatch. A match is marked confirming and then
  follows the normal confirm and callback flow.

RPC errors leave the order for the next round. Cost: a few RPC calls per
expired Solana order plus one getTransaction per candidate payment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:41:36 +08:00
sylearnandClaude Opus 5.5 efe4a3873e refactor(solana): extract transaction parsing with mainnet fixtures
Move the per-transaction body of slotParse into parseTransaction so the
same parser can be used on getTransaction results. No behavior change:
`git diff -w` shows only the loop/return edits.

Add mainnet fixtures for legacy transfer (USDT), legacy transferChecked,
a transfer to a token account created in the same transaction, and a v1
transaction; expected transfers come from an independent decoder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:37:45 +08:00
sylearnandClaude Opus 5.5 f46b4b7f74 fix(task): cover every pending order window in lookback
pendingLookbackUnix ended the lookback range at the expiry of the last
expired order in created_at order. When a batch mixes expired and still
waiting orders (common after a restart), or an earlier order has a
longer timeout, part of the other orders' windows was outside the range
but they were still marked as looked back.

End the range at the latest min(expired_at, now) over the batch. Used by
every chain's lookback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:25:18 +08:00
sylearnandClaude Opus 5.5 e7f857d21e fix(solana): check confirmations from the signature status
With block_offset_confirm enabled, tradeConfirmHandle compared the
order's slot with lastSlotNum, the forward scan cursor. The cursor stops
moving once no unexpired order is pending and is 0 after a restart, so a
payment matched shortly before expiry stayed "confirming" forever.

Use result.context.slot from the same getSignatureStatuses response
instead. This also removes the unsynchronized read of lastSlotNum from
the confirm goroutines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:23:52 +08:00
sylearnandClaude Opus 5.5 b0292c87dc fix(solana): keep catching up instead of skipping slots
The jump to the latest slot when the scanner falls more than
block_height_max_diff behind is meant for resuming after an idle period
(no pending orders) or on startup. It also fired while orders were
active, e.g. after a retry pause, dropping every slot in between without
a log; payments in those slots were never matched.

Now the scanner jumps only on startup or after idling, and otherwise
logs a warning and keeps catching up within blockQueueLimit per round.
A full queue does not count as idle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:23:17 +08:00
sylearnandClaude Opus 5.5 0354e07232 fix(solana): stop retrying permanently failing slots
- Give up a slot after 10 failed scans (about 7 minutes with the
  existing backoff) and log an ERROR with the slot number. Before, a slot
  that can never be fetched (e.g. "Block cleaned up", -32001) was retried
  forever, and forward sync stayed paused the whole time.
- A retry is queued as soon as its timer fires instead of being
  postponed while the queue is full, so a busy queue is never counted as
  a failed attempt.
- Add shared task test helpers (temporary log dir and SQLite).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:22:59 +08:00
sylearnandClaude Opus 5.5 1f127e237b fix(solana): skip transactions that failed on chain
- slotParse ignores transactions whose meta.err is not null. Failed
  transactions are still included in blocks with their instructions and
  token balances, but every transfer in them was rolled back.
- tradeConfirmHandle only confirms a signature that is finalized and has
  err == null; getSignatureStatuses reports failed transactions as
  finalized too.
- Add mainnet fixtures (failed v1 top-level transfer, failed v0 inner
  transfer, succeeded v0 inner transfer) and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 13:22:43 +08:00
sylearn 6dcbc2ad00 fix(solana): validate and resume lookback ranges 2026-10-18 10:48:01 +08:00
v03413 d36d34fe04 fix: 订单 URL 字段改为 text
return_url/notify_url 原为 varchar(255),超长时 PostgreSQL 写入订单报错 (SQLSTATE 22001),由 AutoMigrate 自动变更列类型。

Fix #234
2026-10-15 18:07:53 +08:00
sylearnandClaude Opus 5.5 16a46716c0 fix(solana): retry failed block scans safely
- Validate getBlock JSON, JSON-RPC error, result and result.transactions;
  record scan success only after a complete block is parsed.
- Treat skipped slots (result: null, -32007, -32009) as empty slots.
- Retry failed slots with bounded 2s/5s/15s/30s/60s backoff, one timer
  per slot; pause forward sync while retries are pending.
- Fill the slot queue only up to blockQueueLimit per round, keeping the
  existing BlockHeightMaxDiff jump-ahead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 13:50:23 +08:00
sylearn 3dafd2e7e1 fix(solana): support versioned v1 transactions 2026-10-14 02:54:37 +08:00
betaxab 7eb0263193 fix: Fixed the issue of dropped orders on the TON blockchain
fix: Set "lookbackDone" only after the lookback has truly completed.
misc: Move TON address validation to utils.
2026-07-24 03:57:58 +08:00
Zhisheng HuangandClaude Opus 4.8 8c95b5b5b8 fix: keep block scanner awake while orders await confirmation
On EVM chains an order can stall forever in OrderStatusConfirming and never
fire its notify when block_offset_confirm is enabled, even though the payment
is on-chain and has far more than enough confirmations.

Block scanning is demand-driven: syncBreak() halts the forward scan once
hasLookbackOrders() finds no "receivable" orders, and receivableOrderStatuses()
only listed {Waiting, Expired}. When an order moves Waiting -> Confirming and it
is the only pending order, the scanner stops and the in-memory chainBlockNum
freezes. With block_offset_confirm enabled, tradeConfirmHandle() requires
chainBlockNum - RefBlockNum >= ConfirmedOffset, so a frozen chainBlockNum means
the order never reaches the threshold and stays Confirming indefinitely: no
notify is sent and the merchant is never credited. Low-traffic merchants hit
this on essentially every order.

Include OrderStatusConfirming in receivableOrderStatuses() so the scanner keeps
advancing while any order is awaiting confirmation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 19:28:41 -07:00
v03413 b321da7bba feat: add checkout network ordering 2026-07-15 10:14:56 +08:00
long2ice efd1ce348a fix: use match_address when locking exclusive wallets
LockTradeAddress queried bep_order with match_addr (wallet column),
causing Error 1054 and breaking exclusive address checks.
2026-07-14 01:11:03 +08:00
v03413 43c579198a fix: remove order fingerprint index 2026-07-08 17:45:24 +08:00
v03413 e180b52c9a Merge branch 'refs/heads/main' into Fingerprint
# Conflicts:
#	app/handler/epusdt/epusdt.go
#	app/model/order.go
#	app/model/trade.go
2026-07-08 17:38:16 +08:00
v03413 3ca46e7fb9 fix: enforce fingerprint checks on payments 2026-07-08 17:32:11 +08:00
v03413 8076cd4b75 refactor: remove MySQL support and add migrations 2026-07-08 15:47:40 +08:00
v03413 e5e847f18f feat: always allow payment type reselect 2026-07-08 10:45:51 +08:00
v03413 54e73e48e4 fix: filter empty TronGrid API keys 2026-07-08 09:22:52 +08:00
v03413 451da12e09 feat: add client fingerprint checks for orders 2026-07-08 09:20:29 +08:00
betaxab 1f92306b03 fix: wallet.go: Pre-initialize MatchAddr = Address to prevent issues: #213 2026-06-27 19:32:26 +08:00
betaxab 79982c935f fix: order model: add default:0 value to fix #211 2026-06-26 13:17:50 +08:00
betaxab 275a2a3d22 feat: static: allow the deployer to use an external checkout theme 2026-06-25 15:55:46 +08:00
betaxab a6381c4aac fix: epusdt handler: math package missing 2026-06-25 15:18:09 +08:00
betaxab aafbac7b7b feat: Add the ability to reselect order trade types 2026-06-24 00:51:20 +08:00
狼哥 befc24487d feat: add LangGe checkout template 2026-06-22 21:56:03 +08:00
betaxab f6e6d485dd feat: Admin can manually cancel unpaid orders 2026-06-22 01:23:57 +08:00
v03413 74ed3fdc91 fix: prevent updating order trade type 2026-06-21 16:32:25 +08:00
v03413 2edf26857e feat: add configurable order lookback hours 2026-06-21 16:23:55 +08:00