From c1e32a8c04ff9ce5252c627f1f2a497c7cb57d83 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 31 Dec 2025 01:47:08 -0800 Subject: [PATCH] fix(co-sign): fix threshold_n display and add missing fields in GetSignSessionByInviteCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add threshold_n to GetSignSessionByInviteCodeResponse interface - Fix main.ts to use result.threshold_n instead of result.parties?.length - Add message_hash, joined_count, join_token to GetSignSessionByInviteCode response - Generate join token for sign session lookup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../adapters/input/http/co_managed_handler.go | 31 ++++++++++++++++--- .../service-party-app/electron/main.ts | 2 +- .../electron/modules/account-client.ts | 1 + 3 files changed, 28 insertions(+), 6 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 7097cddc..819f0f13 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 @@ -685,13 +685,14 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) { var thresholdN, thresholdT int var status string var expiresAt time.Time + var messageHash []byte err := h.db.QueryRowContext(ctx, ` SELECT id, COALESCE(wallet_name, ''), COALESCE(keygen_session_id::text, ''), - threshold_n, threshold_t, status, expires_at + threshold_n, threshold_t, status, expires_at, COALESCE(message_hash, '') FROM mpc_sessions WHERE invite_code = $1 AND session_type = 'sign' - `, inviteCode).Scan(&sessionID, &walletName, &keygenSessionID, &thresholdN, &thresholdT, &status, &expiresAt) + `, inviteCode).Scan(&sessionID, &walletName, &keygenSessionID, &thresholdN, &thresholdT, &status, &expiresAt, &messageHash) if err != nil { if err == sql.ErrNoRows { @@ -727,28 +728,48 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) { "session_id": sessionID, "keygen_session_id": keygenSessionID, "wallet_name": walletName, + "message_hash": hex.EncodeToString(messageHash), "threshold_n": thresholdN, "threshold_t": thresholdT, "status": status, + "joined_count": 0, "expires_at": expiresAt.UnixMilli(), }) return } + // Generate join token for this session (wildcard token that allows any party to join) + var joinToken string + if h.jwtService != nil { + sessionUUID, parseErr := uuid.Parse(sessionID) + if parseErr == nil { + token, err := h.jwtService.GenerateJoinToken(sessionUUID, "*", time.Hour) // Wildcard party ID, 1 hour expiry + if err != nil { + logger.Warn("Failed to generate join token for sign session", + zap.String("session_id", sessionID), + zap.Error(err)) + } else { + joinToken = token + } + } + } + logger.Info("Found sign session for invite_code", zap.String("invite_code", inviteCode), zap.String("session_id", sessionID), - zap.String("wallet_name", walletName)) + zap.String("wallet_name", walletName), + zap.Bool("has_join_token", joinToken != "")) c.JSON(http.StatusOK, gin.H{ "session_id": sessionID, "keygen_session_id": keygenSessionID, "wallet_name": walletName, + "message_hash": hex.EncodeToString(messageHash), "threshold_n": thresholdN, "threshold_t": thresholdT, "status": statusResp.Status, - "completed_parties": statusResp.CompletedParties, - "total_parties": statusResp.TotalParties, + "joined_count": statusResp.CompletedParties, "expires_at": expiresAt.UnixMilli(), + "join_token": joinToken, }) } 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 b706031a..48caca98 100644 --- a/backend/mpc-system/services/service-party-app/electron/main.ts +++ b/backend/mpc-system/services/service-party-app/electron/main.ts @@ -1712,7 +1712,7 @@ function setupIpcHandlers() { messageHash: result.message_hash, threshold: { t: result.threshold_t, - n: result.parties?.length || 0, + n: result.threshold_n, }, status: result.status, currentParticipants: result.joined_count || 0, 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 79cedf1e..778647ff 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 @@ -133,6 +133,7 @@ export interface GetSignSessionByInviteCodeResponse { wallet_name: string; message_hash: string; threshold_t: number; + threshold_n: number; status: string; invite_code: string; expires_at: number;