| 51 | } |
| 52 | |
| 53 | bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion) const |
| 54 | { |
| 55 | assert(sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0); |
| 56 | |
| 57 | CKey key; |
| 58 | if (!provider.GetKey(address, key)) |
| 59 | return false; |
| 60 | |
| 61 | // Signing with uncompressed keys is disabled in witness scripts |
| 62 | if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed()) |
| 63 | return false; |
| 64 | |
| 65 | // Signing without known amount does not work in witness scripts. |
| 66 | if (sigversion == SigVersion::WITNESS_V0 && !MoneyRange(amount)) return false; |
| 67 | |
| 68 | // BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead. |
| 69 | const int hashtype = m_options.sighash_type == SIGHASH_DEFAULT ? SIGHASH_ALL : m_options.sighash_type; |
| 70 | |
| 71 | uint256 hash = SignatureHash(scriptCode, m_txto, nIn, hashtype, amount, sigversion, m_txdata); |
| 72 | if (!key.Sign(hash, vchSig)) |
| 73 | return false; |
| 74 | vchSig.push_back((unsigned char)hashtype); |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | std::optional<uint256> MutableTransactionSignatureCreator::ComputeSchnorrSignatureHash(const uint256* leaf_hash, SigVersion sigversion) const |
| 79 | { |
no test coverage detected