Skip to content

Conversation

maurermi
Copy link

Description

Supports execution of multiple scripts chained together

Overview

Thanks for creating this project, I have found it quite nice to use recently in an educational context.

Made a very small addition that I have found useful, which just reads in multiple files concatenated together. This was nice for the question of "does script X unlock script Y". Figured I'd PR it in case it's useful for others!

Testing

Try writing up two scripts and execute them together
Ex.

# makes-eight.bs
OP_1
OP_DUP
OP_ADD
OP_DUP
OP_ADD
OP_DUP
OP_ADD
# checks-equal-to-eight.bs
OP_8
OP_EQUAL

Executing:

$ btcexec ./makes-eight.bs ./checks-equal-to-eight.bs
Script in hex: 517693769376935887
Script size: 9 bytes
--------------------------------------------------
Execution ended. Success: true
Final stack: <01>
Stats:
ExecStats {
    max_nb_stack_items: 2,
    opcode_count: 0,
    start_validation_weight: 51,
    validation_weight: 51,
}
Time elapsed: 0ms

Executing with --debug

)$ btcexec ./makes-eight.bs ./checks-equal-to-eight.bs --debug
Script in hex: 517693769376935887
Script size: 9 bytes
--------------------------------------------------
Remaining script: OP_PUSHNUM_1 OP_DUP OP_ADD OP_DUP OP_ADD OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: 
AltStack: 
--------------------------------------------------
Remaining script: OP_DUP OP_ADD OP_DUP OP_ADD OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <01>
AltStack: 
--------------------------------------------------
Remaining script: OP_ADD OP_DUP OP_ADD OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <01> <01>
AltStack: 
--------------------------------------------------
Remaining script: OP_DUP OP_ADD OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <02>
AltStack: 
--------------------------------------------------
Remaining script: OP_ADD OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <02> <02>
AltStack: 
--------------------------------------------------
Remaining script: OP_DUP OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <04>
AltStack: 
--------------------------------------------------
Remaining script: OP_ADD OP_PUSHNUM_8 OP_EQUAL
Stack: <04> <04>
AltStack: 
--------------------------------------------------
Remaining script: OP_PUSHNUM_8 OP_EQUAL
Stack: <08>
AltStack: 
--------------------------------------------------
Remaining script: OP_EQUAL
Stack: <08> <08>
AltStack: 
--------------------------------------------------
Remaining script: 
Stack: <01>
AltStack: 
--------------------------------------------------
Execution ended. Success: true
Final stack: <01>
Stats:
ExecStats {
    max_nb_stack_items: 2,
    opcode_count: 0,
    start_validation_weight: 51,
    validation_weight: 51,
}
Time elapsed: 0ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant