Bitcoin-com / bitbox-sdk

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

bitbox.Transaction.details() does not throw errors #74

Closed adrianbarwicki closed 5 years ago

adrianbarwicki commented 5 years ago

I'd expect that if an error happens, it is thrown so it can be caught in the catch block. It took us some time at Honest.Cash to figure out that the Transaction.details() returns errors as a successful data.

Example

This code requests details of 50 transactions:

bildschirmfoto 2019-03-04 um 15 00 14

The details method returns successfully but the returned data is: { error: 'Array too large. Max 20 txids' }

Statically we would expect an array or an thrown error.

christroutner commented 5 years ago

The error handling code in BITBOX code should be updated to detect http status codes in the 400 or 500 range and throw an error. Test cases need to be added to the integration tests as well.

christroutner commented 5 years ago

The source of this bug is not in BITBOX, but in rest.bitcoin.com, and should be fixed once this rest PR is merged.

christroutner commented 5 years ago

This PR for rest will fix this issue with BITBOX: https://github.com/Bitcoin-com/rest.bitcoin.com/pull/357

christroutner commented 5 years ago

Issue is fixed. And an integration test was created to verify. The test will also detect it if it should ever be a problem again.