3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Script: expose execute publicly

This commit is contained in:
Mike Hearn 2014-10-01 15:54:42 +02:00
parent a8f85d1158
commit ba4aeff2a5

View File

@ -723,7 +723,14 @@ public class Script {
return Utils.decodeMPI(Utils.reverseBytes(chunk), false); return Utils.decodeMPI(Utils.reverseBytes(chunk), false);
} }
private static void executeScript(Transaction txContainingThis, long index, /**
* Exposes the script interpreter. Normally you should not use this directly, instead use
* {@link org.bitcoinj.core.TransactionInput#verify(org.bitcoinj.core.TransactionOutput)} or
* {@link org.bitcoinj.script.Script#correctlySpends(org.bitcoinj.core.Transaction, long, Script)}. This method
* is useful if you need more precise control or access to the final state of the stack. This interface is very
* likely to change in future.
*/
public static void executeScript(@Nullable Transaction txContainingThis, long index,
Script script, LinkedList<byte[]> stack, boolean enforceNullDummy) throws ScriptException { Script script, LinkedList<byte[]> stack, boolean enforceNullDummy) throws ScriptException {
int opCount = 0; int opCount = 0;
int lastCodeSepLocation = 0; int lastCodeSepLocation = 0;
@ -1198,10 +1205,14 @@ public class Script {
break; break;
case OP_CHECKSIG: case OP_CHECKSIG:
case OP_CHECKSIGVERIFY: case OP_CHECKSIGVERIFY:
if (txContainingThis == null)
throw new IllegalStateException("Script attempted signature check but no tx was provided");
executeCheckSig(txContainingThis, (int) index, script, stack, lastCodeSepLocation, opcode); executeCheckSig(txContainingThis, (int) index, script, stack, lastCodeSepLocation, opcode);
break; break;
case OP_CHECKMULTISIG: case OP_CHECKMULTISIG:
case OP_CHECKMULTISIGVERIFY: case OP_CHECKMULTISIGVERIFY:
if (txContainingThis == null)
throw new IllegalStateException("Script attempted signature check but no tx was provided");
opCount = executeMultiSig(txContainingThis, (int) index, script, stack, opCount, lastCodeSepLocation, opcode, enforceNullDummy); opCount = executeMultiSig(txContainingThis, (int) index, script, stack, opCount, lastCodeSepLocation, opcode, enforceNullDummy);
break; break;
case OP_NOP1: case OP_NOP1: