| 76 | } |
| 77 | |
| 78 | std::optional<uint256> MutableTransactionSignatureCreator::ComputeSchnorrSignatureHash(const uint256* leaf_hash, SigVersion sigversion) const |
| 79 | { |
| 80 | assert(sigversion == SigVersion::TAPROOT || sigversion == SigVersion::TAPSCRIPT); |
| 81 | |
| 82 | // BIP341/BIP342 signing needs lots of precomputed transaction data. While some |
| 83 | // (non-SIGHASH_DEFAULT) sighash modes exist that can work with just some subset |
| 84 | // of data present, for now, only support signing when everything is provided. |
| 85 | if (!m_txdata || !m_txdata->m_bip341_taproot_ready || !m_txdata->m_spent_outputs_ready) return std::nullopt; |
| 86 | |
| 87 | ScriptExecutionData execdata; |
| 88 | execdata.m_annex_init = true; |
| 89 | execdata.m_annex_present = false; // Only support annex-less signing for now. |
| 90 | if (sigversion == SigVersion::TAPSCRIPT) { |
| 91 | execdata.m_codeseparator_pos_init = true; |
| 92 | execdata.m_codeseparator_pos = 0xFFFFFFFF; // Only support non-OP_CODESEPARATOR BIP342 signing for now. |
| 93 | if (!leaf_hash) return std::nullopt; // BIP342 signing needs leaf hash. |
| 94 | execdata.m_tapleaf_hash_init = true; |
| 95 | execdata.m_tapleaf_hash = *leaf_hash; |
| 96 | } |
| 97 | uint256 hash; |
| 98 | if (!SignatureHashSchnorr(hash, execdata, m_txto, nIn, m_options.sighash_type, sigversion, *m_txdata, MissingDataBehavior::FAIL)) return std::nullopt; |
| 99 | return hash; |
| 100 | } |
| 101 | |
| 102 | bool MutableTransactionSignatureCreator::CreateSchnorrSig(const SigningProvider& provider, std::vector<unsigned char>& sig, const XOnlyPubKey& pubkey, const uint256* leaf_hash, const uint256* merkle_root, SigVersion sigversion) const |
| 103 | { |
nothing calls this directly
no test coverage detected