示例#1
0
    def test_serialize_protocol_version_70210(self):
        announce = MasternodeAnnounce.deserialize(raw_announce_70210)
        msg = announce.serialize_for_sig()
        expected = to_bytes(''.join([
            '178.151.192.107:19999',
            '1530021571',
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0221088c51bef8c9c891b385fa1e8a78b016f01db41741aea7e43e67a7415ab7be'))),
            bitcoin.hash_encode(bitcoin.hash_160(bfh('042379a871a10ae6bf06e756262f69d7f0ce9b8b562f223bde964db573fb7d0f1e219c246a4b3a6133c5cec136d83f4049df51321ba2cb01d676cc3982c7e24d1f'))),
            '70210',
        ]))
        print('7'*50, expected)
        print('8'*50, msg)

        self.assertEqual(expected, msg)
示例#2
0
    def test_serialize_protocol_version_70210(self):
        announce = MasternodeAnnounce.deserialize(raw_announce_70210)
        msg = announce.serialize_for_sig()
        expected = to_bytes(''.join([
            '178.151.192.107:19999',
            '1530021571',
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0221088c51bef8c9c891b385fa1e8a78b016f01db41741aea7e43e67a7415ab7be'))),
            bitcoin.hash_encode(bitcoin.hash_160(bfh('042379a871a10ae6bf06e756262f69d7f0ce9b8b562f223bde964db573fb7d0f1e219c246a4b3a6133c5cec136d83f4049df51321ba2cb01d676cc3982c7e24d1f'))),
            '70210',
        ]))
        print('7'*50, expected)
        print('8'*50, msg)

        self.assertEqual(expected, msg)
示例#3
0
    def test_serialize_protocol_version_70201(self):
        raw = '08108933d948aed6a107cd01e7862ed61ef9bf14e87da0a14e8d17791e9f9c570100000000ffffffff00000000000000000000ffff7f0000014e1f210269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23210269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e234120b8bc547ce2471125eddfdfd5af30ea1e892e750acfe2896b241097b7f21442a61da073d47c885535769bf215eb3e97eca692d868db1bfb9dee469a1ece5acb92a1945457000000003912010008108933d948aed6a107cd01e7862ed61ef9bf14e87da0a14e8d17791e9f9c570100000000ffffffffefc894d8431c1774a19aeb732ea7fc56925b740ed80486f30424109a05000000a1945457000000004120818f17742e6644359c8b9a91e56b595615bd2c593de713304435dcfd07ceb6a815559fd3b2f05f531d9b9918b22b8748491c3f36cb25e8397ff950f74030444f0000000000000000'
        announce = MasternodeAnnounce.deserialize(raw)
        announce.sig_time = 1465161129
        msg = announce.serialize_for_sig()
        expected = to_bytes(''.join([
            '127.0.0.1:19999',
            '1465161129',
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23'))),
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23'))),
            '70201',
        ]))
        print('7'*50, expected)
        print('8'*50, msg)

        self.assertEqual(expected, msg)
示例#4
0
    def test_serialize_protocol_version_70201(self):
        raw = '08108933d948aed6a107cd01e7862ed61ef9bf14e87da0a14e8d17791e9f9c570100000000ffffffff00000000000000000000ffff7f0000014e1f210269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23210269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e234120b8bc547ce2471125eddfdfd5af30ea1e892e750acfe2896b241097b7f21442a61da073d47c885535769bf215eb3e97eca692d868db1bfb9dee469a1ece5acb92a1945457000000003912010008108933d948aed6a107cd01e7862ed61ef9bf14e87da0a14e8d17791e9f9c570100000000ffffffffefc894d8431c1774a19aeb732ea7fc56925b740ed80486f30424109a05000000a1945457000000004120818f17742e6644359c8b9a91e56b595615bd2c593de713304435dcfd07ceb6a815559fd3b2f05f531d9b9918b22b8748491c3f36cb25e8397ff950f74030444f0000000000000000'
        announce = MasternodeAnnounce.deserialize(raw)
        announce.sig_time = 1465161129
        msg = announce.serialize_for_sig()
        expected = to_bytes(''.join([
            '127.0.0.1:19999',
            '1465161129',
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23'))),
            bitcoin.hash_encode(bitcoin.hash_160(bfh('0269e1abb1ffe231ea045068272a06f0fae231d11b11a54225867d89267faa4e23'))),
            '70201',
        ]))
        print('7'*50, expected)
        print('8'*50, msg)

        self.assertEqual(expected, msg)
示例#5
0
 def code_hashid(self, txt):
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()
示例#6
0
 def code_hashid(self, txt):
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()
示例#7
0
 def code_hashid(cls, txt: str) -> str:
     txt = txt.lower()
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()