154 Commits
Author SHA1 Message Date
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
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
betaxab aafbac7b7b feat: Add the ability to reselect order trade types 2026-06-24 00:51:20 +08:00
v03413 2edf26857e feat: add configurable order lookback hours 2026-06-21 16:23:55 +08:00
v03413 13d3fad174 refactor: move block api package to core 2026-06-21 01:30:04 +08:00
v03413 5e598cd2f3 feat: add unified checkout template 2026-06-21 01:24:12 +08:00
v03413 d458ef7ca3 feat: add API-backed block lookback 2026-06-19 01:33:56 +08:00
v03413 8033ccfe93 fix: exclude failed orders from recovery
「交易确认失败」本身就是一种合法状态
2026-06-18 22:46:41 +08:00
Jason.li 1e52f40a6c Merge origin/main into payment reconciliation fix 2026-06-07 14:40:38 +08:00
Jason.li 24372a9639 fix(task): recover missed payments across chains
Keep recent waiting, expired, and failed orders eligible for transfer matching, and use the same recoverable-order window when bootstrapping chain backfill.

Add periodic reconciliation backfill for EVM, Tron, and Aptos so scanners continue to revisit recent historical blocks or versions when recoverable orders exist, and add regression coverage for recoverable order selection and scanner activation.
2026-06-07 14:05:30 +08:00
Jason.li f28ae2aa8d fix(solana): reconcile missed token payments
Add a Solana reconciliation task that backfills recent waiting, expired, and failed orders by scanning token accounts, signatures, and parsed transactions for matching SPL transfers.

Reuse shared order matching for realtime transfer handling, return DB errors from MarkConfirming, and keep confirming orders eligible when the on-chain payment timestamp was inside the order window even if final confirmation happens after expiry.
2026-06-07 12:51:23 +08:00
v03413 2bf1406566 feat: rename TON native coin to GRAM
ref: https://t.me/toncoin/2384
ref: https://ton.vote/EQDQvywF226NXojPky_9gwbCz0FPoygqY11bGl03SONNBs5V/proposal/EQAv-VS2OM80SYLB0ouRWRcpFg4J0L-egUf1-utF-OJ6h0rK
2026-06-03 15:25:41 +08:00
v03413 ea113e6e90 feat: 增加支持 Ton 区块链网络扫块
新增交易类型 ton.toncoin usdt.ton
close: https://github.com/v03413/BEpusdt/pull/192
2026-06-02 21:03:19 +08:00
v03413 041f7e9cef feat: 增加区块网络状态可视化 2026-05-26 22:02:37 +08:00
v03413 e46706370c refactor: optimize type casting and formatting logic
fix: https://github.com/v03413/BEpusdt/issues/184
2026-04-30 22:27:25 +08:00
betaxab 609a850e61 update: minor adjustments to order confirmation 2026-04-29 18:52:19 +08:00
betaxab 17b0d1cad1 fix: Try to resolve the failed queue blocking web issue in Tron 2026-04-27 08:48:58 +08:00
v03413 6ccd93a161 feat: 增加支持历史汇率自动清理 2026-04-16 10:57:57 +08:00
v03413 2edf71dee1 feat: 增加支持自定义Topic 路径前缀 2026-04-15 21:44:34 +08:00
v03413 86251ac054 perf: unify mqtt subscription logic across modules 2026-04-15 16:30:05 +08:00
v03413 0f4346cd5f fix: 补漏Tron 网络 MQTT 广播判断 2026-04-15 15:10:47 +08:00
v03413 c4d5e20c7a feat: 实现交易监听 MQTT服务器广播 2026-04-15 14:58:24 +08:00