-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lnrpc: set JS_STRING option for chan_id #2352
Conversation
I reopened this branch/PR and rebased onto master (including adding the jstype attribute in a few more places where channel id fields are used). This definitely seems helpful to have in the main repo as it would prevent bugs in javascript code that uses an unmodified version of the proto definitions. |
cc @tanx any thoughts on this? |
Bump. |
We don't use |
Let me know if you agree that this would be worth adding to the codebase and I'll rebase this PR, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after rebase and proto-regen 👍
Sorry only seeing the approval now! Rebasing & regenerating protos now. |
2064556
to
ef22c64
Compare
@halseth Rebased and searched all proto files for |
Need another rebase 😅 |
45948a8
to
ebdb393
Compare
@halseth done! |
ebdb393
to
0875035
Compare
@halseth Rebased again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Needs oneee last rebase 😅
0875035
to
81b4dd5
Compare
@cfromknecht @halseth All your rebase are belong to us. |
81b4dd5
to
8e13ff4
Compare
Re-rebased. |
This sets the `jstype` option to `JS_STRING` for all `chan_id` fields in the proto rpc definition. `chan_id` is a 64 bit integer, which is not natively supported by javascript's floating-point `number` with only 52 bit precision. Nevertheless, by default protobuf will use the `number` type for 64 bit integer fields in javascript, which can cause loss of precision problems with `chan_id`. Explicitly setting the type for javascript as a string will prevent these issues, and should not interfere with its use as an identifier.
8e13ff4
to
f437b35
Compare
@sangaman could you tell us which JS library you are using? |
I'm using the |
This sets the
jstype
option toJS_STRING
for allchan_id
fields in the proto rpc definition.chan_id
is a 64 bit integer, which is not natively supported by javascript's floating-pointnumber
with only 52 bit precision. Nevertheless, by default protobuf will use thenumber
type for 64 bit integer fields in javascript, which can cause loss of precision problems withchan_id
. Explicitly setting the type for javascript as a string will prevent these issues, and should not interfere with its use as an identifier.I've run into this issue in a javascript project, and making these changes to the proto file manually was the solution. I figure this change would save the headache for others who may run into this as well down the road.