I'm trying to send testnet with bitcoinjs, but when I go to broadcast the hex, it gives me an error code that says "fee is too high: 12372928". Now, from my understanding, the fee is the input - output. However, even if I increase the output to match the wallet's balance, I get the same exact error message. Here's my code:
this.setState({
address: 'mphWVWbPgGKuaMpSpGNA3Ffrpva5cRChqP',
privateKey: 'cW6dLEqkk2HAbQTSJaHnn4w3kd2iJfhBREccEE3vzrq8kcVE5TqS',
});
}
createTransaction = (e) => {
e.preventDefault()
const {address, privateKey} = this.state;
var hashURL = `https://api.blockcypher.com/v1/btc/test3/addrs/${address}`
axios.get(hashURL).then((response) => {
this.setState({
hash: response.data.txrefs[0].tx_hash
})
}).then((result) => {
var tx = new bitcoin.TransactionBuilder(testnet);
var txId = this.state.hash;
console.log(txId);
tx.addInput(txId, 0)
tx.addOutput(this.state.add, 1000000)
var keyPair2 = bitcoin.ECPair.fromWIF(privateKey, testnet);
tx.sign(0, keyPair2);
console.log(tx.build().toHex());
}
)
}
Would there be a way to manually set the fee to always be something like .0001?