|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.bitcoin.core.Script
public class Script
BitCoin transactions don't specify what they do directly. Instead a small binary stack language is used to define programs that when evaluated return whether the transaction "accepts" or rejects the other transactions connected to it.
This implementation of the scripting language is incomplete. It contains enough support to run standard transactions generated by the official client, but non-standard transactions will fail.
Field Summary | |
---|---|
static int |
OP_CHECKSIG
|
static int |
OP_DUP
|
static int |
OP_EQUALVERIFY
|
static int |
OP_HASH160
|
static int |
OP_PUSHDATA1
|
static int |
OP_PUSHDATA2
|
static int |
OP_PUSHDATA4
|
Constructor Summary | |
---|---|
Script(NetworkParameters params,
byte[] programBytes,
int offset,
int length)
Construct a Script using the given network parameters and a range of the programBytes array. |
Method Summary | |
---|---|
Address |
getFromAddress()
Convenience wrapper around getPubKey. |
byte[] |
getPubKey()
If a program has two data buffers (constants) and nothing else, the second one is returned. |
byte[] |
getPubKeyHash()
If a program matches the standard template DUP HASH160 |
Address |
getToAddress()
Gets the destination address from this script, if it's in the required form (see getPubKey). |
boolean |
isSentToIP()
Returns true if this transaction is of a format that means it was a direct IP to IP transaction. |
static Script |
join(Script a,
Script b)
Concatenates two scripts to form a new one. |
boolean |
run(Transaction context)
Runs the script with the given Transaction as the "context". |
void |
setTracing(boolean value)
If true, running a program will log its instructions. |
String |
toString()
Returns the program opcodes as a string, for example "[1234] DUP HAHS160" |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int OP_PUSHDATA1
public static final int OP_PUSHDATA2
public static final int OP_PUSHDATA4
public static final int OP_DUP
public static final int OP_HASH160
public static final int OP_EQUALVERIFY
public static final int OP_CHECKSIG
Constructor Detail |
---|
public Script(NetworkParameters params, byte[] programBytes, int offset, int length) throws ScriptException
params
- Network parameters.programBytes
- Array of program bytes from a transaction.offset
- How many bytes into programBytes to start reading from.length
- How many bytes to read.
ScriptException
Method Detail |
---|
public static Script join(Script a, Script b) throws ScriptException
ScriptException
public void setTracing(boolean value)
public String toString()
toString
in class Object
public boolean isSentToIP()
public byte[] getPubKeyHash() throws ScriptException
ScriptException
public byte[] getPubKey() throws ScriptException
ScriptException
public Address getFromAddress() throws ScriptException
ScriptException
public Address getToAddress() throws ScriptException
ScriptException
public boolean run(Transaction context) throws ScriptException
ScriptException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |