hexonaut / bitcoin-transaction

Send Bitcoins from one wallet to another. This is designed to be as simple to use as possible.
MIT License
49 stars 34 forks source link

Error: Private key must be greater than 0 and Error: Bad Request #11

Closed VishalDalve closed 5 years ago

VishalDalve commented 6 years ago

Working on mainnet, getting these two issues. Creating WIF From Node Module :

var wif = require('wif');
var privateKey = new Buffer('btc_private_key', 'hex');
var key = wif.encode(128, privateKey, true)
console.log("WIF key",key);

What i'm doing wrong?

bitcoinTransaction.getBalance(from, { network: "mainnet" }).then((balanceInBTC) => {
    return bitcoinTransaction.sendTransaction({
        from: from,
        to: to,
        privKeyWIF: key,
        btc: 0.0002,
        fee:"hour",
        network: "mainnet"
    });
}).then((res) => {
    console.log(res.body);
    console.log("---------------------------------------------------------");
    console.log("Hash: ",res.body.tx.hash);
});
hexonaut commented 6 years ago

Is your private key of the form that looks like this? cNZi8iySqBToXMpcsQaHKD5uv7HExBQJBSi4dTg3ZPaEzeNAzvbj

VishalDalve commented 6 years ago

Is your private key of the form that looks like this? cNZi8iySqBToXMpcsQaHKD5uv7HExBQJBSi4dTg3ZPaEzeNAzvbj

My Private key : KxdaerRrP1fcrxxxxxxgGgXMvxXXX3A4u3jxHxxxxxxHuPc5yNNg (kind of, 52 char).

VishalDalve commented 5 years ago

Now able to send value (But only whole amount present on address, not specific ),Also Not getting HASH of transaction on mainnet.i.e Empty response. Thanks.