Compare commits

...

14 Commits

Author SHA1 Message Date
24d80ef505 no message 2026-02-03 15:15:02 +08:00
c1bf6690a2 fix 2026-02-03 15:05:17 +08:00
061c690948 add usdtman 2026-02-03 13:06:26 +08:00
d4127b1eba 11 2026-02-03 00:10:53 +08:00
53f91447e4 remove coinman 2026-02-02 23:52:21 +08:00
5ed34ffc06 fix 2026-02-02 23:46:57 +08:00
b52bab194f fix bugs 2026-02-02 23:38:27 +08:00
5136e470e4 fix bugs 2026-02-02 22:51:54 +08:00
d4cd1cecee fix 2026-02-02 02:23:21 +08:00
795ccbfd51 fix 2026-01-30 22:09:17 +08:00
7211525ef8 userId 2026-01-30 11:45:55 +08:00
11cce27665 fix back 2026-01-30 11:20:02 +08:00
099880ab72 fix 2026-01-30 10:40:25 +08:00
25aa9e9cbe dev socket 2026-01-30 00:13:53 +08:00
10 changed files with 276 additions and 1328 deletions

1
.gitignore vendored
View File

@@ -13,3 +13,4 @@ android/.gradle/file-system.probe
android/.gradle/8.0.1/checksums/checksums.lock
android/.gradle/8.0.1/checksums/md5-checksums.bin
android/.gradle/8.0.1/checksums/sha1-checksums.bin
android/.idea/caches

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "libs/rnauto"]
path = libs/rnauto
url = https://gitea.seaflygames.live/true_casey/rnauto.git
[submodule "servers/usdtman"]
path = servers/usdtman
url = https://gitea.seaflygames.live/true_casey/usdtman.git

12
.vscode/launch.json vendored
View File

@@ -12,6 +12,18 @@
"env": {
"PATH": "/Users/hybro/go/bin:${env:PATH}"
}
},
{
"name": "Debug USDTMan Server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/servers/usdtman/cmd/server",
"cwd": "${workspaceFolder}/servers/usdtman",
"preLaunchTask": "build usdtman",
"env": {
"PATH": "/Users/hybro/go/bin:${env:PATH}"
}
}
]
}

23
.vscode/tasks.json vendored
View File

