diff --git a/cmd/testrunner/lnd-managej.go b/cmd/testrunner/lnd-managej.go index 7e3db56..644d442 100644 --- a/cmd/testrunner/lnd-managej.go +++ b/cmd/testrunner/lnd-managej.go @@ -1,11 +1,14 @@ package main import ( + "bufio" "encoding/json" "errors" "fmt" "io" "net/http" + "strings" + "time" ) const lndManageJHost = "lnd-managej" @@ -32,7 +35,7 @@ func getLndManageJConnection(alias string) (nodeInterface, error) { func (l *lndManageJConnection) resetCache() error { resp, err := http.Get( fmt.Sprintf( - "http://%v:8081/beta/pickhardt-payments/reset-graph-cache", + "http://%v:8081/api/payments/reset-graph-cache", lndManageJHost, ), ) @@ -123,13 +126,15 @@ func (l *lndManageJConnection) IsSynced(totalEdges, localChannels int) (bool, er return true, nil } +type TimestampAndMessage struct { + Timestamp string + Message string +} + func (l *lndManageJConnection) SendPayment(invoice string, aliasMap map[string]string) error { - resp, err := http.Get( - fmt.Sprintf( - "http://%v:8081/beta/pickhardt-payments/pay-payment-request/%v/fee-rate-weight/1", - lndManageJHost, invoice, - ), - ) + requestBodyReader := strings.NewReader("{\"feeRateWeight\": 1}") + url := fmt.Sprintf("http://%v:8081/api/payments/pay-payment-request/%v", lndManageJHost, invoice) + resp, err := http.Post(url, "application/json", requestBodyReader) if err != nil { return err } @@ -139,12 +144,18 @@ func (l *lndManageJConnection) SendPayment(invoice string, aliasMap map[string]s return errors.New("payment error") } - body, err := io.ReadAll(resp.Body) - if err != nil { + scanner := bufio.NewScanner(resp.Body) + for scanner.Scan() { + var timestampAndMessage TimestampAndMessage + line := scanner.Text() + _ = json.Unmarshal([]byte(line), ×tampAndMessage) + timestamp, _ := time.Parse(time.RFC3339Nano, timestampAndMessage.Timestamp) + formattedTimestamp := timestamp.Format("2006-01-02T15:04:05.000Z07") + fmt.Printf("%v: %v\n", formattedTimestamp, timestampAndMessage.Message) + } + if err := scanner.Err(); err != nil { return err } - fmt.Println(string(body)) - return nil } diff --git a/lnd-managej/Dockerfile b/lnd-managej/Dockerfile index da4d7ae..c561041 100644 --- a/lnd-managej/Dockerfile +++ b/lnd-managej/Dockerfile @@ -1,15 +1,8 @@ FROM gradle:latest -RUN apt-get update -RUN apt-get install postgresql sudo -y - -RUN /etc/init.d/postgresql start && \ - sudo -u postgres psql -c "CREATE USER bitcoin WITH PASSWORD 'unset'" && \ - sudo -u postgres createdb lndmanagej -O bitcoin && \ - /etc/init.d/postgresql stop RUN git clone https://github.com/C-Otto/lnd-manageJ.git && \ cd lnd-manageJ && \ - git checkout 777a0e9c2412b3b7bd682b3cd1b4832472135650 + git checkout c57eca472aafe2546768a6f68ffe39499919e36b WORKDIR lnd-manageJ RUN gradle application:bootJar @@ -20,12 +13,10 @@ RUN echo "host=node-start" >> /root/.config/lnd-manageJ.conf RUN echo "macaroon_file=/cfg/start/admin.macaroon" >> /root/.config/lnd-manageJ.conf RUN echo "cert_file=/cfg/start/tls.cert" >> /root/.config/lnd-manageJ.conf +RUN echo "[pickhardt-payments]" >> /root/.config/lnd-manageJ.conf +RUN echo "enabled=true" >> /root/.config/lnd-manageJ.conf + RUN echo "server.address=0.0.0.0" >> /root/override.properties EXPOSE 8081 -CMD /etc/init.d/postgresql start && \ - java -jar application/build/libs/application-boot.jar --spring.config.location=classpath:application.properties,/root/override.properties - - -# docker build -t lnd-managej . -# docker run --network host -v /home/xxx/.lnd/:/root/.lnd lnd-managej +CMD java -Dspring.profiles.active=h2 -jar application/build/libs/application-boot.jar --spring.config.location=classpath:application.properties,/root/override.properties