Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: LRZ on December 13, 2018, 11:55:44 PM



Title: Error validating Transaction. Sum of inputs lesser than outputs
Post by: LRZ on December 13, 2018, 11:55:44 PM
Hi I was wondering if someone could help me out with some code.
I'm trying to create a HD wallet for a user to deposit into, and then move that money to a main wallet once that deposit has been confirmed.
I'm having a little trouble. Quite new to blockchain dev and and how it all works.

Any help would be greatly appreciated.

https://stackoverflow.com/questions/53771644/error-validating-transaction-sum-of-inputs-lesser-than-outputs-bitcore


Title: Re: Error validating Transaction. Sum of inputs lesser than outputs
Post by: HCP on December 15, 2018, 06:57:03 PM
I think it may be because you have called transaction.to() twice?

Each time you do this, I believe you are creating a new output... so I suspect you have ONE UTXO (input)... but have then created TWO outputs...

transaction.to(main_wallet, max);

and then

transaction.to(main_wallet, max-finalFee);

This is also the most likely reason why the sum of your outputs is a little under twice the input... 39962 * 2 = 79924... your outputs sum to 78904, because of the "-finalFee" (ie. it has subtracted a fee of 1020).