diff --git a/core/src/main/scala/org/bitcoins/core/protocol/NetworkElement.scala b/core/src/main/scala/org/bitcoins/core/protocol/NetworkElement.scala index c49faa773d..8f10f894bb 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/NetworkElement.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/NetworkElement.scala @@ -16,8 +16,14 @@ trait NetworkElement extends Any { /** The hexadecimal representation of the NetworkElement */ def hex: String = bytes.toHex + /** The hexadecimal representation of the NetworkElement in little endian */ + def hexLE: String = bytesLE.toHex + /** The byte representation of the NetworkElement */ def bytes: ByteVector + /** The byte representation of the NetworkElement in little endian */ + def bytesLE: ByteVector = bytes.reverse + def logger = BitcoinSLogger.logger } diff --git a/core/src/main/scala/org/bitcoins/core/util/Factory.scala b/core/src/main/scala/org/bitcoins/core/util/Factory.scala index 92f4b8bee5..83970383f4 100644 --- a/core/src/main/scala/org/bitcoins/core/util/Factory.scala +++ b/core/src/main/scala/org/bitcoins/core/util/Factory.scala @@ -12,9 +12,15 @@ abstract class Factory[+T] { /** Creates a T out of a hex string. */ def fromHex(hex: String): T = fromBytes(BitcoinSUtil.decodeHex(hex)) + /** Creates a T out of a hex string in little endian. */ + def fromHexLE(hex: String): T = fromBytesLE(BitcoinSUtil.decodeHex(hex)) + /** Creates a T out of a sequence of bytes. */ def fromBytes(bytes: ByteVector): T + /** Creates a T out of a sequence of bytes in little endian. */ + def fromBytesLE(bytes: ByteVector): T = fromBytes(bytes.reverse) + /** Creates a T out of a sequence of bytes. */ def apply(bytes: ByteVector): T = fromBytes(bytes)