@@ -21,6 +21,27 @@
"kind": "build",
"isDefault": true
}
}
},
{
"label": "build usdtman",
"type": "shell",
"command": "go",
"args": [
"build",
"-o",
"${workspaceFolder}/servers/usdtman/bin/server",
"./cmd/server"
],
"options": {
"cwd": "${workspaceFolder}/servers/usdtman"
},
"problemMatcher": [
"$go"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}

299
App.tsx
View File

@@ -1,5 +1,6 @@
import React, { Component } from "react";
import { Alert, Modal, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { Alert, AppState, AppStateStatus, Modal, StyleSheet, Text, TouchableOpacity, View } from "react-native";
import DeviceInfo from 'react-native-device-info';
import {
PaytmBusinessBind,
PhonePeBusinessBind,
@@ -33,25 +34,38 @@ import {
PhonePePersonalBind,
SmsMessage,
NotificationMessage,
proxyManager,
} from "rnwalletman";
import BarcodeScanning from '@react-native-ml-kit/barcode-scanning';
import RNFS from 'react-native-fs';
import rnauto from 'rnauto';
interface AppProps {
}
interface AppState {
showPaytmBusinessBind: boolean;
interface WalletmanAppState {
/* Paytm Personal */
showPaytmPersonalBind: boolean;
paytmPersonalBindType: 'otpMode' | 'authMode';
showPaytmBusinessBind: boolean;
/* PhonePe Personal */
showPhonePePersonalBind: boolean;
phonePePersonalBindType: 'otpMode' | 'authMode';
showPhonePeBusinessBind: boolean;
/* GooglePay Business */
showGooglePayBusinessBind: boolean;
/* BharatPe Business */
showBharatPeBusinessBind: boolean;
/* Mobikwik Personal */
showMobikwikPersonalBind: boolean;
/* Freecharge Personal */
showFreechargePersonalBind: boolean;
}
@@ -67,7 +81,7 @@ const styles = StyleSheet.create({
backgroundColor: "lightblue",
borderRadius: 5,
width: 200,
height: 50,
height: 55,
},
text: {
fontSize: 20,
@@ -84,28 +98,38 @@ const styles = StyleSheet.create({
alignItems: "center",
},
bindButton: {
padding: 10,
borderRadius: 5,
width: 250,
height: 40,
width: 350,
height: 50,
justifyContent: "center",
alignItems: "center",
margin: 10,
marginBottom : 10,
},
bindButtonText: {
fontSize: 15,
fontWeight: "bold",
textAlign: "center",
textAlignVertical: "center",
},
});
class Api {
private static readonly BASE_URL = 'http://192.168.1.155:16000';
public static readonly BASE_URL = 'http://192.168.1.117:16000';
private static _instance: Api | null = null;
private userId: number = 0;
private constructor() {
}
public setUserId(userId: number) {
this.userId = userId;
}
public getUserId(): number {
return this.userId;
}
public static get instance() {
if (Api._instance === null) {
Api._instance = new Api();
@@ -113,42 +137,72 @@ class Api {
return Api._instance;
}
public async register(walletType: WalletType, params: any) {
const response = await fetch(`${Api.BASE_URL}/register`, {
private headers(): Record<string, string> {
const h: Record<string, string> = { 'Content-Type': 'application/json' };
if (this.userId) h['X-User-ID'] = String(this.userId);
return h;
}
public async login(username: string, password: string): Promise<number> {
const res = await fetch(`${Api.BASE_URL}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
});
const data = await res.json();
if (!data.success) throw new Error(data.message);
this.userId = data.data.userId;
return this.userId;
}
public async register(walletType: WalletType, params: any) {
const res = await fetch(`${Api.BASE_URL}/register`, {
method: 'POST',
headers: this.headers(),
body: JSON.stringify({ walletType, params }),
});
return response.json();
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data;
}
public async requestOTP(walletType: WalletType, mobile: string, params: any = {}) {
const response = await fetch(`${Api.BASE_URL}/request-otp`, {
const res = await fetch(`${Api.BASE_URL}/request-otp`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ walletType, mobile, params }),
headers: this.headers(),
body: JSON.stringify({ walletType, mobile, ...params }),
});
return response.json();
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data;
}
public async verifyOTP(walletType: WalletType, mobile: string, otp: string, params: any = {}) {
const response = await fetch(`${Api.BASE_URL}/verify-otp`, {
const res = await fetch(`${Api.BASE_URL}/verify-otp`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
headers: this.headers(),
body: JSON.stringify({ walletType, mobile, otp, params }),
});
return response.json();
const data = await res.json();
if (!data.success) throw new Error(data.message);
return data;
}
}
export default class App extends Component<AppProps, AppState> {
export default class App extends Component<AppProps, WalletmanAppState> {
private deviceId: string;
private tuneUserId: string;
private clientId: string = '';
private appStateSubscription?: any;
constructor(props: AppProps) {
super(props);
this.state = {
paytmPersonalBindType: 'otpMode',
showPaytmBusinessBind: false,
showPaytmPersonalBind: false,
phonePePersonalBindType: 'otpMode',
showPhonePeBusinessBind: false,
showPhonePePersonalBind: false,
showGooglePayBusinessBind: false,
@@ -163,6 +217,30 @@ export default class App extends Component<AppProps, AppState> {
}
async componentDidMount() {
/* 获取真实 Android ID */
try {
this.clientId = await DeviceInfo.getAndroidId();
console.log('[设备ID]', this.clientId);
} catch (error) {
this.clientId = `android_${Date.now()}`;
console.warn('[设备ID] 获取失败使用随机ID:', this.clientId);
}
/* 监听应用状态 */
this.appStateSubscription = AppState.addEventListener('change', this.handleAppStateChange);
/* 登录获取 userId */
try {
await Api.instance.login('test123', '123456');
console.log('[登录成功] userId:', Api.instance.getUserId());
} catch (error) {
console.error('[登录失败]', error);
Alert.alert('登录失败', String(error));
return;
}
/* 初始化代理客户端 */
await this.initProxyClient();
/* 权限申请 */
let smsPermission = await checkSmsPermission();
let notificationPermission = await checkNotificationPermission();
@@ -188,7 +266,7 @@ export default class App extends Component<AppProps, AppState> {
{ text: '取消' }
]
);
return; // 等用户手动授权后重启应用
return;
}
// 启动监听
@@ -201,9 +279,6 @@ export default class App extends Component<AppProps, AppState> {
console.log('[Notification]', notification);
});
/*
* 获取所有短信和通知
*/
if (smsPermission) {
getAllSms().then((sms: SmsMessage[]) => {
console.log('[所有短信]', sms.length, '条');
@@ -217,11 +292,81 @@ export default class App extends Component<AppProps, AppState> {
}
}
private wsHeartbeatTimer?: NodeJS.Timeout;
/**
* 初始化代理客户端
*/
async initProxyClient() {
const wsUrl = `ws://${Api.BASE_URL.replace('http://', '')}/ws`;
proxyManager.start({
wsUrl,
clientId: this.clientId,
userId: Api.instance.getUserId(),
debug: true,
onConnected: () => {
console.log('[代理] ✅ 已连接');
},
onDisconnected: () => {
console.log('[代理] ❌ 已断开');
},
onError: (error) => {
console.error('[代理] 错误:', error);
},
// 自定义注册逻辑(可选)
onRegister: (ws, clientId, userId) => {
// 可以在这里自定义发送的注册消息
ws.send(JSON.stringify({
type: 'register',
clientId,
messageId: 'register_' + Date.now(),
data: {
userId,
// 可以添加额外参数
deviceInfo: {
platform: 'android',
version: '1.0.0'
}
}
}));
}
}).catch(err => {
console.error('[代理] 启动失败:', err);
});
}
/**
* 停止代理客户端
*/
stopProxyClient() {
proxyManager.stop();
}
componentWillUnmount(): void {
// 清理应用状态监听
this.appStateSubscription?.remove();
// 停止代理
this.stopProxyClient();
stopSmsListener();
stopNotificationListener();
}
/**
* 处理应用状态变化
*/
handleAppStateChange = (nextAppState: AppStateStatus) => {
if (nextAppState === 'background' || nextAppState === 'inactive') {
console.log('[AppState] 应用进入后台,关闭代理');
this.stopProxyClient();
} else if (nextAppState === 'active') {
console.log('[AppState] 应用回到前台,重连代理');
this.initProxyClient();
}
}
decodeQRFromUrl = async (url: string) => {
const localPath = `${RNFS.CachesDirectoryPath}/temp_qr_${Date.now()}.jpg`;
@@ -242,8 +387,8 @@ export default class App extends Component<AppProps, AppState> {
};
/* 绑定 Paytm Personal */
handlePaytmPersonalBind = () => {
this.setState({ showPaytmPersonalBind: true });
handlePaytmPersonalBind = (type: 'otpMode' | 'authMode') => {
this.setState({ showPaytmPersonalBind: true ,paytmPersonalBindType: type});
}
/* 上传 Paytm Personal 到服务器 */
@@ -314,8 +459,8 @@ export default class App extends Component<AppProps, AppState> {
}
/* 绑定 PhonePe Personal */
handlePhonePePersonalBind = () => {
this.setState({ showPhonePePersonalBind: true });
handlePhonePePersonalBind = (type: 'otpMode' | 'authMode') => {
this.setState({ showPhonePePersonalBind: true ,phonePePersonalBindType: type});
}
/* 上传 PhonePe Personal 到服务器 */
@@ -396,6 +541,44 @@ export default class App extends Component<AppProps, AppState> {
renderBindModal = () => {
/* 绑定 Paytm Personal */
if (this.state.showPaytmPersonalBind) {
return (
<Modal visible={this.state.showPaytmPersonalBind} transparent={true} onRequestClose={() => this.setState({ showPaytmPersonalBind: false })}>
<PaytmPersonalBind
processString="Processing Paytm Personal..."
isDebug={true}
otpMode={this.state.paytmPersonalBindType === 'otpMode'}
onRequestOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.requestOTP(walletType, params.mobile, {});
return response;
} catch (error) {
return { success: false, message: (error as Error).message };
}
}}
onVerifyOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.verifyOTP(walletType, params.mobile, params.otp, {
sessionId: params.sessionId, // 只需要传 sessionId
});
return response;
} catch (error) {
return { success: false, message: (error as Error).message };
}
}}
onSuccess={(result: PaytmPersonalBindResult) => {
this.handleUploadPaytmPersonal(result);
}}
onError={(error) => {
console.log(error);
this.setState({ showPaytmPersonalBind: false });
}}
/>
</Modal>
);
}
/* 绑定 PhonePe Personal */
if (this.state.showPhonePePersonalBind) {
return (
@@ -403,7 +586,7 @@ export default class App extends Component<AppProps, AppState> {
<PhonePePersonalBind
processString="Processing PhonePe Personal..."
isDebug={true}
otpMode={true}
otpMode={this.state.phonePePersonalBindType === 'otpMode'}
onRequestOTP={async (walletType: WalletType, params: any) => {
try {
const response = await Api.instance.requestOTP(walletType, params.mobile, {});
@@ -511,25 +694,6 @@ export default class App extends Component<AppProps, AppState> {
);
}
/* 绑定 Paytm Personal */
if (this.state.showPaytmPersonalBind) {
return (
<Modal visible={this.state.showPaytmPersonalBind} transparent={true} onRequestClose={() => this.setState({ showPaytmPersonalBind: false })}>
<PaytmPersonalBind
processString="Processing Paytm Personal..."
isDebug={true}
onSuccess={(result: PaytmPersonalBindResult) => {
this.handleUploadPaytmPersonal(result);
}}
onError={(error) => {
console.log(error);
this.setState({ showPaytmPersonalBind: false });
}}
/>
</Modal>
);
}
/* 绑定 Mobikwik Personal */
if (this.state.showMobikwikPersonalBind) {
return (
@@ -617,28 +781,29 @@ export default class App extends Component<AppProps, AppState> {
return null;
}
handlePaytmPay = async () => {
try {
const result = await paytmPay("100", "test", "1234567890", "1234567890", "test");
Alert.alert('Paytm Pay Success', result.toString());
} catch (error) {
Alert.alert('Paytm Pay Error', (error as Error).message || 'Unknown error');
}
}
render() {
return (
<View style={styles.container}>
{this.renderBindModal()}
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "purple" }]} onPress={this.handlePaytmPersonalBind}>
<Text style={styles.bindButtonText}> Paytm Personal</Text>
</TouchableOpacity>
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#888888" }]} onPress={this.handlePaytmPersonalBind.bind(this, 'otpMode')}>
<Text style={styles.bindButtonText}> Paytm Personal(OTP)</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#F88888" }]} onPress={this.handlePaytmPersonalBind.bind(this, 'authMode')}>
<Text style={styles.bindButtonText}> Paytm Personal()</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "lightblue" }]} onPress={this.handlePaytmBusinessBind}>
<Text style={styles.bindButtonText}> Paytm Business</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "#1890ff" }]} onPress={this.handlePhonePePersonalBind}>
<Text style={styles.bindButtonText}> PhonePe Personal</Text>
</TouchableOpacity>
<View style={[styles.bindButton, { backgroundColor: "transparent", flexDirection: "row", justifyContent: "space-between", alignItems: "center" }]}>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#C88888" }]} onPress={this.handlePhonePePersonalBind.bind(this, 'otpMode')}>
<Text style={styles.bindButtonText}> PhonePe Personal(OTP)</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { marginBottom : 0,width : '45%', backgroundColor: "#A88888" }]} onPress={this.handlePhonePePersonalBind.bind(this, 'authMode')}>
<Text style={styles.bindButtonText}> PhonePe Personal()</Text>
</TouchableOpacity>
</View>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "lightgreen" }]} onPress={this.handlePhonePeBusinessBind}>
<Text style={styles.bindButtonText}> PhonePe Business</Text>
</TouchableOpacity>
@@ -648,10 +813,6 @@ export default class App extends Component<AppProps, AppState> {
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "pink" }]} onPress={this.handleBharatPeBusinessBind}>
<Text style={styles.bindButtonText}> BharatPe Business</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "orange" }]} onPress={this.handlePaytmPay}>
<Text style={styles.bindButtonText}> Paytm Personal</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.bindButton, { backgroundColor: "brown" }]} onPress={this.handleMobikwikPersonalBind}>
<Text style={styles.bindButtonText}> Mobikwik Personal</Text>
</TouchableOpacity>

