Skip to content

Commit

Permalink
another batch of updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmysong committed Nov 13, 2018
1 parent 9492a7b commit bdb0505
Show file tree
Hide file tree
Showing 37 changed files with 333 additions and 102 deletions.
2 changes: 1 addition & 1 deletion session2/complete/2.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_example_4(self):
prime = 223
a = FieldElement(0, prime)
b = FieldElement(7, prime)
G = Point(FieldElement(47, prime), FieldElement(71, prime), a, b)
g = Point(FieldElement(47, prime), FieldElement(71, prime), a, b)
inf = Point(None, None, a, b)
total = g
count = 1
Expand Down
2 changes: 1 addition & 1 deletion session4/complete/session4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@
"stream = BytesIO(bytes.fromhex(hex_tx))\n",
"index = 0\n",
"\n",
"# parse the transaction using Tx.Parse\n",
"# parse the transaction using Tx.parse\n",
"t = Tx.parse(stream)\n",
"# grab the input at index\n",
"tx_in = t.tx_ins[index]\n",
Expand Down
8 changes: 8 additions & 0 deletions session4/complete/tx.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"45f3f79066d251addc04fd889f776c73afab1cb22559376ff820e6166c5e3ad6": "01000000012aa311f7789d362ceb2d802a98a703e0ac44815c021293633b80d08e67232e36010000006a4730440220142d8810ab29cac9199e6b570d47bd5ee402accf9d754cfa7de9b2e84e3997b402207a7d8c77c6a721bc64dba39eabe23e915c979683e621921c243bb35b3f538dfb01210371cb7d04e95471c4ea5c200e8c4729608754c74bee4e289bd66f431482407ec8feffffff02a08601000000000017a914fc7d096f19063ece361e2b309ec4da41fe4d789487f2798e00000000001976a914311b232c3400080eb2636edb8548b47f6835be7688ac31430600",
"75d7454b7010fa28b00f16cccb640b1756fd6e357c03a3b81b9d119505f47b56": "010000000367d54ded4c43569acbc213073fc63bfc49bf420391f0ab304758b16600a8ea88010000006a4730440220404b3bb28af45437c989328122aa6f4462021a0a2d4f20141ebe84e80edd72e202204184dd9d833d57246eaeed39021e9ab8c0546f3270bd9d2fc138a4bf161ea2310121039550662b907f788cc96708dc017aee0d407b74427f11e656b87f84146337f183feffffff5edf7dbc586b5fddace63a6614f5a731787c104d3c1c9225c4542db067d4296d010000006b483045022100b2335adb91e1ac3bb4e0479b54a9e7d4b765d9b646ca71e2547776c4e7e6bdfb02201fa8aaa4d2557768329befd61d4abda95668f88065df6eac6076e3e123c121eb012103b80229ec7a62793132ff432be0ecf21bca774ade18af7eaf2215febad0c4321ffeffffffdfa74eb50768daeb4beca2ca83d1732128d2439f9df9508efc8f7820718b4ae1000000006a47304402204818b29bed4a8ea4eb383f996389866a732b44d98f6342ecc25007ca472526fb0220496ed1213d63b7686f6936940e8f566f291bab211e6600c0f71e3659787b91fc0121036a30f9e6f645191c6216f84c21ae3b4f0aca0c4be987889276089cf9ef7a89d6feffffff028deb0f00000000001976a914cd0b3a22cd16e182291aa2708c41cb38de5a330788acc0e1e400000000001976a91424505f6d2f0fe7c4a3f4af32f50506034d89095d88ac43430600",
"9e067aedc661fca148e13953df75f8ca6eada9ce3b3d8d68631769ac60999156": "0100000001c228021e1fee6f158cc506edea6bad7ffa421dd14fb7fd7e01c50cc9693e8dbe02000000fdfe0000483045022100c679944ff8f20373685e1122b581f64752c1d22c67f6f3ae26333aa9c3f43d730220793233401f87f640f9c39207349ffef42d0e27046755263c0a69c436ab07febc01483045022100eadc1c6e72f241c3e076a7109b8053db53987f3fcc99e3f88fc4e52dbfd5f3a202201f02cbff194c41e6f8da762e024a7ab85c1b1616b74720f13283043e9e99dab8014c69522102b0c7be446b92624112f3c7d4ffc214921c74c1cb891bf945c49fbe5981ee026b21039021c9391e328e0cb3b61ba05dcc5e122ab234e55d1502e59b10d8f588aea4632102f3bd8f64363066f35968bd82ed9c6e8afecbd6136311bb51e91204f614144e9b53aeffffffff05a08601000000000017a914081fbb6ec9d83104367eb1a6a59e2a92417d79298700350c00000000001976a914677345c7376dfda2c52ad9b6a153b643b6409a3788acc7f341160000000017a914234c15756b9599314c9299340eaabab7f1810d8287c02709000000000017a91469be3ca6195efcab5194e1530164ec47637d44308740420f00000000001976a91487fadba66b9e48c0c8082f33107fdb01970eb80388ac00000000",
"d1c789a9c60383bf715f3f6ad9d14b91fe55f3deb369fe5d9280cb1a01793f81": "0100000002137c53f0fb48f83666fcfd2fe9f12d13e94ee109c5aeabbfa32bb9e02538f4cb000000006a47304402207e6009ad86367fc4b166bc80bf10cf1e78832a01e9bb491c6d126ee8aa436cb502200e29e6dd7708ed419cd5ba798981c960f0cc811b24e894bff072fea8074a7c4c012103bc9e7397f739c70f424aa7dcce9d2e521eb228b0ccba619cd6a0b9691da796a1ffffffff517472e77bc29ae59a914f55211f05024556812a2dd7d8df293265acd8330159010000006b483045022100f4bfdb0b3185c778cf28acbaf115376352f091ad9e27225e6f3f350b847579c702200d69177773cd2bb993a816a5ae08e77a6270cf46b33f8f79d45b0cd1244d9c4c0121031c0b0b95b522805ea9d0225b1946ecaeb1727c0b36c7e34165769fd8ed860bf5ffffffff027a958802000000001976a914a802fc56c704ce87c42d7c92eb75e7896bdc41ae88aca5515e00000000001976a914e82bd75c9c662c3f5700b33fec8a676b6e9391d588ac00000000",
"d37f9e7282f81b7fd3af0fde8b462a1c28024f1d83cf13637ec18d03f4518feb": "0100000001b74780c0b9903472f84f8697a7449faebbfb1af659ecb8148ce8104347f3f72d010000006b483045022100bb8792c98141bcf4dab4fd4030743b4eff9edde59cec62380c60ffb90121ab7802204b439e3572b51382540c3b652b01327ee8b14cededc992fbc69b1e077a2c3f9f0121027c975c8bdc9717de310998494a2ae63f01b7a390bd34ef5b4c346fa717cba012ffffffff01a627c901000000001976a914af24b3f3e987c23528b366122a7ed2af199b36bc88ac00000000",
"d6bedcd57e07436b2b1c5b37a2b06ae32a0c066231a66448a4446766d2b45a2f": "01000000016790a157e79cb8bcd588b62b3aead53dece805479cb234da3f52be2bef11b77e010000006a47304402207dcb5725c4a0b6111e91cba5471032954f5c52ac965c665422af51de0321ab6202200cb71c155224d7e5a41defa1f7a9d51cba51c881cb68f57d156f50352fb479c001210356fbcbcab8330563813c25724c65f3da791b8270c58fcafd784be3176519348cfeffffff02a32b4600000000001976a9143e2b4a8e52b50db9b0f4601cf3f58ec514ca45ae88acb47ea700000000001976a914cf2fba63a329fc398ff82d0012bb1a411866a7db88ac2e470600"
}
11 changes: 11 additions & 0 deletions session4/complete/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ def serialize(self):


