nmarley / bitcoinjs-lib-dash

Bitcoin-related functions implemented in pure JavaScript
MIT License
2 stars 0 forks source link

Confusion about the transaction #5

Open waliguder opened 5 years ago

waliguder commented 5 years ago

Why is the transaction created cannot set the value of the fees, and there is an issue in bitcoinjs-lib that the remaining amount of the transaction will be used as the transaction fee, which is obviously unreasonable? Because you can't guarantee that the offset value of each input and output is the fee you are willing to pay.

nmarley commented 5 years ago

That's how Bitcoin and similar currencies work. Fee = inputs - outputs.

Because you can't guarantee that the offset value of each input and output is the fee you are willing to pay

Inputs are fixed. You change the outputs and adjust the fee in that way. You can always create another output to send a balance back to yourself (and adjust that one for the fee). This is how Bitcoin has always worked.