File diff suppressed because it is too large Load Diff

View File

@@ -25,7 +25,9 @@
<option value="$PROJECT_DIR$/../node_modules/@react-native-cookies/cookies/android" />
<option value="$PROJECT_DIR$/../node_modules/@react-native-ml-kit/barcode-scanning/android" />
<option value="$PROJECT_DIR$/../node_modules/@react-native/gradle-plugin" />
<option value="$PROJECT_DIR$/../node_modules/react-native-device-info/android" />
<option value="$PROJECT_DIR$/../node_modules/react-native-fs/android" />
<option value="$PROJECT_DIR$/../node_modules/react-native-tcp-socket/android" />
<option value="$PROJECT_DIR$/../node_modules/react-native-webview/android" />
<option value="$PROJECT_DIR$/../node_modules/rnauto/android" />
<option value="$PROJECT_DIR$/../node_modules/rnwalletman/android" />

2
android/.idea/vcs.xml generated
View File

@@ -5,6 +5,8 @@
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../libs/rnauto" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../libs/rnwalletman" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../node_modules/rnauto" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../node_modules/rnwalletman" vcs="Git" />
<mapping directory="$PROJECT_DIR$/../servers/walletman" vcs="Git" />
</component>
</project>

View File

@@ -12,9 +12,12 @@
"dependencies": {
"@react-native-cookies/cookies": "^6.2.1",
"@react-native-ml-kit/barcode-scanning": "^2.0.0",
"buffer": "^6.0.3",
"react": "18.2.0",
"react-native": "0.72.10",
"react-native-device-info": "14.0.4",
"react-native-fs": "^2.20.0",
"react-native-tcp-socket": "^6.4.1",
"react-native-webview": "13.6.2",
"rnauto": "./libs/rnauto",
"rnwalletman": "./libs/rnwalletman"

1
servers/usdtman Submodule

Submodule servers/usdtman added at 753bd4a4d6