Beispiel #1
0
 def test_process_onion_packet(self):
     # this test is not from bolt-04, but is based on the one there;
     # except here we have the privkeys for these pubkeys
     payment_path_pubkeys = [
         bfh('03d75c0ee70f68d73d7d13aeb6261d8ace11416800860c7e59407afe4e2e2d42bb'
             ),
         bfh('03960a0b830c7b8e76de745b819f252c62508346196b916f5e813cdb0773283cce'
             ),
         bfh('0385620e0a571cbc3552620f8bf1bdcdab2d1a4a59c36fa10b8249114ccbdda40d'
             ),
         bfh('02ee242cf6c38b7285f0152c33804ff777f5c51fd352ca8132e845e2cf23b3d8ba'
             ),
         bfh('025c585fd2e174bf8245b2b4a119e52a417688904228643ea3edaa1728bf2a258e'
             ),
     ]
     payment_path_privkeys = [
         bfh('3463a278617b3dd83f79bda7f97673f12609c54386e1f0d2b67b1c6354fda14e'
             ),
         bfh('7e1255fddb52db1729fc3ceb21a46f95b8d9fe94cc83425e936a6c5223bb679d'
             ),
         bfh('c7ce8c1462c311eec24dff9e2532ac6241e50ae57e7d1833af21942136972f23'
             ),
         bfh('3d885f374d79a5e777459b083f7818cdc9493e5c4994ac9c7b843de8b70be661'
             ),
         bfh('dd72ab44729527b7942e195e7a835e7c71f9c0ff61844eb21274d9c26166a8f8'
             ),
     ]
     session_key = bfh(
         '4141414141414141414141414141414141414141414141414141414141414141')
     associated_data = bfh(
         '4242424242424242424242424242424242424242424242424242424242424242')
     hops_data = [
         OnionHopsDataSingle(
             OnionPerHop(bfh('0000000000000000'), bfh('0000000000000000'),
                         bfh('00000000'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0101010101010101'), bfh('0000000000000001'),
                         bfh('00000001'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0202020202020202'), bfh('0000000000000002'),
                         bfh('00000002'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0303030303030303'), bfh('0000000000000003'),
                         bfh('00000003'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0404040404040404'), bfh('0000000000000004'),
                         bfh('00000004'))),
     ]
     packet = new_onion_packet(payment_path_pubkeys, session_key, hops_data,
                               associated_data)
     self.assertEqual(
         bfh('0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661954176cd9869da33d713aa219fcef1e5c806fef11e696bcc66844de8271c27974a049d041ffc5be934b8575c6ff4371f2f88d4edfd73e445534d3f6ae15b64b0d8308390bebf8d149002e31bdc283056477ba27c8054c248ad7306de31663a7c99ec65b251704041f7c4cc40a0016ba172fbf805ec59132a65a4c7eb1f41337931c5df0f840704535729262d30c6132d1b390f073edec8fa057176c6268b6ad06a82ff0229c3be444ee50b40686bc1306838b93c65771de1b6ca05dace1ff9814a6e58b2dd71e8244c83e28b2ed5a3b09e9e7df5c8c747e5765ba366a4f7407a6c6b0a32fb5521cce7cd668f7434c909c1be027d8595d85893e5f612c49a93eeeed80a78bab9c4a621ce0f6f5df7d64a9c8d435db19de192d9db522c7f7b4e201fc1b61a9bd3efd062ae24455d463818b01e2756c7d0691bc3ac4c017be34c9a8b2913bb1b94056bf7a21730afc3f254ffa41ca140a5d87ff470f536d08619e8004d50de2fe5954d6aa4a00570da397ba15ae9ea4d7d1f136256a9093f0a787a36cbb3520b6a3cf4d1b13b16bf399c4b0326da1382a90bd79cf92f4808c8c84eaa50a8ccf44acbde0e35b2e6b72858c8446d6a05f3ba70fb4adc70af27cea9bd1dc1ea35fb3cc236b8b9b69b614903db339b22ad5dc2ddda7ac65fd7de24e60b7dbba7aafc9d26c0f9fcb03f1bb85dfc21762f862620651db52ea703ae60aa7e07febf11caa95c4245a4b37eb9c233e1ab1604fb85849e7f49cb9f7c681c4d91b7c320eb4b89b9c6bcb636ceadda59f6ed47aa5b1ea0a946ea98f6ad2614e79e0d4ef96d6d65903adb0479709e03008bbdf3355dd87df7d68965fdf1ad5c68b6dc2761b96b10f8eb4c0329a646bf38cf4702002e61565231b4ac7a9cde63d23f7b24c9d42797b3c434558d71ed8bf9fcab2c2aee3e8b38c19f9edc3ad3dfe9ebba7387ce4764f97ed1c1a83552dff8315546761479a6f929c39bcca0891d4a967d1b77fa80feed6ae74ac82ed5fb7be225c3f2b0ebdc652afc2255c47bc318ac645bbf19c0819ff527ff6708a78e19c8ca3dc8087035e10d5ac976e84b71148586c8a5a7b26ed11b5b401ce7bb2ac532207eaa24d2f53aaa8024607da764d807c91489e82fcad04e6b8992a507119367f576ee5ffe6807d5723d60234d4c3f94adce0acfed9dba535ca375446a4e9b500b74ad2a66e1c6b0fc38933f282d3a4a877bceceeca52b46e731ca51a9534224a883c4a45587f973f73a22069a4154b1da03d307d8575c821bef0eef87165b9a1bbf902ecfca82ddd805d10fbb7147b496f6772f01e9bf542b00288f3a6efab32590c1f34535ece03a0587ca187d27a98d4c9aa7c044794baa43a81abbe307f51d0bda6e7b4cf62c4be553b176321777e7fd483d6cec16df137293aaf3ad53608e1c7831368675bb9608db04d5c859e7714edab3d2389837fa071f0795adfabc51507b1adbadc7f83e80bd4e4eb9ed1a89c9e0a6dc16f38d55181d5666b02150651961aab34faef97d80fa4e1960864dfec3b687fd4eadf7aa6c709cb4698ae86ae112f386f33731d996b9d41926a2e820c6ba483a61674a4bae03af37e872ffdc0a9a8a034327af17e13e9e7ac619c9188c2a5c12a6ebf887721455c0e2822e67a621ed49f1f50dfc38b71c29d0224954e84ced086c80de552cca3a14adbe43035901225bafc3db3b672c780e4fa12b59221f93690527efc16a28e7c63d1a99fc881f023b03a157076a7e999a715ed37521adb483e2477d75ba5a55d4abad22b024c5317334b6544f15971591c774d896229e4e668fc1c7958fbd76fa0b152a6f14c95692083badd066b6621367fd73d88ba8d860566e6d55b871d80c68296b80ae8847d'
             ), packet.to_bytes())
     for i, privkey in enumerate(payment_path_privkeys):
         processed_packet = process_onion_packet(packet, associated_data,
                                                 privkey)
         self.assertEqual(hops_data[i].per_hop.to_bytes(),
                          processed_packet.hop_data.per_hop.to_bytes())
         packet = processed_packet.next_packet
Beispiel #2
0
 def test_process_onion_packet(self):
     # this test is not from bolt-04, but is based on the one there;
     # except here we have the privkeys for these pubkeys
     payment_path_pubkeys = [
         bfh('03d75c0ee70f68d73d7d13aeb6261d8ace11416800860c7e59407afe4e2e2d42bb'
             ),
         bfh('03960a0b830c7b8e76de745b819f252c62508346196b916f5e813cdb0773283cce'
             ),
         bfh('0385620e0a571cbc3552620f8bf1bdcdab2d1a4a59c36fa10b8249114ccbdda40d'
             ),
         bfh('02ee242cf6c38b7285f0152c33804ff777f5c51fd352ca8132e845e2cf23b3d8ba'
             ),
         bfh('025c585fd2e174bf8245b2b4a119e52a417688904228643ea3edaa1728bf2a258e'
             ),
     ]
     payment_path_privkeys = [
         bfh('3463a278617b3dd83f79bda7f97673f12609c54386e1f0d2b67b1c6354fda14e'
             ),
         bfh('7e1255fddb52db1729fc3ceb21a46f95b8d9fe94cc83425e936a6c5223bb679d'
             ),
         bfh('c7ce8c1462c311eec24dff9e2532ac6241e50ae57e7d1833af21942136972f23'
             ),
         bfh('3d885f374d79a5e777459b083f7818cdc9493e5c4994ac9c7b843de8b70be661'
             ),
         bfh('dd72ab44729527b7942e195e7a835e7c71f9c0ff61844eb21274d9c26166a8f8'
             ),
     ]
     session_key = bfh(
         '4141414141414141414141414141414141414141414141414141414141414141')
     associated_data = bfh(
         '4242424242424242424242424242424242424242424242424242424242424242')
     hops_data = [
         OnionHopsDataSingle(
             OnionPerHop(bfh('0000000000000000'), bfh('0000000000000000'),
                         bfh('00000000'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0101010101010101'), bfh('0000000000000001'),
                         bfh('00000001'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0202020202020202'), bfh('0000000000000002'),
                         bfh('00000002'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0303030303030303'), bfh('0000000000000003'),
                         bfh('00000003'))),
         OnionHopsDataSingle(
             OnionPerHop(bfh('0404040404040404'), bfh('0000000000000004'),
                         bfh('00000004'))),
     ]
     packet = new_onion_packet(payment_path_pubkeys, session_key, hops_data,
                               associated_data)
     self.assertEqual(
         bfh('0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661954176cd9869da33d713aa219fcef1e5c806fef11e696bcc66844de8271c27974a0fd57c2dbcb2c6dd4e8ef35d96db28d5a0e49b6ab3d6de31af65950723b8cddc108390bebf8d149002e31bdc283056477ba27c8054c248ad7306de31663a7c99ec659da15d0f6fbc7e1687485b39e9be0ec3b70164cb3618a9b546317e7c2d62ae9f0f840704535729262d30c6132d1b390f073edec8fa057176c6268b6ad06a82ff0d16d4c662194873e8b4ecf46eb2c9d4d58d2ee2021adb19840605ac5afd8bd942dd71e8244c83e28b2ed5a3b09e9e7df5c8c747e5765ba366a4f7407a6c6b0a32f74bc5e428f7fa4c3cf70e13ed91563177d94190d5149aa4b9c96d00e40d2ac35ab9c4a621ce0f6f5df7d64a9c8d435db19de192d9db522c7f7b4e201fc1b61a9bd3efd062ae24455d463818b01e2756c7d0691bc3ac4c017be34c9a8b2913bb1b937e31e0ae40f650a7cd820bcb4996825b1cbad1ff7ccc2b513b1104524c34f6573e1b59201c005a632ee5dccd3711a32e3ba1ff00fcffbe636e4b3a84bbe491b836a57ccec138b8cc2ec733846904d872f305d538d51db8e56232ec6e07877075328874cb7b09c7e799100a9ff085dead253886b174fc408a0ea7b48bce2c5d8992285011960af088f7e006ef60089d46ac9aa15acfac6c87c3cf6904764dd785419292fbafa9cca09c8ade24a6cd63f12d1cfc83fa35cf2f1cf503c39cbf78293f06c68a3cece7177169cd872bb49bf69d933a27a887dd9daefa9239fca9f0c3e309ec61d9df947211da98cf11a6e0fb77252629cdf9f2226dd69ca73fa51be4df224592f8d471b69a1aebbdaa2f3a798b3581253d97feb0a12e6606043ca0fc5efc0f49b8061d6796eff31cd8638499e2f25ffb96eec32837438ed7ebebbe587886648f63e35d80f41869f4c308f2e6970bd65fead5e8544e3239a6acc9d996b08d1546455bcafbe88ed3ed547714841946fe2e77180e4d7bf1452414e4b1745a7897184a2c4cbc3ac46f83342a55a48e29dc8f17cf595dd28f51e297ba89fd25ed0dbd1c0081a810beaab09758a36fbfd16fbdc3daa9fe05c8a73195f244ef2743a5df761f01ee6e693eb6c7f1a7834fab3671391e5ddebf611e119a2ae4456e2cee7a6d4f27a2246cdb1f8ef35f0b3d7044b3799d8d0ed0a6470557fd807c065d6d83acba07e96e10770ada8c0b4d4921522944188d5f30086a6ee0a4795331273f32beaaa43363fc58208a257e5c5c434c7325b583642219d81c7d67b908d5263b42ac1991edc69a777da60f38eff138c844af9e549374e8b29b166211bfded24587a29394e33828b784da7e7b62ab7e49ea2693fcdd17fa96186a5ef11ef1a8adffa50f93a3119e95e6c09014f3e3b0709183fa08a826ced6deb4608b7d986ebbcf99ad58e25451d4d9d38d0059734d8501467b97182cd11e0c07c91ca50f61cc31255a3147ade654976a5989097281892aafd8df595c63bd14f1e03f5955a9398d2dd6368bbcae833ae1cc2df31eb0980b4817dfd130020ffb275743fcc01df40e3ecda1c5988e8e1bde965353b0b1bf34ea05f095000c45b6249618d275905a24d3eb58c600aeab4fb552fbf1ccdb2a5c80ace220310f89829d7e53f78c126037b6d8d500220c7a118d9621b4d6bd5379edd7e24bcf540e87aba6b88862db16fa4ee00b009fda80577be67ab94910fd8a7807dfe4ebe66b8fdcd040aa2dc17ec22639298be56b2a2c9d8940647b75f2f6d81746df16e1cb2f05e23397a8c63baea0803441ff4b7d517ff172980a056726235e2f6af85e8aa9b91ba85f14532272d6170df3166b91169dc09d4f4a251610f57ff0885a93364cfaf650bdf436c89795efed5ca934bc7ffc0a4'
             ), packet.to_bytes())
     for i, privkey in enumerate(payment_path_privkeys):
         processed_packet = process_onion_packet(packet, associated_data,
                                                 privkey)
         self.assertEqual(hops_data[i].per_hop.to_bytes(),
                          processed_packet.hop_data.per_hop.to_bytes())
         packet = processed_packet.next_packet
Beispiel #3
0
 def test_process_onion_packet_mixed_payloads(self):
     # this test is not from bolt-04, but is based on the one there;
     # here the TLV payloads are actually sane...
     payment_path_pubkeys = [
         bfh('02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619'
             ),
         bfh('0324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c'
             ),
         bfh('027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007'
             ),
         bfh('032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991'
             ),
         bfh('02edabbd16b41c8371b92ef2f04c1185b4f03b6dcd52ba9b78d9d7c89c8f221145'
             ),
     ]
     payment_path_privkeys = [
         bfh('4141414141414141414141414141414141414141414141414141414141414141'
             ),
         bfh('4242424242424242424242424242424242424242424242424242424242424242'
             ),
         bfh('4343434343434343434343434343434343434343434343434343434343434343'
             ),
         bfh('4444444444444444444444444444444444444444444444444444444444444444'
             ),
         bfh('4545454545454545454545454545454545454545454545454545454545454545'
             ),
     ]
     session_key = bfh(
         '4141414141414141414141414141414141414141414141414141414141414141')
     associated_data = bfh(
         '4242424242424242424242424242424242424242424242424242424242424242')
     hops_data = [
         OnionHopsDataSingle(is_tlv_payload=False,
                             payload={
                                 "amt_to_forward": {
                                     "amt_to_forward": 0
                                 },
                                 "outgoing_cltv_value": {
                                     "outgoing_cltv_value": 0
                                 },
                                 "short_channel_id": {
                                     "short_channel_id":
                                     bfh('0000000000000000')
                                 },
                             }),
         OnionHopsDataSingle(is_tlv_payload=True,
                             payload={
                                 "amt_to_forward": {
                                     "amt_to_forward": 1
                                 },
                                 "outgoing_cltv_value": {
                                     "outgoing_cltv_value": 1
                                 },
                                 "short_channel_id": {
                                     "short_channel_id":
                                     bfh('0101010101010101')
                                 },
                             }),
         OnionHopsDataSingle(is_tlv_payload=True,
                             payload={
                                 "amt_to_forward": {
                                     "amt_to_forward": 2
                                 },
                                 "outgoing_cltv_value": {
                                     "outgoing_cltv_value": 2
                                 },
                                 "short_channel_id": {
                                     "short_channel_id":
                                     bfh('0202020202020202')
                                 },
                             }),
         OnionHopsDataSingle(is_tlv_payload=True,
                             payload={
                                 "amt_to_forward": {
                                     "amt_to_forward": 3
                                 },
                                 "outgoing_cltv_value": {
                                     "outgoing_cltv_value": 3
                                 },
                                 "short_channel_id": {
                                     "short_channel_id":
                                     bfh('0303030303030303')
                                 },
                             }),
         OnionHopsDataSingle(is_tlv_payload=False,
                             payload={
                                 "amt_to_forward": {
                                     "amt_to_forward": 4
                                 },
                                 "outgoing_cltv_value": {
                                     "outgoing_cltv_value": 4
                                 },
                                 "short_channel_id": {
                                     "short_channel_id":
                                     bfh('0404040404040404')
                                 },
                             }),
     ]
     packet = new_onion_packet(payment_path_pubkeys, session_key, hops_data,
                               associated_data)
     self.assertEqual(
         bfh('0002eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619e5f14350c2a76fc232b5e46d421e9615471ab9e0bc887beff8c95fdb878f7b3a71bde5adfa90b337f34616d8673d09dd055937273045566ce537ffbe3f9d1f263dc10c7d61ae590536c609010079a232a247922a5395359a63dfbefb85f40317e23254f3023f7d4a98f746c9ab06647645ce55c67308e3c77dc87a1caeac51b03b23c60f05e536e1d757c8c1093e34accfc4f97b5920f6dd2069d5b9ddbb384c3ac575e999a92a4434470ab0aa040c4c3cace3162a405842a88be783e64fad54bd6727c23fc446b7ec0dc3eec5a03eb6c70ec2784911c9e6d274322ec465f0972eb8e771b149f319582ba64dbc2b8e56a3ea79002801c09354f1541cf79bd1dccf5d6bd6b6bacc87a0f24ce497e14e8037e5a79fb4d9ca63fe47f17765963e8f17468a5eaec19a6cca2bfc4e4a366fea3a92112a945856be55e45197ecbab523025e7589529c30cc8addc8fa39d23ef64fa2e51a219c3bd4d3c484832f8e5af16bc46cdba0403991f4fc1b74beef857acf15fefed82ac8678ca66d26262c681beddfdb485aa498813b1a6c5833f1339c1a35244ab76baa0ccaf681ec1f54004e387063335648a77b65d90dde74f1c4b0a729ca25fa53256f7db6d35818b4e5910ba78ec69cf3646bf248ef46cf9cc33062662de2afe4dcf005951b85fd759429fa1ae490b78b14132ccb791232a6c680f03634c0136817f51bf9603a0dba405e7b347830be4327fceccd4734456842b82cf6275393b279bc6ac93d743e00a2d6042960089f70c782ce554b9f73eeeefeea50df7f6f80de1c4e869a7b502f9a5df30d1175402fa780812d35c6d489a30bb0cea53a1088669a238cccf416ecb37f8d8e6ea1327b64979d48e937db69a44a902923a75113685a4aca4a8d9c62b388b48d9c9e2ab9c2df4d529223144de6e16f2dd95a063da79163b3fe006a80263cde4410648f7c3e1f4a7707f82eb0e209002d972c7e57b4ff8ce063fa7b4140f52f569f0cc8793a97a170613efb6b27ba3a0370f8ea74fc0d6aabba54e0ee967abc70e87b580d2aac244236b7752db9d83b159afc1faf6b44b697643235bf59e99f43428caff409d26b9139538865b1f5cf4699f9296088aca461209024ad1dd00e3566e4fde2117b7b3ffced6696b735816a00199890056de86dcbb1b930228143dbf04f07c0eb34370089ea55c43b2c4546cbe1ff0c3a6217d994af9b4225f4b5acb1e3129f5f5b98d381a4692a8561c670b2ee95869f9614e76bb07f623c5194e1c9d26334026f8f5437ec1cde526f914fa094a465f0adcea32b79bfa44d2562536b0d8366da9ee577666c1d5e39615444ca5c900b8199fafac002b8235688eaa0c6887475a913b37d9a4ed43a894ea4576102e5d475ae0b962240ea95fc367b7ac214a4f8682448a9c0d2eea35727bdedc235a975ecc8148a5b03d6291a051dbefe19c8b344d2713c6664dd94ced53c6be39a837fbf1169cca6a12b0a2710f443ba1afeecb51e94236b2a6ed1c2f365b595443b1515de86dcb8c67282807789b47c331cde2fdd721262bef165fa96b7919d11bc5f2022f5affffdd747c7dbe3de8add829a0a8913519fdf7dba4e8a7a25456d2d559746d39ea6ffa31c7b904792fb734bba30f2e1adf7457a994513a1807785fe7b22bf419d1f407f8e2db8b22c0512b078c0cfdfd599e6c4a9d0cc624b9e24b87f30541c3248cd6643df15d251775cc457df4ea6b4e4c5990d87541028c6f0eb28502db1c11a92797168d0b68cb0a0d345b3a3ad05fc4016862f403c64670c41a2c0c6d4e384f5f7da6a204a24530a51182fd7164f120e74a78decb1ab6cda6b9cfc68ac0a35f7a57e750ead65a8e0429cc16e733b9e4feaea25d06c1a4768'
             ), packet.to_bytes())
     for i, privkey in enumerate(payment_path_privkeys):
         processed_packet = process_onion_packet(packet, associated_data,
                                                 privkey)
         self.assertEqual(hops_data[i].to_bytes(),
                          processed_packet.hop_data.to_bytes())
         packet = processed_packet.next_packet