Skip to content
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
16 changes: 16 additions & 0 deletions scripts/filter_incomplete_sessions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if [[ -z "$1" ]]; then
echo "Usage: $0 <path_to_json_file>"
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 <path_to_json_file>"
exit 1
fi

jq '.checkout_sessions |
to_entries |
map(select(.value.invoice != null and .value.completed == false)) |
from_entries' "$1"
40 changes: 40 additions & 0 deletions scripts/ping_checkouts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Check if exactly one argument is given (the filename)
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <filename of text file containing checkout session UUIDs separated by newlines>"
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=$(<response.txt)

# Print UUID and corresponding HTTP response code and server response
echo "UUID: $uuid"
echo "HTTP Response Code: $RESPONSE"
echo "Server Response: $SERVER_RESPONSE"
echo # new line for better readability between entries

done < "$FILE"

# Clean up the temporary file
rm response.txt
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
mkShell {
buildInputs = [ node2nix ] ++ (with python3Packages; [ pandas matplotlib plotly ]);
buildInputs = [ node2nix jq ] ++ (with python3Packages; [ pandas matplotlib plotly ]);
}
Loading