src/apps/wallet/sign_tx: update ZIP243 Sapling code

pull/25/head
Pavol Rusnak 6 years ago
parent e16a8fc8c9
commit e2d405aa0a
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -137,19 +137,22 @@ class Zip243(Zip143):
write_bytes(h_preimage, bytearray(self.get_sequence_hash())) # 4. hashSequence
write_bytes(h_preimage, bytearray(self.get_outputs_hash())) # 5. hashOutputs
write_bytes(h_preimage, b"\x00" * 32) # 6. hashJoinSplits
write_uint32(h_preimage, tx.lock_time) # 7. nLockTime
write_uint32(h_preimage, tx.expiry) # 8. expiryHeight
write_uint32(h_preimage, sighash) # 9. nHashType
write_bytes_reversed(h_preimage, txi.prev_hash) # 10a. outpoint
write_bytes(h_preimage, b"\x00" * 32) # 7. hashShieldedSpends
write_bytes(h_preimage, b"\x00" * 32) # 8. hashShieldedOutputs
write_uint32(h_preimage, tx.lock_time) # 9. nLockTime
write_uint32(h_preimage, tx.expiry) # 10. expiryHeight
write_uint64(h_preimage, 0) # 11. valueBalance
write_uint32(h_preimage, sighash) # 12. nHashType
write_bytes_reversed(h_preimage, txi.prev_hash) # 13a. outpoint
write_uint32(h_preimage, txi.prev_index)
script_code = derive_script_code(txi, pubkeyhash) # 10b. scriptCode
script_code = derive_script_code(txi, pubkeyhash) # 13b. scriptCode
write_varint(h_preimage, len(script_code))
write_bytes(h_preimage, script_code)
write_uint64(h_preimage, txi.amount) # 10c. value
write_uint64(h_preimage, txi.amount) # 13c. value
write_uint32(h_preimage, txi.sequence) # 10d. nSequence
write_uint32(h_preimage, txi.sequence) # 13d. nSequence
return get_tx_hash(h_preimage)

@ -36,7 +36,7 @@ class TestZcashZip243(unittest.TestCase):
"prevouts_hash": b"bd4318eecf841a0cf01c2be532cf4bc3303e881e2aface159f1882f153152688",
"sequence_hash": b"9ac6a31952ff626bf5a0a30d3d8ac63a0d4298d33d7bc38854bfa5860695e30a",
"outputs_hash": b"d0cadf116b4441f5e1e17814908dee509ec262a79f3c88f7f3389e8200658992",
"preimage_hash": b"80b3cdfbefc9cea6818e148b5af6133dfac7d9ff8435b256ef1958b906b3647f",
"preimage_hash": b"53a12bca557c27defa366c2b4c0e46ede01f81ef3dd3aa3750db62a5505c1d06",
},
{
"expiry": 231041495,
@ -73,7 +73,7 @@ class TestZcashZip243(unittest.TestCase):
"prevouts_hash": b"8e286c6c0dde3119271c9c1398ef46614b0253c502b00a3691cec2e9047da35b",
"sequence_hash": b"58477fd9ecd5faf3e08159e0ab5fdaab66cab364d081498ddcef41de0af3624e",
"outputs_hash": b"c518797fc6f2c08fc22aa3f66122047b360e1db4df5c3feb28573c00cdf45fa1",
"preimage_hash": b"25769ee5a943f0e1fd165c2b049de2732ea88f059658f63932f12b16087337fd",
"preimage_hash": b"d1bc60986cc5c4d57f91002e48459a50f72bdb96b8f5889cf8f467a7d968b97c",
},
{
"expiry": 186996458,
@ -97,7 +97,7 @@ class TestZcashZip243(unittest.TestCase):
"prevouts_hash": b"445bc6328cd33b3c86259953dd674bded341ff1e1104dc21856919e9761036dd",
"sequence_hash": b"42e1d5c2636f165afaa954afa6d7a50779eb145e947bf668f1a40dd771c711fc",
"outputs_hash": b"869eda84eecf7257f9979a4848bbf52f4969a5736594ab7ba41452e7bb906824",
"preimage_hash": b"e2d5a735f8f4c3f6e382405a214daa520a7f80200c177d8daafe1c0344db9dd3",
"preimage_hash": b"7536cdb202a30bf09c45e1a2f775c4efd41b9e67557b62abe12b64d367a2316e",
},
{
"expiry": 254788522,
@ -133,7 +133,7 @@ class TestZcashZip243(unittest.TestCase):
"prevouts_hash": b"509abdfafcc75265037f1ce6a4658ac9ecadd7b82378c3fbaeb48ab437ff6898",
"sequence_hash": b"2b13f671cd1a9aa04c1e250eef74a316d7d2b049360d20604514ddc2dfacfd23",
"outputs_hash": b"4f01b8785e80779290aa86c16b24952f9b7f8bc09da44e68f760ab1920ab8f2a",
"preimage_hash": b"74908bfb31d1ce68f1b82c12e96fb7799669293d92da84a689a1dd1f9ed74d8d",
"preimage_hash": b"df1359c0aacc05e88ae6bbecfc54fef50bd31f21f543c49f95a321dd835263be",
},
]

Loading…
Cancel
Save