2

I have raw data (tx_hex) for raw transaction, but I cant send it to litecoin tesnet using post request to testnet.litecore.api. If I insert tx_hex manually in the browser, the transaction is correctly sent. My code:

request({
    url: 'https://testnet.litecore.io/tx/send',
    method: 'POST',
    data: test_tx
}, ((error, response, body) => {
    if(error) {
        console.log(error);
    } else {
        console.log(body);
    }
}));

I also tried to use another service, but it's failing too.

Code :

postdata = { tx_hex : test_tx };
request.post('https://chain.so/api/v2/send_tx/LTCTEST', postdata, function 
             optionalCallback(err, httpResponse, body) {
        if (err) {
            return console.error('upload failed:', err);
        }
        console.log('Upload successful!  Server responded with:', body);
});
  • 2
    Does it give you an error message on failing? – Raghav Sood May 25 '18 at 14:56
  • It return html-page with "Cannot POST to /tx/send". – Дима Марков May 29 '18 at 7:32
  • From what I recall, the POST is supposed to be sent to the api /tx/send endpoint, which depends on your insight API prefix (it's usually /api or /insight-api) – Raghav Sood May 29 '18 at 7:40
1

Postdata must be String, not Object. ('tx_hex=...')

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.