/** * Creates a new instance that wraps the given hash value (represented as a hex string). * * @param hexString a hash value represented as a hex string * @return a new instance * @throws IllegalArgumentException if the given string is not a valid * hex string, or if it does not represent exactly 32 bytes */ public static Sha256Hash wrap(String hexString) { return wrap(Utils.HEX.decode(hexString)); }
/** * Creates a new instance that wraps the given hash value (represented as a hex string). * * @param hexString a hash value represented as a hex string * @return a new instance * @throws IllegalArgumentException if the given string is not a valid * hex string, or if it does not represent exactly 32 bytes */ public static Sha256Hash wrap(String hexString) { return wrap(Utils.HEX.decode(hexString)); }
/** * Creates a new instance that wraps the given hash value (represented as a hex string). * * @param hexString a hash value represented as a hex string * @return a new instance * @throws IllegalArgumentException if the given string is not a valid * hex string, or if it does not represent exactly 32 bytes */ public static Sha256Hash wrap(String hexString) { return wrap(Utils.HEX.decode(hexString)); }
/** * Creates a new instance that wraps the given hash value (represented as a hex string). * * @param hexString a hash value represented as a hex string * @return a new instance * @throws IllegalArgumentException if the given string is not a valid * hex string, or if it does not represent exactly 32 bytes */ public static Sha256Hash wrap(String hexString) { return wrap(Utils.HEX.decode(hexString)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance that wraps the given hash value, but with byte order reversed. * * @param rawHashBytes the raw hash bytes to wrap * @return a new instance * @throws IllegalArgumentException if the given array length is not exactly 32 */ @SuppressWarnings("deprecation") // the constructor will be made private in the future public static Sha256Hash wrapReversed(byte[] rawHashBytes) { return wrap(Utils.reverseBytes(rawHashBytes)); }
/** * Creates a new instance containing the calculated (one-time) hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (one-time) hash */ public static Sha256Hash of(byte[] contents) { return wrap(hash(contents)); }
/** * Creates a new instance that wraps the given hash value, but with byte order reversed. * * @param rawHashBytes the raw hash bytes to wrap * @return a new instance * @throws IllegalArgumentException if the given array length is not exactly 32 */ @SuppressWarnings("deprecation") // the constructor will be made private in the future public static Sha256Hash wrapReversed(byte[] rawHashBytes) { return wrap(Utils.reverseBytes(rawHashBytes)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance that wraps the given hash value, but with byte order reversed. * * @param rawHashBytes the raw hash bytes to wrap * @return a new instance * @throws IllegalArgumentException if the given array length is not exactly 32 */ @SuppressWarnings("deprecation") // the constructor will be made private in the future public static Sha256Hash wrapReversed(byte[] rawHashBytes) { return wrap(Utils.reverseBytes(rawHashBytes)); }
@Override public Sha256Hash deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken token = p.getCurrentToken(); switch (token) { case VALUE_STRING: return Sha256Hash.wrap(p.getValueAsString()); default: return (Sha256Hash) ctxt.handleUnexpectedToken(Sha256Hash.class, p); } } }
/** * Creates a new instance containing the calculated (one-time) hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (one-time) hash */ public static Sha256Hash of(byte[] contents) { return wrap(hash(contents)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
/** * Creates a new instance containing the hash of the calculated hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (two-time) hash */ public static Sha256Hash twiceOf(byte[] contents) { return wrap(hashTwice(contents)); }
private Sha256Hash numAsHash(int num) { byte[] bits = new byte[32]; bits[0] = (byte) num; return Sha256Hash.wrap(bits); }
private Sha256Hash calculateMerkleRoot() { List<byte[]> tree = buildMerkleTree(); return Sha256Hash.wrap(tree.get(tree.size() - 1)); }
/** * Creates a new instance containing the calculated (one-time) hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (one-time) hash */ public static Sha256Hash of(byte[] contents) { return wrap(hash(contents)); }
/** * Creates a new instance containing the calculated (one-time) hash of the given bytes. * * @param contents the bytes on which the hash value is calculated * @return a new instance containing the calculated (one-time) hash */ public static Sha256Hash of(byte[] contents) { return wrap(hash(contents)); }
private Map<TransactionOutPoint, Script> parseScriptPubKeys(JsonNode inputs) throws IOException { Map<TransactionOutPoint, Script> scriptPubKeys = new HashMap<>(); for (JsonNode input : inputs) { String hash = input.get(0).asText(); int index = input.get(1).asInt(); String script = input.get(2).asText(); Sha256Hash sha256Hash = Sha256Hash.wrap(HEX.decode(hash)); scriptPubKeys.put(new TransactionOutPoint(PARAMS, index, sha256Hash), parseScriptString(script)); } return scriptPubKeys; }
public Channel () { keyServer = new ECKey(); channelStatus = new ChannelStatus(); anchorTxHash = Sha256Hash.wrap(Tools.getRandomByte(32)); masterPrivateKeyServer = Tools.getRandomByte(20); }