From 2dc92ae0a6bdb11faf1847300d7083a0813c2d9a Mon Sep 17 00:00:00 2001 From: elnosh Date: Tue, 18 Jun 2024 11:35:34 -0500 Subject: [PATCH] mint - update contact info --- cashu/nuts/nut06/nut06.go | 21 +++++++++++++-------- mint/config.go | 10 ++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/cashu/nuts/nut06/nut06.go b/cashu/nuts/nut06/nut06.go index 0c96da0..6533021 100644 --- a/cashu/nuts/nut06/nut06.go +++ b/cashu/nuts/nut06/nut06.go @@ -10,14 +10,19 @@ import ( ) type MintInfo struct { - Name string `json:"name"` - Pubkey string `json:"pubkey"` - Version string `json:"version"` - Description string `json:"description"` - LongDescription string `json:"description_long,omitempty"` - Contact [][]string `json:"contact,omitempty"` - Motd string `json:"motd,omitempty"` - Nuts NutsMap `json:"nuts"` + Name string `json:"name"` + Pubkey string `json:"pubkey"` + Version string `json:"version"` + Description string `json:"description"` + LongDescription string `json:"description_long,omitempty"` + Contact []ContactInfo `json:"contact,omitempty"` + Motd string `json:"motd,omitempty"` + Nuts NutsMap `json:"nuts"` +} + +type ContactInfo struct { + Method string `json:"method"` + Info string `json:"info"` } type NutSetting struct { diff --git a/mint/config.go b/mint/config.go index 024ba0d..3e353d5 100644 --- a/mint/config.go +++ b/mint/config.go @@ -42,12 +42,18 @@ func getMintInfo() (*nut06.MintInfo, error) { mintInfo.Pubkey = hex.EncodeToString(privateKey.PubKey().SerializeCompressed()) contact := os.Getenv("MINT_CONTACT_INFO") - var mintContactInfo [][]string + var mintContactInfo []nut06.ContactInfo if len(contact) > 0 { - err := json.Unmarshal([]byte(contact), &mintContactInfo) + var infoArr [][]string + err := json.Unmarshal([]byte(contact), &infoArr) if err != nil { return nil, fmt.Errorf("error parsing contact info: %v", err) } + + for _, info := range infoArr { + contactInfo := nut06.ContactInfo{Method: info[0], Info: info[1]} + mintContactInfo = append(mintContactInfo, contactInfo) + } } mintInfo.Contact = mintContactInfo