forked from dev-protocol/Mecenas-recurring-payment-EC-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mecenas.spedn
executable file
·41 lines (35 loc) · 1.47 KB
/
mecenas.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
41
contract Mecenas(Ripemd160 pkh, Ripemd160 pkh2, int pledge) {
challenge protege(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 amount2 = num2bin(pledge, 8);
bin amount1 =num2bin(bin2num(value)-pledge - fee, 8);
bin opDup = 0x76;
bin opEqual = 0x87;
bin opHash160 = 0xa9;
bin pushHash = 0x14;
bin newVarInt1 = 0x17;
bin newVarInt2 = 0x19;
bin opEqualverify = 0x88;
bin opChecksig = 0xac;
bin [_, rawscr] = scriptCode @ 3;
verify checkSequence(30d);
verify bin2num(ver) >= 2;
bin out1 = amount1 . newVarInt1 . opHash160 . pushHash . hash160(rawscr) . opEqual ;
bin out2 = amount2 . newVarInt2 . opDup . opHash160 . pushHash . pkh . opEqualverify . opChecksig;
verify hash256(out1 . out2) == Sha256(hashOutput);
}
challenge mecenas(PubKey pk, Sig sig) {
verify hash160(pk) == pkh2;
verify checkSig(sig, pk);
}
}