kzemek / macaroons

An Erlang Macaroons library compatible with libmacaroons
BSD 3-Clause "New" or "Revised" License
29 stars 3 forks source link

Cannot deserialize a LND macaroon admin.macaroon file #4

Open sezaru opened 6 years ago

sezaru commented 6 years ago

Hello,

I'm trying to use your library inside an Elixir project to deserialize a LND macaroon admin.macaroon file.

I'm using this code inside the REPL:

{:ok, file} = File.read "admin.macaroon"
encoded = Base.encode64(file)
{:ok, mac} = :macaroon.deserialize(encoded)

which will give me the error:

** (MatchError) no match of right hand side value: {:error, :macaroon_invalid}

Testing the same file with pythons pymacaroons works, so it seems a specific deserialization problem with the library.

Since I cannot paste here the binary data from admin.macaroon I will post a link to the file directly and also the base64 with it: admin.macaroon

AgEDbG5kArsBAwoQ5TMSJjie992RIEsCGCuq5xIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaFgoHbWVzc2FnZRIEcmVhZBIFd3JpdGUaFwoIb2ZmY2hhaW4SBHJlYWQSBXdyaXRlGhYKB29uY2hhaW4SBHJlYWQSBXdyaXRlGhQKBXBlZXJzEgRyZWFkEgV3cml0ZQAABiBoyNHs3jlsGlXIZEV8HtJuIiCh+vA56AFg9poHdCG6zA==

kzemek commented 6 years ago

Thanks for the report, I'll look into it shortly

kzemek commented 6 years ago

@sezaru can you try branch v2-serialization?

sezaru commented 6 years ago

Very nice! It works like a charm with the v2-serialization.