skip change if it is not above dust threshold
This commit is contained in:
parent
90921798cf
commit
471bc7ed97
2 changed files with 20 additions and 9 deletions
src
|
@ -197,7 +197,7 @@ var Wallet = function (seed, options) {
|
|||
if(totalInValue < value + fee) continue;
|
||||
|
||||
var change = totalInValue - value - fee
|
||||
if(change > 0) {
|
||||
if(change > 0 && !isDust(change)) {
|
||||
tx.addOutput(getChangeAddress(), change)
|
||||
}
|
||||
break;
|
||||
|
@ -210,9 +210,14 @@ var Wallet = function (seed, options) {
|
|||
return tx
|
||||
}
|
||||
|
||||
this.dustThreshold = 5430
|
||||
function isDust(amount) {
|
||||
return amount <= me.dustThreshold
|
||||
}
|
||||
|
||||
function checkDust(value){
|
||||
if (isNullOrUndefined(value) || value < 5430) {
|
||||
throw new Error("Value below dust threshold")
|
||||
if (isNullOrUndefined(value) || isDust(value)) {
|
||||
throw new Error("Value must be above dust threshold")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue