[bug]: base64 parsing fails at /v2/invoices/lookup?payment_hash=X (base64 typesafe + urlencoded, still) #9423
-
BackgroundI am trying to use the REST endpoint at /v2/invoices/lookup?payment_hash=X to get information about a payment/invoice. Your environment
Steps to reproduceGET /v2/invoices/lookup?payment_hash=ZNC%2BM5yd%2BS%2FFiu1cJEG94j9qdBo5Z7oc7TGsq4xVoIc%3D HTTP/1.1 Expected behaviourJson response with invoice/payment data Actual behaviour{"code":3,"message":"parsing field "payment_hash": illegal base64 data at input byte 3","details":[]} The above is just an example random 32-byte-base-64-urlencoded for privacy. If I do the exact same thing but pick an r_hash that doesn't contain a + or /, there is no base64 error thrown, it returns the invoice data. If I pick one with + or / and then replace the naughty characters in the base64 with something else (say "A" or %41) the complaining about invalid base64 stops, but of course then the invoice is non existent as expected. GET /v2/invoices/lookup?payment_hash=f2cu0kZA7IrlAt4F8vmDo4CIGwYVVs1L1ImkqXuBrW8= HTTP/1.1 {"code":5,"message":"unable to locate invoice","details":[]} If I'm missing something, apologies and please do let me know. For now, it seems like a bug. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
You need to use typesafe base64 encoding, meaning the base64 encoding should not have a + or /, how did you convert the bytes of the hash to a base64 string ? |
Beta Was this translation helpful? Give feedback.
-
try replacing + and / with the following:
|
Beta Was this translation helpful? Give feedback.
-
because the underlying go lib uses typ-safe encoding/decoding |
Beta Was this translation helpful? Give feedback.
try replacing + and / with the following:
echo -n "This is some text to encode" | base64 | tr '+/' '-_'