Ejemplo n.º 1
0
    def test_from_string(self):
        address = Address.from_string(data['base58h'])

        assert address.network is data['network']
        assert address.phash == decode_hex(data['phash'])
        assert address.type == data['type']
        assert address.to_hex() == data['hex']
Ejemplo n.º 2
0
    def test_from_string(self):
        address = Address.from_string(data['base58h'])

        assert address.network is data['network']
        assert address.phash == decode_hex(data['phash'])
        assert address.type == data['type']
        assert address.to_hex() == data['hex']
Ejemplo n.º 3
0
    def test_bitcoind_addresses(self, valid_addresses):
        for string_b58h, string_hex, network, type in valid_addresses:
            address = Address.from_string(string_b58h)

            assert address.network is network
            assert address.type == type
            assert address.to_string() == string_b58h
            assert encode_hex(address.phash) == string_hex
Ejemplo n.º 4
0
    def test_bitcoind_addresses(self, valid_addresses):
        for string_b58h, string_hex, network, type in valid_addresses:
            address = Address.from_string(string_b58h)

            assert address.network is network
            assert address.type == type
            assert address.to_string() == string_b58h
            assert encode_hex(address.phash) == string_hex.encode('utf-8')
Ejemplo n.º 5
0
    def _build_from_dict(self, args):
        MEMBERS = ['address', 'amount', 'message', 'label', 'r']
        self.extras = {}

        for k, v in args.items():
            if k in MEMBERS:
                setattr(self, k, v)
            else:
                self.extras[k] = v

        self.address = Address.from_string(self.address)
        self.amount = Unit(satoshis = self.amount) if 'amount' in args else None
Ejemplo n.º 6
0
    def _build_from_dict(self, args):
        MEMBERS = ['address', 'amount', 'message', 'label', 'r']
        self.extras = {}

        for k, v in args.iteritems():
            if k in MEMBERS:
                setattr(self, k, v)
            else:
                self.extras[k] = v

        self.address = Address.from_string(self.address)
        self.amount = Unit(satoshis = self.amount) if 'amount' in args else None
Ejemplo n.º 7
0
    def test_from_pubkey(self):
        pubkey  = PublicKey(data['pubkey'], data['network'])
        address = Address.from_public_key(pubkey)

        assert address == Address.from_string(data['base58h'])
Ejemplo n.º 8
0
 def test_from_invalid_string(self):
     with raises(Address.InvalidBase58h): Address.from_string('a')
     with raises(Address.InvalidBase58h): Address.from_string('a@')
Ejemplo n.º 9
0
    def test_from_pubkey(self):
        pubkey  = PublicKey(data['pubkey'], data['network'])
        address = Address.from_public_key(pubkey)

        assert address == Address.from_string(data['base58h'])
Ejemplo n.º 10
0
 def test_from_invalid_string(self):
     with raises(Address.InvalidBase58h): Address.from_string('a')
     with raises(Address.InvalidBase58h): Address.from_string('a@')