fix bug about empty seed random value -> NPE
@@ -36,6 +36,7 @@ import io.nuls.contract.vm.util.Constants;
import io.nuls.contract.vm.util.JsonUtils;
import io.nuls.contract.vm.util.Utils;
import io.nuls.core.tools.crypto.Sha3Hash;
+import org.apache.commons.lang3.StringUtils;
import java.util.LinkedHashMap;
import java.util.List;
@@ -323,7 +324,9 @@ public class NativeUtils {
String algorithm = frame.heap.runToString(algorithmRef);
String seed = frame.vm.getRandomSeed(endHeight, count, algorithm);
-
+ if (StringUtils.isBlank(seed)) {
+ seed = "0";
+ }
ObjectRef objectRef = frame.heap.newBigInteger(seed);
Result result = NativeMethod.result(methodCode, objectRef, frame);
@@ -340,7 +343,9 @@ public class NativeUtils {
String algorithm = frame.heap.runToString(algorithmRef);
String seed = frame.vm.getRandomSeed(startHeight, endHeight, algorithm);
-
+ if (StringUtils.isBlank(seed)) {
+ seed = "0";
+ }
ObjectRef objectRef = frame.heap.newBigInteger(seed);
Result result = NativeMethod.result(methodCode, objectRef, frame);
