public class ScriptPattern
extends java.lang.Object
Constructor and Description |
---|
ScriptPattern() |
Modifier and Type | Method and Description |
---|---|
static java.math.BigInteger |
extractExpiryFromCltvPaymentChannel(Script script)
Retrieves the locktime from a LOCKTIMEVERIFY transaction.
|
static byte[] |
extractHashFromP2PKH(Script script)
Extract the pubkey hash from a P2PKH scriptPubKey.
|
static byte[] |
extractHashFromP2SH(Script script)
Extract the script hash from a P2SH scriptPubKey.
|
static byte[] |
extractHashFromP2WH(Script script)
Extract the pubkey hash from a P2WPKH or the script hash from a P2WSH scriptPubKey.
|
static byte[] |
extractKeyFromP2PK(Script script)
Extract the pubkey from a P2SH scriptPubKey.
|
static byte[] |
extractRecipientPubKeyFromCltvPaymentChannel(Script script)
Retrieves the public key of the recipient from a LOCKTIMEVERIFY transaction.
|
static byte[] |
extractSenderPubKeyFromCltvPaymentChannel(Script script)
Retrieves the public key of the sender from a LOCKTIMEVERIFY transaction.
|
static Sha256Hash |
extractWitnessCommitmentHash(Script script)
Retrieves the hash from a segwit commitment (in an output of the coinbase transaction).
|
static boolean |
isOpReturn(Script script)
Returns whether this script is using OP_RETURN to store arbitrary data.
|
static boolean |
isP2PK(Script script)
Returns true if this script is of the form
<pubkey> OP_CHECKSIG . |
static boolean |
isP2PKH(Script script)
Returns true if this script is of the form
DUP HASH160 <pubkey hash> EQUALVERIFY CHECKSIG , ie, payment to an
address like 1VayNert3x1KzbpzMGt2qdqrAThiRovi8 . |
static boolean |
isP2SH(Script script)
Whether or not this is a scriptPubKey representing a P2SH output.
|
static boolean |
isP2WH(Script script)
Returns true if this script is of the form
OP_0 <hash> . |
static boolean |
isP2WPKH(Script script)
Returns true if this script is of the form
OP_0 <hash> and hash is 20 bytes long. |
static boolean |
isP2WSH(Script script)
Returns true if this script is of the form
OP_0 <hash> and hash is 32 bytes long. |
static boolean |
isSentToCltvPaymentChannel(Script script)
Returns whether this script matches the format used for LOCKTIMEVERIFY transactions.
|
static boolean |
isSentToMultisig(Script script)
Returns whether this script matches the format used for multisig outputs:
[n] [keys...] [m] CHECKMULTISIG |
static boolean |
isWitnessCommitment(Script script)
Returns whether this script matches the pattern for a segwit commitment (in an output of the coinbase
transaction).
|
public static boolean isP2PKH(Script script)
DUP HASH160 <pubkey hash> EQUALVERIFY CHECKSIG
, ie, payment to an
address like 1VayNert3x1KzbpzMGt2qdqrAThiRovi8
. This form was originally intended for the case where you wish
to send somebody money with a written code because their node is offline, but over time has become the standard
way to make payments due to the short and recognizable base58 form addresses come in.public static byte[] extractHashFromP2PKH(Script script)
isP2PKH(Script)
.public static boolean isP2SH(Script script)
Whether or not this is a scriptPubKey representing a P2SH output. In such outputs, the logic that controls reclamation is not actually in the output at all. Instead there's just a hash, and it's up to the spending input to provide a program matching that hash.
P2SH is described by BIP16.
public static byte[] extractHashFromP2SH(Script script)
isP2SH(Script)
.public static boolean isP2PK(Script script)
<pubkey> OP_CHECKSIG
. This form was originally intended for transactions
where the peers talked to each other directly via TCP/IP, but has fallen out of favor with time due to that mode
of operation being susceptible to man-in-the-middle attacks. It is still used in coinbase outputs and can be
useful more exotic types of transaction, but today most payments are to addresses.public static byte[] extractKeyFromP2PK(Script script)
isP2PK(Script)
.public static boolean isP2WH(Script script)
OP_0 <hash>
. This can either be a P2WPKH or P2WSH scriptPubKey. These
two script types were introduced with segwit.public static boolean isP2WPKH(Script script)
OP_0 <hash>
and hash is 20 bytes long. This can only be a P2WPKH
scriptPubKey. This script type was introduced with segwit.public static boolean isP2WSH(Script script)
OP_0 <hash>
and hash is 32 bytes long. This can only be a P2WSH
scriptPubKey. This script type was introduced with segwit.public static byte[] extractHashFromP2WH(Script script)
isP2WH(Script)
.public static boolean isSentToMultisig(Script script)
[n] [keys...] [m] CHECKMULTISIG
public static boolean isSentToCltvPaymentChannel(Script script)
public static byte[] extractSenderPubKeyFromCltvPaymentChannel(Script script)
isSentToCltvPaymentChannel(Script)
.public static byte[] extractRecipientPubKeyFromCltvPaymentChannel(Script script)
isSentToCltvPaymentChannel(Script)
.public static java.math.BigInteger extractExpiryFromCltvPaymentChannel(Script script)
isSentToCltvPaymentChannel(Script)
.public static boolean isOpReturn(Script script)
public static boolean isWitnessCommitment(Script script)
public static Sha256Hash extractWitnessCommitmentHash(Script script)