-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscript.txt
59 lines (45 loc) · 2.01 KB
/
script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copy taproot, merkle root and "inner" internal key (the key before it has
# been tweaked with the commitment) to alt stack.
OP_3DUP OP_ROT OP_TOALTSTACK OP_TOALTSTACK OP_TOALTSTACK
OP_ROT OP_ROT
# Check input internal key is [x] tweaked with d = merkleroot, and t = taproot.
# [t][x][d][index][flags]
81 # index -1 means current index
01 # check input flag
OP_CHECKCONTRACTVERIFY
# On alt stack we now have the committed taproot and merkle root, and the input
# inner internal key (we keep it for later since we'll verify that the output
# internal key is the same)
# Push the hash of 0x01 to the alt stack.
# This will be the new merkle leaf (indicating the pubkey is no longer part of
# the pool).
01 OP_SHA256 OP_TOALTSTACK
OP_OVER OP_CHECKSIGVERIFY
# Calculate hash of pubkey:value
OP_CAT OP_SHA256
# Use merkle sibling together with new leaf on alt stack to find new merkle
# node and push it to the altstack.
OP_3DUP OP_DROP OP_FROMALTSTACK
OP_SWAP OP_IF OP_SWAP OP_ENDIF OP_CAT OP_SHA256 OP_TOALTSTACK
# Do the same with the current merkle leaf.
OP_SWAP OP_IF OP_SWAP OP_ENDIF OP_CAT OP_SHA256
# Same for next level in the tree.
OP_3DUP OP_DROP OP_FROMALTSTACK
OP_SWAP OP_IF OP_SWAP OP_ENDIF OP_CAT OP_SHA256 OP_TOALTSTACK
OP_SWAP OP_IF OP_SWAP OP_ENDIF OP_CAT OP_SHA256
# Now we're at the top, so check merkle root against what we was committed in
# the input.
OP_FROMALTSTACK OP_FROMALTSTACK OP_SWAP OP_TOALTSTACK
OP_EQUALVERIFY
# ==================== END Claim [value1, preimage1] ==========================
# New merkle root, existing taproot and "inner" internal key is now on alt stack
OP_FROMALTSTACK OP_FROMALTSTACK OP_FROMALTSTACK
# Move stack order to [t][x][d]
OP_ROT
# Check input internal key is [x] tweaked with d = merkleroot, and t = taproot.
# [t][x][d][index][flags]
81 # index -1 means current index
02 # check output flag, disable amount check. We currently have no way to verify that the output is exatcly input-exitbalance.
OP_CHECKCONTRACTVERIFY
# Add 1 to stack for script to successfully finish.
OP_1