Package org.bitcoinj.crypto
Class DumpedPrivateKey
- java.lang.Object
-
- org.bitcoinj.crypto.EncodedPrivateKey
-
- org.bitcoinj.crypto.DumpedPrivateKey
-
public class DumpedPrivateKey extends EncodedPrivateKey
Parses and generates private keys in the form used by the Bitcoin "dumpprivkey" command. This is the private key bytes with a header byte and 4 checksum bytes at the end. If there are 33 private key bytes instead of 32, then the last byte is a discriminator value for the compressed pubkey.
-
-
Field Summary
-
Fields inherited from class org.bitcoinj.crypto.EncodedPrivateKey
bytes, network
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DumpedPrivateKey
fromBase58(Network network, java.lang.String base58)
Construct a private key from its Base58 representation.static DumpedPrivateKey
fromBase58(NetworkParameters params, java.lang.String base58)
Deprecated.ECKey
getKey()
Returns an ECKey created from this encoded private key.boolean
isPubKeyCompressed()
Returns true if the public key corresponding to this private key is compressed.java.lang.String
toBase58()
Returns the base58-encoded textual form, including version and checksum bytes.java.lang.String
toString()
-
Methods inherited from class org.bitcoinj.crypto.EncodedPrivateKey
equals, getParameters, hashCode, network
-
-
-
-
Method Detail
-
fromBase58
public static DumpedPrivateKey fromBase58(@Nullable Network network, java.lang.String base58) throws AddressFormatException, AddressFormatException.WrongNetwork
Construct a private key from its Base58 representation.- Parameters:
network
- The expected Network or null if you don't want validation.base58
- The textual form of the private key.- Throws:
AddressFormatException
- if the given base58 doesn't parse or the checksum is invalidAddressFormatException.WrongNetwork
- if the given private key is valid but for a different chain (e.g. testnet vs mainnet)
-
fromBase58
@Deprecated public static DumpedPrivateKey fromBase58(@Nullable NetworkParameters params, java.lang.String base58) throws AddressFormatException, AddressFormatException.WrongNetwork
Deprecated.Construct a private key from its Base58 representation.- Parameters:
params
- The expected Network or null if you don't want validation.base58
- The textual form of the private key.- Throws:
AddressFormatException
- if the given base58 doesn't parse or the checksum is invalidAddressFormatException.WrongNetwork
- if the given private key is valid but for a different chain (e.g. testnet vs mainnet)
-
toBase58
public java.lang.String toBase58()
Returns the base58-encoded textual form, including version and checksum bytes.- Returns:
- textual form
-
getKey
public ECKey getKey()
Returns an ECKey created from this encoded private key.
-
isPubKeyCompressed
public boolean isPubKeyCompressed()
Returns true if the public key corresponding to this private key is compressed.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-