package com.itranswarp.bitcoin.serializer;

import java.io.IOException;

import org.bouncycastle.util.Arrays;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.itranswarp.bitcoin.util.HashUtils;

/**
 * Serialize byte[] to hex string.
 * 
 * @author Michael Liao
 */
public class HashSerializer extends JsonSerializer<byte[]> {

	@Override
	public void serialize(byte[] value, JsonGenerator gen, SerializerProvider serializers)
			throws IOException, JsonProcessingException {
		String s = HashUtils.toHexString(Arrays.reverse(value));
		gen.writeString(s);
	}

}

@@ -403,17 +403,36 @@
 to h
-ex
+ash
  string
+ (byte%5B%5D reversed)
 .%0A *

refactor hash serializer