This adds a new multi_a(k,key_1,key_2,...,key_n)
(and corresponding sortedmulti_a
) descriptor for k-of-n policies inside tr()
. Semantically it is very similar to the existing multi()
descriptor, but with the following changes:
- The corresponding script is
<key1> OP_CHECKSIG <key2> OP_CHECKSIGADD <key3> OP_CHECKSIGADD ... <key_n> OP_CHECKSIGADD <k> OP_NUMEQUAL
, rather than the traditionalOP_CHECKMULTISIG
-based script, making it usable inside thetr()
descriptor. - The keys can optionally be specified in x-only notation.
- Both the number of keys and the threshold can be as high as 999; this is the limit due to the consensus stacksize=1000 limit
I expect that this functionality will later be replaced with a miniscript-based implementation, but I don’t think it’s necessary to wait for that.
Limitations:
- The wallet code will for not estimate witness size incorrectly for script path spends, which may result in a (dramatic) fee underpayment with large multi_a scripts.
- The multi_a script construction is (slightly) suboptimal for n-of-n (where a
<key1> OP_CHECKSIGVERIFY ... <key_n-1> OP_CHECKSIGVERIFY <key_n> OP_CHECKSIG
would be better). Such a construction is not included here.