From ec3688a6102a7686acb3a014418a2dd685711827 Mon Sep 17 00:00:00 2001
From: Jeremy Rubin <j@rubin.io>
Date: Tue, 10 May 2022 08:38:37 -0700
Subject: [BIP-119] Clarify Endianness of serializations

---
 bip-0119.mediawiki | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

(limited to 'bip-0119.mediawiki')

diff --git a/bip-0119.mediawiki b/bip-0119.mediawiki
index cd7c8aa..99a9150 100644
--- a/bip-0119.mediawiki
+++ b/bip-0119.mediawiki
@@ -217,7 +217,8 @@ def get_default_check_template_precomputed_data(self):
     # If there are no scriptSigs we do not need to precompute a hash
     if any(inp.scriptSig for inp in self.vin):
         result["scriptSigs"] = sha256(b"".join(ser_string(inp.scriptSig) for inp in self.vin))
-    # The same value is also pre-computed for and defined in BIP-341 and can be shared
+    # The same value is also pre-computed for and defined in BIP-341 and can be shared.
+    # each nSequence is packed as 4 byte unsigned integer (little endian)
     result["sequences"] = sha256(b"".join(struct.pack("<I", inp.nSequence) for inp in self.vin))
     # The same value is also pre-computed for and defined in BIP-341 and can be shared
     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):
     if precomputed == None:
         precomputed = self.get_default_check_template_precomputed_data()
     r = b""
-    # pack as 4 byte signed integer
+    # pack as 4 byte signed integer (little endian)
     r += struct.pack("<i", self.nVersion)
-    # pack as 4 byte unsigned integer
+    # pack as 4 byte unsigned integer (little endian)
     r += struct.pack("<I", self.nLockTime)
     # we do not include the hash in the case where there is no
     # scriptSigs
     if "scriptSigs" in precomputed:
         r += precomputed["scriptSigs"]
-    # pack as 4 byte unsigned integer
+    # pack as 4 byte unsigned integer (little endian)
     r += struct.pack("<I", len(self.vin))
     r += precomputed["sequences"]
-    # pack as 4 byte unsigned integer
+    # pack as 4 byte unsigned integer (little endian)
     r += struct.pack("<I", len(self.vout))
     r += precomputed["outputs"]
-    # pack as 4 byte unsigned integer
+    # pack as 4 byte unsigned integer (little endian)
     r += struct.pack("<I", nIn)
     return sha256(r)
 </source>
-- 
cgit v1.2.3

