RadarTech / lnrpc

A Typescript gRPC client for LND with support for all LND sub-servers
MIT License
43 stars 13 forks source link

SubscribeInvoice endpoint not returning InvoiceState #64

Closed MrHash closed 4 years ago

MrHash commented 4 years ago

When an invoice is added in LND the invoice state field and other empty fields are not populated in to the response. I'm wondering if empty fields are excluded, and whether InvoiceState::OPEN being value 0 is the cause.

cavanmflynn commented 4 years ago

Looking into this, @MrHash. As far as I know the state should always be returned. The 0 index certainly seems like the cause if it's not being returned for OPEN orders. I'll follow up soon.

cavanmflynn commented 4 years ago

As suspected, protobuf.js considers 0 to be a default value and strips it out of the response. There is a configuration option that we can set internally, which will prevent these values from being stripped out.

Unfortunately, it could be a breaking change for consumers of this library. As such, it makes sense to hold off on a fix until LND v0.9.0-beta, when other breaking changes will be expected.

MrHash commented 4 years ago

Alright then i can work around this issue if only the OPENED state is missing. Thanks

cavanmflynn commented 4 years ago

Thinking more about it, we can expose an optional config value to prevent the stripping of falsy values from the response prior to the v0.9.0-beta release.

MrHash commented 4 years ago

Is this the GRPC object options? I thought it would be nice if those could be overridden as i'd like to keep case also.

MrHash commented 4 years ago

although maybe that would create some other issues in the code. not sure.

cavanmflynn commented 4 years ago

The issue with allowing the library consumer to provide any of the grpc load options is that some will either break the package completely or invalidate the types. For example, keepCase will invalidate the types because they are written for camel case only.

MrHash commented 4 years ago

OK understood.

cavanmflynn commented 4 years ago

Resolved in #69 and released in v0.8.2-beta