首页 > 解决方案 > 使用 api 或模块在莱特币测试网上发送原始交易(有 tx_hex)

问题描述

我有原始交易的原始数据(tx_hex),但我无法使用对 testnet.litecore.api 的发布请求将其发送到 litecoin tesnet。如果我在浏览器中手动插入 tx_hex,则交易已正确发送。我的代码:

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);
    }
}));

我也尝试使用其他服务,但它也失败了。

代码 :

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);
    });

有人提议?

标签: transactionslitecoin

解决方案


Postdata必须是字符串,而不是对象。('tx_hex=...')


推荐阅读