Bitcoin-com / bitbox-sdk

BITBOX SDK for Bitcoin Cash
https://developer.bitcoin.com/bitbox
MIT License
87 stars 62 forks source link

bitbox-sdk throws exception when signing transactions after minification #153

Open devalbo opened 4 years ago

devalbo commented 4 years ago

I have created a React app using the standard React create-react-app (CRA) and then npm installed Bitbox. I can develop my BCH app with no issues in development mode. I can also use the CRA build command to create a production build.

However, when my code calls the sign method of the TransactionBuilder class in the production build, an exception with the message "Expected property "0" of type BigInteger, got n" gets thrown. I've narrowed it down to the use of the typeforce library in the bitcoincashjs-lib files ecdsa.js and ecsignature.js. If I comment out the typeforce lines in those files, my transaction is signed as expected.

I really don't like the idea of ejecting from the CRA configuration just to fix this, especially since I'd like to release my code as a library and I don't want other web devs to not be able to use minification in their build chains.

I'm wondering if this is a known issue, if there are any plans to fix it, or if there are any workarounds that do not require ejecting.

christroutner commented 4 years ago

I need to look into it, but I'm wondering if this issue is related to the Issue filed for slp-sdk: https://github.com/Bitcoin-com/slp-sdk/issues/76#issuecomment-554716566

devalbo commented 4 years ago

This looks very similar to what I've been seeing. I'll post a sample project with the fixes that seem to be working for my particular use case.

devalbo commented 4 years ago

@christroutner - Example project here: https://github.com/devalbo/bbtest