Author

Topic: How to use script interpreter? (Read 615 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
March 14, 2017, 12:31:45 PM
#4
You are verifying the script incorrectly. The way that script verification works is that the scripts have to be spent. You take the input script and concatenate the output script it spends from to the end of the input script. That is the full script as the input script and the output script by themselves are not full scripts.
member
Activity: 138
Merit: 25
March 14, 2017, 06:57:06 AM
#3
OK - SCRIPT_VERIFY_P2SH
but when I interpret script OP_DUP OP_HASH160 N/A_20 [20 bytes] OP_EQUALVERIFY OP_CHECKSIG
is error: OP_DUP required non empty stack and I at start have empty stack.
In https://github.com/bitcoinbook/bitcoinbook/blob/first_edition/ch05.asciidoc#pay-to-script-hash-p2sh is
Quote
In the first few years of bitcoin’s development, the developers introduced some limitations in the types of scripts that could be processed by the reference client. These limitations are encoded in a function called isStandard(), which defines five types of "standard" transactions. These limitations are temporary and might be lifted by the time you read this. Until then, the five standard types of transaction scripts are the only ones that will be accepted by the reference client and most miners who run the reference client. Although it is possible to create a nonstandard transaction containing a script that is not one of the standard types, you must find a miner who does not follow these limitations to mine that transaction into a block.
But in blockchain I can found nonstandard.
Locking script is in output script
but where is unlocking? How interpret input scripts?
What is how much bytes have ?
newbie
Activity: 3
Merit: 0
March 14, 2017, 06:43:24 AM
#2
I have extracted file interpreter.cpp from Bitcoin sources with dependencies.
I call:
Code:
EvalScript(stack, scriptOut, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
scriptOut is "76a914592fc3990026334c8c6fb2b9da457179cdb5c68888ac":
OP_DUP OP_HASH160 N/A_20 [20 bytes] OP_EQUALVERIFY OP_CHECKSIG
But is error: at start, stack is empty and need OP_DUP opcode.
Next I try interpret input script, then output:
Code:
	int err = EvalScript(stack, scriptInp, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
err = EvalScript(stack, scriptOut, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
but is also badly.
How to use EvalScript and maybe VerifyScript instead?
p.s.I must use SCRIPT_VERIFY_STRICTENC or SCRIPT_VERIFY_NONE,SCRIPT_VERIFY_P2SH? class BaseSignatureChecker or TransactionSignatureChecker?
--Goal: acquire address from script (or addresses from multisig script) using Bitcoin script interperter

Try SCRIPT_VERIFY_P2SH, it should not cause any trouble
member
Activity: 138
Merit: 25
March 14, 2017, 06:26:02 AM
#1
I have extracted file interpreter.cpp from Bitcoin sources with dependencies.
I call:
Code:
EvalScript(stack, scriptOut, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
scriptOut is "76a914592fc3990026334c8c6fb2b9da457179cdb5c68888ac":
OP_DUP OP_HASH160 N/A_20 [20 bytes] OP_EQUALVERIFY OP_CHECKSIG
But is error: at start, stack is empty and need OP_DUP opcode.
Next I try interpret input script, then output:
Code:
	int err = EvalScript(stack, scriptInp, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
err = EvalScript(stack, scriptOut, SCRIPT_VERIFY_STRICTENC, BaseSignatureChecker(), SIGVERSION_BASE);
but is also badly.
How to use EvalScript and maybe VerifyScript instead?
p.s.I must use SCRIPT_VERIFY_STRICTENC or SCRIPT_VERIFY_NONE,SCRIPT_VERIFY_P2SH? class BaseSignatureChecker or TransactionSignatureChecker?
--Goal: acquire address from script (or addresses from multisig script) using Bitcoin script interperter
Jump to: