Add validation if Aval have amount then transfer

This commit is contained in:
Ghulam Mustafa Raza Qadri 2018-10-12 04:56:50 -07:00 committed by GitHub
parent 94c21eb9bd
commit 5fc79e1651
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,7 +88,9 @@ var Chaincode = class {
if (typeof amount !== 'number') {
throw new Error('Expecting integer value for amount to be transaferred');
}
if (!(Aval > amount)) {
throw new Error(util.format('amount in account A must must be greater then amount (%d) but found %d', amount, Aval));
}
Aval = Aval - amount;
Bval = Bval + amount;
console.info(util.format('Aval = %d, Bval = %d\n', Aval, Bval));