Closed offerm closed 5 years ago
Reason for the problem (most probably can be found here):
https://github.com/protocolbuffers/protobuf/issues/3666 and https://stackoverflow.com/questions/9643626/does-javascript-support-64-bit-integers
@sangaman @moshababo can you jump in here, looks indeed like xud
has some integer problem...
I've been researching this issue for a while, it seems like all 64 bit integers defined in the proto file are being defaulted to numbers instead of strings in the generated javascript code. This causes us to lose precision anytime the number is greater than 2^55.
Adding jstype=JS_STRING
to the field definition in the proto file seems to partly fix the issue for a given field - but it's not updating the type definitions strings as per offer's latest link, and it's referred to as a "legacy option" here. Plus it's clunky to have to specify this field on every type, especially for the lnd proto definition.
This is also a relevant issue: https://github.com/protocolbuffers/protobuf/pull/1832
Still looking into what the best solution might be.
An option is to use the protobufjs library to generate proto code instead of protoc
. They support the long.js
package for 64 bit types which supports 64 bit numbers. I've played with it a bit and it seems like it should work. It would require changing around the proto scripts but it might be the cleanest approach. We can discuss tomorrow.
@sangaman can you please post a PR for this even if not final. It is currently blocking me without an easy workaround.
Yes, I've been working on it. Expect a PR soon.
I'm connected to xud1 and try to swap with it. should send BTC to xud1 and get LTC from xud1. LTC route from xud1 to me is xud1->xud2->xud3-me. When I do queryroutes on xud1 I get:
But when XUD does it gets :
If you look carefully the channelID for the first hop that XUD prints is 139024449239580670 while queryroutes shows 139024449239580673
3 at the end is missing!
As a result the swap fails since LND can't find the first channel.