feat: support TON and USDT Jetton payments

- add TON chain, token, RPC, address normalization, and order matching support
- add liteclient scanner with masterchain/shard catch-up and Jetton validation
- add TON manual payment verification and focused tests
This commit is contained in:
line-6000
2026-06-11 14:47:46 +08:00
parent 225cae2c24
commit 9b397bd45e
34 changed files with 3131 additions and 57 deletions
+37
View File
@@ -0,0 +1,37 @@
package service
import (
"context"
"fmt"
"strings"
"time"
"github.com/xssnick/tonutils-go/liteclient"
"github.com/xssnick/tonutils-go/ton"
)
// ConnectTonLiteAPI builds a tonutils-go API client from a liteserver global
// config URL. Scanner and manual verification use this same connection setup.
func ConnectTonLiteAPI(ctx context.Context, configURL string, requestTimeout time.Duration, reconnectLimit int) (ton.APIClientWrapped, func(), error) {
configURL = strings.TrimSpace(configURL)
if configURL == "" {
return nil, func() {}, fmt.Errorf("ton lite config url is empty")
}
if reconnectLimit <= 0 {
reconnectLimit = 3
}
cfg, err := liteclient.GetConfigFromUrl(ctx, configURL)
if err != nil {
return nil, func() {}, err
}
pool := liteclient.NewConnectionPool()
pool.SetOnDisconnect(pool.DefaultReconnect(3*time.Second, reconnectLimit))
if err = pool.AddConnectionsFromConfig(ctx, cfg); err != nil {
pool.Stop()
return nil, func() {}, err
}
base := ton.NewAPIClient(pool, ton.ProofCheckPolicyFast)
base.SetTrustedBlockFromConfig(cfg)
api := base.WithRetry(2).WithTimeout(requestTimeout).WithLSInfoInErrors()
return api, pool.Stop, nil
}