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 e0b5d372..a139d2d7 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 @@ -615,13 +615,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, 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 { @@ -684,21 +685,52 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) { } } + // Query participants for this session + var parties []gin.H + partiesRows, err := h.db.QueryContext(ctx, ` + SELECT party_id, party_index + FROM participants + WHERE session_id = $1 + ORDER BY party_index + `, sessionID) + if err == nil { + defer partiesRows.Close() + for partiesRows.Next() { + var partyID string + var partyIndex int + if err := partiesRows.Scan(&partyID, &partyIndex); err == nil { + parties = append(parties, gin.H{ + "party_id": partyID, + "party_index": partyIndex, + }) + } + } + } + + // Convert message_hash to hex string + messageHashHex := "" + if len(messageHash) > 0 { + messageHashHex = hex.EncodeToString(messageHash) + } + logger.Info("Found sign session for invite_code", zap.String("invite_code", inviteCode), zap.String("session_id", sessionID), zap.String("wallet_name", walletName), - zap.Bool("has_join_token", joinToken != "")) + zap.Bool("has_join_token", joinToken != ""), + zap.Int("parties_count", len(parties))) c.JSON(http.StatusOK, gin.H{ "session_id": sessionID, "keygen_session_id": keygenSessionID, "wallet_name": walletName, + "message_hash": messageHashHex, "threshold_n": thresholdN, "threshold_t": thresholdT, "status": statusResp.Status, "completed_parties": statusResp.CompletedParties, "total_parties": statusResp.TotalParties, + "parties": parties, "expires_at": expiresAt.UnixMilli(), "join_token": joinToken, })