From 85102542cd0a3a849fb10031b81d734f53ddbd10 Mon Sep 17 00:00:00 2001 From: elnosh Date: Fri, 14 Jun 2024 14:27:44 -0500 Subject: [PATCH] wallet client call to get keyset by id --- .gitignore | 3 +++ wallet/client.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d9f1da --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +cmd/nutw/nutw +**/.env +*.txt diff --git a/wallet/client.go b/wallet/client.go index 0152887..c8eb3b4 100644 --- a/wallet/client.go +++ b/wallet/client.go @@ -47,6 +47,22 @@ func GetAllKeysets(mintURL string) (*nut02.GetKeysetsResponse, error) { return keysetsRes, nil } +func GetKeysetById(mintURL, id string) (*nut01.GetKeysResponse, error) { + resp, err := get(mintURL + "/v1/keys/" + id) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var keysetRes *nut01.GetKeysResponse + err = json.NewDecoder(resp.Body).Decode(&keysetRes) + if err != nil { + return nil, fmt.Errorf("json.Decode: %v", err) + } + + return keysetRes, nil +} + func PostMintQuoteBolt11(mintURL string, mintQuoteRequest nut04.PostMintQuoteBolt11Request) ( *nut04.PostMintQuoteBolt11Response, error) { requestBody, err := json.Marshal(mintQuoteRequest)