summaryrefslogtreecommitdiff
path: root/bip-0119.mediawiki
diff options
context:
space:
mode:
authorJeremy Rubin <j@rubin.io>2022-05-10 08:38:37 -0700
committerJeremy Rubin <j@rubin.io>2022-05-10 08:38:37 -0700
commitec3688a6102a7686acb3a014418a2dd685711827 (patch)
tree20e7189670296d8dadd1bf7655febf694561d9a7 /bip-0119.mediawiki
parentc8c8e27c2c4623bb17b20a9aebea965a23d425de (diff)
[BIP-119] Clarify Endianness of serializations
Diffstat (limited to 'bip-0119.mediawiki')
-rw-r--r--bip-0119.mediawiki13
1 files changed, 7 insertions, 6 deletions
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>