def get_addr(self):
     """Get a NetworkAddress instance from this widget's data."""
     ip = str(self.ip_edit.text())
     port = self.port_edit.value()
     if self.validate_ip(ip):
         return NetworkAddress(ip=ip, port=port)
     return NetworkAddress()
Beispiel #2
0
    def test_create_and_sign(self):
        collateral_pub = '0218864d879997fefbb2846e54ac4db0df99029b91cd12be32312d7e0da45029a8'  # PUFpXCipFhCM1n3CvY1pdJnsuBYGXopNoZ
        delegate_pub = '0329e04e958045a2866e59d13423772e16551cc1bedc50adb0e10b33ae28146cfc'  # P9h6zCz253jmc4TvqgKPRNpkx5qELdNWWT
        protocol_version = 70103

        ip = '0.0.0.0'
        port = 20000
        addr = NetworkAddress(ip=ip, port=port)

        vin = {
            'prevout_hash': '00' * 32,
            'prevout_n': 0,
            'scriptSig': '',
            'sequence': 0xffffffff
        }

        last_ping = MasternodePing(vin=vin, block_hash='ff' * 32)

        announce = MasternodeAnnounce(vin=vin,
                                      addr=addr,
                                      collateral_key=collateral_pub,
                                      delegate_key=delegate_pub,
                                      protocol_version=protocol_version,
                                      last_ping=last_ping)

        collateral_wif = 'XDL8kYsDheEviC7EYMNbo3Myy1txzKyfhZFZBaYUSPDPm9BZZae8'
        delegate_wif = 'XFsDL1FgC4VWQWZQu1NZAs5ri1rUP8mu1CviQYBbXedBTK37uppF'
        announce.last_ping.sign(delegate_wif, bfh(delegate_pub), 1461858375)
        sig = announce.sign(collateral_wif, 1461858375)

        address = 'PUFpXCipFhCM1n3CvY1pdJnsuBYGXopNoZ'
        self.assertTrue(announce.verify(address))
        self.assertTrue(
            ecc.verify_message_with_address(address, sig,
                                            announce.serialize_for_sig()))
Beispiel #3
0
 def test_serialize(self):
     expected = '00000000000000000000ffffc0a801654e1f'
     addr = NetworkAddress(ip='192.168.1.101', port=19999)
     self.assertEqual(expected, addr.serialize())
     self.assertEqual('192.168.1.101:19999', str(addr))