From c1e749e53291ca6f1ad19dda85fe8652b59b44c7 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 30 Dec 2025 19:54:20 -0800 Subject: [PATCH] fix(co-sign): return join_tokens map for initiator auto-join MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add join_tokens (map[partyID]token) to CreateSignSession response - Keep join_token for backward compatibility - Update frontend to use join_tokens[partyId] for initiator auto-join 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../adapters/input/http/co_managed_handler.go | 26 ++++++++++--------- .../service-party-app/electron/main.ts | 3 ++- .../electron/modules/account-client.ts | 7 ++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/backend/mpc-system/services/account/adapters/input/http/co_managed_handler.go b/backend/mpc-system/services/account/adapters/input/http/co_managed_handler.go index ddc05f3b..630c18de 100644 --- a/backend/mpc-system/services/account/adapters/input/http/co_managed_handler.go +++ b/backend/mpc-system/services/account/adapters/input/http/co_managed_handler.go @@ -563,7 +563,7 @@ func (h *CoManagedHTTPHandler) CreateSignSession(c *gin.Context) { } } - // Get wildcard join token for participants + // Get wildcard token for backward compatibility (join_token field) wildcardToken := "" if token, ok := resp.JoinTokens["*"]; ok { wildcardToken = token @@ -572,20 +572,22 @@ func (h *CoManagedHTTPHandler) CreateSignSession(c *gin.Context) { logger.Info("Co-managed sign session created successfully", zap.String("session_id", resp.SessionID), zap.String("invite_code", inviteCode), - zap.Int("num_parties", len(resp.SelectedParties))) + zap.Int("num_parties", len(resp.SelectedParties)), + zap.Int("num_join_tokens", len(resp.JoinTokens))) c.JSON(http.StatusCreated, gin.H{ - "session_id": resp.SessionID, - "keygen_session_id": req.KeygenSessionID, - "wallet_name": req.WalletName, - "invite_code": inviteCode, - "join_token": wildcardToken, - "threshold_t": req.ThresholdT, - "selected_parties": resp.SelectedParties, - "status": "waiting_for_participants", - "current_participants": 0, + "session_id": resp.SessionID, + "keygen_session_id": req.KeygenSessionID, + "wallet_name": req.WalletName, + "invite_code": inviteCode, + "join_token": wildcardToken, // Backward compatible: wildcard token (may be empty) + "join_tokens": resp.JoinTokens, // New: all join tokens (map[partyID]token) + "threshold_t": req.ThresholdT, + "selected_parties": resp.SelectedParties, + "status": "waiting_for_participants", + "current_participants": 0, "required_participants": len(req.Parties), - "expires_at": resp.ExpiresAt, + "expires_at": resp.ExpiresAt, }) } diff --git a/backend/mpc-system/services/service-party-app/electron/main.ts b/backend/mpc-system/services/service-party-app/electron/main.ts index 12ca0435..1794a93e 100644 --- a/backend/mpc-system/services/service-party-app/electron/main.ts +++ b/backend/mpc-system/services/service-party-app/electron/main.ts @@ -1595,7 +1595,8 @@ function setupIpcHandlers() { }); // 发起方自动加入会话 - const joinToken = result.join_token; + // 支持新格式 join_tokens (map[partyID]token) 和旧格式 join_token (单一通配符 token) + const joinToken = result.join_tokens?.[partyId] || (result as { join_token?: string }).join_token; if (joinToken) { console.log('[CO-SIGN] Initiator auto-joining session...'); const joinResult = await grpcClient?.joinSession(result.session_id, partyId, joinToken); diff --git a/backend/mpc-system/services/service-party-app/electron/modules/account-client.ts b/backend/mpc-system/services/service-party-app/electron/modules/account-client.ts index d1d6dc9c..42ee099d 100644 --- a/backend/mpc-system/services/service-party-app/electron/modules/account-client.ts +++ b/backend/mpc-system/services/service-party-app/electron/modules/account-client.ts @@ -119,11 +119,12 @@ export interface CreateSignSessionResponse { session_id: string; invite_code: string; keygen_session_id: string; - message_hash: string; + wallet_name: string; threshold_t: number; - parties: SignPartyInfo[]; + selected_parties: string[]; expires_at: number; - join_token: string; + join_token?: string; // Backward compatible: wildcard token (may be empty) + join_tokens: Record; // New: all join tokens (map[partyID]token) } export interface GetSignSessionByInviteCodeResponse {