It is possible set the mining fee inside the transaction after the transaction has built?
This is because, I want set a recomended fee, now is 200 satoshis byte, but I only have the size after the tx is built. And when I'm creating the tx I'm put the fee for mining substracting the amount from the total to receive (or adding from the total to send).
Some clue? Thanks!
You can鈥檛 change the fee after it鈥檚 signed.
You can鈥檛 change the fee after it鈥檚 signed.
Actually, we can change fee :)
but hashType should be changed to SIGHASH_NONE
@CodersBrothers use a library like https://github.com/bitcoinjs/coinselect that will estimate the total transaction size for you in advance, so you only have to build once.
It is an estimate, but, you can pre-sign the inputs if you wish and set their exact .script.length - then it will be guaranteed.
@dcousens Interesting, thanks!! I think that this can solve my problem. Take the size in advance is enough for me to use https://www.npmjs.com/package/bitcoinfees-21co and calculate the desired fee.
@fanatid can you explain more about? thanks.
@CodersBrothers it was a joke.
Don鈥檛 ever use SIGHASH_NONE as your only sighash lol.
Most helpful comment
@CodersBrothers use a library like https://github.com/bitcoinjs/coinselect that will estimate the total transaction size for you in advance, so you only have to build once.
It is an estimate, but, you can pre-sign the inputs if you wish and set their exact
.script.length- then it will be guaranteed.