Bitcoin Forum
May 23, 2024, 11:43:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to use script interpreter?  (Read 589 times)
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
March 14, 2017, 11: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
LensFlareProject
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
March 14, 2017, 11: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
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
March 14, 2017, 11:57:06 AM
Last edit: March 14, 2017, 01:05:10 PM by Frodek
 #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 <sig> how much bytes have <sig>?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6647


Just writing some code


View Profile WWW
March 14, 2017, 05: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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!