fix(account): add message_hash and parties to GetSignSessionByInviteCode

- Query message_hash from mpc_sessions table and return as hex string
- Query participants table to get party_id and party_index
- Add parties array to response for Sign.tsx to use

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-30 07:47:24 -08:00
parent b79289bc29
commit ea66a3987e
1 changed files with 35 additions and 3 deletions

View File

@ -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,
})