| 163 | } |
| 164 | |
| 165 | static bool SignTaprootScript(const SigningProvider& provider, const BaseSignatureCreator& creator, SignatureData& sigdata, int leaf_version, const CScript& script, std::vector<valtype>& result) |
| 166 | { |
| 167 | // Only BIP342 tapscript signing is supported for now. |
| 168 | if (leaf_version != TAPROOT_LEAF_TAPSCRIPT) return false; |
| 169 | SigVersion sigversion = SigVersion::TAPSCRIPT; |
| 170 | |
| 171 | uint256 leaf_hash = (CHashWriter(HASHER_TAPLEAF_ELEMENTS) << uint8_t(leaf_version) << script).GetSHA256(); |
| 172 | |
| 173 | // <xonly pubkey> OP_CHECKSIG |
| 174 | if (script.size() == 34 && script[33] == OP_CHECKSIG && script[0] == 0x20) { |
| 175 | XOnlyPubKey pubkey{Span{script}.subspan(1, 32)}; |
| 176 | std::vector<unsigned char> sig; |
| 177 | if (CreateTaprootScriptSig(creator, sigdata, provider, sig, pubkey, leaf_hash, sigversion)) { |
| 178 | result = Vector(std::move(sig)); |
| 179 | return true; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return false; |
| 184 | } |
| 185 | |
| 186 | static bool SignTaproot(const SigningProvider& provider, const BaseSignatureCreator& creator, const WitnessV1Taproot& output, SignatureData& sigdata, std::vector<valtype>& result) |
| 187 | { |
no test coverage detected