libitx / txforge

Modern Bitcoin transaction builder, capable of supporting any non-standard and custom script type.
Apache License 2.0
63 stars 21 forks source link

if you feed changeTo with undefined it does not return error, but burn the coins #17

Closed oyocash closed 2 years ago

libitx commented 2 years ago

The coins are not 'burned' - you are creating a tx without a change output so you are overpaying the fee.

There are two places where you can set changeTo:

  1. When when instantiate the Forge, eg: new Forge(opts) In this case changeTo is an optional option - we can't throw an error if it is undefined as its perfectly valid to leave it undefined - for example if you are setting a custom changeScript or you don't want a change output at all.

  2. By calling the changeTo function on the forge instance, eg: forge.changeTo(address) In this case you will get an error if you pass the address as undefined.