internal
addressFor(network[, rnd]) -> String
- network(String): network we're getting address for
- rnd(Buffer): hash of a private key (generated randomly if not supplied)

Generate bitcoin address for a given network
962858
function addressFor(network, rnd) {
  var version = PROTOCOL_VERSIONS[network];

  //                      ver   payload  checksum
  var packed = new Buffer('00' + rnd + '00112233', 'hex');

  packed[0] = version;

  var hash = crypto.createHash('sha256').update(packed.slice(0, packed.length - 4)).digest();

  hash = crypto.createHash('sha256').update(hash).digest();

  packed[packed.length - 4] = hash[0];
  packed[packed.length - 3] = hash[1];
  packed[packed.length - 2] = hash[2];
  packed[packed.length - 1] = hash[3];

  return base58(packed);
}
668288
def address(self) -> str:
        ''''''

        return str(self._public_key.to_address(
                   net_query(self.network))
                   )
851824
public static byte[] generateContractAddress(byte[] address, BigInteger nonce) {
        List<RlpType> values = new ArrayList<>();

        values.add(RlpString.create(address));
        values.add(RlpString.create(nonce));
        RlpList rlpList = new RlpList(values);

        byte[] encoded = RlpEncoder.encode(rlpList);
        byte[] hashed = Hash.sha3(encoded);
        return Arrays.copyOfRange(hashed, 12, hashed.length);
    }
606084
def segwit_address(self):
        """"""
        # Only make segwit-address if all public keys are compressed
        if self._segwit_address is None and self.is_compressed:
            self._segwit_address = multisig_to_segwit_address(self.public_keys,
                self.m, version=self.version)
        return self._segwit_address
695218
def _get_address_by_hash(self, block_hash):
        
        address_key = address_prefix + block_hash
        return self.db.get(address_key)
119678
public static synchronized byte[] addressHash(byte[] pubkeyBytes) {
      try {
         byte[] sha256 = MessageDigest.getInstance(SHA256).digest(pubkeyBytes);
         byte[] out = new byte[20];
         ripeMD160.update(sha256, 0, sha256.length);
         ripeMD160.doFinal(out, 0); // This also resets the hash function for
                                    // next use
         return out;
      } catch (NoSuchAlgorithmException e) {
         throw new RuntimeException(e); // Cannot happen.
      }
   }
285726
def _make_pkh_address(pubkey_hash, witness=False, cashaddr=True):
    '''
    
    '''
    addr_bytes = bytearray()
    if riemann.network.CASHADDR_P2PKH is not None and cashaddr:
        addr_bytes.extend(riemann.network.CASHADDR_P2PKH)
        addr_bytes.extend(pubkey_hash)
        return riemann.network.CASHADDR_ENCODER.encode(addr_bytes)
    if witness:
        addr_bytes.extend(riemann.network.P2WPKH_PREFIX)
        addr_bytes.extend(pubkey_hash)
        return riemann.network.SEGWIT_ENCODER.encode(addr_bytes)
    else:
        addr_bytes.extend(riemann.network.P2PKH_PREFIX)
        addr_bytes.extend(pubkey_hash)
        return riemann.network.LEGACY_ENCODER.encode(addr_bytes)
421614
def p2pkh(self, s):
        
        data = self.parse_b58_hashed(s)
        if data is None or not data.startswith(self._address_prefix):
            return None
        size = len(self._address_prefix)
        script = self._network.contract.for_p2pkh(data[size:])
        script_info = self._network.contract.info_for_script(script)
        return Contract(script_info, self._network)
1232128
def address_reencode(address, blockchain='bitcoin', **blockchain_opts):
    
    if blockchain == 'bitcoin':
        return btc_address_reencode(address, **blockchain_opts)
    else:
        raise ValueError("Unknown blockchain '{}'".format(blockchain))
915464
def randomwif(prefix, num):
    
    from bitsharesbase.account import PrivateKey

    t = [["wif", "pubkey"]]
    for n in range(0, num):
        wif = PrivateKey()
        t.append([str(wif), format(wif.pubkey, prefix)])
    print_table(t)
24442
def get_address(pk, main_net=True, prefix=None):
    
    if isinstance(pk, str):
        pk = unhexlify(pk.encode())
    assert len(pk) == 32, 'PK is 32bytes {}'.format(len(pk))
    k = keccak_256(pk).digest()
    ripe = RIPEMD160.new(k).digest()
    if prefix is None:
        body = (b"\x68" if main_net else b"\x98") + ripe
    else:
        assert isinstance(prefix, bytes), 'Set prefix 1 bytes'
        body = prefix + ripe
    checksum = keccak_256(body).digest()[0:4]
    return b32encode(body + checksum).decode()
9454
public static function fromPrivateKey(EccPrivateKey $privateKey, AbstractNetwork $network = null): string
    {
        $digest = Hash::ripemd160($privateKey->getPublicKey()->getBuffer());

        return (new PayToPubKeyHashAddress($digest))->getAddress($network);
    }
346677
def p2sh_p2pkh_script(network: str, address: str) -> P2shScript:
    ''''''

    network_params = net_query(network)

    addr = Address.from_string(network=network_params,
                               string=address)

    p2pkh = P2pkhScript(addr)

    return P2shScript(p2pkh)
594644
def get_nonzero_random_bytes(length, rnd=default_crypto_random):
    '''
       
    '''
    result = []
    i = 0
    while i < length:
        rnd = rnd.getrandbits(12*length)
        s = i2osp(rnd, 3*length)
        s = s.replace('\x00', '')
        result.append(s)
        i += len(s)
    return (''.join(result))[:length]
140915
def address_in_network(ip, net):
    
    ipaddr = struct.unpack('=L', socket.inet_aton(ip))[0]
    netaddr, bits = net.split('/')
    netmask = struct.unpack('=L', socket.inet_aton(dotted_netmask(int(bits))))[0]
    network = struct.unpack('=L', socket.inet_aton(netaddr))[0] & netmask
    return (ipaddr & netmask) == (network & netmask)
186012
private static String computeKeyHash(String memcachedPrefix, NamedKey key)
  {
    // hash keys to keep things under 250 characters for memcached
    return memcachedPrefix + ":" + DigestUtils.sha1Hex(key.namespace) + ":" + DigestUtils.sha1Hex(key.key);
  }
832182
function Address(options) {
  if (!(this instanceof Address))
    return new Address(options);

  this.hash = encoding.ZERO_HASH160;
  this.type = Address.types.PUBKEYHASH;
  this.version = -1;
  this.network = Network.primary;

  if (options)
    this.fromOptions(options);
}