When using the complex miniscript policy below, it yields the following type error.
TypeError: expecting bool or Boolean, not (2, [pk.dave, pk.eve, pk.frank]).
Snippet which raises the error:
if function_name in ['and', 'or']:
if len(function_args) != 2:
raise ValueError(f"Invalid number of arguments for {function_name}: {len(function_args)}")
left = miniscript_to_sympy(function_args[0])
right = miniscript_to_sympy(function_args[1])
return And(left, right) if function_name == 'and' else Or(left, right)
It looks like the problem is the way it handles thresh, which is creating a tuple, that works fine when thresh is the root function, but seems to break when it is a child function.
Idea: A possible solution maybe could be transforming the whole tuple in a string, or making it a symbol like functions which are not boolean, however it might break later functions.
A new idea involves parsing and simplifying from deeper threshs. Then, transform the entire thresh subfunctions into variables for later simplification in an upper level.
When using the complex miniscript policy below, it yields the following type error.
Snippet which raises the error:
Input:
miniscript = 'and(or(pk(alice),and(pk(bob),older(10080))),or(and(pk(charlie),sha256(h)),thresh(2,pk(dave),pk(eve),pk(frank))))'
It looks like the problem is the way it handles
thresh
, which is creating a tuple, that works fine when thresh is the root function, but seems to break when it is a child function.Idea: A possible solution maybe could be transforming the whole tuple in a string, or making it a symbol like functions which are not boolean, however it might break later functions.