Skip to content

Instantly share code, notes, and snippets.

@reardencode
Last active February 9, 2024 18:26
Show Gist options
  • Save reardencode/fb35968977a09b48c909e9602eab4119 to your computer and use it in GitHub Desktop.
Save reardencode/fb35968977a09b48c909e9602eab4119 to your computer and use it in GitHub Desktop.
VAULT quine

VAULT quine:

op stack
START {1,0,<release_sig>}
<counter> <counter> {1,0,<release_sig>}
<leaf-update-script-body> <leaf-update-script-body> <counter> {1,-1,<release_sig>}
TOALTSTACK <counter> {1,0}
DUP <counter> <counter> {1,0,<release_sig>}
NOTIF <counter> <release_sig>
DROP <release_sig>
<relase_pubkey> <release_pubkey> <release_sig>
CHECKSIG {1,0}
ELSE <counter> {1,0}
SWAP {1,0} <counter>
IF <counter>
1ADD <next_counter>
ELSE <counter>
1SUB <next_counter>
ENDIF <next_counter>
0 0 <next_counter>
-1 -1 0 <next_counter>
0 0 -1 0 <next_counter>
3 3 0 -1 0 <next_counter>
ROLL <next_counter> 0 -1 0
FROMALTSTACK <leaf-update-script-body> <next_counter> 0 -1 0
DUP <leaf-update-script-body> <leaf-update-script-body> <next_counter> 0 -1 0
2 2 <leaf-update-script-body> <leaf-update-script-body> <next_counter> 0 -1 0
SWAP <leaf-update-script-body> 2 <leaf-update-script-body> <next_counter> 0 -1 0
VAULT 1
ENDIF {1,0}

Initial script: 0 -1 0 <initial_counter> 'TOALTSTACK DUP NOTIF DROP <release_pubkey> CHECKSIG ELSE SWAP IF 1ADD ELSE 1SUB ENDIF 0 -1 0 3 ROLL FROMALTSTACK DUP 2 SWAP VAULT ENDIF' DUP 2 SWAP OP_VAULT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment