コード例 #1
0
ファイル: address.py プロジェクト: maraoz/bitforge
    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']
コード例 #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']
コード例 #3
0
ファイル: address.py プロジェクト: maraoz/bitforge
    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
コード例 #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')
コード例 #5
0
ファイル: uri.py プロジェクト: coinforge/bitforge
    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
コード例 #6
0
ファイル: uri.py プロジェクト: Unepic/wifiportal21
    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
コード例 #7
0
 def test_create(self):
     Address('a' * 20, networks.livenet, Address.Type.PublicKey)
     Address('a' * 20, networks.livenet, Address.Type.Script)
     Address('a' * 20, networks.testnet, Address.Type.PublicKey)
     Address('a' * 20, networks.testnet, Address.Type.Script)
コード例 #8
0
ファイル: address.py プロジェクト: maraoz/bitforge
    def test_from_pubkey(self):
        pubkey  = PublicKey(data['pubkey'], data['network'])
        address = Address.from_public_key(pubkey)

        assert address == Address.from_string(data['base58h'])
コード例 #9
0
 def test_invalid_network(self):
     with raises(Address.UnknownNetwork):
         Address('a' * 20, -1)
コード例 #10
0
ファイル: address.py プロジェクト: maraoz/bitforge
 def test_from_invalid_string(self):
     with raises(Address.InvalidBase58h): Address.from_string('a')
     with raises(Address.InvalidBase58h): Address.from_string('a@')
コード例 #11
0
ファイル: address.py プロジェクト: maraoz/bitforge
 def test_from_invalid_bytes(self):
     with raises(Address.InvalidBinaryLength):
         Address.from_bytes('a')
コード例 #12
0
ファイル: address.py プロジェクト: maraoz/bitforge
 def test_from_invalid_hex(self):
     with raises(Address.InvalidHex): Address.from_hex('a')
     with raises(Address.InvalidHex): Address.from_hex('a@')
コード例 #13
0
 def test_invalid_version(self):
     with raises(Address.InvalidVersion):
         Address.from_bytes(b'\x0f' + b'a' * 20)
コード例 #14
0
 def test_invalid_phash(self):
     with raises(Address.InvalidHashLength):
         Address('a')
コード例 #15
0
ファイル: address.py プロジェクト: maraoz/bitforge
 def test_invalid_version(self):
     with raises(Address.InvalidVersion):
         Address.from_bytes(chr(15) + 'a' * 20)
コード例 #16
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'])
コード例 #17
0
 def test_from_invalid_bytes(self):
     with raises(Address.InvalidBinaryLength):
         Address.from_bytes('a')
コード例 #18
0
 def test_from_invalid_string(self):
     with raises(Address.InvalidBase58h): Address.from_string('a')
     with raises(Address.InvalidBase58h): Address.from_string('a@')
コード例 #19
0
 def test_invalid_type(self):
     with raises(Address.InvalidType):
         Address('a' * 20, networks.livenet, None)
コード例 #20
0
 def test_from_invalid_hex(self):
     with raises(Address.InvalidHex): Address.from_hex('a')
     with raises(Address.InvalidHex): Address.from_hex('a@')