-
Notifications
You must be signed in to change notification settings - Fork 6
/
LastWill.spedn
44 lines (33 loc) · 1.32 KB
/
LastWill.spedn
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
contract LastWill(Ripemd160 pkh, Ripemd160 pkh2, Ripemd160 pkh3) {
challenge refresh(PubKey pk, Sig sig, bin ver, bin hPhSo, bin scriptCode, bin value, bin nSequence, bin hashOutput, bin tail ) {
verify size(ver) == 4;
verify size(hPhSo) == 100;
verify size(value) == 8;
verify size(nSequence) == 4;
verify size(hashOutput) == 32;
verify size(tail) == 8;
verify hash160(pk) == pkh;
verify checkSig(sig, pk);
bin preimage = ver . hPhSo . scriptCode . value . nSequence . hashOutput . tail;
verify checkDataSig(toDataSig(sig), sha256(preimage), pk);
int fee = 1000;
bin amount= num2bin(bin2num(value) - fee, 8);
verify bin2num(ver) >= 2;
bin opEqual = 0x87;
bin opHash160 = 0xa9;
bin pushHash = 0x14;
bin newVarInt = 0x17;
bin [_, rawscr] = scriptCode @ 3;
verify checkSequence(7d);
verify hash256(amount . newVarInt . opHash160 . pushHash . hash160(rawscr) . opEqual ) == Sha256(hashOutput);
}
challenge cold(PubKey pk, Sig sig) {
verify hash160(pk) == pkh2;
verify checkSig(sig, pk);
}
challenge inherit(PubKey pk, Sig sig) {
verify checkSequence(180d);
verify hash160(pk) == pkh3;
verify checkSig(sig, pk);
}
}