Skip to content

Commit ec3688a

Browse files
committed
[BIP-119] Clarify Endianness of serializations
1 parent c8c8e27 commit ec3688a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bip-0119.mediawiki

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ def get_default_check_template_precomputed_data(self):
217217
# If there are no scriptSigs we do not need to precompute a hash
218218
if any(inp.scriptSig for inp in self.vin):
219219
result["scriptSigs"] = sha256(b"".join(ser_string(inp.scriptSig) for inp in self.vin))
220-
# The same value is also pre-computed for and defined in BIP-341 and can be shared
220+
# The same value is also pre-computed for and defined in BIP-341 and can be shared.
221+
# each nSequence is packed as 4 byte unsigned integer (little endian)
221222
result["sequences"] = sha256(b"".join(struct.pack("<I", inp.nSequence) for inp in self.vin))
222223
# The same value is also pre-computed for and defined in BIP-341 and can be shared
223224
result["outputs"] = sha256(b"".join(out.serialize() for out in self.vout))
@@ -228,21 +229,21 @@ def get_default_check_template_hash(self, nIn, precomputed = None):
228229
if precomputed == None:
229230
precomputed = self.get_default_check_template_precomputed_data()
230231
r = b""
231-
# pack as 4 byte signed integer
232+
# pack as 4 byte signed integer (little endian)
232233
r += struct.pack("<i", self.nVersion)
233-
# pack as 4 byte unsigned integer
234+
# pack as 4 byte unsigned integer (little endian)
234235
r += struct.pack("<I", self.nLockTime)
235236
# we do not include the hash in the case where there is no
236237
# scriptSigs
237238
if "scriptSigs" in precomputed:
238239
r += precomputed["scriptSigs"]
239-
# pack as 4 byte unsigned integer
240+
# pack as 4 byte unsigned integer (little endian)
240241
r += struct.pack("<I", len(self.vin))
241242
r += precomputed["sequences"]
242-
# pack as 4 byte unsigned integer
243+
# pack as 4 byte unsigned integer (little endian)
243244
r += struct.pack("<I", len(self.vout))
244245
r += precomputed["outputs"]
245-
# pack as 4 byte unsigned integer
246+
# pack as 4 byte unsigned integer (little endian)
246247
r += struct.pack("<I", nIn)
247248
return sha256(r)
248249
</source>

0 commit comments

Comments
 (0)