Basic Taproot derivation support for descriptors #22051

pull sipa wants to merge 9 commits into bitcoin:master from sipa:202105_taproot_derive changing 16 files +834 −55
  1. sipa commented at 9:52 pm on May 24, 2021: member

    This is a subset of #21365, to aide review.

    This adds support tr(KEY) or tr(KEY,SCRIPT) or tr(KEY,{{S1,{{S2,S3},...}},...}) descriptors, describing Taproot outputs with specified internal key, and optionally any number of scripts, in nested groups of 2 inside {/} if there are more than one. While it permits importing tr(KEY), anything beyond that is just laying foundations for more features later.

    Missing:

    • Signing support (see #21365)
    • Support for more interesting scripts inside the tree (only pk(KEY) is supported for now). In particular, a multisig policy based on the new OP_CHECKSIGADD opcode would be very useful.
    • Inferring tr() descriptors from outputs (given sufficient information).
    • getaddressinfo support.
    • MuSig support. Standardizing that is still an ongoing effort, and is generally kind of useless without corresponding PSBT support.
    • Convenient ways of constructing descriptors without spendable internal key (especially ones that arent’t trivially recognizable as such).
  2. Make XOnlyPubKey act like byte container 4b1cc08f9f
  3. Change Solver() output for WITNESS_V1_TAPROOT
    This is just a small simplification to prepare for the follow-up instruction
    of a CTxDestination variant for taproot outputs.
    
    In the old code, WITNESS_V1_TAPROOT and WITNESS_UNKNOWN both produced
    {version, program} as Solver() output. Change this so that WITNESS_V1_TAPROOT
    produces just {program}, like WITNESS_V0_* do.
    31df02a070
  4. Avoid dependence on CTxDestination index order 41839bdb89
  5. Separate WitnessV1Taproot variant in CTxDestination a4bf84039c
  6. Make consensus checking of tweaks in pubkey.* Taproot-specific
    That results in a much safer interface (making the tweak commit
    to the key implicitly using a fixed tag means it can't be used for
    unrelated tweaking).
    2fbfb1becb
  7. Add XOnlyPubKey::CreateTapTweak 5f6cc8daa8
  8. Add TaprootBuilder class
    This class functions as a utility for building taproot outputs, from
    internal key and script leaves.
    90fcac365e
  9. Add tr() descriptor (derivation only, no signing)
    This adds a new descriptor with syntax e.g. tr(KEY,{S1,{{S2,S3},S4})
    where KEY is a key expression for the internal key and S_i are
    script expression for the leaves. They have to be organized in
    nested {A,B} groups, with exactly two elements.
    
    tr() only exists at the top level, and inside the script expressions
    only pk() scripts are allowed for now.
    7cedafc541
  10. tests: check derivation of P2TR 2667366aaa
  11. sipa force-pushed on May 24, 2021
  12. DrahtBot added the label Consensus on May 24, 2021
  13. DrahtBot added the label Descriptors on May 24, 2021
  14. DrahtBot added the label RPC/REST/ZMQ on May 24, 2021
  15. DrahtBot added the label Utils/log/libs on May 24, 2021
  16. DrahtBot added the label Wallet on May 24, 2021
  17. Sjors commented at 9:10 am on May 25, 2021: member
    utACK 2667366 (based on #21365 (comment) review, plus the new functional test)
  18. laanwj added this to the "Blockers" column in a project

  19. meshcollider commented at 12:20 pm on May 30, 2021: contributor

    This is so exciting 🎉

    utACK 2667366aaa69447a9de4d819669d254a5ebd4d4b

    Will test

  20. in src/script/standard.cpp:377 in 90fcac365e outdated
    372@@ -370,3 +373,99 @@ CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys)
    373 bool IsValidDestination(const CTxDestination& dest) {
    374     return dest.index() != 0;
    375 }
    376+
    377+/*static*/ TaprootBuilder::NodeInfo TaprootBuilder::Combine(NodeInfo&& a, NodeInfo&& b)
    


    fjahr commented at 11:41 pm on May 31, 2021:
    Are these static keywords here and one more below intentionally commented out?

    sipa commented at 0:11 am on June 1, 2021:
    Yes, the static needs to be mentioned at declaration time (in the class in the .h) file, you can’t repeat it at definition time. But putting it here in comments reminds the reader that it’s actually a static member function.

    fjahr commented at 8:37 pm on June 1, 2021:
    I see, thanks! I had never seen this before.

    laanwj commented at 7:44 pm on June 3, 2021:
    C++’s dual use of the keyword static is kind of confusing, but not @sipa’s fault of course. I think documenting that it’s a static member function is useful here.
  21. achow101 commented at 9:01 pm on June 2, 2021: member
    Code Review ACK 2667366aaa69447a9de4d819669d254a5ebd4d4b
  22. laanwj merged this on Jun 3, 2021
  23. laanwj closed this on Jun 3, 2021

  24. sidhujag referenced this in commit 4de66cc6fe on Jun 3, 2021
  25. meshcollider removed this from the "Blockers" column in a project

  26. in src/script/descriptor.cpp:651 in 41839bdb89 outdated
    646+    if (std::holds_alternative<WitnessV0KeyHash>(dest) ||
    647+        std::holds_alternative<WitnessV0ScriptHash>(dest) ||
    648+        std::holds_alternative<WitnessUnknown>(dest)) {
    649+        return OutputType::BECH32;
    650+    }
    651+    return std::nullopt;
    


    fjahr commented at 9:55 am on June 6, 2021:
    nit: could add a comment that this is for CNoDestination.
  27. in src/wallet/rpcwallet.cpp:3740 in a4bf84039c outdated
    3736@@ -3737,6 +3737,7 @@ class DescribeWalletAddressVisitor
    3737         return obj;
    3738     }
    3739 
    3740+    UniValue operator()(const WitnessV1Taproot& id) const { return UniValue(UniValue::VOBJ); }
    


    fjahr commented at 10:21 am on June 6, 2021:
    nit: param seems to be named tap everywhere else
  28. fjahr commented at 8:31 pm on June 6, 2021: member
    utACK 2667366aaa69447a9de4d819669d254a5ebd4d4b
  29. in test/functional/wallet_taproot.py:201 in 2667366aaa
    196+                i = random.randrange(len(KEYS))
    197+                if not i in idxes:
    198+                    break
    199+            idxes.add(i)
    200+            ret.append(KEYS[i])
    201+        return ret
    


    jnewbery commented at 12:21 pm on June 8, 2021:
    I think this can be replaced with set(random.sample(KEYS, k=n))

    sipa commented at 3:35 pm on June 8, 2021:
    I think you’re right.
  30. meshcollider referenced this in commit 5c2e2afe99 on Jun 17, 2021
  31. apoelstra referenced this in commit 79715fbfc5 on Aug 19, 2021
  32. apoelstra referenced this in commit 6be625c049 on Aug 19, 2021
  33. apoelstra referenced this in commit af2d6cdc34 on Aug 19, 2021
  34. sanket1729 referenced this in commit f20dfb1e1b on Aug 19, 2021
  35. sanket1729 referenced this in commit 9b5141448f on Aug 19, 2021
  36. sanket1729 referenced this in commit 43bd21c1e9 on Aug 19, 2021
  37. sanket1729 referenced this in commit cbd1a6d625 on Aug 19, 2021
  38. sanket1729 referenced this in commit 9d2f866a74 on Aug 19, 2021
  39. sanket1729 referenced this in commit 0c6fb200fc on Aug 19, 2021
  40. sanket1729 referenced this in commit d0fc458b0b on Aug 19, 2021
  41. sanket1729 referenced this in commit b0d8a453d0 on Aug 19, 2021
  42. sanket1729 referenced this in commit 35791ed180 on Aug 19, 2021
  43. sanket1729 referenced this in commit d2536ed670 on Aug 20, 2021
  44. sanket1729 referenced this in commit 6137f46ba5 on Aug 20, 2021
  45. sanket1729 referenced this in commit 0d2a36085a on Aug 20, 2021
  46. sanket1729 referenced this in commit 55ed7b5a04 on Aug 20, 2021
  47. sanket1729 referenced this in commit ad77ecab25 on Aug 20, 2021
  48. sanket1729 referenced this in commit ce0a2499ad on Aug 20, 2021
  49. sanket1729 referenced this in commit cc42bbcf9a on Aug 20, 2021
  50. sanket1729 referenced this in commit e8c087b76a on Aug 20, 2021
  51. sanket1729 referenced this in commit d8cdb1e2e5 on Aug 20, 2021
  52. sanket1729 referenced this in commit 5e5b463d63 on Aug 20, 2021
  53. sanket1729 referenced this in commit 34f2b2aa1b on Aug 20, 2021
  54. sanket1729 referenced this in commit 7b5e4d50ce on Aug 20, 2021
  55. sanket1729 referenced this in commit 890aa181b6 on Aug 23, 2021
  56. sanket1729 referenced this in commit c7a9b9e615 on Aug 23, 2021
  57. sanket1729 referenced this in commit 73ec755dcd on Aug 23, 2021
  58. sanket1729 referenced this in commit 49a31c93bc on Aug 23, 2021
  59. sanket1729 referenced this in commit 8436f0f9ae on Aug 23, 2021
  60. sanket1729 referenced this in commit 5ed1caefc9 on Aug 23, 2021
  61. sanket1729 referenced this in commit 258bf33a2b on Aug 23, 2021
  62. sanket1729 referenced this in commit cc2ede6690 on Aug 23, 2021
  63. sanket1729 referenced this in commit fdef6811b2 on Aug 23, 2021
  64. sanket1729 referenced this in commit c7c763c25f on Aug 23, 2021
  65. sanket1729 referenced this in commit 86f35b24d1 on Aug 23, 2021
  66. sanket1729 referenced this in commit 78d200963c on Aug 23, 2021
  67. sanket1729 referenced this in commit 88e2c5b744 on Aug 24, 2021
  68. sanket1729 referenced this in commit de6d9b33de on Aug 24, 2021
  69. sanket1729 referenced this in commit 39c3002bf7 on Aug 24, 2021
  70. sanket1729 referenced this in commit 358913f8f2 on Aug 24, 2021
  71. sanket1729 referenced this in commit 9d5e75fa1d on Aug 24, 2021
  72. sanket1729 referenced this in commit 73aa6060d9 on Aug 24, 2021
  73. sanket1729 referenced this in commit 2887b8bc27 on Aug 25, 2021
  74. sanket1729 referenced this in commit c48d2a25d4 on Aug 25, 2021
  75. sanket1729 referenced this in commit 7ff15d6ad0 on Aug 25, 2021
  76. sanket1729 referenced this in commit ef683e95ba on Aug 25, 2021
  77. sanket1729 referenced this in commit eadf495323 on Aug 25, 2021
  78. sanket1729 referenced this in commit a2a089c493 on Aug 25, 2021
  79. sanket1729 referenced this in commit 8888fd43af on Aug 25, 2021
  80. sanket1729 referenced this in commit de14b1f19b on Aug 25, 2021
  81. sanket1729 referenced this in commit 91ef33a41f on Aug 25, 2021
  82. sanket1729 referenced this in commit a4b6e3d2d7 on Aug 25, 2021
  83. sanket1729 referenced this in commit e2a8fd29f2 on Aug 25, 2021
  84. sanket1729 referenced this in commit afc1956848 on Aug 25, 2021
  85. sanket1729 referenced this in commit 3f354e8c1c on Aug 25, 2021
  86. sanket1729 referenced this in commit 52466f47a9 on Aug 25, 2021
  87. sanket1729 referenced this in commit 4081921ee9 on Aug 25, 2021
  88. sanket1729 referenced this in commit 840a698e5b on Aug 25, 2021
  89. sanket1729 referenced this in commit e01a0176ac on Aug 25, 2021
  90. sanket1729 referenced this in commit 72d9ea74c9 on Aug 25, 2021
  91. sanket1729 referenced this in commit 3fe23cc53e on Aug 25, 2021
  92. sanket1729 referenced this in commit 3f445b2f7d on Aug 25, 2021
  93. sanket1729 referenced this in commit 4dda4ee0f8 on Aug 25, 2021
  94. sanket1729 referenced this in commit 14bc2a1fb9 on Aug 25, 2021
  95. sanket1729 referenced this in commit f47538108f on Aug 25, 2021
  96. sanket1729 referenced this in commit fe56faee94 on Aug 25, 2021
  97. sanket1729 referenced this in commit 39ee933863 on Aug 25, 2021
  98. sanket1729 referenced this in commit b20dbd896e on Aug 25, 2021
  99. sanket1729 referenced this in commit cc997e93d7 on Aug 25, 2021
  100. sanket1729 referenced this in commit db33678101 on Aug 26, 2021
  101. sanket1729 referenced this in commit db198cbd8f on Aug 26, 2021
  102. sanket1729 referenced this in commit 60a87e0be7 on Aug 26, 2021
  103. sanket1729 referenced this in commit 582b257538 on Aug 26, 2021
  104. sanket1729 referenced this in commit 7926d8f6e5 on Aug 26, 2021
  105. sanket1729 referenced this in commit 32508704f2 on Aug 26, 2021
  106. sanket1729 referenced this in commit 96945defe9 on Aug 26, 2021
  107. sanket1729 referenced this in commit 00db733149 on Aug 26, 2021
  108. sanket1729 referenced this in commit 05c926589a on Aug 26, 2021
  109. sanket1729 referenced this in commit 4d7746b784 on Aug 26, 2021
  110. sanket1729 referenced this in commit 27f66a9531 on Aug 26, 2021
  111. sanket1729 referenced this in commit 40f8f1aabd on Aug 26, 2021
  112. sanket1729 referenced this in commit 87b8a20e2c on Aug 26, 2021
  113. sanket1729 referenced this in commit 1edda9accf on Aug 26, 2021
  114. sanket1729 referenced this in commit 08d0a459bb on Aug 26, 2021
  115. sanket1729 referenced this in commit c3945cb39f on Aug 27, 2021
  116. sanket1729 referenced this in commit 68961ca60e on Aug 27, 2021
  117. sanket1729 referenced this in commit 8a20fbe8a6 on Aug 27, 2021
  118. gwillen referenced this in commit 3ffb9aa14f on Jun 1, 2022
  119. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me