def multisig_script(cls, public_keys, m): n = len(public_keys) assert n <= 15 assert m <= n op_m = format(opcodes.OP_1 + m - 1, 'x') op_n = format(opcodes.OP_1 + n - 1, 'x') keylist = [op_push(len(k) / 2) + k for k in public_keys] return op_m + ''.join(keylist) + op_n + 'ae'
def test_op_push(self): self.assertEqual(op_push(0x00), '00') self.assertEqual(op_push(0x12), '12') self.assertEqual(op_push(0x4b), '4b') self.assertEqual(op_push(0x4c), '4c4c') self.assertEqual(op_push(0xfe), '4cfe') self.assertEqual(op_push(0xff), '4dff00') self.assertEqual(op_push(0x100), '4d0001') self.assertEqual(op_push(0x1234), '4d3412') self.assertEqual(op_push(0xfffe), '4dfeff') self.assertEqual(op_push(0xffff), '4effff0000') self.assertEqual(op_push(0x10000), '4e00000100') self.assertEqual(op_push(0x12345678), '4e78563412')
def push_script(x): return op_push(len(x) / 2) + x