diff --git a/scripts/filter_incomplete_sessions.sh b/scripts/filter_incomplete_sessions.sh new file mode 100644 index 0000000..95840dd --- /dev/null +++ b/scripts/filter_incomplete_sessions.sh @@ -0,0 +1,16 @@ +if [[ -z "$1" ]]; then + echo "Usage: $0 " + echo "Description: This script outputs checkout sessions from the JSON where the invoice is not null and completed is false." + exit 1 +fi + +if [[ ! -f "$1" ]]; then + echo "Error: File does not exist." + echo "Usage: $0 " + exit 1 +fi + +jq '.checkout_sessions | + to_entries | + map(select(.value.invoice != null and .value.completed == false)) | + from_entries' "$1" diff --git a/scripts/ping_checkouts.sh b/scripts/ping_checkouts.sh new file mode 100755 index 0000000..b3cabb0 --- /dev/null +++ b/scripts/ping_checkouts.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Check if exactly one argument is given (the filename) +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + echo "Description: This script pings the Damus API to check the status of each checkout session UUID in the file." + exit 1 +fi + +# Assign the first command-line argument to FILE +FILE=$1 + +# Check if file exists +if [ ! -f "$FILE" ]; then + echo "Error: File does not exist." + exit 1 +fi + +# Loop through each line in the file +while IFS= read -r uuid +do + # URL where UUID is passed as part of the path + URL="https://api.damus.io/ln-checkout/${uuid}/check-invoice" + + # Make the CURL call and capture the HTTP response code + RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -X POST "$URL") + + # Read server response from the file + SERVER_RESPONSE=$( {} }: with pkgs; mkShell { - buildInputs = [ node2nix ] ++ (with python3Packages; [ pandas matplotlib plotly ]); + buildInputs = [ node2nix jq ] ++ (with python3Packages; [ pandas matplotlib plotly ]); }