Skip to content

Commit

Permalink
Fix input quantity summation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcramer committed Mar 4, 2019
1 parent a5ed737 commit de4960d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/localvalidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ export class LocalValidator implements SlpValidator {
input_slpmsg.tokenIdHex = input_txid;
if(input_slpmsg.tokenIdHex === slpmsg.tokenIdHex) {
if(input_slpmsg.transactionType === SlpTransactionType.SEND) {
tokenInQty = tokenInQty.plus(input_slpmsg.sendOutputs![txn.inputs[i].outputIndex])
this.cachedValidations[txid].parents.push({txid: txn.inputs[i].prevTxId.toString('hex'), versionType: input_slpmsg.versionType, valid: null, inputQty: input_slpmsg.sendOutputs![txn.inputs[i].outputIndex] })
if(txn.inputs[i].outputIndex <= input_slpmsg.sendOutputs!.length-1) {
tokenInQty = tokenInQty.plus(input_slpmsg.sendOutputs![txn.inputs[i].outputIndex])
this.cachedValidations[txid].parents.push({txid: txn.inputs[i].prevTxId.toString('hex'), versionType: input_slpmsg.versionType, valid: null, inputQty: input_slpmsg.sendOutputs![txn.inputs[i].outputIndex] })
}
}
else if(input_slpmsg.transactionType === SlpTransactionType.GENESIS || input_slpmsg.transactionType === SlpTransactionType.MINT) {
if(txn.inputs[i].outputIndex === 1)
Expand All @@ -161,7 +163,7 @@ export class LocalValidator implements SlpValidator {
}
} catch(_) {}
}

// Check token inputs are greater than token outputs (includes valid and invalid inputs)
if(tokenOutQty.isGreaterThan(tokenInQty)) {
this.cachedValidations[txid].invalidReason = "Token outputs are greater than possible token inputs."
Expand Down

0 comments on commit de4960d

Please sign in to comment.