update coindata fee
package io.nuls.kernel.model;
+import io.nuls.kernel.constant.KernelErrorCode;
import io.nuls.kernel.exception.NulsException;
+import io.nuls.kernel.exception.NulsRuntimeException;
import io.nuls.kernel.utils.NulsByteBuffer;
import io.nuls.kernel.utils.NulsOutputStreamBuffer;
import io.nuls.kernel.utils.SerializeUtils;
@@ -139,8 +141,15 @@ public class CoinData extends BaseNulsData {
}
Na fromNa = Na.ZERO;
for (Coin coin : from) {
+ if(coin.getNa().equals(Na.ZERO)) {
+ if(coin.getFrom() == null) {
+ throw new NulsRuntimeException(KernelErrorCode.DATA_NOT_FOUND, "can not get tx fee");
+ }
+ fromNa = fromNa.add(coin.getFrom().getNa());
+ } else {
fromNa = fromNa.add(coin.getNa());
}
+ }
return fromNa.subtract(toNa);
}
