diff --git a/backend/mpc-system/services/service-party-app/electron/modules/tss-handler.ts b/backend/mpc-system/services/service-party-app/electron/modules/tss-handler.ts index 433e1364..3a0d09f4 100644 --- a/backend/mpc-system/services/service-party-app/electron/modules/tss-handler.ts +++ b/backend/mpc-system/services/service-party-app/electron/modules/tss-handler.ts @@ -198,12 +198,16 @@ export class TSSHandler extends EventEmitter { return new Promise((resolve, reject) => { try { const binaryPath = this.getTSSBinaryPath(); + console.log(`[TSS] Binary path: ${binaryPath}`); + console.log(`[TSS] Binary exists: ${fs.existsSync(binaryPath)}`); // 构建参与者列表 JSON const participantsJson = JSON.stringify(participants); + console.log(`[TSS] Participants: ${participantsJson}`); + console.log(`[TSS] partyIndex=${partyIndex}, threshold=${threshold.t}-of-${threshold.n}`); // 启动 TSS 子进程 - this.tssProcess = spawn(binaryPath, [ + const args = [ 'keygen', '--session-id', sessionId, '--party-id', partyId, @@ -212,9 +216,13 @@ export class TSSHandler extends EventEmitter { '--threshold-n', threshold.n.toString(), '--participants', participantsJson, '--password', encryptionPassword, - ]); + ]; + console.log(`[TSS] Spawning: ${binaryPath} ${args.join(' ')}`); + + this.tssProcess = spawn(binaryPath, args); let resultData = ''; + let stderrData = ''; // 如果没有预订阅,现在订阅消息 // 如果已经预订阅,消息监听器已经注册,不需要重复注册 @@ -254,7 +262,9 @@ export class TSSHandler extends EventEmitter { // 处理标准错误 this.tssProcess.stderr?.on('data', (data: Buffer) => { - console.error('[TSS Error]', data.toString()); + const errorText = data.toString(); + stderrData += errorText; + console.error('[TSS stderr]', errorText); }); // 处理进程退出 @@ -289,7 +299,9 @@ export class TSSHandler extends EventEmitter { reject(new Error(`Failed to parse keygen result: ${e}`)); } } else { - reject(new Error(`Keygen process exited with code ${code}`)); + const errorMsg = stderrData.trim() || `Keygen process exited with code ${code}`; + console.error(`[TSS] Process failed: code=${code}, stderr=${stderrData}`); + reject(new Error(errorMsg)); } });