haveno icon indicating copy to clipboard operation
haveno copied to clipboard

Always represent XMR in atomic units

Open woodser opened this issue 3 years ago • 0 comments

Currently, XMR is denominated in centineros throughout the protobuf data model.

This is because Bisq denominated bitcoin in satoshis using protobuf's uint64 type. The problem is uint64 is not sufficient for XMR atomic units when translated to Java long or JavaScript number, so XMR amounts were converted to centineros to avoid loss of precision issues.

This issue requests changing the protobuf data model and usage to represent amounts as XMR atomic units using the string type in protobuf instead.

The string should be converted to Java BigInteger or TypeScript BigInt when used.

For example, OfferPayload in proto.pb has fields amount, min_amount, buyer_security_deposit, and seller_security_deposit which are currently storing centineros into uint64, but should instead store atomic units as string.

GrpcOffersService.createOffer() converts atomic units received from the API as a string to centineros for use throughout the system and data model.

Fixing this issue will resolve the need to call centinerosToAtomicUnits() in the backend and tests, so those method can be deleted as a good starting point for compile errors to fix.

woodser avatar May 31 '22 22:05 woodser