{"number":387,"title":"Tapscript Multisig Output Script Descriptors","authors":["Pieter Wuille","Ava Chow"],"status":"Deployed","type":"Specification","layer":"Applications","created":"2024-04-17","license":"BSD-2-Clause","requires":[380],"replaces":[],"replacedBy":[],"discussion":[],"abstract":"This document specifies multi_a() and sortedmulti_a() output script descriptors. Like BIP 383's multi() and sortedmulti() , both functions take a threshold and one or more public keys and produce a multisig script. The primary distinction is that multi_a() and sortedmulti_a() only produce tapscripts and are only allowed in a tapscript context.","eli5":"Defines descriptor functions for multisignature setups inside Taproot scripts, which require a different construction than older multisig. One form keeps keys in the given order and the other sorts them, helping wallets describe Taproot multisig wallets consistently.","categories":["transactions"],"filename":"bip-0387.mediawiki","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0387.mediawiki","format":"mediawiki","readingMinutes":2,"inbound":1,"revisions":8,"impact":33,"core":false,"references":[],"lastModified":"2026-09-17","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>This document specifies <code>multi_a()</code> and <code>sortedmulti_a()</code> output script descriptors. Like BIP 383's <code>multi()</code> and <code>sortedmulti()</code>, both functions take a threshold and one or more public keys and produce a multisig script. The primary distinction is that <code>multi_a()</code> and <code>sortedmulti_a()</code> only produce tapscripts and are only allowed in a tapscript context.</p>\n<h2 id=\"copyright\">Copyright</h2>\n<p>This BIP is licensed under the BSD 2-clause license.</p>\n<h2 id=\"motivation\">Motivation</h2>\n<p>The most common complex script used in Bitcoin is a threshold multisig. These expressions allow specifying multisig scripts as a descriptor.</p>\n<h2 id=\"specification\">Specification</h2>\n<p>Two new script expressions are defined: <code>multi_a()</code> and <code>sortedmulti_a()</code>. Both expressions produce the scripts of the same template and take the same arguments. They are written as <code>multi_a(k,KEY_1,KEY_2,...,KEY_n)</code>. <code>k</code> is the threshold - the number of keys that must sign the input for the script to be valid. <code>KEY_1,KEY_2,...,KEY_n</code> are the key expressions for the multisig. <code>k</code> must be less than or equal to <code>n</code>.</p>\n<p><code>multi_a()</code> and <code>sortedmulti_a()</code> expressions can only be used inside of a <code>tr()</code> descriptor. The maximum number of keys is 999.</p>\n<p>The output script produced also depends on the value of <code>k</code>. If <code>k</code> is less than or equal to 16:</p>\n<pre><code>KEY_1 OP_CHECKSIG KEY_2 OP_CHECKSIGADD ... KEY_n OP_CHECKSIGADD OP_k OP_NUMEQUAL</code></pre>\n<p>if <code>k</code> is greater than 16:</p>\n<pre><code>KEY_1 OP_CHECKSIG KEY_2 OP_CHECKSIGADD ... KEY_n OP_CHECKSIGADD k OP_NUMEQUAL</code></pre>\n<h3 id=\"sortedmulti-a\"><code>sortedmulti_a()</code></h3>\n<p>The only change for <code>sortedmulti_a()</code> is that the x-only public keys are sorted lexicographically prior to the creation of the output script. This sorting is on the keys that are to be put into the output script, i.e. after all extended keys are derived.</p>\n<h3 id=\"multiple-extended-keys\">Multiple Extended Keys</tt></h3>\n<p>When one or more of the key expressions in a <code>multi_a()</code> or <code>sortedmulti_a()</code> expression are extended keys, the derived keys use the same child index. This changes the keys in lockstep and allows for output scripts to be indexed in the same way that the derived keys are indexed.</p>\n<h2 id=\"test-vectors\">Test Vectors</h2>\n<p>Valid descriptors followed by the scripts they produce. Descriptors involving derived child keys will have the 0th, 1st, and 2nd scripts listed.</p>\n<ul><li>\n<code>tr(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1,multi_a(1,KzoAz5CanayRKex3fSLQ2BwJpN7U52gZvxMyk78nDMHuqrUxuSJy))</code>\n<ul><li>\n<code>5120eb5bd3894327d75093891cc3a62506df7d58ec137fcd104cdd285d67816074f3</code>\n</li></ul>\n</li><li>\n<code>tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,multi_a(1,669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))</code>\n<ul><li>\n<code>5120eb5bd3894327d75093891cc3a62506df7d58ec137fcd104cdd285d67816074f3</code>\n</li></ul>\n</li><li>\n<code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(2,[00000000/111'/222]xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc,xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0))</code>\n<ul><li>\n<code>51202eea93581594a43c0c8423b70dc112e5651df63984d108d4fc8ccd3b63b4eafa</code>\n</li></ul>\n</li><li>\n<code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,sortedmulti_a(2,[00000000/111'/222]xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc,xprv9uPDJpEQgRQfDcW7BkF7eTya6RPxXeJCqCJGHuCJ4GiRVLzkTXBAJMu2qaMWPrS7AANYqdq6vcBcBUdJCVVFceUvJFjaPdGZ2y9WACViL4L/0))</code>\n<ul><li>\n<code>512016fa6a6ba7e98c54b5bf43b3144912b78a61b60b02f6a74172b8dcb35b12bc30</code>\n</li></ul>\n</li><li>\n<code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,sortedmulti_a(2,xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/*,xpub68NZiKmJWnxxS6aaHmn81bvJeTESw724CRDs6HbuccFQN9Ku14VQrADWgqbhhTHBaohPX4CjNLf9fq9MYo6oDaPPLPxSb7gwQN3ih19Zm4Y/0/0/*))</code>\n<ul><li>\n<code>5120abd47468515223f58a1a18edfde709a7a2aab2b696d59ecf8c34f0ba274ef772</code>\n</li></ul>\n<ul><li>\n<code>5120fe62e7ed20705bd1d3678e072bc999acb014f07795fa02cb8f25a7aa787e8cbd</code>\n</li></ul>\n<ul><li>\n<code>51201311093750f459039adaa2a5ed23b0f7a8ae2c2ffb07c5390ea37e2fb1050b41</code>\n</li></ul>\n</li><li>\n<code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(2,xprv9s21ZrQH143K31xYSDQpPDxsXRTUcvj2iNHm5NUtrGiGG5e2DtALGdso3pGz6ssrdK4PFmM8NSpSBHNqPqm55Qn3LqFtT2emdEXVYsCzC2U/2147483647'/0,xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKYnjwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt/1/2/*,xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi/10/20/30/40/*'))</code>\n<ul><li>\n<code>5120e4c8f2b0a7d3a688ac131cb03248c0d4b0a59bbd4f37211c848cfbd22a981192</code>\n</li></ul>\n<ul><li>\n<code>5120827faedaa21e52fca2ac83b53afd1ab7d4d1e6ce67ff42b19f2723d48b5a19ab</code>\n</li></ul>\n<ul><li>\n<code>5120647495ed09de61a3a324704f9203c130d655bf3141f9b748df8f7be7e9af55a4</code>\n</li></ul>\n</li></ul>\n<p>Invalid descriptors</p>\n<ul><li>\nUnsupported top level: <code>multi_a(1,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0)</code>\n</li></ul>\n<ul><li>\nUnsupported <code>sh()</code> context: <code>sh(multi_a(1,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))</code>\n</li></ul>\n<ul><li>\nUnsupported <code>wsh()</code> context: <code>wsh(multi_a(1,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))</code>\n</li></ul>\n<ul><li>\nInvalid threshold: <code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(a,03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n</li></ul>\n<ul><li>\nThreshold of 0: <code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(0,03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd))</code>\n</li></ul>\n<ul><li>\nUncompressed pubkey: <code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(1,04a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235))</code>\n</li></ul>\n<ul><li>\nThreshold larger than keys: <code>tr(50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,multi_a(3,L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1,5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss))</code>\n</li></ul>\n<h2 id=\"backwards-compatibility\">Backwards Compatibility</h2>\n<p><code>multi_a()</code> and <code>sortedmulti_a()</code> descriptors use the format and general operation specified in <a href=\"/bip/380\">380</a>. As these are wholly new descriptors, they are not compatible with any implementation. However, the scripts produced are standard scripts, so existing software are likely to be familiar with them.</p>\n<h2 id=\"reference-implementation\">Reference Implementation</h2>\n<p><code>multi_a()</code> and <code>sortedmulti_a()</code> descriptors were implemented in Bitcoin Core in <a href=\"https://github.com/bitcoin/bitcoin/pull/24043\">https://github.com/bitcoin/bitcoin/pull/24043</a> and have been available since version 24.0.</p>","toc":[{"id":"abstract","title":"Abstract","level":2},{"id":"copyright","title":"Copyright","level":2},{"id":"motivation","title":"Motivation","level":2},{"id":"specification","title":"Specification","level":2},{"id":"sortedmulti-a","title":"sortedmulti_a()","level":3},{"id":"multiple-extended-keys","title":"Multiple Extended Keys","level":3},{"id":"test-vectors","title":"Test Vectors","level":2},{"id":"backwards-compatibility","title":"Backwards Compatibility","level":2},{"id":"reference-implementation","title":"Reference Implementation","level":2}],"history":{"totalCommits":8,"firstCommit":"2024-04-17T18:25:00-04:00","lastUpdated":"2026-09-17T15:04:28+02:00","events":[{"sha":"3ac7c77174780bea5aa8999b1cf205f98da2ab46","date":"2026-09-17T15:04:28+02:00","author":"Daniela Brozzoni","message":"bip387: Update to Specification type","url":"https://github.com/bitcoin/bips/commit/3ac7c77174780bea5aa8999b1cf205f98da2ab46","kind":"edit"},{"sha":"24e96e870fffaa257b465ce1f0370c14aac588e8","date":"2025-10-08T14:59:36-07:00","author":"Murch","message":"process: Created ↦ Assigned","url":"https://github.com/bitcoin/bips/commit/24e96e870fffaa257b465ce1f0370c14aac588e8","kind":"edit"},{"sha":"5207ef92a52d0b8902895b0dbb40823a4d698ec9","date":"2025-04-11T20:08:17-07:00","author":"Murch","message":"process: Author ↦ Authors","url":"https://github.com/bitcoin/bips/commit/5207ef92a52d0b8902895b0dbb40823a4d698ec9","kind":"edit"},{"sha":"59730dec4fb641a41589aa1b91d3c452f13e0e36","date":"2025-04-11T20:05:13-07:00","author":"Murch","message":"process: Remove Comments-URI and -Summary","url":"https://github.com/bitcoin/bips/commit/59730dec4fb641a41589aa1b91d3c452f13e0e36","kind":"edit"},{"sha":"5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","date":"2025-04-11T18:08:44-07:00","author":"Murch","message":"process: Final/Active ↦ Deployed","url":"https://github.com/bitcoin/bips/commit/5d3ceb37734f80b2ec206fc94245e3bfd6d5b0f0","kind":"status"},{"sha":"bc66fdb1664781eacfa23c9077f268eb918103e2","date":"2025-06-18T14:56:02-07:00","author":"Ava Chow","message":"descriptors: Require BIP 380","url":"https://github.com/bitcoin/bips/commit/bc66fdb1664781eacfa23c9077f268eb918103e2","kind":"edit"},{"sha":"d71428ade56ad9a90e18d643eefefefb6088fbd7","date":"2024-07-10T19:02:19-04:00","author":"Ava Chow","message":"380-387: Mark basic descriptor BIPs as final","url":"https://github.com/bitcoin/bips/commit/d71428ade56ad9a90e18d643eefefefb6088fbd7","kind":"status"},{"sha":"945b281155f12d50be76ade722cbb1a04681caa0","date":"2024-04-17T18:25:00-04:00","author":"Ava Chow","message":"BIP 387: multi_a() descriptor","url":"https://github.com/bitcoin/bips/commit/945b281155f12d50be76ade722cbb1a04681caa0","kind":"edit"}]}}