class TxTest(TestCase):
cache_file = 'tx.cache'

@classmethod
def setUpClass(cls):
# fill with cache so we don't have to be online to run these tests
TxFetcher.load_cache(cls.cache_file)

@classmethod
def tearDownClass(cls):
# write the cache to disk
TxFetcher.dump_cache(cls.cache_file)

def test_parse_version(self):
raw_tx = bytes.fromhex('0100000001813f79011acb80925dfe69b3def355fe914bd1d96a3f5f71bf8303c6a989c7d1000000006b483045022100ed81ff192e75a3fd2304004dcadb746fa5e24c5031ccfcf21320b0277457c98f02207a986d955c6e0cb35d446a89d3f56100f4d7f67801c31967743a9c8e10615bed01210349fc4e631e3624a545de3f89f5d8684c7b8138bd94bdd531d2e213bf016b278afeffffff02a135ef01000000001976a914bc3b654dca7e56b04dca18f2566cdaf02e8d9ada88ac99c39800000000001976a9141c4bc762dd5423e332166702cb75f40df79fea1288ac19430600')
Expand Down
2 changes: 1 addition & 1 deletion session4/session4.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
"stream = BytesIO(bytes.fromhex(hex_tx))\n",
"index = 0\n",
"\n",
"# parse the transaction using Tx.Parse\n",
"# parse the transaction using Tx.parse\n",
"# grab the input at index\n",
"# use the sig_hash method on index and hash_type to get z\n",
"# combine the script_sig and script_pubkey\n",
Expand Down
8 changes: 8 additions & 0 deletions session4/tx.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"45f3f79066d251addc04fd889f776c73afab1cb22559376ff820e6166c5e3ad6": "01000000012aa311f7789d362ceb2d802a98a703e0ac44815c021293633b80d08e67232e36010000006a4730440220142d8810ab29cac9199e6b570d47bd5ee402accf9d754cfa7de9b2e84e3997b402207a7d8c77c6a721bc64dba39eabe23e915c979683e621921c243bb35b3f538dfb01210371cb7d04e95471c4ea5c200e8c4729608754c74bee4e289bd66f431482407ec8feffffff02a08601000000000017a914fc7d096f19063ece361e2b309ec4da41fe4d789487f2798e00000000001976a914311b232c3400080eb2636edb8548b47f6835be7688ac31430600",
"75d7454b7010fa28b00f16cccb640b1756fd6e357c03a3b81b9d119505f47b56": "010000000367d54ded4c43569acbc213073fc63bfc49bf420391f0ab304758b16600a8ea88010000006a4730440220404b3bb28af45437c989328122aa6f4462021a0a2d4f20141ebe84e80edd72e202204184dd9d833d57246eaeed39021e9ab8c0546f3270bd9d2fc138a4bf161ea2310121039550662b907f788cc96708dc017aee0d407b74427f11e656b87f84146337f183feffffff5edf7dbc586b5fddace63a6614f5a731787c104d3c1c9225c4542db067d4296d010000006b483045022100b2335adb91e1ac3bb4e0479b54a9e7d4b765d9b646ca71e2547776c4e7e6bdfb02201fa8aaa4d2557768329befd61d4abda95668f88065df6eac6076e3e123c121eb012103b80229ec7a62793132ff432be0ecf21bca774ade18af7eaf2215febad0c4321ffeffffffdfa74eb50768daeb4beca2ca83d1732128d2439f9df9508efc8f7820718b4ae1000000006a47304402204818b29bed4a8ea4eb383f996389866a732b44d98f6342ecc25007ca472526fb0220496ed1213d63b7686f6936940e8f566f291bab211e6600c0f71e3659787b91fc0121036a30f9e6f645191c6216f84c21ae3b4f0aca0c4be987889276089cf9ef7a89d6feffffff028deb0f00000000001976a914cd0b3a22cd16e182291aa2708c41cb38de5a330788acc0e1e400000000001976a91424505f6d2f0fe7c4a3f4af32f50506034d89095d88ac43430600",
"9e067aedc661fca148e13953df75f8ca6eada9ce3b3d8d68631769ac60999156": "0100000001c228021e1fee6f158cc506edea6bad7ffa421dd14fb7fd7e01c50cc9693e8dbe02000000fdfe0000483045022100c679944ff8f20373685e1122b581f64752c1d22c67f6f3ae26333aa9c3f43d730220793233401f87f640f9c39207349ffef42d0e27046755263c0a69c436ab07febc01483045022100eadc1c6e72f241c3e076a7109b8053db53987f3fcc99e3f88fc4e52dbfd5f3a202201f02cbff194c41e6f8da762e024a7ab85c1b1616b74720f13283043e9e99dab8014c69522102b0c7be446b92624112f3c7d4ffc214921c74c1cb891bf945c49fbe5981ee026b21039021c9391e328e0cb3b61ba05dcc5e122ab234e55d1502e59b10d8f588aea4632102f3bd8f64363066f35968bd82ed9c6e8afecbd6136311bb51e91204f614144e9b53aeffffffff05a08601000000000017a914081fbb6ec9d83104367eb1a6a59e2a92417d79298700350c00000000001976a914677345c7376dfda2c52ad9b6a153b643b6409a3788acc7f341160000000017a914234c15756b9599314c9299340eaabab7f1810d8287c02709000000000017a91469be3ca6195efcab5194e1530164ec47637d44308740420f00000000001976a91487fadba66b9e48c0c8082f33107fdb01970eb80388ac00000000",
"d1c789a9c60383bf715f3f6ad9d14b91fe55f3deb369fe5d9280cb1a01793f81": "0100000002137c53f0fb48f83666fcfd2fe9f12d13e94ee109c5aeabbfa32bb9e02538f4cb000000006a47304402207e6009ad86367fc4b166bc80bf10cf1e78832a01e9bb491c6d126ee8aa436cb502200e29e6dd7708ed419cd5ba798981c960f0cc811b24e894bff072fea8074a7c4c012103bc9e7397f739c70f424aa7dcce9d2e521eb228b0ccba619cd6a0b9691da796a1ffffffff517472e77bc29ae59a914f55211f05024556812a2dd7d8df293265acd8330159010000006b483045022100f4bfdb0b3185c778cf28acbaf115376352f091ad9e27225e6f3f350b847579c702200d69177773cd2bb993a816a5ae08e77a6270cf46b33f8f79d45b0cd1244d9c4c0121031c0b0b95b522805ea9d0225b1946ecaeb1727c0b36c7e34165769fd8ed860bf5ffffffff027a958802000000001976a914a802fc56c704ce87c42d7c92eb75e7896bdc41ae88aca5515e00000000001976a914e82bd75c9c662c3f5700b33fec8a676b6e9391d588ac00000000",
"d37f9e7282f81b7fd3af0fde8b462a1c28024f1d83cf13637ec18d03f4518feb": "0100000001b74780c0b9903472f84f8697a7449faebbfb1af659ecb8148ce8104347f3f72d010000006b483045022100bb8792c98141bcf4dab4fd4030743b4eff9edde59cec62380c60ffb90121ab7802204b439e3572b51382540c3b652b01327ee8b14cededc992fbc69b1e077a2c3f9f0121027c975c8bdc9717de310998494a2ae63f01b7a390bd34ef5b4c346fa717cba012ffffffff01a627c901000000001976a914af24b3f3e987c23528b366122a7ed2af199b36bc88ac00000000",
"d6bedcd57e07436b2b1c5b37a2b06ae32a0c066231a66448a4446766d2b45a2f": "01000000016790a157e79cb8bcd588b62b3aead53dece805479cb234da3f52be2bef11b77e010000006a47304402207dcb5725c4a0b6111e91cba5471032954f5c52ac965c665422af51de0321ab6202200cb71c155224d7e5a41defa1f7a9d51cba51c881cb68f57d156f50352fb479c001210356fbcbcab8330563813c25724c65f3da791b8270c58fcafd784be3176519348cfeffffff02a32b4600000000001976a9143e2b4a8e52b50db9b0f4601cf3f58ec514ca45ae88acb47ea700000000001976a914cf2fba63a329fc398ff82d0012bb1a411866a7db88ac2e470600"
}
11 changes: 11 additions & 0 deletions session4/tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ def serialize(self):


class TxTest(TestCase):
cache_file = 'tx.cache'

@classmethod
def setUpClass(cls):
# fill with cache so we don't have to be online to run these tests
TxFetcher.load_cache(cls.cache_file)

@classmethod
def tearDownClass(cls):
# write the cache to disk
TxFetcher.dump_cache(cls.cache_file)

def test_parse_version(self):
raw_tx = bytes.fromhex('0100000001813f79011acb80925dfe69b3def355fe914bd1d96a3f5f71bf8303c6a989c7d1000000006b483045022100ed81ff192e75a3fd2304004dcadb746fa5e24c5031ccfcf21320b0277457c98f02207a986d955c6e0cb35d446a89d3f56100f4d7f67801c31967743a9c8e10615bed01210349fc4e631e3624a545de3f89f5d8684c7b8138bd94bdd531d2e213bf016b278afeffffff02a135ef01000000001976a914bc3b654dca7e56b04dca18f2566cdaf02e8d9ada88ac99c39800000000001976a9141c4bc762dd5423e332166702cb75f40df79fea1288ac19430600')
Expand Down
Loading

0 comments on commit bdb0505

Please sign in to comment.