Skip to content

Instantly share code, notes, and snippets.

@bezysoftware
Last active March 17, 2022 09:42
Show Gist options
  • Select an option

  • Save bezysoftware/116db44f61ca21357f795b2f8bcc2a77 to your computer and use it in GitHub Desktop.

Select an option

Save bezysoftware/116db44f61ca21357f795b2f8bcc2a77 to your computer and use it in GitHub Desktop.
Get a list of LNURLp messages
$i = 0
$metadata
$metadataCounter = 0
$errorCounter = 0
$url = Read-Host "Enter LNURLp URL, e.g. https://wallet.paralelnipolis.cz/lnurlp/api/v1/lnurl/"
while ($true)
{
try
{
$i++
$result = Invoke-RestMethod -Method Get -Uri "$url$i"
$errorCounter = 0
if ($metadata -ne $result.metadata)
{
Write-Host
$metadataCounter = 0
}
$metadataCounter++
$metadata = $result.metadata
if ($metadataCounter -gt 1)
{
Write-Host "`r$metadata ($metadataCounter)" -NoNewline
}
else
{
Write-Host "`r$metadata" -NoNewline
}
}
catch
{
$errorCounter++
if ($errorCounter -gt 5)
{
Write-Host
Write-Host $_
Write-Host "$url$i"
Write-Host "No more messages"
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment