Accumulator MultiSig
可选择参与者的门限多签样板。
这个示例在 if/else 分支中使用了 alt stack 操作,编译时请加 --asa 或 --allow-subscope-altstack。
txt
# 这里预留三个公钥槽位,`masks` 用来选择本次参与花费的槽位。
Contract AccumulatorMultiSig:
def main(sigs: hex[3], pubKeys: hex[3], masks: bool[3]):
# 逐个检查被选中的槽位,并把累计数量暂存在副栈。
total = Push(0)
SetAlt(total)
for i in Range(2, -1, -1):
if masks[i] == 1:
SetMain(total)
if And(Equal(Hash160(pubKeys[i].Clone()), self.addr[i]), CheckSig(sigs[i], pubKeys[i])):
total = total + 1
SetAlt(total)
else:
total = total + 0
SetAlt(total)
else:
Delete(pubKeys[i])
Delete(sigs[i])
# 最终通过验证的数量必须达到预设门限。
SetMain(total)
NumEqualVerify(GreaterOrEqual(total, self.threshold), 1)