Package ch.bitagent.bitcoin.lib.script
Class Script
- java.lang.Object
-
- ch.bitagent.bitcoin.lib.script.Script
-
public class Script extends Object
Script class.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Scriptadd(Script other)add.Stringaddress(Boolean testnet)Returns the address corresponding to the scriptbooleanevaluate(Int z, Script witness)evaluate.List<ScriptCmd>getCmds()Getter for the fieldcmds.booleanisP2pkhScriptPubkey()Returns whether this follows the OP_DUP OP_HASH160 20 byte hash OP_EQUALVERIFY OP_CHECKSIG pattern.booleanisP2shScriptPubkey()Returns whether this follows the OP_HASH160 20 byte hash OP_EQUAL pattern.booleanisP2wpkhScriptPubkey()isP2wpkhScriptPubkey.booleanisP2wpkhStack(Deque<byte[]> stack)isP2wpkhStack.booleanisP2wshScriptPubkey()isP2wshScriptPubkey.booleanisP2wshStack(Deque<byte[]> stack)isP2wshStack.static ScriptopReturn(String data)https://learnmeabitcoin.com/technical/script/return/static Scriptp2pkhScript(byte[] h160, boolean... pushbytes)Takes a hash160 and returns the p2pkh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2pkh/static Scriptp2shScript(byte[] h160, boolean... pushbytes)Takes a hash160 and returns the p2sh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2sh/static Scriptp2trScript(byte[] tweakedPubkey, boolean... pushbytes)static Scriptp2wpkhScript(byte[] h160, boolean... pushbytes)Takes a hash160 and returns the p2wpkh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2wpkh/static Scriptparse(ByteArrayInputStream stream)parse.byte[]serialize()serialize.StringtoHex()toHexStringtoString()
-
-
-
Method Detail
-
p2pkhScript
public static Script p2pkhScript(byte[] h160, boolean... pushbytes)
Takes a hash160 and returns the p2pkh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2pkh/- Parameters:
h160- an array ofbyteobjectspushbytes- .- Returns:
- a
Scriptobject
-
p2shScript
public static Script p2shScript(byte[] h160, boolean... pushbytes)
Takes a hash160 and returns the p2sh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2sh/- Parameters:
h160- an array ofbyteobjectspushbytes- .- Returns:
- a
Scriptobject
-
p2wpkhScript
public static Script p2wpkhScript(byte[] h160, boolean... pushbytes)
Takes a hash160 and returns the p2wpkh ScriptPubKey https://learnmeabitcoin.com/technical/script/p2wpkh/- Parameters:
h160- an array ofbyteobjectspushbytes- .- Returns:
- a
Scriptobject
-
p2trScript
public static Script p2trScript(byte[] tweakedPubkey, boolean... pushbytes)
-
opReturn
public static Script opReturn(String data)
https://learnmeabitcoin.com/technical/script/return/- Parameters:
data- .- Returns:
- .
-
parse
public static Script parse(ByteArrayInputStream stream)
parse.
- Parameters:
stream- aByteArrayInputStreamobject- Returns:
- a
Scriptobject
-
serialize
public byte[] serialize()
serialize.
- Returns:
- an array of
byteobjects
-
isP2pkhScriptPubkey
public boolean isP2pkhScriptPubkey()
Returns whether this follows the OP_DUP OP_HASH160 20 byte hash OP_EQUALVERIFY OP_CHECKSIG pattern.- Returns:
- a boolean
-
isP2shScriptPubkey
public boolean isP2shScriptPubkey()
Returns whether this follows the OP_HASH160 20 byte hash OP_EQUAL pattern.- Returns:
- a boolean
-
isP2wpkhScriptPubkey
public boolean isP2wpkhScriptPubkey()
isP2wpkhScriptPubkey.
- Returns:
- a boolean
-
isP2wpkhStack
public boolean isP2wpkhStack(Deque<byte[]> stack)
isP2wpkhStack.
- Parameters:
stack- aDequeobject- Returns:
- a boolean
-
isP2wshScriptPubkey
public boolean isP2wshScriptPubkey()
isP2wshScriptPubkey.
- Returns:
- a boolean
-
isP2wshStack
public boolean isP2wshStack(Deque<byte[]> stack)
isP2wshStack.
- Parameters:
stack- aDequeobject- Returns:
- a boolean
-
toHex
public String toHex()
toHex- Returns:
- .
-
-