Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a docker config for the demo uma vasp #56

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ lnurl-server
!lnurl-server/
remote-signing-server
!remote-signing-server/

local.env
env.local
2 changes: 2 additions & 0 deletions examples/uma-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
uma-server
env.local
local.env
22 changes: 22 additions & 0 deletions examples/uma-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM --platform=$BUILDPLATFORM golang:1.21-bookworm as builder

ARG TARGETOS TARGETARCH
RUN echo "$TARGETARCH" | sed 's,arm,aarch,;s,amd,x86_,' > /tmp/arch
RUN apt-get update && apt-get install -y "gcc-$(tr _ - < /tmp/arch)-linux-gnu" && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV GOOS $TARGETOS
ENV GOARCH $TARGETARCH

COPY . /src
RUN go env
RUN cd /src/examples/uma-server && CGO_ENABLED=1 CC=$(cat /tmp/arch)-linux-gnu-gcc go install
RUN if [ -e /go/bin/${TARGETOS}_${TARGETARCH} ]; then mv /go/bin/${TARGETOS}_${TARGETARCH}/* /go/bin/; fi

FROM debian:bookworm as final

RUN addgroup --system --gid 1000 go && adduser --system --uid 1000 --ingroup go go
RUN apt-get update && apt-get -y install ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists

COPY --from=builder /go/bin/uma-server /usr/local/bin

ENTRYPOINT ["uma-server"]
36 changes: 36 additions & 0 deletions examples/uma-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,39 @@ $ curl -X GET "http://localhost:8080/api/umapayreq/52ca86cd-62ed-4110-9774-4e07b
curl -X POST http://localhost:8080/api/sendpayment/e26cbee9-f09d-4ada-a731-965cbd043d50
```

### Running with Docker

You can also run this server with Docker. First we need to build the image. From the root `go-sdk` directory, run:

```bash
$ docker build -t uma-server -f examples/uma-server/Dockerfile .
```

Next, we need to set up the config variables. You can do this by creating a file called `local.env` in the root `go-sdk`
directory. This file should contain the following:

```bash
LIGHTSPARK_API_TOKEN_CLIENT_ID=<your lightspark API token client ID from https://app.lightspark.com/api-config>
LIGHTSPARK_API_TOKEN_CLIENT_SECRET=<your lightspark API token client secret from https://app.lightspark.com/api-config>
LIGHTSPARK_UMA_NODE_ID=<your lightspark node ID. ex: LightsparkNodeWithOSKLND:018b24d0-1c45-f96b-0000-1ed0328b72cc>
LIGHTSPARK_UMA_RECEIVER_USER=<receiver UMA>
LIGHTSPARK_UMA_ENCRYPTION_PUBKEY=<hex-encoded encryption pubkey>
LIGHTSPARK_UMA_ENCRYPTION_PRIVKEY=<hex-encoded encryption privkey>
LIGHTSPARK_UMA_SIGNING_PUBKEY=<hex-encoded signing pubkey>
LIGHTSPARK_UMA_SIGNING_PRIVKEY=<hex-encoded signing privkey>

# If you are using an OSK node:
LIGHTSPARK_UMA_OSK_NODE_SIGNING_KEY_PASSWORD=<password for the signing key>

# If you are using a remote signing node:
LIGHTSPARK_UMA_REMOTE_SIGNING_NODE_MASTER_SEED=<hex-encoded master seed>

# Optional: A custom VASP domain in case you're hosting this at a fixed hostname.
LIGHTSPARK_UMA_VASP_DOMAIN=<your custom VASP domain. ex: vasp1.example.com>
```

Then, run the image:

```bash
$ docker run --env-file local.env -p 8081:8081 uma-server
```
44 changes: 23 additions & 21 deletions examples/uma-server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
)

type UmaConfig struct {
ApiClientID string
ApiClientSecret string
NodeUUID string
Username string
UserID string
UmaEncryptionPubKeyHex string
UmaEncryptionPrivKeyHex string
UmaSigningPubKeyHex string
UmaSigningPrivKeyHex string
NodeMasterSeedHex string
ClientBaseURL string
SenderVaspDomain string
ApiClientID string
ApiClientSecret string
NodeUUID string
Username string
UserID string
UmaEncryptionPubKeyHex string
UmaEncryptionPrivKeyHex string
UmaSigningPubKeyHex string
UmaSigningPrivKeyHex string
RemoteSigningNodeMasterSeedHex string
OskNodeSigningKeyPassword string
ClientBaseURL string
SenderVaspDomain string
}

func (c *UmaConfig) UmaEncryptionPubKeyBytes() ([]byte, error) {
Expand All @@ -38,7 +39,7 @@ func (c *UmaConfig) UmaSigningPrivKeyBytes() ([]byte, error) {
}

func (c *UmaConfig) NodeMasterSeedBytes() ([]byte, error) {
return hex.DecodeString(c.NodeMasterSeedHex)
return hex.DecodeString(c.RemoteSigningNodeMasterSeedHex)
}

/**
Expand Down Expand Up @@ -71,13 +72,14 @@ func NewConfig() UmaConfig {
NodeUUID: os.Getenv("LIGHTSPARK_UMA_NODE_ID"),
Username: username,
// Static UUID so that callback URLs are always the same.
UserID: "4b41ae03-01b8-4974-8d26-26a35d28851b",
UmaEncryptionPubKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PUBKEY"),
UmaEncryptionPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PRIVKEY"),
UmaSigningPubKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PUBKEY"),
UmaSigningPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PRIVKEY"),
NodeMasterSeedHex: os.Getenv("LIGHTSPARK_UMA_MASTER_SEED"),
ClientBaseURL: fmt.Sprintf("https://%s/graphql/server/rc", os.Getenv("LIGHTSPARK_EXAMPLE_BASE_URL")),
SenderVaspDomain: os.Getenv("LIGHTSPARK_UMA_VASP_DOMAIN"),
UserID: "4b41ae03-01b8-4974-8d26-26a35d28851b",
UmaEncryptionPubKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PUBKEY"),
UmaEncryptionPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_ENCRYPTION_PRIVKEY"),
UmaSigningPubKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PUBKEY"),
UmaSigningPrivKeyHex: os.Getenv("LIGHTSPARK_UMA_SIGNING_PRIVKEY"),
RemoteSigningNodeMasterSeedHex: os.Getenv("LIGHTSPARK_UMA_REMOTE_SIGNING_NODE_MASTER_SEED"),
OskNodeSigningKeyPassword: os.Getenv("LIGHTSPARK_UMA_OSK_NODE_SIGNING_KEY_PASSWORD"),
ClientBaseURL: fmt.Sprintf("https://%s/graphql/server/rc", os.Getenv("LIGHTSPARK_EXAMPLE_BASE_URL")),
SenderVaspDomain: os.Getenv("LIGHTSPARK_UMA_VASP_DOMAIN"),
}
}