bitcoinerlab / descriptors

A TypeScript library for parsing Bitcoin Descriptors, including Miniscript-based ones. Streamlines creating Partially Signed Bitcoin Transactions (PSBTs) from Descriptors. Features BIP32, single-signature, and Hardware Wallet signing capabilities, and facilitates finalizing transactions.
https://bitcoinerlab.com/modules/descriptors
41 stars 14 forks source link

`sortedmulti` nestedn in `wsh`? #17

Closed serious-sammy closed 1 year ago

serious-sammy commented 1 year ago

This lib is lit, it's really cool! 🔥

It seems though there's only one problem - it doesn't appear to support sortedmulti nested in wsh.

So when I try to use an expression like "wsh(sortedmulti(2,[deadbeef/87'/0'/0']xpub.../0/*,[feedbeef/87'/0'/0']xpub.../0/*))#checksum", i get "Error: Miniscript sortedmulti(2,@0,@1) is not sane", but when I replace sortedmulti with just multi, it works, but, well, it's not sorted!

Am I using it wrong or is sortedmulti not yet fully supported?

Thanks 🙏🙏🙏

landabaso commented 1 year ago

Thank you for your kind words, @serious-sammy !

I will update the documentation with the supported scripts. In summary, any miniscript expression is supported in wsh(SCRIPT),sh(SCRIPT), or sh(wsh(SCRIPT)).

As a consequence, the following top-level fragments are currently NOT supported: sortedmulti, multi_a, sortedmulti_a, tr, raw and rawtr. Since sortedmulti is not a valid miniscript fragment, adding support for it would require a specialized solution.

Today I will evaluate how feasible it is to add support for sortedmulti, but unfortunately, I cannot provide a clear timeline. To be honest, I would prioritize adding support for taproot first, as it's a matter of bandwidth and resource focus. Meanwhile, have you tried using bitcoinjs-lib to see if it could help with your use case?

EDIT: After a cursory look, it looks like this should be pretty doable unless I missed something...