Package org.bitcoinj.base
Enum ScriptType
- java.lang.Object
-
- java.lang.Enum<ScriptType>
-
- org.bitcoinj.base.ScriptType
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ScriptType>
public enum ScriptType extends java.lang.Enum<ScriptType>
Supported Bitcoin script types and their script identifier strings. The script identifier string for aScriptType
is the "human-readable identifier string" of a Script Expression as defined in BIP 380. Only the subset of identifier strings defined in BIP 381 and BIP 382 map to validScriptType
instances.
-
-
Field Summary
Fields Modifier and Type Field Description int
id
Deprecated.UsenumericId()
or better yet useid()
to get a script identifier string
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.util.Optional<ScriptType>
find(java.lang.String id)
Use this method to create aScriptType
from a script identifier string that should be validated.java.lang.String
id()
Return the script identifier string for thisScriptType
.int
numericId()
Deprecated.Usingid()
to get a script identifier string is preferred.static ScriptType
of(java.lang.String id)
Use this method to create aScriptType
from a known good script identifier string.static ScriptType
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ScriptType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
P2PKH
public static final ScriptType P2PKH
-
P2PK
public static final ScriptType P2PK
-
P2SH
public static final ScriptType P2SH
-
P2WPKH
public static final ScriptType P2WPKH
-
P2WSH
public static final ScriptType P2WSH
-
P2TR
public static final ScriptType P2TR
-
-
Field Detail
-
id
@Deprecated public final int id
Deprecated.UsenumericId()
or better yet useid()
to get a script identifier string
-
-
Method Detail
-
values
public static ScriptType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ScriptType c : ScriptType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ScriptType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
of
public static ScriptType of(java.lang.String id)
Use this method to create aScriptType
from a known good script identifier string.- Parameters:
id
- A script identifier string- Returns:
- the script type
- Throws:
java.lang.IllegalArgumentException
- if unknown/invalid script identifier string
-
find
public static java.util.Optional<ScriptType> find(java.lang.String id)
Use this method to create aScriptType
from a script identifier string that should be validated.- Parameters:
id
- A script identifier string- Returns:
- A
ScriptType
-containingOptional
orOptional.empty()
-
id
public java.lang.String id()
Return the script identifier string for thisScriptType
.Be careful: the
id()
method returns a different type and value than what is in thedeprecated
id
field.- Returns:
- A script identifier string
-
-