From 8c5ab4a000542770e2b1979fa79e5d4970609bc9 Mon Sep 17 00:00:00 2001 From: shreyav Date: Thu, 18 Apr 2024 17:49:16 -0700 Subject: [PATCH 1/2] allow nonuma lnurl --- examples/uma-server/go.mod | 2 +- examples/uma-server/vasp1.go | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/examples/uma-server/go.mod b/examples/uma-server/go.mod index 66825d8..0a70e84 100644 --- a/examples/uma-server/go.mod +++ b/examples/uma-server/go.mod @@ -9,7 +9,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.3.1 github.com/lightsparkdev/go-sdk v0.10.0 - github.com/uma-universal-money-address/uma-go-sdk v1.0.0 + github.com/uma-universal-money-address/uma-go-sdk v1.0.0 // TODO (shreya): update to v1.0.1 ) require ( diff --git a/examples/uma-server/vasp1.go b/examples/uma-server/vasp1.go index 71eebe7..34796f1 100644 --- a/examples/uma-server/vasp1.go +++ b/examples/uma-server/vasp1.go @@ -56,9 +56,28 @@ func (v *Vasp1) handleClientUmaLookup(context *gin.Context) { receiverId := addressParts[0] receiverVasp := addressParts[1] signingKey, err := v.config.UmaSigningPrivKeyBytes() + if err != nil { + context.JSON(http.StatusInternalServerError, gin.H{ + "status": "ERROR", + "reason": err.Error(), + }) + return + } - lnurlpRequest, err := uma.GetSignedLnurlpRequestUrl( - signingKey, receiverAddress, v.getVaspDomain(context), true, nil) + var lnurlpRequest *url.URL + if strings.HasPrefix(receiverVasp, "$") { + lnurlpRequest, err = uma.GetSignedLnurlpRequestUrl( + signingKey, receiverAddress, v.getVaspDomain(context), true, nil) + if err != nil { + context.JSON(http.StatusInternalServerError, gin.H{ + "status": "ERROR", + "reason": err.Error(), + }) + return + } + } else { + lnurlpRequest = v.getNonUmaLnurlRequestUrl(receiverId, receiverVasp, context.Request.Host) + } resp, err := http.Get(lnurlpRequest.String()) if err != nil { @@ -143,6 +162,19 @@ func (v *Vasp1) handleClientUmaLookup(context *gin.Context) { }) } +func (v *Vasp1) getNonUmaLnurlRequestUrl(receiverId string, receiverVasp string, domain string) *url.URL { + scheme := "https" + if umautils.IsDomainLocalhost(domain) { + scheme = "http" + } + + return &url.URL{ + Scheme: scheme, + Host: receiverVasp, + Path: fmt.Sprintf("/.well-known/lnurlp/%s", receiverId), + } +} + func (v *Vasp1) handleUnsupportedVersionResponse(response *http.Response, signingKey []byte, receiverAddress string, context *gin.Context) (*http.Response, bool) { responseBodyBytes, err := io.ReadAll(response.Body) if err != nil { From 08c2f82e35bc3947af75b743209a562a77fb1ccb Mon Sep 17 00:00:00 2001 From: shreyav Date: Tue, 23 Apr 2024 10:37:25 -0700 Subject: [PATCH 2/2] bump uma version --- examples/uma-server/go.mod | 2 +- examples/uma-server/go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/uma-server/go.mod b/examples/uma-server/go.mod index 0a70e84..7d839dc 100644 --- a/examples/uma-server/go.mod +++ b/examples/uma-server/go.mod @@ -9,7 +9,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.3.1 github.com/lightsparkdev/go-sdk v0.10.0 - github.com/uma-universal-money-address/uma-go-sdk v1.0.0 // TODO (shreya): update to v1.0.1 + github.com/uma-universal-money-address/uma-go-sdk v1.0.1 ) require ( diff --git a/examples/uma-server/go.sum b/examples/uma-server/go.sum index 838d1e2..5f15148 100644 --- a/examples/uma-server/go.sum +++ b/examples/uma-server/go.sum @@ -711,6 +711,8 @@ github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4d github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/uma-universal-money-address/uma-go-sdk v1.0.0 h1:HaIsygLK2UovO5gXje4TCoHCW2O1Ab+gWjCNzm/ahvc= github.com/uma-universal-money-address/uma-go-sdk v1.0.0/go.mod h1:OimSKjRNT7Wm2lA0Q9C0DmxsMvqBickucUjtQmB8Cl8= +github.com/uma-universal-money-address/uma-go-sdk v1.0.1 h1:vPSR7w4gkY7GVG6NlruhPw/gyHA914MuIh70AQInFzI= +github.com/uma-universal-money-address/uma-go-sdk v1.0.1/go.mod h1:OimSKjRNT7Wm2lA0Q9C0DmxsMvqBickucUjtQmB8Cl8= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=