Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Wif

  1. Object
  2. Wif
Wallet Import Format: a private key in Base58Check, the form paper wallets and dumpprivkey use. The trailing 0x01 flag says the key’s addresses use the compressed public key.

Methods

public static String encode(byte[] privateKey, boolean compressed, BitcoinNetwork network)Encodes a private key.
public static Wif decode(String wif, BitcoinNetwork network)Decodes a WIF string of the given network.
public byte[] getPrivateKey()A copy of the private key.
public boolean isCompressed()Tells whether the key’s addresses use the compressed public key.
public byte[] getPublicKey()The public key in the form the flag selects.
public BitcoinNetwork getNetwork()The network.
public void destroy()Wipes the private key.

Inherited methods

Method details

encode

public static String encode(byte[] privateKey, boolean compressed, BitcoinNetwork network)
Encodes a private key.

decode

public static Wif decode(String wif, BitcoinNetwork network)
Decodes a WIF string of the given network.

Throws

IllegalArgumentException
for a malformed key, a bad checksum or another network

getPrivateKey

public byte[] getPrivateKey()
A copy of the private key. Wipe it after use.

isCompressed

public boolean isCompressed()
Tells whether the key’s addresses use the compressed public key.

getPublicKey

public byte[] getPublicKey()
The public key in the form the flag selects.

getNetwork

public BitcoinNetwork getNetwork()
The network.

destroy

public void destroy()
Wipes the private key.