From 6efe411a1043dd58c5ecdd527c150fd6d42595a8 Mon Sep 17 00:00:00 2001 From: DanGould Date: Fri, 21 Apr 2023 19:12:21 -0400 Subject: [PATCH] Draft payjoin integration payjoin-client enables receiving payjoin at spending01.dat wallet. The payjoin endpoint is exposed at https://localhost/payjoin. The receiving invoice is printed to the payjoin-client container's logs. --- payjoin/docker-compose.yaml | 47 +++++++++++++++++++++++++++++++++++++ payjoin/isCoreApp | 0 payjoin/test.sh | 40 +++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 payjoin/docker-compose.yaml create mode 100644 payjoin/isCoreApp create mode 100644 payjoin/test.sh diff --git a/payjoin/docker-compose.yaml b/payjoin/docker-compose.yaml new file mode 100644 index 0000000..6199d94 --- /dev/null +++ b/payjoin/docker-compose.yaml @@ -0,0 +1,47 @@ +version: "3" + +services: + payjoin: + environment: + - "RUST_LOG=debug" + - "TRACING=1" + - "CYPHERNODE_URL=https://gatekeeper:${GATEKEEPER_PORT}" + image: dangould/payjoin-client:0.1.28 + command: 18443 bitcoin p receive 69420 "https://localhost/pj" + # // port cookie receive amount endpoint + volumes: + - "$APP_SCRIPT_PATH/data:/payjoin/data" + - "$GATEKEEPER_DATAPATH/certs/cert.pem:/payjoin/cert.pem:ro" + - "$LOGS_DATAPATH:/payjoin/logs" + networks: + - cyphernodeappsnet + - payjoinnet + restart: always + labels: + - "traefik.enable=true" + - "traefik.docker.network=cyphernodeappsnet" + - "traefik.frontend.rule=PathPrefixStrip:/pj" + - "traefik.frontend.passHostHeader=true" + - "traefik.port=3000" + deploy: + labels: + - "traefik.enable=true" + - "traefik.docker.network=cyphernodeappsnet" + - "traefik.frontend.rule=PathPrefixStrip:/pj" + - "traefik.frontend.passHostHeader=true" + - "traefik.port=3000" + replicas: 1 + placement: + constraints: + - node.labels.io.cyphernode == true + restart_policy: + delay: 1s + update_config: + parallelism: 1 + logging: + driver: local +networks: + cyphernodeappsnet: + external: true + payjoinnet: + external: true diff --git a/payjoin/isCoreApp b/payjoin/isCoreApp new file mode 100644 index 0000000..e69de29 diff --git a/payjoin/test.sh b/payjoin/test.sh new file mode 100644 index 0000000..509fb33 --- /dev/null +++ b/payjoin/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +timeout_feature() { + local interval=10 + local totaltime=60 + local testwhat=${1} + local returncode + local endtime=$(($(date +%s) + ${totaltime})) + + while : + do + eval ${testwhat} + returncode=$? + + # If no error or 2 minutes passed, we get out of this loop + ([ "${returncode}" -eq "0" ] || [ $(date +%s) -gt ${endtime} ]) && break + + printf "\e[1;31mMaybe it's too early, I'll retry every ${interval} seconds for $((${totaltime} / 60)) minutes ($((${endtime} - $(date +%s))) seconds left).\e[1;0m\r\n" + + sleep ${interval} + done + + return ${returncode} +} + +do_test() { + local rc + rc=$(curl -k -s -o /dev/null -w "%{http_code}" https://127.0.0.1:${TRAEFIK_HTTPS_PORT}/payjoin) + [ "${rc}" -ne "400" ] && return 400 + return 0 +} + +export TRAEFIK_HTTPS_PORT + +timeout_feature do_test +returncode=$? + +# return 0: tests cool +# return 1: tests failed +return $returncode