From 5fc79e16511c1956d7c7fcadf0760f126130a459 Mon Sep 17 00:00:00 2001 From: Ghulam Mustafa Raza Qadri Date: Fri, 12 Oct 2018 04:56:50 -0700 Subject: [PATCH] Add validation if Aval have amount then transfer --- chaincode/chaincode_example02/node/chaincode_example02.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chaincode/chaincode_example02/node/chaincode_example02.js b/chaincode/chaincode_example02/node/chaincode_example02.js index 545092af..7df4cdff 100644 --- a/chaincode/chaincode_example02/node/chaincode_example02.js +++ b/chaincode/chaincode_example02/node/chaincode_example02.js @@ -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));