Sibit::Json#post wraps every body in `tx=`, mangling Blockchair and Cryptoapis `push` requests
#260 opened on Jun 19, 2026
Repository metrics
- Stars
- (27 stars)
- PR merge metrics
- (PR metrics pending)
Description
Sibit::Json#post in lib/sibit/json.rb wraps every body argument as tx=#{CGI.escape(body)} and forces Content-Type: application/x-www-form-urlencoded, so it only fits the Blockchain.com pushtx endpoint. Every other caller that passes a different body shape gets that body re-encoded on top of its own format.
Sibit::Blockchair#push (lib/sibit/blockchair.rb around line 75) hands the pre-formed body "data=#{hex}", expecting it to be sent verbatim. After Sibit::Json#post wraps it, the request body becomes tx=data%3D<hex>, so the Blockchair endpoint receives no data= parameter and rejects the transaction.
Sibit::Cryptoapis#push (lib/sibit/cryptoapis.rb around line 90) hands a JSON document {"hex":"…"} and supplies an X-API-Key header. Sibit::Json#post URL-encodes that JSON into a tx=… form body and pins Content-Type: application/x-www-form-urlencoded, so the Cryptoapis endpoint receives a form-encoded JSON string rather than the JSON payload it expects.
The fix is to let the caller decide both body shape and Content-Type: pass the body through untouched and use whatever the caller provides in headers: (defaulting only when absent). The Blockchain.com call site can then form its own tx=<hex> body and content type, while Blockchair and Cryptoapis send the bytes they already build.